Example #1
0
  public void updateConnectionStatus(boolean connected) {
    if (connected == true) {
      headerPanel.setLogoutText();
      loginMenuItem.setText("Logout");
    } else {
      headerPanel.setLoginText();
      loginMenuItem.setText("Login...");
    }
    mainCommandPanel.updateConnectionStatus(connected);
    propertiePanel.updateConnectionStatus(connected);
    cmdConsole.updateConnectionStatus(connected);
    Iterator iterator = plugins.iterator();
    PluginPanel updatePluginPanel = null;
    while (iterator.hasNext()) {
      updatePluginPanel = (PluginPanel) iterator.next();
      updatePluginPanel.updateConnectionStatus(connected);
    }

    if (connected == true) {
      int selected = tabbedPane.getSelectedIndex();
      if (selected >= 2) {
        ((PluginPanel) pluginPanelMap.get("" + selected)).activated();
      }
    }
  }
Example #2
0
 public void propertyChange(PropertyChangeEvent e) {
   String propertyName = e.getPropertyName();
   if (e.getPropertyName().equals(Action.NAME)) {
     String text = (String) e.getNewValue();
     menuItem.setText(text);
   } else if (propertyName.equals("enabled")) {
     Boolean enabledState = (Boolean) e.getNewValue();
     menuItem.setEnabled(enabledState.booleanValue());
   }
 }
Example #3
0
  /**
   * Modified "Generated Code". Initialize the GUI Components of the program. THIS PART GETS
   * EXTREMELY CONFUSING.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Bull Excrements Code">
  private void initComponents() {
    // MainFrame = new JFrame();

    sb = new StringBuilder(64);

    sb.append(instructions2());

    MessageLabel = new JLabel(sb.toString());

    MainPanel = new JPanel();
    MainMenuBar = new JMenuBar();
    FileMenu = new JMenu();
    NewGameMenu = new JMenu();
    EasyButton = new JMenuItem();
    MediumButton = new JMenuItem();
    HardButton = new JMenuItem();
    QuitButton = new JMenuItem();
    HelpMenu = new JMenu();

    // frame things -- useless!
    /*
    GroupLayout mainFrameLayout = new GroupLayout(MainFrame.getContentPane());
    MainFrame.getContentPane().setLayout(mainFrameLayout);
    mainFrameLayout.setHorizontalGroup(
        mainFrameLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 400, Short.MAX_VALUE)
    );
    mainFrameLayout.setVerticalGroup(
        mainFrameLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGap(0, 300, Short.MAX_VALUE)
    );
    */
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            formMouseReleased(evt);
          }
        });
    addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent evt) {
            formKeyPressed(evt);
          }
        });

    GroupLayout mainPanelLayout = new GroupLayout(MainPanel);
    MainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
        mainPanelLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                mainPanelLayout
                    .createSequentialGroup()
                    .addGap(40, 60, 80)
                    .addComponent(MessageLabel)
                    .addContainerGap(50, Short.MAX_VALUE)));
    mainPanelLayout.setVerticalGroup(
        mainPanelLayout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                mainPanelLayout
                    .createSequentialGroup()
                    .addGap(54, 54, 54)
                    .addComponent(MessageLabel)
                    .addContainerGap(200, Short.MAX_VALUE)));

    FileMenu.setText("File");
    FileMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            FileMenuMouseClicked(evt);
          }
        });

    NewGameMenu.setText("New Game");

    EasyButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    EasyButton.setText("Easy");
    EasyButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            EasyButtonMouseReleased(evt);
          }
        });
    NewGameMenu.add(EasyButton);

    MediumButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    MediumButton.setText("Medium");
    MediumButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            MediumButtonMouseReleased(evt);
          }
        });
    NewGameMenu.add(MediumButton);

    HardButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0));
    HardButton.setText("Hard");
    HardButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            HardButtonMouseReleased(evt);
          }
        });
    NewGameMenu.add(HardButton);

    FileMenu.add(NewGameMenu);

    QuitButton.setText("Quit");
    QuitButton.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent evt) {
            QuitButtonMouseReleased(evt);
          }
        });
    FileMenu.add(QuitButton);

    MainMenuBar.add(FileMenu);

    HelpMenu.setText("Help");
    MainMenuBar.add(HelpMenu);

    setJMenuBar(MainMenuBar);

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(
                MainPanel,
                GroupLayout.PREFERRED_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(
                MainPanel,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.DEFAULT_SIZE,
                GroupLayout.PREFERRED_SIZE));

    // post everything
    this.setTitle("Arcade");

    JLabel label = new JLabel(sb.toString());
    add(label);

    setVisible(true);
    repaint();
    pack();
  } // </editor-fold>