• 窗口实训1


    package tjc;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.*;
    public class tjc  {
        JFrame f;
        JPanel p1,p2;
        JButton b1,b2,b3;
        public tjc(){
            f=new JFrame();
            p1=new JPanel();
            p2=new JPanel();
            b1=new JButton("黄色");
            b2=new JButton("绿色");
            b3=new JButton("粉色");
            f.add(p1,BorderLayout.NORTH);
            f.add(p2,BorderLayout.CENTER);
            p1.add(b1);
            p1.add(b2);
            p1.add(b3);   
            f.setSize(400,500);
            f.setVisible(true);
        b1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                p2.setBackground(Color.YELLOW);
                   
            }
                   
        });
        b2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                p2.setBackground(Color.GREEN);
                   
            }
               
        });
        b3.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                p2.setBackground(Color.PINK);
                   
            }
               
        });
        }
        public static void main(String[]args){
            new tjc
            ();
        }}
       

    package tjc;
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class tjc1 {
     JFrame jf;
     JPanel jp;
     JTextField jt;
     JButton jb;
     GridLayout g;
     public tjc1(){
    jf=new JFrame("计算器");
    g=new GridLayout(4,4);
    jp=new JPanel();
    jp.setLayout(g);
    jt=new JTextField();
    jb=new JButton("7");
    jp.add(jb);
    jb=new JButton("8");
    jp.add(jb);
    jb=new JButton("9");
    jp.add(jb);
    jb=new JButton("/");
    jp.add(jb); 
    jb=new JButton("4");
    jp.add(jb);
    jb=new JButton("5");
    jp.add(jb);
    jb=new JButton("6");
    jp.add(jb);
    jb=new JButton("*");
    jp.add(jb);
    jb=new JButton("1");
    jp.add(jb);
    jb=new JButton("2");
    jp.add(jb);
    jb=new JButton("3");
    jp.add(jb);
    jb=new JButton("-");
    jp.add(jb);
    jb=new JButton("0");
    jp.add(jb);
    jb=new JButton(".");
    jp.add(jb);
    jb=new JButton("=");
    jp.add(jb);
    jb=new JButton("+");
    jp.add(jb);
    jf.add(jt,BorderLayout.NORTH);
    jf.add(jp,BorderLayout.CENTER);
    jf.setSize(400,300);
    jf.setVisible(true);
    }
     public static void main(String[]args){
      new tjc1();}}
     
     
  • 相关阅读:
    lr参数化取值规则总结
    LoadRunner中InvokeMethod failure: 外部组件发生异常解决办法
    Error: Exception was raised when calling event-notify Vuser function in extension parameng.dll: System Exceptions: EXCEPTION_ACCESS_VIOLATION
    loadrunner场景执行出现:Failed to Initialize. Reason: TimeOut
    loadrunner场景中按scenario和group执行的区别
    lr关联抓有相同左右边界的动态值
    lr中用strtok函数分割字符串
    LoadRunner11设置场景百分比模式完成多台客户端压力测试
    lr如何屏蔽全局变量的影响
    Oracle in与exist条件分析
  • 原文地址:https://www.cnblogs.com/tangjiachen/p/10904937.html
Copyright © 2020-2023  润新知