简体   繁体   English

摆动:将数据从JFrame传递到另一个

[英]Swing: passing data from JFrame to another

I have 2 forms in my program, one is basic application form which shows when app starts and second is form for adding entities to database. 我的程序中有2种形式,一种是基本的应用程序形式,它显示应用程序何时启动,第二种是用于向数据库添加实体的形式。 It works intuitively: in default form you click add button, second form shows, where you fill some text areas and click done button. 它直观地工作:在默认表单中,单击add按钮,显示第二个表单,在其中填充一些文本区域并单击done按钮。

My question, how to pass data from second form to first one? 我的问题是,如何将数据从第二种形式传递给第一种形式?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM