예제 #1
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();
     }
   }
 }
예제 #2
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
 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();
 }
예제 #4
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();
    }
  }
예제 #6
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);
     }
   }
 }
예제 #7
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));
     }
   }
 }
예제 #8
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();
  }
예제 #9
0
 /**
  * Automatically press the cancel button when this dialog has been escaped.
  *
  * @param escaped indicates if this dialog has been closed by pressing the ESC key
  */
 @Override
 protected void close(boolean escaped) {
   if (escaped) cancelButton.doClick();
 }
예제 #10
0
  private void initComponents() {
    nameText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    titleText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    gameVersionText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    launchFlagsArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
    userFilesIncludeArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

    launchFlagsArea.setFont(nameText.getFont());
    userFilesIncludeArea.setFont(nameText.getFont());
    userFilesExcludeArea.setFont(nameText.getFont());

    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel container = new JPanel();
    container.setLayout(new MigLayout("fill, insets dialog"));

    tabbedPane.addTab("Modpack", null, createMainPanel());
    tabbedPane.addTab("Launch", null, createLaunchPanel());
    tabbedPane.addTab("User Files", null, createUserFilesPanel());
    tabbedPane.addTab("Optional Features", null, createFeaturesPanel());

    container.add(tabbedPane, "span, grow, gapbottom unrel");

    JButton saveButton = new JButton("Save");
    JButton cancelButton = new JButton("Cancel");

    container.add(saveButton, "tag ok, span, split 2, sizegroup bttn");
    container.add(cancelButton, "tag cancel, sizegroup bttn");

    getRootPane().setDefaultButton(saveButton);
    getRootPane()
        .registerKeyboardAction(
            event -> cancelButton.doClick(),
            KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    add(container, BorderLayout.CENTER);

    saveButton.addActionListener(
        e -> {
          if (nameText.getText().trim().isEmpty()) {
            SwingHelper.showErrorDialog(
                BuilderConfigDialog.this, "The 'Name' field cannot be empty.", "Input Error");
            return;
          }

          if (gameVersionText.getText().trim().isEmpty()) {
            SwingHelper.showErrorDialog(
                BuilderConfigDialog.this,
                "The 'Game Version' field must be a Minecraft version.",
                "Input Error");
            return;
          }

          copyTo();
          saved = true;
          dispose();
        });

    cancelButton.addActionListener(e -> dispose());

    TableSearchable tableSearchable = SearchableUtils.installSearchable(featuresTable);
    tableSearchable.setMainIndex(-1);
  }
예제 #11
0
 /** Clicks the call contact button in order to call the unknown contact. */
 public void startCall() {
   callButton.doClick();
 }
예제 #12
0
  public void actionPerformed(ActionEvent e) {
    if (dados != null) {
      if (e.getSource() == dados.pane.rollButton) {
        Thread t =
            new Thread(
                () -> {
                  try {
                    Thread.sleep(3000);
                  } catch (InterruptedException e1) {
                    e1.printStackTrace();
                  }

                  if (Objects.equals(dados.pane.text.getText(), "3")) {
                    dados.label.setBounds(70, 316 + 50, 507, 41);
                    dados.label.setText("Tie, Roll again");
                    dados.label.setVisible(true);
                    try {
                      Thread.sleep(1000);
                    } catch (InterruptedException e1) {
                      e1.printStackTrace();
                    }
                    b2.doClick();
                    dados.label.setBounds(70, 316 + 50, 507, 41);
                    dados.label.setText("Tie, Roll again");
                    dados.label.setVisible(true);
                  } else {
                    dados.label.setBounds(150, 316, 507, 41);
                    dados.pane.rollButton.setVisible(false);
                    dados.pane.setVisible(false);
                    try {
                      turno = new FileWriter("turno.txt");
                      pw = new PrintWriter(turno);
                    } catch (IOException e1) {
                      e1.printStackTrace();
                    }

                    if (Objects.equals(dados.pane.text.getText(), "1")) {
                      dados.label.setText("Congratulations , fate is on your side");
                      dados.label.setVisible(true);
                      try {
                        Thread.sleep(500);
                      } catch (InterruptedException e1) {
                        e1.printStackTrace();
                      }

                      dados.label.setText("Now select who is playing first");
                      dados.label.setBounds(295, 316, 507, 41);
                      add(dados.label);

                      Aifirst = new JButton();
                      Aifirst.setBounds(650, 400, 200, 200);
                      Aifirst.setIcon(new ImageIcon("seccond.png"));
                      add(Aifirst);

                      playerfirst = new JButton();
                      playerfirst.setBounds(250, 400, 200, 200);
                      playerfirst.setIcon(new ImageIcon("first.png"));
                      add(playerfirst);

                      player = new JLabel("Player");
                      player.setBounds(350, 620, 200, 30);
                      player.setAlignmentX(CENTER_ALIGNMENT);
                      player.setForeground(Color.WHITE);
                      add(player);

                      ai = new JLabel("Ai");
                      ai.setBounds(750, 620, 200, 30);
                      ai.setAlignmentX(CENTER_ALIGNMENT);
                      ai.setForeground(Color.WHITE);
                      add(ai);

                      playerfirst.addActionListener(this);
                      Aifirst.addActionListener(this);

                      repaint();
                      pw.println(1);
                    } else {
                      dados.label.setText("AI player gets the  first turn");
                      dados.pane.setVisible(true);
                      dados.label.setVisible(true);
                      dados.btnPlay.setVisible(true);
                      repaint();
                      pw.println(2);
                    }

                    try {
                      turno.close();
                    } catch (IOException e1) {
                      e1.printStackTrace();
                    }
                  }
                });
        t.start();
      }

      if (e.getSource() == Aifirst) {
        dados.pane.text.setText("2");
        dados.btnPlay.doClick();
      }

      if (e.getSource() == playerfirst) {
        dados.pane.text.setText("1");
        dados.btnPlay.doClick();
      }

      if (e.getSource() == dados.btnPlay) {
        try {
          player1 = new PlayGui(0, 0, Nombre1, this);
          Thread t =
              new Thread(
                  () -> {
                    try {
                      Thread.sleep(1000);
                    } catch (InterruptedException e1) {
                      e1.printStackTrace();
                    }
                    if (Objects.equals(dados.pane.text.getText(), "2")) {
                      try {
                        player1.Aiturn();
                        player1.contTurn++;
                      } catch (IOException
                          | UnsupportedAudioFileException
                          | LineUnavailableException
                          | InterruptedException e1) {
                        e1.printStackTrace();
                      }
                    } else {
                      player1.firstPlayerTurn();
                    }
                  });
          t.start();
        } catch (IOException | UnsupportedAudioFileException | LineUnavailableException e1) {
          e1.printStackTrace();
        }

        PlayGui.player.pdeck.btnNewButton_1.addMouseListener(this);
        PlayGui.player.pdeck.btnNewButton.addMouseListener(this);
        PlayGui.player.pdeck.textField.addMouseListener(this);

        try {
          addbackground3(this);
        } catch (IOException e1) {
          e1.printStackTrace();
        }
        getContentPane().setBackground(new Color(153, 204, 204));
        getContentPane().setLayout(null);

        player1.repaint.addActionListener(this);
        add(player1);

        setVisible(true);
      }
    }

    if (e.getSource() == b2) {
      try {
        dados = new RollDice();
        addbackground4(this);
      } catch (IOException e1) {
        e1.printStackTrace();
      }
      getContentPane().setLayout(null);

      dados.pane.rollButton.addActionListener(this);
      dados.btnPlay.addActionListener(this);
      add(dados);

      setVisible(true);
    }

    if (player1 != null) {
      if (e.getSource() == player1.repaint) {
        repaint();
      }

      if (e.getSource() == accionarAgarreAutomatico) {
        if (this.player1.getPhaseActual() == 0) {
          if (player1.cardDrawn == 0) {
            if (PlayGui.player.pdeck.Deck.cardsLeft() != 0) {
              CardGui nueva = null;
              try {
                nueva = new CardGui(PlayGui.player.pdeck.Deck.extractCard(), 0, 0);
              } catch (IOException e1) {
                e1.printStackTrace();
              }
              appear(nueva);
              final CardGui finalNueva = nueva;
              Thread t1 =
                  new Thread(
                      () -> {
                        try {
                          Thread.sleep(1000);
                        } catch (InterruptedException e1) {
                          e1.printStackTrace();
                        }
                        try {
                          PlayGui.player.hand.draw(finalNueva);
                        } catch (UnsupportedAudioFileException
                            | IOException
                            | LineUnavailableException e1) {
                          e1.printStackTrace();
                        }
                        repaint();
                      });
              t1.start();
            } else {
              doGameOver();
            }
          } else {
            JOptionPane.showMessageDialog(null, "Sorry , u can pick only a card per turn");
          }
        } else {
          JOptionPane.showMessageDialog(null, "Sorry , u can only pick cards on the draw phase");
        }
      }
    }
  }
예제 #13
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();
 }
예제 #14
0
 public void keyPressed(KeyEvent e) {
   //		System.out.println("Key Pressed: " + e);
   if (e.getKeyCode() == KeyEvent.VK_ENTER) login.doClick();
 }
예제 #15
0
 /** Clicks the add contact button in order to add the unknown contact to the contact list. */
 public void addUnknownContact() {
   addButton.doClick();
 }
예제 #16
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();
      }
    }
  }
예제 #17
0
파일: JChat.java 프로젝트: ThatoP/JChat
 public void actionPerformed(ActionEvent e) {
   button.doClick();
 }