Java Swing:将数据从JFrame传递到另一个JFrame
我的程序中有两个表单,一个是显示应用程序启动时间的基本应用表单,另一个是向数据库添加实体的表单。它直观地工作:在默认表单中,您单击Java Swing:将数据从JFrame传递到另一个JFrame,java,swing,jframe,Java,Swing,Jframe,我的程序中有两个表单,一个是显示应用程序启动时间的基本应用表单,另一个是向数据库添加实体的表单。它直观地工作:在默认表单中,您单击add按钮,第二个表单显示,您在其中填充一些文本区域,然后单击done按钮 我的问题是,如何将数据从第二个表单传递到第一个表单 是的,这是一个非常好的方法,但它不可能导致应用程序复杂。如果被否决,那么很好,只是一个解释就可以阻止你重复同样的错误。无论如何,很高兴我能帮助“解释一下”看到我对这个问题的评论。这就是原因。你的解决方案对于一个每天都在讨论的简单问题来说是一个
add
按钮,第二个表单显示,您在其中填充一些文本区域,然后单击done
按钮
我的问题是,如何将数据从第二个表单传递到第一个表单 是的,这是一个非常好的方法,但它不可能导致应用程序复杂。如果被否决,那么很好,只是一个解释就可以阻止你重复同样的错误。无论如何,很高兴我能帮助“解释一下”看到我对这个问题的评论。这就是原因。你的解决方案对于一个每天都在讨论的简单问题来说是一个夸张的(格式不好的)解决方案。所以它没有错,但是格式不好。ohk现在我可以安详地死去了:):)请看“表格2”应该是模态的
JDialog
。大约每8小时一次,所以。
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