当前位置: 代码迷 >> Eclipse >> JAVA,该怎么处理
  详细解决方案

JAVA,该怎么处理

热度:93   发布时间:2016-04-23 02:10:17.0
JAVA
import java.awt.BorderLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;


public class Java5 extends JFrame implements ActionListener{
///private JDesktopPane desktopPane;
private JPanel panel;
private JLabel StuName,StuSex,Habit,Home,Others;
private JTextField name;
private JRadioButton Man,Woman;
private ButtonGroup btnGroup;
private JComboBox home;
private JCheckBox list1,list2,list3,list4,list5,list6;
private JTextArea textArea1,textArea2;
private JButton btn1;
public Java5(){
Panel panel = new Panel(null);
  ///desktopPane = new JDesktopPane();
StuName = new JLabel("姓名:",4);
  StuSex = new JLabel("性别:",4);
  Habit = new JLabel("爱好:",4);
Home = new JLabel("籍贯:",4);
Others = new JLabel("其他信息:",4);
 
name = new JTextField(10);
 
Man = new JRadioButton("男");
Woman = new JRadioButton("女");
 
btnGroup = new ButtonGroup();
btnGroup.add(Man);
btnGroup.add(Woman);
 
list1 = new JCheckBox("运动");
list2 = new JCheckBox("跳舞");
list3 = new JCheckBox("唱歌");
list4 = new JCheckBox("画画");
list5 = new JCheckBox("下棋");
list6 = new JCheckBox("登山");
 
home = new JComboBox(new String[]{"泸州","自贡","成都","康定","重庆","内江"});
 
textArea1 = new JTextArea();
textArea2 = new JTextArea();
 
btn1 = new JButton("确定");
//////////////////////////////////////
btn1.addActionListener(this);
//////////////////////////
StuName.setBounds(50, 20, 50, 25);
name.setBounds(110, 20, 90, 25);
 
StuSex.setBounds(50, 60, 50, 25);
Man.setBounds(110, 60, 40, 25);
Woman.setBounds(150, 60, 40, 25);
 
Habit.setBounds(50, 100, 50, 25);
list1.setBounds(110, 100, 60, 25);
list2.setBounds(180, 100, 60, 25);
list3.setBounds(240, 100, 60, 25);
list4.setBounds(110, 140, 60, 25);
list5.setBounds(180, 140, 60, 25);
list6.setBounds(240, 140, 60, 25);
 
Home.setBounds(50, 180, 50, 25);
home.setBounds(110, 180, 80, 25);

Others.setBounds(49, 220, 80, 25);
textArea1.setBounds(140, 220, 240, 100);
 
btn1.setBounds(160, 340, 70, 25);
 
textArea2.setBounds(105, 400, 240, 100);
 
 
///////////////////////////////////////

this.setContentPane(panel);
panel.add(StuName);
panel.add(name);
panel.add(StuSex);
panel.add(Man);
panel.add(Woman);
panel.add(Habit);
panel.add(list1);
  panel.add(list2);
panel.add(list3);
panel.add(list4);
panel.add(list5);
panel.add(list6);
panel.add(Home);
panel.add(home);
panel.add(Others);
panel.add(textArea1);
panel.add(btn1);
panel.add(textArea2);
 


 
this.setBounds(10, 10, 410, 620);
  this.setVisible(true);
  this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  this.setResizable(false);
}

/**
* @param args
**/
public static void main(String[] args) {
  相关解决方案