• Exec68


    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Exec68 extends JFrame{
        JTextField text;
        Boolean flag1,flag2;
        public Exec68() {
            setSize(400,500);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLocationRelativeTo(null);
            setTitle("Exec68 test");
            JPanel panel = new JPanel();
            text = new JTextField(10);
            
            text.setFont(new Font(null,Font.PLAIN,60));
            text.setAlignmentX(CENTER_ALIGNMENT);
            final JButton bt1 = new JButton("打开体育之窗");
            final JButton bt2 = new JButton("打开音乐之窗");
            flag1 = true;
            flag2 = true;
            bt1.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    if (flag1)     {
                        text.setText("体育之窗");
                        bt1.setText("关闭体育之窗");
                        bt2.setText("打开音乐之窗");
                        flag2 = true;
                    }
                    else {
                        text.setText("");
                        bt1.setText("打开体育之窗");
                    }
                    flag1 = !flag1;
                }
            });
            bt2.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    if (flag2)     {
                        text.setText("音乐之窗");
                        bt2.setText("关闭音乐之窗");
                        bt1.setText("打开体育之窗");
                        flag1 = true;
                    }
                    else {
                        text.setText("");
                        bt2.setText("打开音乐之窗");
                    }
                    flag2 = !flag2;
                }
            });
            panel.add(bt1);
            panel.add(bt2);
            add(panel,BorderLayout.NORTH);
            add(text);
            setVisible(true);
            pack();
        }
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            new Exec68();
        }
    
    }
  • 相关阅读:
    前端总结挺全面的
    cmd与bat脚本的使用
    Spring控制反转(IoC)的理解
    C# 中迭代器
    URL 分页并排序
    结合Flash上传文件时显示进度条
    C# 语言特性
    where T:new()
    图片缩放特效
    C# 隐藏窗体 ALT+TAb不可见
  • 原文地址:https://www.cnblogs.com/qqjue/p/2627948.html
Copyright © 2020-2023  润新知