怎么实现在子窗口没有关闭的情况下父窗口不能被操作呢 网上说把
JDialog jj= new JDialog(container,"游戏设置",false);false改成true 但是就变成这样了 不知道怎么解决希望大家帮我看看
还有游戏设置这个子窗口我用GridBagLayout布局的时候不知道为什么控件都跑到中间混在一起了。。。不知道怎么解决就用了绝对定位的方法。。有好心人用GridBagLayout帮我布局下 万分感激
子窗口代码
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class GamesetDialog {
private JPanel panel;
private JLabel choosenandu,choosediscaccount,discsize,jmin,jmax;
private JButton disccolor,confirm;
private JRadioButton primary,middle,high;
private JTextField account,min,max;
private ButtonGroup buttongroup;
public GamesetDialog(JFrame container) {
JDialog jj= new JDialog(container,"游戏设置",true);
Container c=jj.getContentPane();
c.setLayout(null);
choosenandu = new JLabel("选择关卡");
choosenandu.setBounds(5,20,100,20);c.add(choosenandu);
buttongroup=new ButtonGroup();
primary= new JRadioButton("初级");middle= new JRadioButton("中级");high= new JRadioButton("高级");
primary.setBounds(5,60,60,20);
middle.setBounds(70,60,60,20);
high.setBounds(135,60,60,20);
c.add(primary);c.add(middle);c.add(high);
buttongroup.add(primary);buttongroup.add(middle);buttongroup.add(high);
choosediscaccount = new JLabel("盘子数量(1-15)");
choosediscaccount.setBounds(5,100,100,20);c.add(choosediscaccount);
account=new JTextField();
account.setBounds(115,100,100,20);c.add(account);
discsize = new JLabel("盘子大小");
discsize.setBounds(5,140,100,20);c.add(discsize);
jmax=new JLabel("最大");max=new JTextField();
jmax.setBounds(5,170,30,20);max.setBounds(40,170,100,20);
c.add(jmax);c.add(max);
jmin=new JLabel("最小");min= new JTextField();
jmin.setBounds(170,170,50,20);min.setBounds(205,170,100,20);
c.add(jmin);c.add(min);
disccolor = new JButton("颜色选择");
disccolor.setBounds(5,210,100,20);c.add(disccolor);
confirm=new JButton("确认");
confirm.setBounds(155,250,100,20);c.add(confirm);
jj.pack();
jj.setResizable(false);
jj.setVisible(true);
jj.setBounds(100,100,400,340);
jj.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
}
}
------解决方案--------------------
构造方法第三个参数设置为false 楼主用setModal(true);这个方法试试
------解决方案--------------------
dialog
------解决方案--------------------