import java.awt.Container;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Sw implements ActionListener{
JFrame frame = new JFrame("学生的信息");
JButton button1 = new JButton("确定");
JButton button2 = new JButton("重写");
JLabel jl=new JLabel (" ");
public void testJFrame() {
frame.setSize(500, 450);
//frame.setIconImage("F:\\1.jpg");
frame.getIconImage();
Container contentPane = frame.getContentPane();
contentPane.setLayout(null);
JLabel lable1 = new JLabel("名字:");
lable1.setBounds(20, 40, 40, 50);
JLabel lable2 = new JLabel("性格:");
lable2.setBounds(250, 40, 150, 50);
JLabel lable3 = new JLabel("家庭地址:");
lable3.setBounds(20, 100, 100, 50);
JLabel lable4 = new JLabel("爱好:");
lable4.setBounds(250, 100, 150, 50);
JLabel lable5 = new JLabel("性别:");
lable5.setBounds(20, 200, 100, 50);
JTextField name = new JTextField();
name.setBounds(80, 40, 120, 50);
JTextArea address = new JTextArea();
address.setBounds(80, 100, 120, 50);
// button1.addActionListener(this);
button1.setBounds(20, 350, 120, 50);
// button2.addActionListener(this);
button2.setBounds(250, 350, 120, 50);
JCheckBox Hobby1 = new JCheckBox("阅读");
Hobby1.setBounds(350, 85, 150, 50);
JCheckBox Hobby2 = new JCheckBox("唱歌");
Hobby2.setBounds(350, 125, 150, 50);
JCheckBox Hobby3 = new JCheckBox("跳舞");
Hobby3.setBounds(350, 165, 150, 50);
JRadioButton Sex1 = new JRadioButton("男");
Sex1.setBounds(80, 200, 100, 50);
JRadioButton Sex2 = new JRadioButton("女");
Sex2.setBounds(80, 200, 100, 150);
JComboBox qualification = new JComboBox();
qualification.addItem("开朗");
qualification.addItem("大方");
qualification.addItem("内敛 ");
qualification.addItem("坚强");
qualification.addItem("乐观");
qualification.setBounds(350, 40, 100, 30);
button1.addActionListener(this);
button2.addActionListener(this);
contentPane.add(lable1);
contentPane.add(name);
contentPane.add(lable2);
contentPane.add(lable3);
contentPane.add(address);
contentPane.add(lable4);
contentPane.add(lable5);
contentPane.add(Sex1);
contentPane.add(Sex2);
contentPane.add(qualification);
contentPane.add(Hobby1);
contentPane.add(Hobby2);
contentPane.add(Hobby3);
contentPane.add(button1);
contentPane.add(button2);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e){
if (e.getSource()==button1){
JOptionPane.showMessageDialog(frame,"填写成功","确定",JOptionPane.INFORMATION_MESSAGE);
jl.setText("恭喜你");
}else if(e.getSource()==button2){
int index=JOptionPane.showConfirmDialog(frame,"请重新填写","确定",JOptionPane.INFORMATION_MESSAGE);
jl.setText("你的输入有误,请重新填写");
}
}
public static void main(String[] args) {
Sw Jie = new OvalPanel();
Jie.testJFrame();
}
}
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Sw extends JFrame implements ActionListener{
JButton button1;
JButton button2;
public Sw() {
super("学生的信息");
setSize(500, 450);
// frame.setIconImage("F:\\1.jpg");
getIconImage();
Container contentPane = getContentPane();
contentPane.setLayout(null);
JLabel jl = new JLabel(" ");
JLabel lable1 = new JLabel("名字:");
lable1.setBounds(20, 40, 40, 50);
JLabel lable2 = new JLabel("性格:");
lable2.setBounds(250, 40, 150, 50);
JLabel lable3 = new JLabel("家庭地址:");
lable3.setBounds(20, 100, 100, 50);
JLabel lable4 = new JLabel("爱好:");
lable4.setBounds(250, 100, 150, 50);
JLabel lable5 = new JLabel("性别:");
lable5.setBounds(20, 200, 100, 50);
JTextField name = new JTextField();
name.setBounds(80, 40, 120, 50);
JTextArea address = new JTextArea();
address.setBounds(80, 100, 120, 50);
button1 = new JButton("确定");
button1.addActionListener(this);
button1.setBounds(20, 350, 120, 50);
button2 = new JButton("重写");
button2.addActionListener(this);
button2.setBounds(250, 350, 120, 50);
JCheckBox Hobby1 = new JCheckBox("阅读");
Hobby1.setBounds(350, 85, 150, 50);
JCheckBox Hobby2 = new JCheckBox("唱歌");
Hobby2.setBounds(350, 125, 150, 50);
JCheckBox Hobby3 = new JCheckBox("跳舞");
Hobby3.setBounds(350, 165, 150, 50);
JRadioButton Sex1 = new JRadioButton("男");
Sex1.setBounds(80, 200, 100, 50);
JRadioButton Sex2 = new JRadioButton("女");
Sex2.setBounds(80, 200, 100, 150);
JComboBox qualification = new JComboBox();
qualification.addItem("开朗");
qualification.addItem("大方");
qualification.addItem("内敛 ");
qualification.addItem("坚强");
qualification.addItem("乐观");
qualification.setBounds(350, 40, 100, 30);
contentPane.add(lable1);
contentPane.add(name);
contentPane.add(lable2);
contentPane.add(lable3);
contentPane.add(address);
contentPane.add(lable4);
contentPane.add(lable5);
contentPane.add(Sex1);
contentPane.add(Sex2);
contentPane.add(qualification);
contentPane.add(Hobby1);
contentPane.add(Hobby2);
contentPane.add(Hobby3);
contentPane.add(button1);
contentPane.add(button2);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == button1) {
JOptionPane.showMessageDialog(this, "填写成功", "确定",JOptionPane.INFORMATION_MESSAGE);
} else if (e.getSource() == button2) {
int index = JOptionPane.showConfirmDialog(this, "请重新填写", "确定", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
}
}
public static void main(String[] args) {
Sw Jie = new Sw();
}
}
JAVA是手机的一种软件,用来下载东西的。国厂机一般都没J AVA
public static void main(String args[])
{
JOptionPane.showMessageDialog(
null,"填写成功!");
System.exit(0);
}