package kaoshi;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
//import java.awt.EventDispatchThread;
/**
* <p>Title: 22班考试题</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: tc25</p>
*
* @author 2007.3.9
* @version 1.0
*/
public class KaoshiFrame extends JFrame {
JPanel contentPane;
JLabel jLabel1 = new JLabel();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
ButtonGroup buttonGroup1 = new ButtonGroup();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JOptionPane jOptionPane1 = new JOptionPane();
public KaoshiFrame() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(400, 300));
setTitle("程序员职业调查");
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 18));
jLabel1.setText("您计划将来成为:");
jLabel1.setBounds(new Rectangle(26, 57, 184, 35));
jRadioButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jRadioButton1.setText("java程序员");
jRadioButton1.setBounds(new Rectangle(111, 109, 185, 35));
jRadioButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 15));
jRadioButton2.setText(".NET程序员");
jRadioButton2.setBounds(new Rectangle(113, 152, 186, 37));
jButton1.setBounds(new Rectangle(38, 201, 135, 43));
jButton1.setText("选择");
jButton1.addActionListener(new KaoshiFrame_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(202, 201, 135, 43));
jButton2.setText("关闭");
jButton2.addActionListener(new KaoshiFrame_jButton2_actionAdapter(this));
contentPane.add(jLabel1);
contentPane.add(jRadioButton1);
contentPane.add(jButton2);
contentPane.add(jButton1);
contentPane.add(jRadioButton2);
buttonGroup1.add(jRadioButton1);
buttonGroup1.add(jRadioButton2);
}
static int i=0,j=0;
public void jButton1_actionPerformed(ActionEvent e) {
if(jRadioButton1.isSelected())
{
i++;
}
if(jRadioButton2.isSelected())
{
j++;
}
jOptionPane1.showMessageDialog(this,"现在共有投票:"+(i+j)
+"\n其中java程序员得"
+i+"票"
+"\n.NET程序员得"
+j+"票","提示:",jOptionPane1.INFORMATION_MESSAGE);
}
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class KaoshiFrame_jButton2_actionAdapter implements ActionListener {
private KaoshiFrame adaptee;
KaoshiFrame_jButton2_actionAdapter(KaoshiFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class KaoshiFrame_jButton1_actionAdapter implements ActionListener {
private KaoshiFrame adaptee;
KaoshiFrame_jButton1_actionAdapter(KaoshiFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}