java - Swing:将数据从 JFrame 传递到另一个 JFrame

标签 java swing jframe

我的程序中有两个表单,一个是基本应用程序表单,显示应用程序何时启动,第二个是将实体添加到数据库的表单。它的工作原理很直观:在默认表单中,您单击add按钮,显示第二个表单,您可以在其中填充一些文本区域,然后单击done按钮。

我的问题,如何将数据从第二个表单传递到第一个表单?

最佳答案

method 1 :
1 : create 1 form
2 : add all fields for entering fields and also the fields from the confirmation form
3 : hide the confirmation fields
4 : when user clicks submit , hide the fields of first form , show the fields of second form

thus you all the data in one form only and you can handle the data as you want

ohk then lets try this

create a form 1
create a form 2
create a bean class having all the fields from form 1
now create a simple main class calling form 1
when user submits the form 1 , take all the values from form1 , create an object of the bean , store the values in the bean object , thus you are still in the main class 
after setting the values in the bean , call the form 2 frame , and set the fields in form 2 by using the same object of the bean class

关于java - Swing:将数据从 JFrame 传递到另一个 JFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16438121/

相关文章:

java - 在整数数组中查找最小最大值,性能问题

java - 我想显示一条消息,显示我选择的内容 (Java)

java - 定时器的嵌套

java - 如何在java swing中自动扩展框架的高度

java - javax.swing.JFrame不包含setDefaultCLoseOperation

Java Swing - 在与 JFrame 不同的类中使用paintIcon

java - 如何从 AlertDialog onClickListener 中访问我的 Activity 实例变量?

java - 从代码创建 JAR 文件并调用函数

java - Derby 时间戳比较

java - GUI、JComboBox 和打开新窗口