Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Java GUI 设计
» Swing
打印话题 寄给朋友 订阅主题 |
作者 | 問卷調查 applet |
angus203
发贴: 9 积分: 0 |
于 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()); } } 有了Swing为什么还要SWT? |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
5706 | 問卷調查 applet | angus203 | 2471 | 2006-06-06 14:40 |
已读帖子 新的帖子 被删除的帖子 |
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 |