示例#1
0
    /** 初始化 1 设置页面 2 创建控件 3 页面添加控件 */
    void init() {
      // 布局
      this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
      this.setBackground(Color.LIGHT_GRAY);

      // 菜单按键
      bt0_HomePanel = new Button("主控制");
      bt1_SettingPanel = new Button("设置");
      bt2_DrawwingPanel = new Button("绘图");
      bt3_InternetPanel = new Button("网路");
      bt4_OtherPanel = new Button("其他");

      // 给bt4添加菜单,其他功能用弹出菜单
      popupmenu = new PopupMenu("popupmenu");
      mi_0 = new MenuItem("其他功能1");
      mi_1 = new MenuItem("其他功能2");
      mi_2 = new MenuItem("其他功能3");
      popupmenu.add(mi_0);
      popupmenu.add(mi_1);
      popupmenu.add(mi_2);
      bt4_OtherPanel.add(popupmenu);

      // 添加到Panel菜单条
      this.add(bt0_HomePanel);
      this.add(bt1_SettingPanel);
      this.add(bt2_DrawwingPanel);
      this.add(bt3_InternetPanel);
      this.add(bt4_OtherPanel);
    }