package assset.huang;import java.awt.BorderLayout;
import java.awt.Frame;import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;public class Dialog1 extends JDialog {
JPanel panel1 = new JPanel();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public Dialog1(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
this.setSize(400,400);
this.setVisible(true);
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
} public Dialog1() {
this(new Frame(), "Dialog1", false);
} private void jbInit() throws Exception {
panel1.setLayout(null);
this.getContentPane().setLayout(null);
jTextField1.setBounds(new Rectangle(225, 58, 72, 21));
jTextField2.setBounds(new Rectangle(225, 123, 72, 21));
jLabel1.setText("用户");
jLabel1.setBounds(new Rectangle(68, 58, 42, 21));
jLabel2.setText("密码");
jLabel2.setBounds(new Rectangle(64, 123, 42, 21));
jButton1.setBounds(new Rectangle(38, 199, 83, 25));
jButton1.setText("确定");
jButton2.setBounds(new Rectangle(242, 199, 83, 25));
jButton2.setText("重置");
this.getContentPane().add(panel1, null);
panel1.add(jTextField1);
panel1.add(jTextField2);
panel1.add(jLabel1);
panel1.add(jLabel2);
panel1.add(jButton1);
panel1.add(jButton2);
panel1.setBounds(new Rectangle(0, 0, 400, 300));
}
public static void main (String arg[])
{
Dialog1 a= new Dialog1();
}
}
也有设了大小只显示标题,还要手动去拉窗口的大小,我错在什么方面?
import java.awt.Frame;import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;public class Dialog1 extends JDialog {
JPanel panel1 = new JPanel();
JTextField jTextField1 = new JTextField();
JTextField jTextField2 = new JTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public Dialog1(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
this.setSize(400,400);
this.setVisible(true);
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
} public Dialog1() {
this(new Frame(), "Dialog1", false);
} private void jbInit() throws Exception {
panel1.setLayout(null);
this.getContentPane().setLayout(null);
jTextField1.setBounds(new Rectangle(225, 58, 72, 21));
jTextField2.setBounds(new Rectangle(225, 123, 72, 21));
jLabel1.setText("用户");
jLabel1.setBounds(new Rectangle(68, 58, 42, 21));
jLabel2.setText("密码");
jLabel2.setBounds(new Rectangle(64, 123, 42, 21));
jButton1.setBounds(new Rectangle(38, 199, 83, 25));
jButton1.setText("确定");
jButton2.setBounds(new Rectangle(242, 199, 83, 25));
jButton2.setText("重置");
this.getContentPane().add(panel1, null);
panel1.add(jTextField1);
panel1.add(jTextField2);
panel1.add(jLabel1);
panel1.add(jLabel2);
panel1.add(jButton1);
panel1.add(jButton2);
panel1.setBounds(new Rectangle(0, 0, 400, 300));
}
public static void main (String arg[])
{
Dialog1 a= new Dialog1();
}
}
也有设了大小只显示标题,还要手动去拉窗口的大小,我错在什么方面?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货