• <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
            亚洲精品乱码久久久久66| 大美女久久久久久j久久| 亚洲а∨天堂久久精品9966| 久久大香萑太香蕉av| 亚洲精品无码久久久久久| 久久精品人人做人人爽电影| 久久婷婷色综合一区二区| 精品久久久久成人码免费动漫| 99久久免费国产特黄| 久久久久久久免费视频| 波多野结衣中文字幕久久| 亚洲а∨天堂久久精品9966| 99久久人妻无码精品系列蜜桃| 欧美精品福利视频一区二区三区久久久精品 | 97超级碰碰碰碰久久久久| 久久久久亚洲AV无码专区网站| 漂亮人妻被黑人久久精品| 国产一区二区三精品久久久无广告 | 国产精品久久国产精麻豆99网站 | 97久久综合精品久久久综合| 久久只这里是精品66| 亚洲国产精品久久66| 精品熟女少妇a∨免费久久| 久久狠狠爱亚洲综合影院| 久久综合久久伊人| 久久国产热这里只有精品| 亚洲国产精品久久久久婷婷老年| 久久精品国产亚洲AV香蕉| 亚洲AV日韩精品久久久久久| 2021最新久久久视精品爱| 亚洲婷婷国产精品电影人久久| 久久婷婷五月综合97色直播| 久久久久婷婷| 久久久久久无码国产精品中文字幕 | 久久A级毛片免费观看| 久久亚洲sm情趣捆绑调教| 亚洲一级Av无码毛片久久精品| 日韩久久久久中文字幕人妻| 日韩中文久久| 奇米影视7777久久精品人人爽| 人妻无码精品久久亚瑟影视|