企业信息调查

                                  企业信息调查

             制作一个简单的企业信息调查表,其主要内容有:企业名称,注册资金(只能为整数),员工数量(只能为整数),从事行业(机构组织、信息产业、医药卫生、机械机电、只能选择其一)、年营业额(浮点数)、利润率(浮点数)。 

   更具这些以上提示做一个窗体设置。

   

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public  class QYxxdc extends Frame implements ActionListener {
        
	// 主标签
	Label lb = new Label("企业信息调查");
	Label lb1 = new Label("企业名称:");
	Label lb2 = new Label("注册资金:");
	Label lb3 = new Label("员工数量:");
	Label lb4 = new Label("从事行业:");
	Label lb5 = new Label("年营业额:");
	Label lb6 = new Label ("利润率:");
	
	  // 文本框
	 TextField name =  new TextField(10);
	 TextField money = new TextField("50",5);
	 TextField count = new TextField(4);
	 List position = new List(4);  // 从事行业
	 TextField year = new TextField();
	 TextField profit = new TextField();  // 利润率
	  
	 //  按钮
	  Button bt1 = new Button("确认");
	  Button bt2 =  new Button("退出");
	  
	  public QYxxdc(String title){
		  
		  super(title);
		  this.setSize(400,400);
		  this.setLayout(null);
		  this.setResizable(false);
		  setLocationRelativeTo(null); // 屏幕居中放置
		  this.setBackground(Color.CYAN);
		  
		 lb.setBounds(150, 50, 80, 20); 
		 lb1.setBounds(50, 100, 55, 20);
		 name.setBounds(110, 100, 110, 20);
		 lb2.setBounds(230, 100, 65, 20);
		 money.setBounds(300, 100, 80, 20);
		 
		 lb5.setBounds(50, 150, 60, 20);
		 year.setBounds(115,150 , 100, 20);
		 
		 lb6.setBounds(230, 150, 50, 20);
		 profit.setBounds(290, 150, 80, 20);
		 
		 lb3.setBounds(50, 220, 60, 20);
		 count.setBounds(110, 220, 80, 20);
		 
		 lb4.setBounds(210, 220, 65, 20);
		 position.setBounds(280, 220, 90, 60);
		 
		  bt1.setBounds(85, 320, 60, 30);
		  bt2.setBounds(235, 320, 60, 30);
		  bt1.setBackground(Color.GRAY);
		  bt2.setBackground(Color.lightGray);
		  
		 position.add("机构组织");
		 position.add("信息产业");
		 position.add("医药卫生");
		 position.add("机械机电");
		
		 this.add(lb);
		 this.add(lb1);
		 this.add(lb2);
		 this.add(lb3);
		 this.add(lb4);
		 this.add(lb5);
		 this.add(lb6);
		 
		 this.add(name);
		 this.add(money);
		 this.add(year);
		 this.add(profit);
		 this.add(count);
		 this.add(position);
		 this.add(bt1);
		 this.add(bt2);
		
		 bt1.addActionListener(this);
		 bt2.addActionListener(this);
		 
		 
		 
		  
		  
	  }
	
	 
	
	
	public static void main(String[] args){
		QYxxdc app = new QYxxdc("企业信息调查");
		app.setVisible(true);
		
		
	}




	@Override
	public void actionPerformed(ActionEvent e) {
		  
		  Object ob = e.getSource();
		  if(ob == bt2){
			 System.exit(0); 
		  }
		  else if( ob == bt1){
//			  JOptionPane.showInputDialog("确定提交企业信息调查?");
			  System.out.println("企业名称:"+" "+ name.getText()+" ");
			  System.out.println("注册资金:"+" "+money.getText());
			  System.out.println("员工数量:"+" " +count.getText()+ " ");
			  System.out.println("从事行业:"+" "+position.getSelectedItem());
			  System.out.println("年营业额:"+" "+year.getText()+" ");
			  System.out.println(" 利润率:"+" "+profit.getText()+" ");
			  
		  }
		
	}

}
  

猜你喜欢

转载自blog.csdn.net/sinat_27406925/article/details/51142278