public String[] cannotUseRequestedNicknames(Server s) {
   synchronized (_nickLock) {
     if (_interface.getComponent() != null) _interface.getComponent().setEnabled(false);
     if (_frame != null) _frame.setEnabled(false);
     JFrame f = new JFrame();
     f.setLayout(new FlowLayout());
     f.setSize(200, 65);
     f.setTitle("Change nickname to");
     // f.setTitle(getText(IRCTextProvider.GUI_CHANGE_NICK));
     JTextField field = new JTextField(_start.getNick());
     JButton b = new JButton("Ok");
     b.addActionListener(this);
     f.add(field);
     f.add(b);
     f.setVisible(true);
     try {
       _nickLock.wait();
     } catch (InterruptedException ex) {
       // ignore...
     }
     f.setVisible(false);
     f.remove(b);
     f.remove(field);
     f.dispose();
     String[] ans = new String[1];
     ans[0] = field.getText();
     if (_frame != null) _frame.setEnabled(true);
     if (_interface.getComponent() != null) _interface.getComponent().setEnabled(true);
     return ans;
   }
 }
Exemplo n.º 2
0
  @Override
  public void run() {

    ventanaPrincipal.setEnabled(false);
    VentanaEspera ventanaEspera = new VentanaEspera(ventanaPrincipal);
    ventanaEspera.setVisible(true);
    uti.subirNuevoExcel(servi);
    ventanaEspera.dispose();
    JOptionPane.showMessageDialog(
        ventanaPrincipal,
        "Servicio guardado correctamente",
        "Servicio",
        JOptionPane.INFORMATION_MESSAGE);
    ventanaPrincipal.setEnabled(true);
    ventanaPrincipal.requestFocus();
  }
Exemplo n.º 3
0
  private void miMain() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    double width = screenSize.getWidth();
    double height = screenSize.getHeight();

    ventana = new JFrame("Prestatxen");
    ventana.setJMenuBar(menubarra());
    ventana.setSize((int) width, (int) height);
    ventana.setLocation(0, 0);
    ventana.setContentPane(panelPrincipal());
    ventana.setEnabled(true);
    ventana.setVisible(true);
    ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  /**
   * run will be exicuted when the thread is called, and will connect to the server and start
   * communicating with it.
   */
  public void run() {
    WaitForConnection wfc = new WaitForConnection("Waiting For Connection");
    m_OldWindow.setEnabled(false);
    try {
      m_Socket = new Socket(m_IP, m_Port);

      // System.out.println("Connecting to ChatService...");
      m_ChatSocket = new Socket(m_IP, m_Port);
      // System.out.println("\nConnected to ChatService...");

      wfc.updateMessage("Waiting For Other Players");

      // System.out.println("Getting OutputStream Stream From server...");
      toServer = new ObjectOutputStream(m_Socket.getOutputStream());
      toChatServer = new ObjectOutputStream(m_ChatSocket.getOutputStream());
      toChatServer.flush();

      // System.out.println("Getting Input Stream From server...");
      fromServer = new ObjectInputStream(m_Socket.getInputStream());
      fromChatServer = new ObjectInputStream(m_ChatSocket.getInputStream());

      m_ChatService = new ChatService();
      m_ChatServiceThread = new Thread(m_ChatService);
      m_ChatServiceThread.start();

      m_MultiPlayerMenu.startGame();
      wfc.dispose();
      m_OldWindow.dispose();
    } catch (java.net.ConnectException e) {
      wfc.dispose();
      MenuWindow menu = new MenuWindow(new JFrame(""));
      JOptionPane.showMessageDialog(menu.getMainFrame(), "Error Connection refused");
      m_OldWindow.setEnabled(true);
    } catch (IOException ex) {
      System.err.print(ex);
    }
  }
Exemplo n.º 5
0
 // function that executes the puzzle graph layout(s) through an animation
 // Uses the organic layout to first separate independent nodes, then uses the
 // hierarchical layout to make it look nifty
 public static void updatePuzzleGraph() {
   frmPuzzledicePuzzleEditor.setEnabled(false);
   puzzleGraph.getModel().beginUpdate();
   try {
     puzzleGraphHierLayout.execute(puzzleGraph.getDefaultParent());
   } finally {
     mxMorphing morph = new mxMorphing(puzzleGraphComponent, 20, 1.2, 20);
     morph.addListener(
         mxEvent.DONE,
         new mxIEventListener() {
           public void invoke(Object sender, mxEventObject evt) {
             puzzleGraph.getModel().endUpdate();
             frmPuzzledicePuzzleEditor.setEnabled(true);
           }
         });
     morph.startAnimation();
   }
 }
Exemplo n.º 6
0
  public void finishedSelectingUnits(TilePanel tilePanel, List<Unit> chosenUnits) {
    UnitActionDetector unitActionDetector =
        new UnitActionDetector(selectedPanel, selectedUnit, tilePanel, chosenUnits);

    if (unitActionDetector.isSelectingUnit()) {
      selectedPanel = tilePanel;
      selectedPanel.addTileStateFromKey(selectedStateKey);
      repaintPanels(selectedPanel);
      selectedUnit = getUnit(chosenUnits);
      selectValidMovements(selectedPanel.getTile(), selectedUnit);
    } else if (unitActionDetector.isDeselectingUnit()) {
      selectedPanel.removeTileStateFromKey(selectedStateKey);
      deselectValidMovements(selectedPanel.getTile(), selectedUnit);
      repaintPanels(selectedPanel);
      selectedPanel = null;
      selectedUnit = null;
    } else if (unitActionDetector.isMovingUnit()) {
      Position from = selectedPanel.getTile().getPosition();
      Position to = tilePanel.getTile().getPosition();
      if (movementStrategy.isValidMove(selectedUnit, from, to, unitMap)) {
        deselectValidMovements(selectedPanel.getTile(), selectedUnit);
        selectedPanel.removeTileStateFromKey(selectedStateKey);

        List<Unit> units = unitMap.get(to);
        if (units != null && !units.isEmpty()) {
          Unit defending = units.get(0);
          BattleStrategy strategy =
              battleStrategyConfiguration.getBattleStrategy(
                  selectedUnit, defending, selectedPanel.getTile(), tilePanel.getTile());
          Unit winner = strategy.getWinner(selectedUnit, defending);
          if (winner.equals(selectedUnit)) {
            units.remove(defending);
          }
        }
        board.move(selectedUnit, from, to);
        repaintPanels(selectedPanel);
        selectedPanel = null;
        selectedUnit = null;
      }
    }
    frame.setEnabled(true);
    resetPositions();
  }
 public void endGame() {
   frame.setEnabled(false);
   FrameEndGame frameEndGame = new FrameEndGame(this);
   String[] data;
   int rank, score;
   try {
     for (String str :
         getController().getConfig().getDataFromEntiereSection(ConfigManager.SECTION_HIGHSCORES)) {
       data = str.split(":");
       rank = Integer.valueOf(data[0]);
       data = data[1].split("-");
       score = (!data[1].equals(" ") ? Integer.valueOf(data[1]) : 0);
       if (score < getController().getScore()) {
         new FrameHighScoreSaver(this, frameEndGame, rank);
         frameEndGame.setEnabled(false);
         break;
       }
     }
   } catch (NumberFormatException | IOException e) {
   }
 }
Exemplo n.º 8
0
  // Δημιουργία μεθόδου για πάτημα κουμπιού NEW
  private void newButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_newButtonActionPerformed
    try {
      playListSong = new PlayListSong();
      playListSong.setPlaylistid(playList1);
      em.persist(playListSong);

      aplsf = new AddPlayListSongForm(playListSong, albumSongList);
      aplsf.setTitle("Επιλογή τραγουδιού");
      aplsf.setVisible(true);
      thisFrame = this;
      thisFrame.setEnabled(false);
      aplsf.addWindowListener(
          new WindowListener() {
            public void windowClosed(WindowEvent arg0) {
              System.out.println("Window close event occur");
              if (((MyWindowEvent) arg0).exitAndSave) {
                playListSongList.add(playListSong);
                // songList.add(((PlayListSong)playListSong).getSongid());

                int row = albumSongList.size() - 1;
                jTable1.setRowSelectionInterval(row, row);
                jTable1.scrollRectToVisible(jTable1.getCellRect(row, 0, true));
                thisFrame.setEnabled(true);
              } else {
                thisFrame.setEnabled(true);
                em.remove(playListSong);
              }
            }

            public void windowActivated(WindowEvent arg0) {
              System.out.println("Window Activated");
            }

            public void windowClosing(WindowEvent arg0) {
              System.out.println("Window Closing");
            }

            public void windowDeactivated(WindowEvent arg0) {
              System.out.println("Window Deactivated");
            }

            public void windowDeiconified(WindowEvent arg0) {
              System.out.println("Window Deiconified");
            }

            public void windowIconified(WindowEvent arg0) {
              System.out.println("Window Iconified");
            }

            public void windowOpened(WindowEvent arg0) {
              System.out.println("Window Opened");
            }
          });
    } catch (RuntimeException e) {
      String message = "Αδυναμία εγγραφής, ελέγξτε τα δεδομένα!";
      JOptionPane.showMessageDialog(thisFrame, message);

      MyWindowEvent we = new MyWindowEvent(this, WindowEvent.WINDOW_CLOSED, false);
      for (WindowListener l : this.getWindowListeners()) l.windowClosed(we);
      this.setVisible(false);
    }
  } // GEN-LAST:event_newButtonActionPerformed
Exemplo n.º 9
0
  // Обработка событий
  @Override
  public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();

    switch (command) {
      case "Добавить материал":
        // Открываем новое окно
        int row = prepModel.material.size(); // Номер добавляемой в будущем строки
        frame.setEnabled(false); // Делаем окно неактивным
        AddMaterial addMt = new AddMaterial();
        addMt.setVisible(true);
        System.out.println("Добавлена\n");
        break;
      case "Удалить материалы":
        Iterator<Material> iter = prepModel.material.iterator(); // Итератор
        ArrayList<Material> selectItems = new ArrayList<Material>(); // Список выделенных элементов
        // Есть ли элементы в таблице?
        if (iter.hasNext()) {
          // Кидаем в список выделенные элементы
          while (iter.hasNext()) {
            Material next = iter.next();
            if (next.checkBox == Boolean.TRUE) {
              selectItems.add(next);
            }
          }

          // Есть ли выделенные элементы?
          if (!selectItems.isEmpty()) {
            // подтверждение удаления
            int res =
                JOptionPane.showConfirmDialog(
                    null,
                    "Вы действительно хотите удалить выделенные элементы?",
                    "Question",
                    JOptionPane.YES_NO_OPTION);
            if (res == JOptionPane.YES_OPTION) {
              // Удаление из таблицы
              for (int i = 0; i < selectItems.size(); i++) {
                prepModel.material.remove(selectItems.get(i));
              }
              prepModel.updateData(); // Обновление данных
              System.out.println("Удалены");
              JOptionPane.showMessageDialog(
                  null, "Удаление выполнено успешно! Сохраните результат!");
            }
          } else {
            JOptionPane.showMessageDialog(null, "Нет выделенных элементов для удаления.");
          }

        } else {
          System.out.println("Нет элементов для удаления\n");
        }
        break;
      case "Сохранить изменения":
        // Проверка, добавдлены ли материалы? (Для установки даты)
        Date dMat = null;
        if (!proj.listMaterial.equals(prepModel.material)) {
          dMat = new Date();
        }
        // Обновление записей в модели таблицы родительского окна
        MainWindow.myModel.pr.set(
            this.row,
            new Project(
                tfName.getText(),
                tfPath.getText(),
                tfDebit.getText(),
                proj.date,
                dMat,
                prepModel.material));

        // MessageBox
        JOptionPane.showMessageDialog(
            null, "Сохраненение выполнено успешно!", "Сохранено", JOptionPane.INFORMATION_MESSAGE);
        MainWindow.myModel.updateData(); // обновляем таблицу родительского окна

        // Закрываем окно после сохранения
        frame.setVisible(false);
        MainWindow.frame.setEnabled(true);
        MainWindow.frame.toFront();
        break;
      default:
        System.err.println("Неизвестная команда");
    }
  }
  public void exportAllImages(String extension, String filePath, boolean showProcess) {

    /*
     * BUGR-108: The aim is to export all the diagrams (along with the
     * hidden ones) and preview them in a separate JFrame, that will have
     * JLabels describing the current action.
     *
     * To fix that, I will create a JFrame and have its contentPane as a
     * JPanel that will have 2 JLabels, 1 JProgressBar and the
     * DiagramViewer. Then, create all the diagrams inside the DiagramViewer
     * as tabs. Next, export each diagram in it and update the JPanel's
     * JLabels and JProgressBar. Finally close the frame.
     */
    UMLModelManager modelManager = UMLModelManager.getInstance();

    JFrame exportingFrame = null;
    JProgressBar bar = null;
    JPanel panel = null;
    JLabel export_num = null;
    JLabel export_name = null;

    exportingFrame = new JFrame("Exporting All Diagrams");
    if (showProcess) {
      exportingFrame.setBounds(100, 100, 500, 500);
      exportingFrame.setAlwaysOnTop(true);
    } else {
      exportingFrame.setBounds(0, 0, 0, 0);
      exportingFrame.setUndecorated(true);
      exportingFrame.setAlwaysOnTop(false);
    }

    exportingFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    exportingFrame.setResizable(false);
    exportingFrame.setEnabled(false);

    panel = new JPanel();
    panel.setLayout(null);
    panel.setVisible(true);
    if (showProcess) {
      export_num = new JLabel("Exporting:");
      export_num.setBounds(10, 10, 200, 20);
      export_num.setVisible(true);
      panel.add(export_num);

      export_name = new JLabel("Current Diagram:");
      export_name.setBounds(10, 30, 480, 20);
      export_name.setVisible(true);
      panel.add(export_name);

      bar = new JProgressBar(0, 0);
      bar.setStringPainted(true);
      bar.setBounds(250, 10, 240, 20);
      bar.setVisible(true);
      panel.add(bar);
    }

    DiagramViewer viewer = null;
    try {
      viewer = new DiagramViewer();
      viewer.setBackgroundGridVisible(false);
      List<Diagram> diagrams = modelManager.getDiagrams();
      int length = diagrams.size();
      for (int i = 0; i < length; i++) {
        Diagram diagram = diagrams.get(i);
        DiagramView view = viewer.openDiagramView(diagram);
        mainFrame.recoverDiagramView(diagram, view, mainFrame.isConverted);
      }
      if (showProcess) {
        bar.setMaximum(length);
      }
      viewer.setBounds(0, 50, 500, 450);

      panel.add(viewer);
      exportingFrame.setContentPane(panel);
      exportingFrame.setVisible(true);

      DiagramView[] views = viewer.getCachedDiagramViews();
      for (int i = 0; i < length; i++) {
        DiagramView view = views[i];
        Diagram diagram = view.getDiagram();
        if (showProcess) {
          export_num.setText("Exporting:                 " + (i + 1) + " of " + length);
          export_name.setText("Current Diagram:    " + diagram.getName());
          bar.setValue(i + 1);
        }
        viewer.getTabbedPane().setSelectedIndex(i);

        panel.paintImmediately(0, 0, 500, 500);

        if (diagram.isVisible()) {
          DeployHelper.exportToFile(
              mainFrame,
              view,
              filePath,
              DeployHelper.generateOutputFileName(diagram.getName()) + "." + extension,
              extension);
        }
      }
      exportingFrame.dispose();

      mainFrame.setLastImageExportPath(filePath);
    } catch (ConfigurationException e) {
    }
  }