Пример #1
0
  // ds KeyListener - just map the keys to the buttons
  public void keyPressed(KeyEvent p_cKey) {
    // ds get the keycode
    final int iKeyCode = p_cKey.getKeyCode();

    // ds if/else tree
    if (iKeyCode == KeyEvent.VK_RIGHT) {
      m_cButtonLike.doClick();
    } else if (iKeyCode == KeyEvent.VK_DOWN) {
      m_cButtonDislike.doClick();
    } else if (iKeyCode == KeyEvent.VK_LEFT) {
      m_cButtonPrevious.doClick();
    } else if (iKeyCode == KeyEvent.VK_R) {
      /*m_cButtonReset.doClick( );*/
    } else if (iKeyCode == KeyEvent.VK_ESCAPE) {
      // ds notify
      System.out.println(
          "["
              + CLogger.getStamp()
              + "]<CGUI>(keyPressed) Caught escape signal - shutting down GUI");

      // ds escape gui
      m_cFrame.removeAll();
      m_cFrame.dispose();
    }
  }
Пример #2
0
 /**
  * ************************************************
  *
  * <pre>
  * Summary: Catch any key pressed.
  *
  * </pre>
  *
  * *************************************************
  */
 public void keyPressed(KeyEvent e) {
   // Have an escape do the same as clicking cancel.
   if (e.getKeyCode() == KeyEvent.VK_ESCAPE) abandonButton.doClick();
   // Return
   else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     if (closeButton.isEnabled()) {
       closeButton.doClick();
     }
   }
 }
Пример #3
0
  public void keyPressed(KeyEvent e) {
    switch (e.getKeyCode()) {
      case KeyEvent.VK_ENTER:
        btApply.doClick();
        break;

      case KeyEvent.VK_ESCAPE:
        btCancel.doClick();
        e.consume();
        break;
    }
  }
Пример #4
0
 @Action
 private void keyTyped(java.awt.event.KeyEvent evt) { // {{{
   switch (evt.getKeyCode()) {
     case KeyEvent.VK_ENTER:
       // sendAsyncTweet();
       btnTweet.doClick();
       // sendTweetClicked().execute();
       break;
     case KeyEvent.VK_M:
       if (evt.isControlDown()) view.showMiniMode();
       break;
     case KeyEvent.VK_ESCAPE:
       view.getMainApp().toggleWindowView("down");
       break;
       //	default:
       //		int c = txtTweet.getDocument().getLength();
       //		lblChars.setText((140 - c)+"");
       //		if((c > 0) && (c < 141)) {
       //			btnTweet.setEnabled(true);
       //			lblChars.setForeground(getResourceMap().getColor("lblChars.foreground"));
       //		}
       //		else if(c > 140) {
       //			lblChars.setForeground(Color.RED);
       //			btnTweet.setEnabled(false);
       //		}
       //		else
       //		{
       //			btnTweet.setEnabled(false);
       //		}
   }
 } // }}}
  @Override
  public void actionPerformed(ActionEvent ae) {
    pakkaNappi.setEnabled(true);
    avoPakkaNappi.setEnabled(true);

    for (JButton nappi : vuoro.getPelaaja().getKorttiNapit()) {
      if (nappi.getName() == null) {
        avoPakkaNappi.setText(pokeri.pakanPaallimmainen.toString());

        Kortti kortti = pokeri.koneKaantaaKortin(vuoro.getKasi());

        nappi.setText(kortti.toString());

        KorttienMaalaaja.maalaaNappi(pokeri, kortti, nappi);

        nappi.setName("painettu");
        nappi.doClick();

        break;
      }
    }
    vuoro.seuraava();

    NappiHallinto.piilotaMuidenPelaajienNapit(pokeri, vuoro);

    lopetaPeliLopussa(pokeri, frame, avoPakkaNappi, pakkaNappi);

    KoneToiminta.luoJaPainaaKoneNappia(pokeri, frame, vuoro, avoPakkaNappi, pakkaNappi);

    if (!frame.getTitle().equals("Piilopokeri")) {
      frame.dispose();
    }
  }
Пример #6
0
  public boolean dispatchKeyEvent(KeyEvent e) {
    if (e.getID() == KeyEvent.KEY_PRESSED) {
      pressed.add(e.getKeyCode());
      MouseListener mlis;

      if ((mlis = mListeners.get(e.getKeyCode())) != null) {
        mlis.mouseClicked(null);
      }
      if (buttons.containsKey(e.getKeyCode())) {
        ArrayList<JButton> list = buttons.get(e.getKeyCode());
        if (bid.containsKey(e.getKeyCode())) {
          for (int i = 0; i < list.size(); ++i) {
            int k = isPressed(KeyEvent.VK_SHIFT) ? -1 : 1;
            int a = (bid.get(e.getKeyCode()) + k + list.size()) % list.size();
            bid.put(e.getKeyCode(), a);
            if (list.get(a).isVisible()) {
              list.get(a).doClick();
              break;
            }
          }
        } else {
          for (JButton button : buttons.get(e.getKeyCode())) {
            if (button != null && button.isVisible()) {
              button.doClick();
              break;
            }
          }
        }
      }
    }
    if (e.getID() == KeyEvent.KEY_RELEASED) {
      pressed.remove(e.getKeyCode());
    }
    return false;
  }
Пример #7
0
  private void jBFecharActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBFecharActionPerformed

    timerTelaExclusao.stop();
    timer.start();
    this.setVisible(false);
    atualizar.doClick();
  } // GEN-LAST:event_jBFecharActionPerformed
Пример #8
0
 public void endGame(String winnerName) {
   JOptionPane.showMessageDialog(
       null, mGameManager.getWinner() + " player won!", "Sorry!", JOptionPane.NO_OPTION);
   // Quit out if over
   JButton exit = new JButton("");
   exit.addActionListener(mQuitAction);
   exit.doClick();
 }
Пример #9
0
 @Override
 public void keyReleased(KeyEvent e) {
   if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     if (e.getSource() == startTimeTF.getDate() || e.getSource() == timeTF.getDate()) {
       // 查询会员
       queryButton.doClick();
     }
   }
 }
 public void actionPerformed(ActionEvent e) {
   if (cChooser == null) {
     cChooser = new JColorChooser();
   }
   Color color =
       cChooser.showDialog(
           target, "Available Colors", ((ColoredIcon) target.getIcon()).getCurrentColor());
   target.setIcon(new ColoredIcon(color));
   target.doClick();
 }
Пример #11
0
  @Override
  public void mouseClicked(MouseEvent e) {
    int column = table.getColumnModel().getColumnIndexAtX(e.getX());
    int row = e.getY() / table.getRowHeight();

    if (row < table.getRowCount() && row >= 0 && column < table.getColumnCount() && column >= 0) {
      Object value = table.getValueAt(row, column);
      if (value != null && value instanceof JButton) ((JButton) value).doClick();
    }
  }
Пример #12
0
  /** Updates the table. */
  public void updateTableForPrint() {
    // Check if already expanded, do nothing.
    BestPracticeButtonPanel bpanel = ((BestPracticeButtonPanel) getButtonsPanel());
    JButton viewBtn = bpanel.getViewBtn();
    if (!bpanel.isExpanded() && this.noOfRecords > 5) {

      viewBtn.doClick();
      this.scrollPane.revalidate();
    }
  }
Пример #13
0
 @Override
 public void keyPressed(KeyEvent e) {
   if (e.getSource() == orderNum.getText()
       || e.getSource() == userNum.getText()
       || e.getSource() == seller.getText()) {
     // 查询
     if (e.getKeyCode() == KeyEvent.VK_ENTER) {
       queryButton.doClick();
     }
   }
 }
Пример #14
0
  private void jBFecharKeyTyped(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jBFecharKeyTyped

    if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
      if (evt.getSource() == jBFechar) {
        timerTelaExclusao.stop();
        timer.start();
        this.setVisible(false);
        atualizar.doClick();
      }
    }
  } // GEN-LAST:event_jBFecharKeyTyped
  /** Sets up how the different GUI components should be viewed at startup. */
  private void initializeDisplay() {
    if (itemNames.getItemCount() > 0) {
      itemNames.setSelectedIndex(0);

    } else {
      txtFlavor.setEnabled(false);
      txtStock.setEnabled(false);
      txtSalePrice.setEnabled(false);
      btnUpdate.setEnabled(false);
      btnDelete.setEnabled(false);
      btnNew.doClick();
    }
  }
Пример #16
0
  public FlashCardSettingFrame(String filePath, long interval, boolean isAutoStart)
      throws ClassNotFoundException, IOException {
    this();
    tfKanjiFilePath.setText(filePath);

    if (interval != -1) {
      tfInterval.setText(interval + "");
    }

    if (isAutoStart) {
      btnApply.doClick();
    }
  }
Пример #17
0
 @Override
 public void mouseReleased(MouseEvent e) {
   JList list = (JList) e.getComponent();
   Point pt = e.getPoint();
   int index = list.locationToIndex(pt);
   if (index >= 0) {
     JButton button = getButton(list, pt, index);
     if (Objects.nonNull(button)) {
       button.doClick();
       Rectangle r = list.getCellBounds(index, index);
       listRepaint(list, r);
     }
   }
 }
Пример #18
0
    @Override
    public void mouseClicked(MouseEvent e) {
      int columna = jTable.getColumnModel().getColumnIndexAtX(e.getX());
      int fila = e.getY() / jTable.getRowHeight();

      if ((fila < jTable.getRowCount() && fila >= 0)
          && (columna < jTable.getColumnCount() && columna >= 0)) {

        if (jTable.getValueAt(fila, columna) instanceof JButton) {
          JButton btn = (JButton) jTable.getValueAt(fila, columna);
          btn.doClick();
        }
      }
    }
Пример #19
0
 private void setLoadOutForEscortGame() {
   possibleUnitList.removeAll();
   possibleUnitListModel.removeAllElements();
   userUnitListModel.removeAllElements();
   userUnitList.removeAll();
   userUnitListModel.addElement(new SoldierUnit("Alice"));
   userUnitListModel.addElement(new SoldierUnit("Bob"));
   userUnitListModel.addElement(new SoldierUnit("Charlie"));
   userUnitListModel.addElement(new SoldierUnit("Danielle"));
   userUnitListModel.addElement(new EscortUnit("Eve", 0));
   possibleUnitList.setEnabled(false);
   userUnitList.setEnabled(false);
   readyButton.doClick();
 }
Пример #20
0
 @Override
 public void mouseReleased(MouseEvent e) {
   // JList list = (JList) e.getComponent();
   Point pt = e.getPoint();
   int index = list.locationToIndex(pt);
   if (index >= 0) {
     JButton button = getButton(list, pt, index);
     if (Objects.nonNull(button)) {
       ButtonsRenderer renderer = (ButtonsRenderer) list.getCellRenderer();
       renderer.pressedIndex = -1;
       renderer.button = null;
       button.doClick();
       listRepaint(list, list.getCellBounds(index, index));
     }
   }
 }
Пример #21
0
  @Test
  public void testBindPresenter() {

    presenter = new PresenterObject();
    model = new ModelObject();
    ViewObject view = new ViewObject();
    appController.bindPresenter(view, presenter);
    // The test on JButton binding with the presenter
    JButton okButton = view.getOkButton();
    Assert.assertTrue(okButton.getActionListeners().length != 0);
    okButton.doClick();
    // The test on JmenuItem binding with the presenter
    JMenuItem menuItem = view.getJmenuitem();
    Assert.assertTrue(menuItem.getActionListeners().length != 0);
    menuItem.doClick();
  }
Пример #22
0
  public Splitter() {
    super(new BorderLayout());

    // Create the demo's UI.
    startButton = new JButton("Start");
    startButton.setActionCommand("start");
    startButton.addActionListener(this);
    startButton.setVisible(false);

    taskOutput = new JTextArea(30, 130);
    taskOutput.setMargin(new Insets(5, 5, 5, 5));
    taskOutput.setEditable(false);

    JPanel panel = new JPanel();
    panel.add(startButton);

    add(panel, BorderLayout.PAGE_START);
    add(new JScrollPane(taskOutput), BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    startButton.doClick();
  }
Пример #23
0
  public LoginBox() {
    initialize();

    if (Primary.settings.get("xmlMode")) {
      readUsers();
    }

    setSizes();
    createLayout();
    setListeners();
    setAdditionalProperties();

    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.pack();
    this.setLocationRelativeTo(null);

    setTitle("Login");
    setVisible(true);

    if (Primary.settings.get("startOnSecondScreen")) {
      GraphicsDevice[] gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

      if (gs.length > 1) {
        this.setLocation(
            gs[1].getDefaultConfiguration().getBounds().x
                + (gs[1].getDefaultConfiguration().getBounds().width - this.getWidth()) / 2,
            gs[1].getDefaultConfiguration().getBounds().y
                + (gs[1].getDefaultConfiguration().getBounds().height - this.getWidth()) / 2);
      }
    }

    if (Primary.settings.get("autoLogin")) {
      tfUsername.setText("origyn");
      tfPassword.setText("gosho");

      btLogin.doClick();
    }
  }
Пример #24
0
  /** Save changes to the current entity */
  private void doSave() {
    Class<? extends ITridas> type;

    if (temporaryEditingEntity == null) throw new IllegalStateException();

    // if nothing actually changed, just ignore it like a cancel
    if (!hasChanged) {
      editEntityCancel.doClick();
      return;
    }

    propertiesPanel.writeToObject(temporaryEditingEntity);

    // the resource we'll use
    EntityResource<? extends ITridas> resource;

    if (temporaryEditingEntity instanceof TridasObject) {
      resource =
          new EntityResource<TridasObject>(
              temporaryEditingEntity, TellervoRequestType.UPDATE, TridasObject.class);
      type = TridasObject.class;
    } else if (temporaryEditingEntity instanceof TridasElement) {
      resource =
          new EntityResource<TridasElement>(
              temporaryEditingEntity, TellervoRequestType.UPDATE, TridasElement.class);
      type = TridasElement.class;
    } else if (temporaryEditingEntity instanceof TridasSample) {
      resource =
          new EntityResource<TridasSample>(
              temporaryEditingEntity, TellervoRequestType.UPDATE, TridasSample.class);
      type = TridasSample.class;
    } else if (temporaryEditingEntity instanceof TridasRadius) {
      resource =
          new EntityResource<TridasRadius>(
              temporaryEditingEntity, TellervoRequestType.UPDATE, TridasRadius.class);
      type = TridasRadius.class;
    } else if (temporaryEditingEntity instanceof TridasMeasurementSeries) {
      resource =
          new EntityResource<TridasMeasurementSeries>(
              temporaryEditingEntity, TellervoRequestType.UPDATE, TridasMeasurementSeries.class);
      type = TridasMeasurementSeries.class;
    } else {
      log.debug("Can't save entity.  Unsupported entity class.");
      return;
    }

    // set up a dialog...
    Window parentWindow = SwingUtilities.getWindowAncestor(this);
    TellervoResourceAccessDialog dialog =
        TellervoResourceAccessDialog.forWindow(parentWindow, resource);

    // query the resource
    resource.query();
    dialog.setVisible(true);

    // on failure, just return
    if (!dialog.isSuccessful()) {
      JOptionPane.showMessageDialog(
          this,
          I18n.getText("error.savingChanges")
              + "\r\n"
              + I18n.getText("error")
              + ": "
              + dialog.getFailException().getLocalizedMessage(),
          I18n.getText("error"),
          JOptionPane.ERROR_MESSAGE);
      return;
    }

    // replace the saved result
    temporaryEditingEntity = resource.getAssociatedResult();

    // sanity check the result
    if (temporaryEditingEntity == null) {
      new BugDialog(new IllegalStateException("CREATE or UPDATE entity returned null"));
      return;
    }

    setEntity(temporaryEditingEntity, type, true);

    // Inform the tree to update itself
    if (nodeSelected != null) {
      if (nodeSelected.getParent() == null) {

      } else if (nodeSelected.getParent().equals(nodeSelected.getRoot())) {
        ((TridasTreeViewPanel) treepanel).refreshNode(nodeSelected);
      } else {
        ((TridasTreeViewPanel) treepanel)
            .refreshNode((DefaultMutableTreeNode) nodeSelected.getParent());
      }
    }

    hasChanged = false;
  }
Пример #25
0
  public void login() {
    mbAutoLogIn = false;
    while (!mbAutoLogIn) {
      try {
        // Confirm logout
        if (isOpen()) {
          if (MessageBox.showConfirmDialog(
                  this,
                  MonitorDictionary.getString("Confirm.Exit"),
                  Global.APP_NAME,
                  MessageBox.YES_NO_OPTION)
              == MessageBox.NO_OPTION) return;

          // Disconnect from server
          disconnect();
        }

        // Login
        DialogLogin dlgLogin = new DialogLogin(this);
        WindowManager.centeredWindow(dlgLogin);

        if (dlgLogin.miReturn == JOptionPane.OK_OPTION) {
          // Update UI
          SwingUtilities.updateComponentTreeUI(pnlUser);
          SwingUtilities.updateComponentTreeUI(pnlThread);

          // Request to connect
          Socket sck = new Socket(dlgLogin.mstrHost, Integer.parseInt(dlgLogin.mstrPort));
          sck.setSoLinger(true, 0);

          // Start up a channel thread that reads messages from the server
          channel =
              new SocketTransmitter(sck) {
                public void close() {
                  if (msckMain != null) {
                    super.close();
                    closeAll();
                    if (mbAutoLogIn) login();
                  }
                }
              };
          channel.setUserName(dlgLogin.mstrUserName);
          channel.setPackage("com.fss.thread.");
          channel.start();

          // Request to Server
          DDTP request = new DDTP();
          request.setRequestID(String.valueOf(System.currentTimeMillis()));
          request.setString("UserName", dlgLogin.mstrUserName);
          request.setString("Password", dlgLogin.mstrPassword);

          // Response from Server
          DDTP response = channel.sendRequest("ThreadProcessor", "login", request);
          mstrThreadAppName = response.getString("strThreadAppName");
          mstrThreadAppVersion = response.getString("strThreadAppVersion");
          mstrAppName = response.getString("strAppName");
          mstrAppVersion = response.getString("strAppVersion");
          if (response != null) {
            if (response.getString("PasswordExpired") != null) {
              DialogChangePassword frm = new DialogChangePassword(this, channel);
              WindowManager.centeredWindow(frm);
              if (frm.miReturnValue != JOptionPane.OK_OPTION) throw new AppException("FSS-10003");
            }
            String strLog = StringUtil.nvl(response.getString("strLog"), "");
            showResult(txtBoard, strLog);
            Vector vtThread = response.getVector("vtThread");
            updateTabBar(vtThread);

            mstrChannel = response.getString("strChannel");
            if (mstrChannel != null) removeUser(mstrChannel);
          }
          btnRefresh.doClick();
          pnlThread.setVisible(true);
          pnlUser.setVisible(true);
          setResizeWeight(1);
          setDividerLocation((int) (getSize().getHeight() - 160));
        }
        mbAutoLogIn = true;
        updateLanguage();
      } catch (Exception e) {
        e.printStackTrace();
        MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);

        // Disconnect from server
        mstrChannel = null;
        disconnect();
      }
    }
  }
Пример #26
0
 public void keyPressed(KeyEvent e) {
   //		System.out.println("Key Pressed: " + e);
   if (e.getKeyCode() == KeyEvent.VK_ENTER) login.doClick();
 }
Пример #27
0
  /** Creates a new Launcher object. */
  public Launcher() {
    // Initialize the SystemTray now (to avoid a bug!)
    SystemTray tray = null;
    try {
      tray = SystemTray.getDefaultSystemTray();
    } catch (Throwable e) {
      // Log to System error instead of standard error log.
      System.err.println("Error loading system tray library, system tray support disabled.");
    }

    // Use the native look and feel.
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (System.getProperty("app.name") != null) {
      appName = System.getProperty("app.name");
    } else {
      appName = "Openfire";
    }

    binDir = new File("").getAbsoluteFile();
    // See if the appdir property is set. If so, use it to find the executable.
    if (System.getProperty("appdir") != null) {
      binDir = new File(System.getProperty("appdir"));
    }

    configFile = new File(new File(binDir.getParent(), "conf"), "openfire.xml");

    frame =
        new DroppableFrame() {
          @Override
          public void fileDropped(File file) {
            String fileName = file.getName();
            if (fileName.endsWith(".jar") || fileName.endsWith(".war")) {
              installPlugin(file);
            }
          }
        };

    frame.setTitle(appName);

    ImageIcon splash;
    JPanel mainPanel = new JPanel();
    JLabel splashLabel = null;

    cardPanel.setLayout(cardLayout);

    // Set the icon.
    try {
      splash = new ImageIcon(getClass().getClassLoader().getResource("splash.gif"));
      splashLabel = new JLabel("", splash, JLabel.CENTER);

      onIcon = new ImageIcon(getClass().getClassLoader().getResource("openfire_on-16x16.gif"));
      offIcon = new ImageIcon(getClass().getClassLoader().getResource("openfire_off-16x16.gif"));
      frame.setIconImage(offIcon.getImage());
    } catch (Exception e) {
      e.printStackTrace();
    }

    mainPanel.setLayout(new BorderLayout());
    cardPanel.setBackground(Color.white);

    // Add buttons
    final JButton startButton = new JButton("Start");
    startButton.setActionCommand("Start");

    final JButton stopButton = new JButton("Stop");
    stopButton.setActionCommand("Stop");

    final JButton browserButton = new JButton("Launch Admin");
    browserButton.setActionCommand("Launch Admin");

    final JButton quitButton = new JButton("Quit");
    quitButton.setActionCommand("Quit");

    toolbar.setLayout(new GridBagLayout());
    toolbar.add(
        startButton,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    toolbar.add(
        stopButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    toolbar.add(
        browserButton,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));
    toolbar.add(
        quitButton,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 5, 5),
            0,
            0));

    mainPanel.add(cardPanel, BorderLayout.CENTER);
    mainPanel.add(toolbar, BorderLayout.SOUTH);

    // create the main menu of the system tray icon
    JPopupMenu menu = new JPopupMenu(appName + " Menu");

    final JMenuItem showMenuItem = new JMenuItem("Hide");
    showMenuItem.setActionCommand("Hide/Show");
    menu.add(showMenuItem);

    final JMenuItem startMenuItem = new JMenuItem("Start");
    startMenuItem.setActionCommand("Start");
    menu.add(startMenuItem);

    final JMenuItem stopMenuItem = new JMenuItem("Stop");
    stopMenuItem.setActionCommand("Stop");
    menu.add(stopMenuItem);

    final JMenuItem browserMenuItem = new JMenuItem("Launch Admin");
    browserMenuItem.setActionCommand("Launch Admin");
    menu.add(browserMenuItem);

    menu.addSeparator();

    final JMenuItem quitMenuItem = new JMenuItem("Quit");
    quitMenuItem.setActionCommand("Quit");
    menu.add(quitMenuItem);

    browserButton.setEnabled(false);
    stopButton.setEnabled(false);
    browserMenuItem.setEnabled(false);
    stopMenuItem.setEnabled(false);

    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if ("Start".equals(e.getActionCommand())) {
              frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              // Adjust button and menu items.
              startButton.setEnabled(false);
              stopButton.setEnabled(true);
              startMenuItem.setEnabled(false);
              stopMenuItem.setEnabled(true);

              // Startup Application
              startApplication();

              // Change to the "on" icon.
              frame.setIconImage(onIcon.getImage());
              trayIcon.setIcon(onIcon);

              // Start a thread to enable the admin button after 8 seconds.
              Thread thread =
                  new Thread() {
                    @Override
                    public void run() {
                      try {
                        sleep(8000);
                      } catch (InterruptedException ie) {
                        // Ignore.
                      }
                      // Enable the Launch Admin button/menu item only if the
                      // server has started.
                      if (stopButton.isEnabled()) {
                        browserButton.setEnabled(true);
                        browserMenuItem.setEnabled(true);
                        frame.setCursor(Cursor.getDefaultCursor());
                      }
                    }
                  };
              thread.start();
            } else if ("Stop".equals(e.getActionCommand())) {
              stopApplication();
              // Change to the "off" button.
              frame.setIconImage(offIcon.getImage());
              trayIcon.setIcon(offIcon);
              // Adjust buttons and menu items.
              frame.setCursor(Cursor.getDefaultCursor());
              browserButton.setEnabled(false);
              startButton.setEnabled(true);
              stopButton.setEnabled(false);
              browserMenuItem.setEnabled(false);
              startMenuItem.setEnabled(true);
              stopMenuItem.setEnabled(false);
            } else if ("Launch Admin".equals(e.getActionCommand())) {
              launchBrowser();
            } else if ("Quit".equals(e.getActionCommand())) {
              stopApplication();
              System.exit(0);
            } else if ("Hide/Show".equals(e.getActionCommand())
                || "PressAction".equals(e.getActionCommand())) {
              // Hide/Unhide the window if the user clicked in the system tray icon or
              // selected the menu option
              if (frame.isVisible()) {
                frame.setVisible(false);
                frame.setState(Frame.ICONIFIED);
                showMenuItem.setText("Show");
              } else {
                frame.setVisible(true);
                frame.setState(Frame.NORMAL);
                showMenuItem.setText("Hide");
              }
            }
          }
        };

    // Register a listener for the radio buttons.
    startButton.addActionListener(actionListener);
    stopButton.addActionListener(actionListener);
    browserButton.addActionListener(actionListener);
    quitButton.addActionListener(actionListener);

    // Register a listener for the menu items.
    quitMenuItem.addActionListener(actionListener);
    browserMenuItem.addActionListener(actionListener);
    stopMenuItem.addActionListener(actionListener);
    startMenuItem.addActionListener(actionListener);
    showMenuItem.addActionListener(actionListener);

    // Set the system tray icon with the menu
    trayIcon = new TrayIcon(offIcon, appName, menu);
    trayIcon.setIconAutoSize(true);
    trayIcon.addActionListener(actionListener);

    if (tray != null) {
      tray.addTrayIcon(trayIcon);
    }

    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            stopApplication();
            System.exit(0);
          }

          @Override
          public void windowIconified(WindowEvent e) {
            // Make the window disappear when minimized
            frame.setVisible(false);
            showMenuItem.setText("Show");
          }
        });

    cardPanel.add("main", splashLabel);
    frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
    frame.pack();

    frame.setSize(400, 300);
    frame.setResizable(true);

    GraphicUtils.centerWindowOnScreen(frame);

    frame.setVisible(true);

    // Setup command area
    final ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource("splash2.gif"));
    pane =
        new DroppableTextPane() {
          @Override
          public void paintComponent(Graphics g) {
            final Dimension size = pane.getSize();

            int x = (size.width - icon.getIconWidth()) / 2;
            int y = (size.height - icon.getIconHeight()) / 2;
            //  Approach 1: Dispaly image at at full size
            g.setColor(Color.white);
            g.fillRect(0, 0, size.width, size.height);
            g.drawImage(icon.getImage(), x, y, null);

            setOpaque(false);
            super.paintComponent(g);
          }

          @Override
          public void fileDropped(File file) {
            String fileName = file.getName();
            if (fileName.endsWith(".jar") || fileName.endsWith(".war")) {
              installPlugin(file);
            }
          }
        };

    pane.setEditable(false);

    final JPanel bevelPanel = new JPanel();
    bevelPanel.setBackground(Color.white);
    bevelPanel.setLayout(new BorderLayout());
    bevelPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    bevelPanel.add(new JScrollPane(pane), BorderLayout.CENTER);
    cardPanel.add("running", bevelPanel);

    // Start the app.
    startButton.doClick();
  }
Пример #28
0
 /**
  * Artificially clicks the cancel button when this panel is escaped.
  *
  * @param isEscaped indicates if this dialog is closed by the Esc shortcut
  */
 protected void close(boolean isEscaped) {
   if (isEscaped) cancelButton.doClick();
 }
Пример #29
0
 @Override
 public void queryMember() {
   queryButton.doClick();
 }
Пример #30
0
 /**
  * Sets the text and re-generates the tree.
  *
  * @param s the options to display
  */
 public void setOptions(String s) {
   m_TextOptionsFull.setText(s);
   m_ButtonUpdate.doClick();
 }