我写了一个类 extends JFrame ,上面有一个文本框,后跟一个按钮。我点按钮新打开一个新Jframe,里面有一个JList和JBUtton,Jlist里面装的是从数据库中查出的值。我想点JButton,关闭当前JFrame ,把JList中的值传到前一个JFrame中的文本框中,如何传?请帮帮忙。
解决方案 »
- 关于自定义运行时异常的问题
- 得到很多javadoc的html格式的文件,有什么软件可以生成象java API 一样的chm帮助文件。
- String类
- 怎么样获取一个字符串占多少像素?
- 一个Jave程序在英文XP下显示中文为方框,烦请大虾解决!
- 一个文件调用另一个文件的问题
- ☆新手学习阶段 希望能有高手指点★
- 为什么用StringTokenizer解析不了这样的"abcdefghi.abcde$fgh 8000"字符串呢?
- 有办法在选中JTree的一个节点时,禁止selection改变么
- 请问,我如何在Applet中点击按钮后弹出对话筐(继承一个Applet类),在两个Applet中如何传递参数?最后20分,送完告别这里!:)
- [求助]不同jre版本开发的程序能不能部署到一个tomcat下面
- 面试题 求N以内的质数
frame1(){ JButton button1 = new JButton("button1");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new frame1(field);
} });
}
private JLst list;
private JTextField field;
frame2(JTextField field){
this.field = field;
JButton button2 = new JButton("button2");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
field.setText(list.getSelectedValues().toString())
frame2.this..dispose();
} });
}
frame1(){ JButton button1 = new JButton("button1");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new frame2(field);
} });
}
private JLst list;
private JTextField field;
frame2(JTextField field){
this.field = field;
JButton button2 = new JButton("button2");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
field.setText(list.getSelectedValues().toString())
frame2.this..dispose();
} });
}
A.a=你要设置的值.
这个很简单的。
JFrame1和JFrame2
你把JFrame2写多一个构造函数,构造函数里面传一个JFrame1这个参数。
在JFrame1中把JFrame2 new 出来的时候就把自己传过去.
在JFrame2中设一个变量接收JFrame1,这样就可以调用JFrame1里的东东了。