• 计算器


    1,利用AWT组件实现计算器的可视化界面。

    2,掌握布局管理器的实现。

    3,计算器的实现利用了网页布局管理器。

    4,布局管理类的实现要在框架之上进行实现。

    5,遇到的问题:实现一个四行四列的计算器,第一次运行的时候是四行四列,第二次运行的时候是三行四列,第三次运行的时候又会恢复之前

    正常的四行四列,

    import java.awt.*;
    public class LoginFrame extends Frame{
     public LoginFrame()
     {
      super("计算器");
      this.setSize(200,130);
      this.setLocation(300,240);//设置组件的显示位置
      this.setBackground(Color.lightGray);//设置组件的背景颜色
      this.setVisible(true);//显示框架窗口
      this.setLayout(new GridLayout(4,4));
      this.add(new Button("7"));
      this.add(new Button("8"));
      this.add(new Button("9"));
      this.add(new Button("/"));
      this.add(new Button("4"));
      this.add(new Button("5"));
      this.add(new Button("6"));
      this.add(new Button("*"));
      this.add(new Button("1"));
      this.add(new Button("2"));
      this.add(new Button("3"));
      this.add(new Button("-"));
      this.add(new Button("0"));
      this.add(new Button("."));
      this.add(new Button("="));
      this.add(new Button("+"));

    }
     public static void main(String arg[])
     {
      new LoginFrame();
     }

    }

  • 相关阅读:
    Codeforces Round #518 Div. 1没翻车记
    BZOJ4310 跳蚤(后缀数组+二分答案)
    后缀数组备忘
    洛谷 P3573 [POI2014]RAJ-Rally 解题报告
    洛谷 P1503 鬼子进村 解题报告
    洛谷 P2375 [NOI2014]动物园 解题报告
    洛谷 P2797 Facer的魔法 解题报告
    【模板】三分法
    那些神奇的DP建模
    洛谷 P1136 迎接仪式 解题报告
  • 原文地址:https://www.cnblogs.com/sdn1229/p/6862449.html
Copyright © 2020-2023  润新知