⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 empview.java

📁 java课程的资料以及实验的代码
💻 JAVA
字号:
/* *EmpView.java:建立职工管理界面(类)。 *包括:增、删、改3个子界面。 */
 
import javax.swing.*;
import java.awt.*;
public class EmpView extends JDialog   {
   public EmpPanel p1;
   public EmpView(ButPanel p2) {
  	getContentPane().setLayout(new BorderLayout());
  	p1 = new EmpPanel();
  	getContentPane().add(p1,BorderLayout.CENTER);
  	getContentPane().add(p2,BorderLayout.SOUTH);
  	
   }
}

class EmpPanel extends JPanel  {
   private Container cont;
   private GridBagLayout layout;
   private GridBagConstraints cons;
   JLabel lblEmployeeId ;
   JLabel lblEmployeeName ;
   JLabel lblPosition ;
   JLabel lblRemark ;
   public JTextField jtfEmployeeId ;
   public JTextField jtfEmployeeName ;
   public JTextField jtfPosition ;
   public JTextArea jtaRemark ;
   JScrollPane jScrollPane1 ;
  
   public EmpPanel() {
   	cont = this;
   	layout = new GridBagLayout();
   	cont.setLayout(layout);
   	cons = new GridBagConstraints();
   	
   	lblEmployeeId = new JLabel("职工号");
  	lblEmployeeName = new JLabel("姓名");
  	lblPosition = new JLabel("工位");
  	lblRemark = new JLabel("备注");
        jtfEmployeeId = new JTextField(10);
  	jtfEmployeeName = new JTextField(10);
  	jtfPosition = new JTextField(10);
  	jtaRemark = new JTextArea(5,10);
  	jScrollPane1 = new JScrollPane(jtaRemark);
        
        addComponent(lblEmployeeId,0,0,1,1);
        addComponent(jtfEmployeeId,0,1,1,1);
  	addComponent(lblEmployeeName,1,0,1,1);
  	addComponent(jtfEmployeeName,1,1,1,1);
  	addComponent(lblPosition,2,0,1,1);
  	addComponent(jtfPosition,2,1,1,1);
  	addComponent(lblRemark,3,0,1,1);
        addComponent(jScrollPane1,3,1,1,1);
        
        setVisible(true);
   }
   
   private void addComponent(Component comp,
   	int row,int column,int width,int height) {
   		cons.gridx = column;
   		cons.gridy = row;
   		cons.gridwidth = width;
   		cons.gridheight = height;
   		layout.setConstraints(comp,cons);
   		cont.add(comp);
   }
}

class AddEmpView extends EmpView {
	public AddEmpView(ButPanel p) {
		super(p);
		setTitle("增加职员");
	}
}
class UptEmpView extends EmpView {
	public UptEmpView(ButPanel p) {
		super(p);
		setTitle("修改职员");
	}
}
class DelEmpView extends EmpView {
	public DelEmpView(ButPanel p) {
		super(p);
		setTitle("删除职员");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -