关于对话框的菜鸟问题 Dialog1.setVisible(true);Dialog1.show();这两个不行吗?如果不是,请把问题说清楚。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 某Window上弹出某Dialog操作完再继续Widow。 如果是想设置Dialog为模态对话框,这样:Dialog.setModal(true); 你的意思是? Dialog.setModal(true); Dialog.setVisible(true); 我不知道你的什么调用的。Kinescopedlg kinescopedlg = new Kinescopedlg(this);Dimension dlgSize = kinescopedlg.getPreferredSize();Dimension frmSize = getSize();Point loc = getLocation();kinescopedlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);kinescopedlg.setModal(true);kinescopedlg.show(); /*DialogTest.java*/import javax.swing.*;import java.awt.*;import java.awt.event.*;class frame1 extends JFrame implements ActionListener{ JButton button; JTextField textfield; frame1() { button=new JButton("b"); textfield=new JTextField(); Container con=getContentPane(); setSize(100,100); con.setLayout(new GridLayout()); con.add(button); con.add(textfield); setVisible(true); addWindowListener(new WindowAdapter() { public void windowClosing() { System.exit(0); } }); } public void actionPerformed(ActionEvent e) { if (e.getSource()==button) { dialog1 d=new dialog1(this,"test"); textfield.setText("sdfadsfa.\n"); } }}class dialog1 extends JDialog implements ActionListener{ JButton button; dialog1(JFrame f,String s) { super(f,s); button=new JButton("b"); Container con=getContentPane(); con.setSize(100,100); con.setLayout(new GridLayout(2,2)); con.add(button); setModal(true); setVisible(true); } public void actionPerformed(ActionEvent e) { if (e.getSource()==button) { dispose(); } }}class DialogTest{ public static void main(String [] args) { frame1 f=new frame1(); }}哪里错了? show 和 setVisible 有何区别? 问问题要问的明确点。dialog.domodal() ? 上面这段代码的目的是要测试: 构造一个Frame,Frame上的按键,点击后弹出对话框,对话框关闭后textfield显示出字符。 但是有错。(不是指GridLayout) 谢谢了。 呵呵,你的frame1和dialog1里的button都没有作addActionListener(this),按下去当然是没反应的,还有DialogTest要是public的才能运行 import javax.swing.*;import java.awt.*;import java.awt.event.*;class frame1 extends JFrame implements ActionListener{ JButton button; JTextField textfield; frame1() { button=new JButton("b"); button.addActionListener(this); textfield=new JTextField(); Container con=getContentPane(); setSize(100,100); con.setLayout(new FlowLayout()); con.add(button); con.add(textfield); setVisible(true); addWindowListener(new WindowAdapter() { public void windowClosing() { System.exit(0); } }); } public void actionPerformed(ActionEvent e) { if (e.getSource()==button) { dialog1 d=new dialog1(this,"test"); textfield.setText("sdfadsfa.\n"); } }}class dialog1 extends JDialog implements ActionListener{ JButton button; dialog1(JFrame f,String s) { super(f,s); button=new JButton("b"); button.addActionListener(this); Container con=getContentPane(); con.setSize(100,100); con.setLayout(new GridLayout(2,2)); con.add(button); setModal(true); setVisible(true); } public void actionPerformed(ActionEvent e) { if (e.getSource()==button) { setVisible(false); } }}public class DialogTest{ public static void main(String [] args) { frame1 f=new frame1(); }}这样似乎还是不行啊! sql查询问题 人机猜拳游戏求助~~~~ 随机正整数序列 取出最大重复次数的数字问题 有段c的程序,需要用java写,请熟悉c和java的高手帮忙,谢谢! java 求获取href值的正则表达式? 求教老手们,javamail有过滤的api吗? 这个copyTo为什么运用不成功? List的组合 300分救助中文问题的解决方案(分两次付清) 我在java.sun.com 上下载JDK1.4下载了七八遍,都是下载到99%就提示不能下载?为什么? 谁有jbuilder 6的序列号,谢谢
Dialog.setModal(true);
Dialog.setModal(true);
Dialog.setVisible(true);
Kinescopedlg kinescopedlg = new Kinescopedlg(this);
Dimension dlgSize = kinescopedlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
kinescopedlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
kinescopedlg.setModal(true);
kinescopedlg.show();
import java.awt.*;
import java.awt.event.*;
class frame1 extends JFrame implements ActionListener
{
JButton button;
JTextField textfield;
frame1()
{
button=new JButton("b");
textfield=new JTextField();
Container con=getContentPane();
setSize(100,100);
con.setLayout(new GridLayout());
con.add(button);
con.add(textfield);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing()
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==button)
{
dialog1 d=new dialog1(this,"test");
textfield.setText("sdfadsfa.\n");
}
}
}class dialog1 extends JDialog implements ActionListener
{
JButton button;
dialog1(JFrame f,String s)
{
super(f,s);
button=new JButton("b");
Container con=getContentPane();
con.setSize(100,100);
con.setLayout(new GridLayout(2,2));
con.add(button);
setModal(true);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==button)
{
dispose();
}
}
}
class DialogTest
{
public static void main(String [] args)
{
frame1 f=new frame1();
}
}哪里错了?
import java.awt.*;
import java.awt.event.*;class frame1 extends JFrame implements ActionListener
{
JButton button;
JTextField textfield;
frame1()
{
button=new JButton("b");
button.addActionListener(this);
textfield=new JTextField();
Container con=getContentPane();
setSize(100,100);
con.setLayout(new FlowLayout());
con.add(button);
con.add(textfield);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing()
{
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==button)
{
dialog1 d=new dialog1(this,"test");
textfield.setText("sdfadsfa.\n");
}
}
}class dialog1 extends JDialog implements ActionListener
{
JButton button;
dialog1(JFrame f,String s)
{
super(f,s);
button=new JButton("b");
button.addActionListener(this);
Container con=getContentPane();
con.setSize(100,100);
con.setLayout(new GridLayout(2,2));
con.add(button);
setModal(true);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==button)
{
setVisible(false);
}
}
}public class DialogTest
{
public static void main(String [] args)
{
frame1 f=new frame1();
}
}这样似乎还是不行啊!