如何将变量值从一个 JFrame 传递到 Netbeans 中的另一个 JFrame

2022-01-24 00:00:00 netbeans java swing jframe

我有两个 JFrames login.javaaccount.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.

相关文章