从一个jframe类里面单击一个按钮,弹出来一个jdialog类,在这个jdialog里面可以操纵jframe里面的值么?或者将jdialog里面的数据返回给jframe?
解决方案 »
- 请大虾指点下,java如何求数组的最值问题(思路与代码)
- 有相互依赖的源文件用eclipse编译成功,单独编译失败,请大家帮忙指点一下,谢谢!
- 北大青鸟都会讲哪些javaee内容?
- 大家帮忙看看为什么我的面板不显示内容
- POI读取Excel的问题,急!!!
- [*] 如何获取当前运行的目录和文件
- 再来个小问题
- 一个关于Jfreechart的问题
- 我是学习C/C+,我现在想要学习java,请介绍一下我该先看什么书和使用什么开发平台或编译器?
- 我用vj写java,因为有msdn的超级帮助,连书也可丢了。可我想用jbuilder,可它速度爆慢,帮助不好。该如何是好?还有有没有好的jbuilder书??
- 一个正则表达式问题????
- JDK文档的解释11111
JFrame frame ;
JTextField field ;
my_frame() {
// 初始化frame和field
// 将field添加到frame中去
} void amethod() {
my_dialog = new my_dialog(this) ;
...
}
}class my_dialog {
JDialog dialog ;
my_frame parent ; my_dialog(my_frame parent) {
this.parent = parent ;
dialog = new JFrame(parent.frame) ;
} void some_method() {
parent.field.setText("accessing from child window") ;
}}
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;import javax.swing.*;public class test3
{
//private static testFrame frame;
//private static testPanel panel;
public static void main(String[] args)
{
JFrame frame=new JFrame();
frame.setSize(500,500);
frame.setTitle("test");
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel=new JPanel();
JButton button=new JButton("test");
frame.add(panel);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JOptionPane.showInputDialog(panel, "test");
String s=JOptionPane.showInputDialog(panel, "test");
System.out.println(s);
ints=Integer.parseInt(s);
System.out.println(ints);
frame.setBounds(0, 0, ints, ints);
frame.repaint();
}
private static int ints;
}
package wuchunzhi;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.*;
public class test
{
public static void main(String[] args)
{
testFrame frame=new testFrame();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class testFrame extends JFrame
{
testFrame()
{
setSize(500,500);
setTitle("test");
testPanel panel=new testPanel();
add(panel);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class testPanel extends JPanel
{
testPanel()
{
JButton button=new JButton("test");
button.addActionListener(new testActionListener());
add(button);
}
}
class testActionListener implements ActionListener
{
private testPanel panel;private JFrame frame;private int ints;
public void actionPerformed(ActionEvent e)
{
JOptionPane.showInputDialog(panel, "test");
String s=JOptionPane.showInputDialog(panel, "test");
System.out.println(s);
ints=Integer.parseInt(s);
System.out.println(ints);
frame.setBounds(0, 0, ints, ints);
frame.repaint();
}
}