• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::

             

            import javax.swing.*;
            import java.awt.*;
            import java.awt.event.*;

            public class MultiPanel extends JPanel {
                
            private static final long serialVersionUID = 1L;
                
            private JButton           changeButton1;
                
            private JButton           changeButton2;
                
            private JButton           changeButton3;
                
            private JPanel            panel1;
                
            private JPanel            panel2;
                
            private JPanel            panel3;
                
            private JPanel            currentPanel;

                
            public MultiPanel() {
                    
            this.setLayout(new BorderLayout());

                    changeButton1 
            = new JButton(
                            
            "<html><font color=red>Red Panel</font></html>");
                    changeButton2 
            = new JButton(
                            
            "<html><font color=green>Green Panel</font></html>");
                    changeButton3 
            = new JButton(
                            
            "<html><font color=blue>Blue Panel</font></html>");
                    panel1 
            = new JPanel();
                    panel2 
            = new JPanel();
                    panel3 
            = new JPanel();

                    panel1.setBackground(Color.RED);
                    panel2.setBackground(Color.GREEN);
                    panel3.setBackground(Color.BLUE);
                    currentPanel 
            = panel1;

                    Box box 
            = Box.createHorizontalBox();
                    box.add(changeButton1);
                    box.add(changeButton2);
                    box.add(changeButton3);
                    
            this.add(box, BorderLayout.SOUTH);

                    
            this.add(currentPanel, BorderLayout.CENTER);

                    addButtonActionListener();
                }


                
            private void addButtonActionListener() {
                    changeButton1.addActionListener(
            new ActionListener() {
                        
            public void actionPerformed(ActionEvent e) {
                            currentPanel.setVisible(
            false);
                            currentPanel 
            = panel1;
                            currentPanel.setVisible(
            true);
                            add(currentPanel, BorderLayout.CENTER);
                            validate();
                        }

                    }
            );

                    changeButton2.addActionListener(
            new ActionListener() {
                        
            public void actionPerformed(ActionEvent e) {
                            currentPanel.setVisible(
            false);
                            currentPanel 
            = panel2;
                            currentPanel.setVisible(
            true);
                            add(currentPanel, BorderLayout.CENTER);
                            validate();
                        }

                    }
            );

                    changeButton3.addActionListener(
            new ActionListener() {
                        
            public void actionPerformed(ActionEvent e) {
                            currentPanel.setVisible(
            false);
                            currentPanel 
            = panel3;
                            currentPanel.setVisible(
            true);
                            add(currentPanel, BorderLayout.CENTER);
                            validate();
                        }

                    }
            );
                }


                
            private static void createAndShowGUI() {
                    JFrame frame 
            = new JFrame("Multi Panel");
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setSize(
            500600);

                    MultiPanel panel 
            = new MultiPanel();
                    frame.getContentPane().add(panel, BorderLayout.CENTER);

                    frame.setVisible(
            true);
                }


                
            /**
                 * 
            @param args
                 
            */

                
            public static void main(String[] args) {
                    SwingUtilities.invokeLater(
            new Runnable() {
                        
            public void run() {
                            MultiPanel.createAndShowGUI();
                        }

                    }
            );
                }


            }

            posted on 2008-03-22 18:35 逛奔的蝸牛 閱讀(866) 評論(0)  編輯 收藏 引用 所屬分類: Java
            久久99热这里只有精品国产| 久久久青草青青亚洲国产免观| 久久99精品久久久久子伦| 成人免费网站久久久| 亚洲精品乱码久久久久久蜜桃| 精品国际久久久久999波多野 | 亚洲国产精品久久久久网站 | 久久丫精品国产亚洲av不卡| 久久久久四虎国产精品| 久久嫩草影院免费看夜色| 久久久久久久久无码精品亚洲日韩 | 久久综合九色综合网站| 久久99精品国产麻豆蜜芽| 午夜人妻久久久久久久久| 亚洲国产成人精品女人久久久| 精品久久久久久亚洲| 精品国际久久久久999波多野| 国内精品欧美久久精品| 久久被窝电影亚洲爽爽爽| 精品多毛少妇人妻AV免费久久 | 久久综合伊人77777| 国产精品99久久免费观看| 一本久久a久久精品亚洲| 久久天天躁狠狠躁夜夜不卡 | 热综合一本伊人久久精品| 久久99精品综合国产首页| 久久精品人妻中文系列| 性欧美大战久久久久久久| 久久精品国产国产精品四凭| 久久精品成人免费观看97| 99久久免费国产特黄| 99国产欧美久久久精品蜜芽| 亚洲AV乱码久久精品蜜桃| 日韩AV无码久久一区二区| 思思久久好好热精品国产| 中文字幕无码久久人妻| 久久久久一级精品亚洲国产成人综合AV区 | 久久无码人妻精品一区二区三区 | 无码人妻久久一区二区三区| 国产精品久久久香蕉| 久久棈精品久久久久久噜噜|