import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
import java.text.*;
import java.util.Vector ;
import javax.swing.table.*;
public class workinformation extends JFrame {
JPanel panel1 = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
String str1[]={"男","女"};
String str2[]={"江西","湖南","湖北","北京","上海","河北","河南","福建","广东"};
String str3[]={"四级","六级","无"};
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField jTextField2 = new JTextField();
JLabel jLabel3 = new JLabel();
JTextField jTextField3 = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField jTextField4 = new JTextField();
JLabel jLabel5 = new JLabel();
JTextField jTextField5 = new JTextField();
JLabel jLabel6 = new JLabel();
JComboBox jComboBox1 = new JComboBox(str1);
JLabel jLabel7 = new JLabel();
JComboBox jComboBox2 = new JComboBox(str2);
JLabel jLabel8 = new JLabel();
JTextField jTextField6 = new JTextField();
JLabel jLabel9 = new JLabel();
JTextField jTextField7 = new JTextField();
JLabel jLabel10 = new JLabel();
JTextField jTextField8 = new JTextField();
JLabel jLabel11 = new JLabel();
JTextField jTextField9 = new JTextField();
JLabel jLabel12 = new JLabel();
JTextField jTextField10 = new JTextField();
JLabel jLabel13 = new JLabel();
JTextField jTextField11 = new JTextField();
JLabel jLabel14 = new JLabel();
JTextField jTextField12 = new JTextField();
JLabel jLabel15 = new JLabel();
JTextField jTextField13 = new JTextField();
JLabel jLabel16 = new JLabel();
JTextField jTextField14 = new JTextField();
JLabel jLabel17 = new JLabel();
JTextField jTextField15 = new JTextField();
JLabel jLabel18 = new JLabel();
JTextField jTextField16 = new JTextField();
JLabel jLabel19 = new JLabel();
JTextField jTextField17 = new JTextField();
JLabel jLabel20 = new JLabel();
JTextField jTextField18 = new JTextField();
JLabel jLabel21 = new JLabel();
JComboBox jComboBox3 = new JComboBox(str3);
JLabel jLabel22 = new JLabel();
JTextField jTextField19 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
public workinformation() {
// super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
// public Dialog1() {
// this(new Frame(), "Dialog1", false);
// }
private void jbInit() throws Exception {
panel1.setLayout(borderLayout1);
this.getContentPane().setLayout(null);
jLabel4.setText("部门名称");
jLabel4.setBounds(new Rectangle(153, 61, 55, 15));
jLabel5.setText("身高");
jLabel5.setBounds(new Rectangle(24, 116, 37, 19));
jLabel4.setText("部门名称");
jLabel5.setText("身高");
jLabel6.setText("性别");
jLabel6.setBounds(new Rectangle(161, 120, 33, 15));
jLabel7.setText("籍贯");
jLabel7.setBounds(new Rectangle(23, 148, 33, 15));
jLabel8.setText("年龄");
jLabel8.setBounds(new Rectangle(161, 148, 33, 15));
jLabel9.setText("出生日期");
jLabel9.setBounds(new Rectangle(23, 184, 55, 15));
jLabel10.setText("身份证");
jLabel10.setBounds(new Rectangle(154, 182, 55, 15));
jLabel11.setText("手机号码");
jLabel11.setBounds(new Rectangle(23, 215, 55, 15));
jLabel12.setText("部门经理");
jLabel12.setBounds(new Rectangle(22, 92, 55, 13));
jLabel13.setText("岗位id");
jLabel13.setBounds(new Rectangle(153, 215, 36, 15));
jLabel14.setText("岗位名称");
jLabel14.setBounds(new Rectangle(23, 248, 55, 15));
jLabel15.setText("配偶id");
jLabel15.setBounds(new Rectangle(154, 248, 36, 15));
jLabel16.setText("配偶姓名");
jLabel16.setBounds(new Rectangle(23, 277, 55, 15));
jLabel17.setText("学历编号");
jLabel17.setBounds(new Rectangle(154, 277, 55, 15));
jLabel18.setText("学历名称");
jLabel18.setBounds(new Rectangle(23, 305, 55, 15));
jLabel19.setText("专业");
jLabel19.setBounds(new Rectangle(161, 305, 33, 15));
jLabel20.setText("毕业院校");
jLabel20.setBounds(new Rectangle(23, 334, 55, 15));
jLabel21.setText("外语水平");
jLabel21.setBounds(new Rectangle(153, 334, 55, 15));
jLabel22.setText("毕业时间");
jLabel22.setBounds(new Rectangle(22, 368, 55, 15));
jButton1.setBounds(new Rectangle(42, 406, 77, 23));
jButton1.setText("添加");
jButton2.setBounds(new Rectangle(117, 406, 77, 23));
jButton2.setText("重置");
jButton3.setBounds(new Rectangle(200, 406, 77, 23));
jButton3.setText("取消");
jLabel3.setText("部门编号");
jLabel3.setBounds(new Rectangle(22, 61, 55, 15));
jLabel2.setText("员工姓名");
jLabel2.setBounds(new Rectangle(153, 23, 55, 15));
jLabel1.setText("员工编号");
jLabel1.setBounds(new Rectangle(22, 23, 55, 15));
this.getContentPane().add(jLabel17, null);
this.setTitle("");
jTextField1.setBounds(new Rectangle(77, 22, 57, 19));
jTextField2.setBounds(new Rectangle(222, 21, 77, 20));
jTextField3.setBounds(new Rectangle(77, 55, 57, 20));
jTextField4.setBounds(new Rectangle(222, 55, 77, 20));
jTextField10.setBounds(new Rectangle(77, 89, 57, 20));
jTextField5.setBounds(new Rectangle(78, 117, 57, 20));
jComboBox1.setBounds(new Rectangle(222, 117, 77, 23));
jComboBox2.setBounds(new Rectangle(78, 145, 57, 23));
jTextField6.setBounds(new Rectangle(222, 148, 77, 20));
jTextField7.setBounds(new Rectangle(78, 181, 57, 20));
jTextField8.setBounds(new Rectangle(222, 181, 77, 20));
jTextField9.setBounds(new Rectangle(78, 212, 57, 20));
jTextField11.setBounds(new Rectangle(221, 212, 78, 20));
jTextField12.setBounds(new Rectangle(77, 245, 58, 20));
jTextField13.setBounds(new Rectangle(222, 245, 77, 20));
jTextField14.setBounds(new Rectangle(78, 274, 57, 20));
jTextField15.setBounds(new Rectangle(222, 274, 77, 20));
jTextField16.setBounds(new Rectangle(78, 303, 57, 20));
jTextField17.setBounds(new Rectangle(222, 303, 77, 20));
jTextField18.setBounds(new Rectangle(78, 331, 57, 20));
jComboBox3.setBounds(new Rectangle(222, 331, 77, 23));
jTextField19.setBounds(new Rectangle(78, 366, 57, 20));
this.getContentPane().add(jTextField14, null);
this.getContentPane().add(jLabel18, null);
this.getContentPane().add(jTextField15, null);
this.getContentPane().add(jLabel19, null);
this.getContentPane().add(jTextField16, null);
this.getContentPane().add(jLabel20, null);
this.getContentPane().add(jTextField17, null);
this.getContentPane().add(jLabel21, null);
this.getContentPane().add(jTextField18, null);
this.getContentPane().add(jComboBox3, null);
this.getContentPane().add(jLabel22, null);
this.getContentPane().add(jButton3, null);
this.getContentPane().add(jButton2, null);
this.getContentPane().add(jButton1, null);
this.getContentPane().add(jTextField19, null);
this.getContentPane().add(jLabel13, null);
this.getContentPane().add(jLabel14, null);
this.getContentPane().add(jTextField8, null);
this.getContentPane().add(jTextField6, null);
this.getContentPane().add(jComboBox1, null);
this.getContentPane().add(jLabel15, null);
this.getContentPane().add(jTextField12, null);
this.getContentPane().add(jLabel16, null);
this.getContentPane().add(jTextField13, null);
this.getContentPane().add(jTextField11, null);
this.getContentPane().add(jLabel4, null);
this.getContentPane().add(jLabel3, null);
this.getContentPane().add(jLabel2, null);
this.getContentPane().add(jTextField1, null);
this.getContentPane().add(jTextField2, null);
this.getContentPane().add(jTextField4, null);
this.getContentPane().add(jTextField3, null);
this.getContentPane().add(jLabel12, null);
this.getContentPane().add(jTextField9, null);
this.getContentPane().add(jLabel11, null);
this.getContentPane().add(jLabel9, null);
this.getContentPane().add(jLabel10, null);
this.getContentPane().add(jTextField7, null);
this.getContentPane().add(jLabel8, null);
this.getContentPane().add(jComboBox2, null);
this.getContentPane().add(jLabel7, null);
this.getContentPane().add(jTextField5, null);
this.getContentPane().add(jLabel6, null);
this.getContentPane().add(jTextField10, null);
this.getContentPane().add(jLabel1, null);
this.getContentPane().add(panel1, null);
this.getContentPane().add(jLabel5, null);
setVisible(true);
}
public static void main(String args[])
{ new workinformation();}
}
----------------解决方案--------------------------------------------------------
把pack()换成setSize(350,500);就可以了
----------------解决方案--------------------------------------------------------
你主要是把顺序弄错了,你的pack应该在setVisible前面调用,这样才有效,否则
你的窗口肯定是小到一坨去了
所以你在setVisible之前,加一句pack就可以了
----------------解决方案--------------------------------------------------------
版主谢谢了.可以了.那问下setBounds 应该也可以吧
----------------解决方案--------------------------------------------------------
可以 你用setBounds(int int int int);
----------------解决方案--------------------------------------------------------
对于一般的程序来说,不推荐使用setBounds,因这个方法使你的组件的大小和座标都固定了
不能再变了,即使改变窗口的大小也不能变了
----------------解决方案--------------------------------------------------------
但是这个方法用起来很简单啊!大小和座标可以再从新设置啊?
----------------解决方案--------------------------------------------------------
是很简单啊 不过你试试 如果把窗口放大了 那会怎么样? 很难看的
----------------解决方案--------------------------------------------------------