How to pass a variable value from one JFrame to Another JFrame in Netbeans(如何将变量值从一个 JFrame 传递到 Netbeans 中的另一个 JFrame)
问题描述
我有两个 JFrames login.java
和 account.java
我需要从 login.java
页面获取 username
并将其放入 account.java
JFrame中的变量中代码>.如何使用 Swing 在 Java NetBeans 中执行此操作?
I have two JFrames login.java
and account.java
I need to get the username
from the login.java
page and put it in a variable in the account.java
JFrame
. How can I do this in the Java NetBeans using the Swing?
推荐答案
您可以使用 CardLayout 代替使用 JFrames 在不同表单之间传递值,它将保留您在前一个表单中输入的数据.您所要做的就是创建一个 JFrameForm 并向其添加面板.
Instead of Using JFrames for passing values between different forms you can use CardLayout which will persist your data which you have entered in the previous form. All you have to do is Create a JFrameForm and add panels to it.
这篇关于如何将变量值从一个 JFrame 传递到 Netbeans 中的另一个 JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!