Пример #1
0
 @Action
 public void showAboutBox() {
   if (aboutBox == null) {
     JFrame mainFrame = JChessApp.getApplication().getMainFrame();
     aboutBox = new JChessAboutBox(mainFrame);
     aboutBox.setLocationRelativeTo(mainFrame);
   }
   JChessApp.getApplication().show(aboutBox);
 }
Пример #2
0
  public String showPawnPromotionBox(String color) {
    if (promotionBox == null) {
      JFrame mainFrame = JChessApp.getApplication().getMainFrame();
      promotionBox = new PawnPromotionWindow(mainFrame, color);
      promotionBox.setLocationRelativeTo(mainFrame);
      promotionBox.setModal(true);
    }
    promotionBox.setColor(color);
    JChessApp.getApplication().show(promotionBox);

    return promotionBox.result;
  }
Пример #3
0
 public void actionPerformed(ActionEvent event) {
   Object target = event.getSource();
   if (target == newGameItem) {
     this.setNewGameFrame(new NewGameWindow());
     JChessApp.getApplication().show(this.getNewGameFrame());
   }
   /*
   else if (target == saveGameItem) //saveGame
   {
       if (this.gamesPane.getTabCount() == 0)
       {
           JOptionPane.showMessageDialog(null, Settings.lang("save_not_called_for_tab"));
           return;
       }
       while (true) //until
       {
           JFileChooser fc = new JFileChooser();
           int retVal = fc.showSaveDialog(this.gamesPane);
           if (retVal == JFileChooser.APPROVE_OPTION)
           {
               File selFile = fc.getSelectedFile();
               Game tempGUI = (Game) this.gamesPane.getComponentAt(this.gamesPane.getSelectedIndex());
               if (!selFile.exists())
               {
                   try
                   {
                       selFile.createNewFile();
                   }
                   catch (IOException exc)
                   {
                       LOG.error("error creating file: " + exc);
                   }
               }
               else if (selFile.exists())
               {
                   int opt = JOptionPane.showConfirmDialog(tempGUI, Settings.lang("file_exists"), Settings.lang("file_exists"), JOptionPane.YES_NO_OPTION);
                   if (opt == JOptionPane.NO_OPTION)//if user choose to now overwrite
                   {
                       continue; // go back to file choose
                   }
               }
               if (selFile.canWrite())
               {
                   tempGUI.saveGame(selFile);
               }
               LOG.debug(fc.getSelectedFile().isFile());
               break;
           }
           else if (retVal == JFileChooser.CANCEL_OPTION)
           {
               break;
           }
           ///JChessView.gui.game.saveGame(fc.);
       }
   }
   */
   /*
   else if (target == loadGameItem)//loadGame
   {
       JFileChooser fc = new JFileChooser();
       int retVal = fc.showOpenDialog(this.gamesPane);
       if (retVal == JFileChooser.APPROVE_OPTION)
       {
           File file = fc.getSelectedFile();
           if (file.exists() && file.canRead())
           {
               Game.loadGame(file);
           }
       }
   }*/
   else if (target == this.themeSettingsMenu) {
     try {
       ThemeChooseWindow choose = new ThemeChooseWindow(this.getFrame());
       JChessApp.getApplication().show(choose);
     } catch (Exception exc) {
       JOptionPane.showMessageDialog(JChessApp.getApplication().getMainFrame(), exc.getMessage());
       LOG.error("Something wrong creating window - perhaps themeList is null: " + exc);
     }
   }
 }