Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5399759
  • 博文数量: 763
  • 博客积分: 12108
  • 博客等级: 上将
  • 技术积分: 15717
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-28 21:21
个人简介

业精于勤,荒于嬉

文章分类

全部博文(763)

文章存档

2018年(6)

2017年(15)

2016年(2)

2015年(31)

2014年(14)

2013年(87)

2012年(75)

2011年(94)

2010年(190)

2009年(38)

2008年(183)

2007年(28)

分类: Java

2008-11-02 12:59:44

package qq.test;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class CardLayoutTest extends JPanel {

    private JPanel panel;
    /**
     * Create the panel
     */

    public CardLayoutTest() {
        super();
        setLayout(null);

        panel = new JPanel();
        panel.setLayout(new CardLayout());
        panel.setBounds(35, 65, 237, 244);
        add(panel);

        final JLabel label1 = new JLabel();
        label1.setText("test1");
        label1.setName("label");
        panel.add(label1, label1.getName());

        final JLabel label2 = new JLabel();
        label2.setText("test2");
        label2.setName("label_1");
        panel.add(label2, label2.getName());

        final JLabel test3Label = new JLabel();
        test3Label.setText("test3");
        test3Label.setName("label1");
        panel.add(test3Label, test3Label.getName());

        final JLabel test4Label = new JLabel();
        test4Label.setText("test4");
        test4Label.setName("label_11");
        panel.add(test4Label, test4Label.getName());

        final JLabel test5Label = new JLabel();
        test5Label.setText(" test5");
        test5Label.setName("label_2");
        panel.add(test5Label, test5Label.getName());

        final JLabel cardLayoutTestLabel = new JLabel();
        cardLayoutTestLabel.setText("Card layout Test");
        cardLayoutTestLabel.setBounds(38, 41, 103, 18);
        add(cardLayoutTestLabel);

        final JButton button1 = new JButton();
        button1.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                CardLayout card= (CardLayout) panel.getLayout();
                card.previous(panel);
            }
        });
        button1.setText("Next");
        button1.setBounds(338, 91, 106, 28);
        add(button1);

        final JButton button2 = new JButton();
        button2.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                CardLayout card= (CardLayout) panel.getLayout();
                card.next(panel);
            }
        });
        button2.setText("last");
        button2.setBounds(338, 165, 106, 28);
        add(button2);

        final JButton endButton = new JButton();
        endButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                CardLayout card= (CardLayout) panel.getLayout();
                card.last(panel);
            }
        });
        endButton.setText("end");
        endButton.setBounds(338, 236, 106, 28);
        add(endButton);

        final JButton firstButton = new JButton();
        firstButton.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                CardLayout card= (CardLayout) panel.getLayout();
                card.first(panel);
            }
        });
        firstButton.setText("first");
        firstButton.setBounds(338, 36, 106, 28);
        add(firstButton);
        
        //

    }
    public JPanel getPanel() {
        return panel;
    }

}

阅读(1422) | 评论(0) | 转发(0) |
0

上一篇:假如生活欺骗了你

下一篇:udp socket demo

给主人留下些什么吧!~~