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

📄 employee.java

📁 用JAVA 编写的一个菜单程序 实现了一些基本计算和信息的录入
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class Employee extends JFrame  implements ActionListener 
{	String title[]={"编号","姓名","性别","称谓","工作单位","工作地址","固定电话","手机" ,"传真","E_mail" };
	
	
	
	JTextField txtNo=new JTextField(10);
	JTextField txtName=new JTextField(10);
	ButtonGroup group=new ButtonGroup();   
	JRadioButton rabSexM=new JRadioButton("男",true);    
	JRadioButton rabSexF=new JRadioButton("女",false);
	JComboBox cobSpeciality=new  JComboBox();
	
	
	JTextField txtworkplace=new JTextField(10);
	JTextField txtAddress=new JTextField(30);
	JTextField txttelephone=new JTextField(30);
	JTextField txtmobile=new JTextField(30);
	JTextField txtchuanzhen=new JTextField(10);
    JTextField email=new JTextField(30);
	JCheckBox chbMember=new JCheckBox("",false);                      
	JButton ok=new JButton("确定");
	JButton cancel=new JButton("退出");
	public Employee()
    {	super("名片管理");
		Container con=getContentPane();
		con.setLayout(new BorderLayout());  
    
		setSize(500,500);
		cobSpeciality.addItem("项目经理");   
		cobSpeciality.addItem("程序员");
		cobSpeciality.addItem("软件工程师");
		cobSpeciality.addItem("测试员");
		cobSpeciality.setSelectedIndex(0);
		group.add(rabSexM);group.add(rabSexF);
		JPanel p[]=new JPanel[10];         
		for(int i=0;i<10;i++)   
		{	p[i]=new JPanel(new FlowLayout(FlowLayout.LEFT));
			p[i].add(new JLabel(title[i]));
		}
		p[0].add(txtNo); 
		p[1].add(txtName); 
		p[2].add(rabSexM);p[2].add(rabSexF);
		p[3].add(cobSpeciality);
		p[4].add(txtworkplace);
		p[5].add(txtAddress);
		p[6].add(txttelephone);
		p[7].add(txtmobile);
		p[8].add(txtchuanzhen);
		p[9].add(email);
		JPanel top=new JPanel();                
		top.setLayout(new GridLayout(10 ,1));   
		for(int i=0;i<10;i++)                    
			top.add(p[i]);
		JPanel center=new JPanel();
		center.setLayout(new BorderLayout());  
		JPanel centerleft=new JPanel();        
		JPanel centerright=new JPanel();      
		JPanel bottom=new JPanel(); 
		bottom.add(ok);bottom.add(cancel);
		center.add(centerleft,"West");center.add(centerright,"Center");
		con.add(top,"North");
		con.add(center,"Center");
		con.add(bottom,"South"); 
		setVisible(true);
		ok.addActionListener(this);
	    cancel.addActionListener(this);
		
			
	}
      public void actionPerformed(ActionEvent e){
		
		String aa[]=new String[10];
		
		if(e.getSource()==ok){
			aa[0]=String.valueOf(txtNo.getText());
			aa[1]=String.valueOf(txtName.getText());
			aa[4]=String.valueOf(txtworkplace.getText());
			aa[5]=String.valueOf(txtAddress.getText());
			aa[6]=String.valueOf(txttelephone.getText());
			aa[7]=String.valueOf(txtmobile.getText());
			aa[8]=String.valueOf(txtchuanzhen.getText());
			aa[9]=String.valueOf(email.getText());
			for(int i=0;i<10;i++)
			System.out.println(aa[i]);
			
				
			}
	    if(e.getSource()==cancel){
	    	dispose();
	    }
	
	}
	
} 

⌨️ 快捷键说明

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