Topic: 問卷調查 applet |
Print this page |
1.問卷調查 applet | Copy to clipboard |
Posted by: angus203 Posted on: 2006-06-06 14:40 這是正確的做法嗎?? 4 題,已經這麼多code.. 可以精簡嗎?? import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; public class TryCardLayout extends JApplet implements ActionListener { CardLayout card = new CardLayout(); JPanel main = new JPanel(); JPanel p1 = new JPanel(); ButtonGroup no1 = new ButtonGroup(); JRadioButton no1_1 = new JRadioButton("Chioce 1",false); JRadioButton no1_2 = new JRadioButton("Chioce 2",false); JPanel p2 = new JPanel(); ButtonGroup no2 = new ButtonGroup(); JRadioButton no2_1 = new JRadioButton("Chioce 1",false); JRadioButton no2_2 = new JRadioButton("Chioce 2",false); JPanel control = new JPanel(); JButton button = new JButton("Press"); JPanel main1 = new JPanel(); JPanel p11 = new JPanel(); ButtonGroup no11 = new ButtonGroup(); JRadioButton no11_1 = new JRadioButton("Chioce 1",false); JRadioButton no11_2 = new JRadioButton("Chioce 2",false); JPanel p21 = new JPanel(); ButtonGroup no21 = new ButtonGroup(); JRadioButton no21_1 = new JRadioButton("Chioce 1",false); JRadioButton no21_2 = new JRadioButton("Chioce 2",false); JPanel control1 = new JPanel(); JButton button1 = new JButton("Press"); public void init() { Container content = getContentPane(); content.setLayout(card); no1.add(no1_1); no1.add(no1_2); p1.add(no1_1); p1.add(no1_2); p1.setBorder(new TitledBorder("No.1")); no11.add(no11_1); no11.add(no11_2); p11.add(no11_1); p11.add(no11_2); p11.setBorder(new TitledBorder("No.11")); no2.add(no2_1); no2.add(no2_2); p2.add(no2_1); p2.add(no2_2); p2.setBorder(new TitledBorder("No.2")); no21.add(no21_1); no21.add(no21_2); p21.add(no21_1); p21.add(no21_2); p21.setBorder(new TitledBorder("No.21")); control.add(button); control1.add(button1); button.addActionListener(this); button1.addActionListener(this); main.setLayout(new GridLayout(0,1)); main.add(p1); main.add(p2); main.add(control); main1.setLayout(new GridLayout(0,1)); main1.add(p11); main1.add(p21); main1.add(control1); content.add(main,""); content.add(main1,""); //content.add(p1,"Crad"); //content.add(p2,"Crad"); } // Handle button events public void actionPerformed(ActionEvent e) { card.next(getContentPane()); } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |