예제 #1
1
 private static void decryptRSA(JFrame screen) {
   screen.dispose();
   screen = init();
   JFrame screen1 = screen;
   JPanel screem = new JPanel();
   JTextField mess = new JTextField("Encoded Message");
   JTextField n = new JTextField("Private Key");
   JTextField d = new JTextField("Public Key");
   JTextField ea = new JTextField("Exponent");
   JButton x = new JButton("submit");
   ActionListener xa =
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           String m = mess.getText();
           String prk = n.getText();
           String puk = d.getText();
           String plk = ea.getText();
           rSAdisplayOutput(screen1, RSACode.decrypt(new String[] {prk, puk, plk, m}));
         }
       };
   x.addActionListener(xa);
   screem.add(mess);
   screem.add(n);
   screem.add(d);
   screem.add(ea);
   screem.add(x);
   screen.add(screem);
   screen.revalidate();
 }
예제 #2
0
 private void onDoneClick() throws IOException {
   for (ImageMarker marker : cornerAndControlMarkers) {
     if (marker.getID() == null) {
       JOptionPane.showMessageDialog(
           this, "You can't be done until you've " + "labeled every corner and control point!");
       return;
     }
   }
   int choice;
   choice =
       JOptionPane.showConfirmDialog(
           null, "Would you like to do another picture??", "Message", JOptionPane.YES_NO_OPTION);
   if (choice == 0) { // YES
     outputHelper();
     cornerAXText.setText("");
     cornerAYText.setText("");
     cornerBXText.setText("");
     cornerBYText.setText("");
     cornerCXText.setText("");
     cornerCYText.setText("");
     cornerDXText.setText("");
     cornerDYText.setText("");
     sideLengthText.setText("8");
     hfovText.setText("");
     JPEGText.setText("");
     framePoints.setVisible(true);
     framePoints.dispose();
   } else if (choice == 1) { // NO
     outputHelper();
     framePoints.setVisible(false);
     framePoints.dispose();
     this.setVisible(false);
     this.dispose();
   }
 }
예제 #3
0
 /**
  * Reads the network structure from Cytoscape and creates an array with node indices as well as
  * the plugin GUI upon clicking on the menu entry. Performs sanity checks on the network data.
  *
  * @param actionEvent The unused click-event on the menu entry.
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   // initialise network and node indices
   net = Cytoscape.getCurrentNetwork();
   netView = Cytoscape.getCurrentNetworkView();
   nodeIndices = net.getNodeIndicesArray();
   // create PluginGUI panel inside frame and display
   JFrame pluginFrame = new JFrame();
   JPanel pluginPanel = new MainPanel(myPlugin, nodeIndices.length, net.getEdgeCount());
   pluginFrame.setTitle("Network Failure Plugin");
   pluginFrame.add(pluginPanel);
   pluginFrame.pack();
   pluginFrame.setResizable(false);
   pluginFrame.setVisible(true);
   // check if netword contains nodes
   if (nodeIndices.length < 3) {
     final String msg = "No network loaded or netword contains under 3 nodes";
     JOptionPane.showMessageDialog(pluginFrame, msg, "Error", JOptionPane.ERROR_MESSAGE);
     pluginFrame.dispose();
     return;
   }
   // check if network is not already split
   boolean nodeReachable[] = new boolean[nodeIndices.length];
   iterateNetwork(0, nodeReachable);
   if (ArrayUtils.indexOf(nodeReachable, false) != -1) {
     final String msg =
         "Need a functional network to analyse, this one is already split.\n"
             + "You may remove isolated subnetworks and re-run the plugin.";
     JOptionPane.showMessageDialog(pluginFrame, msg, "Error", JOptionPane.ERROR_MESSAGE);
     pluginFrame.dispose();
     return;
   }
 }
예제 #4
0
 /**
  * handleHangmanEvent.
  *
  * @param e the HangmanEvent that was received.
  */
 @Override
 public void handleHangmanEvent(HangmanEvent e) {
   switch (e.type) {
     case UPDATE:
       update(e.letter);
       break;
     case WIN:
       JOptionPane.showMessageDialog(
           frame, "You have won the game!", "Win", JOptionPane.WARNING_MESSAGE);
       frame.dispose();
       break;
     case LOSE:
       update(e.letter);
       JOptionPane.showMessageDialog(
           frame, "You have lost the game!", "Lose", JOptionPane.WARNING_MESSAGE);
       frame.dispose();
       break;
     case KICKED:
       JOptionPane.showMessageDialog(
           frame, "You have been kicked!", "Kicked", JOptionPane.WARNING_MESSAGE);
       frame.dispose();
       break;
     case CONNECT:
       update(e.letter);
       break;
   }
 }
예제 #5
0
 public static void reconnect(JFrame frame) {
   if (frame != null) {
     frame.dispose();
   } else {
     menu.dispose();
   }
   new KilCliThread("restart", tmp).start();
 }
예제 #6
0
 /** closes the window on game end */
 @Override
 public void dispose() {
   if (inventoryWin != null && inventoryWin.isVisible()) {
     inventoryWin.dispose();
   }
   if (characterWindow != null && characterWindow.isVisible()) {
     characterWindow.dispose();
   }
   mainWindow.dispose();
 }
예제 #7
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    String destination = dest.getText();
    if (destination.matches("[a-zA-Z]+")) {
    } else {
      super.dispose();
    }

    String via = vi.getText();
    if (via.matches("[a-zA-Z]+")) {

    } else {
      super.dispose();
    }
    Date date = new Date();
    String date1 = dat.getText();
    SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
      date = date2.parse(date1);
    } catch (ParseException ex) {
      Logger.getLogger(AddFlight.class.getName()).log(Level.SEVERE, null, ex);
    }

    String remarks = rem.getText();

    String airline = air.getSelectedItem().toString();
    String code = flight.getSelectedItem().toString();

    try {
      String sql = "DELETE FROM FLIGHTS WHERE CODE='" + code + "'";
      db.setPst(db.getCon().prepareStatement(sql));
      db.setRs(db.getPst().executeQuery());

      sql =
          "INSERT INTO FLIGHTS VALUES ('"
              + destination
              + "','"
              + code
              + "','"
              + via
              + "','"
              + remarks
              + "',"
              + date
              + ",'"
              + airline
              + "')";
      db.setPst(db.getCon().prepareStatement(sql));
      db.setRs(db.getPst().executeQuery());

    } catch (SQLException ex) {
      Logger.getLogger(AddFlight.class.getName()).log(Level.SEVERE, null, ex);
    }
    super.dispose();
  } // GEN-LAST:event_jButton1ActionPerformed
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub

    if (e.getSource().equals(b2)) {
      f.dispose();
    } else if (e.getSource().equals(b1)) {
      f.dispose();
      new fenetre();
    }
  }
  @Override
  public void actionPerformed(ActionEvent event) {
    String source = event.getActionCommand();
    if (source.equals("open")) {
      if (trap == true) {
        int springTrap = rand.nextInt(100);
        if (springTrap < 70) {
          JOptionPane.showConfirmDialog(null, "You sprung a trap!");
          damge = damge * level;
          currentGame.getPlayer().setHp(currentGame.getPlayer().getHp() - damge);
          frame.dispose();
          currentGame.createCompass();
          currentGame.createPlayerWindow();
          currentGame.createGameWindow();
        } else {
          treasure = treasure * level;
          JOptionPane.showConfirmDialog(null, "You got " + treasure + " gold.");
          currentGame.createCompass();
          currentGame.createPlayerWindow();
          currentGame.createGameWindow();
        } // End if-else
      } else {
        treasure = treasure * level;
        currentGame.getPlayer().setMoney(currentGame.getPlayer().getMoney() + treasure);
        JOptionPane.showConfirmDialog(null, "You got " + treasure + " gold.");
        frame.dispose();
        currentGame.createCompass();
        currentGame.createPlayerWindow();
        currentGame.createGameWindow();
      } // End if-else

    } else if (source.equals("disarm")) {
      int disarmTrap = rand.nextInt(100);
      if (disarmTrap < 50) {
        JOptionPane.showConfirmDialog(null, "You disarmed the trap!");
        xpGained = xpGained * level;
        currentGame.getPlayer().setXp(currentGame.getPlayer().getXp() + xpGained);
        trap = false;
      } else {
        JOptionPane.showConfirmDialog(null, "You sprung a trap!");
        damge = damge * level;
        currentGame.getPlayer().setHp(currentGame.getPlayer().getHp() - damge);
        frame.dispose();
        currentGame.createCompass();
        currentGame.createPlayerWindow();
        currentGame.createGameWindow();
      } // End if-else
    } else if (source.equals("leave")) {
      frame.dispose();
      currentGame.createCompass();
      currentGame.createPlayerWindow();
      currentGame.createGameWindow();
    } // End if-else
  } // End ActionListener
예제 #10
0
 @Override
 public void update(Observable arg0, Object arg1) {
   DownloadInfo info = (DownloadInfo) arg1;
   window.setTitle(info.prg + " % " + info.file);
   url.setText(info.url);
   if (info.state == IXDMConstants.FAILED) status.setText("Error");
   else status.setText(info.status);
   filesize.setText(info.length);
   downloaded.setText(info.downloaded + " (" + info.progress + "%)");
   rate.setText(info.speed);
   time.setText(info.eta);
   resume.setText(info.resume);
   p.setValues(info.startoff, info.len, info.dwn, info.rlen);
   prg.setValue(info.prg);
   model.update(info.dwnld, info.stat);
   file = info.path;
   // if (info.resume.equalsIgnoreCase("yes")) {
   // pause.setEnabled(true);
   // } else {
   // pause.setEnabled(false);
   // }
   if (info.state == IXDMConstants.FAILED) {
     // pause.setEnabled(false);
     ConnectionManager c = (ConnectionManager) arg0;
     if (!c.stop) {
       if (!(c.state == ConnectionManager.COMPLETE)) {
         if (!showed) {
           JOptionPane.showMessageDialog(window, info.msg);
           window.setVisible(false);
           window.dispose();
           showed = true;
         }
       }
     }
   }
   if (info.state == IXDMConstants.COMPLETE) {
     System.out.println("%%%%%%%%%%%%%%%%%%DOWNLOAD COMPLETE");
     bg.setEnabled(false);
     // pause.setEnabled(false);
     window.setVisible(false);
     window.dispose();
   }
   if (info.state == IXDMConstants.STOPPED) {
     System.out.println("%%%%%%%%%%%%%%%%%%DOWNLOAD STOPPED");
     bg.setEnabled(false);
     // pause.setEnabled(false);
     window.setVisible(false);
     window.dispose();
   }
 }
  // this method is called when the user close the java window
  public void quit() {
    super.quit();

    // disposing the displayFrame automatically calls quit() on the display,
    // so we don't need to do so ourselves here.
    if (displayFrame != null) {
      displayFrame.dispose();
      displayFrame2.dispose();
    }
    // displayFrame = null;  // let gc
    // displayFrame2=null;
    // display = null;       // let gc
    // display2=null;
  }
예제 #12
0
  public void quit() {
    super.quit();

    if (displayFrame != null) displayFrame.dispose();
    displayFrame = null;
    display = null;
  }
예제 #13
0
  public static void main(String[] args) {
    createConnection();
    JFrame frm = new JFrame();

    Object[] options = {"Admin", "User", "Exit"};
    int selection =
        JOptionPane.showOptionDialog(
            frm,
            "Choose run mode:",
            "Untidaled",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);

    frm.dispose();
    switch (selection) {
      case 0:
        // Run as admin.
        map = new WorldMap(true);
        break;
      case 1:
        // Run as user.
        map = new WorldMap(false);
        break;
      case 2:
        System.exit(0);
        break;
    }
  }
예제 #14
0
  /**
   * Finalizes our changes and updates the hashmaps
   *
   * @param slot - item slot we edited
   * @param shopId - shop id we are in
   */
  protected void enterSlotChange(int slot, int shopId) {

    // load data from shops hashmap into our temporary arrays
    Object[] shopData = new Object[3];
    int[][] itemsArrayLoaded = new int[41][2];
    for (HashMap.Entry<Object[], int[][]> entry :
        ShopEditorPanel.shopsMap.get(Integer.valueOf(shopId)).entrySet()) {
      shopData = (Object[]) entry.getKey();
      itemsArrayLoaded = (int[][]) entry.getValue();
    }

    // edit temporary arrays
    itemsArrayLoaded[slot][0] = Integer.parseInt(itemField.getText());
    itemsArrayLoaded[slot][1] = Integer.parseInt(amountField.getText());

    HashMap<Object[], int[][]> shopValues = new HashMap<Object[], int[][]>();

    // put edited data back into the shops hashmap
    shopValues.put(shopData, itemsArrayLoaded);
    ShopEditorPanel.shopsMap.put(Integer.valueOf(shopId), shopValues);

    // redraw the grid of items and close the popup jframe
    ShopEditorPanel.createItemsGrid(shopId);
    popupJFrame.dispose();
  }
  public void testEmptyHeader() {
    fFrame = new JFrame("Test Window");

    // Create a panel to hold all other components
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());

    // Create a new table instance
    MyTableModel myModel = new MyTableModel();
    fTable = new JTable(myModel);

    // Add the table to a scrolling pane
    JScrollPane scrollPane = new JScrollPane(fTable);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    fFrame.getContentPane().setLayout(new BorderLayout());
    fFrame.getContentPane().add(BorderLayout.CENTER, topPanel);

    fFrame.setSize(400, 450);
    fFrame.setLocation(20, 20);
    fFrame.setVisible(true);
    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    JTableHeader header = fTable.getTableHeader();
    assertTrue(
        "JTableHeader greater than 5 pixels tall with empty string first element.",
        header.getSize().height > 5);
    fFrame.setVisible(false);
    fFrame.dispose();
  }
  public void dispose() {
    removeComponents(this);
    editorPanel.cleanup(); // 1.3.1 popup mem leak & remove listener
    szap.removeHighlightRegion(editorPanel);
    editorPanel = null;
    translationViewer = null;
    viewport.removeChangeListener(scrollListener);
    viewport = null;

    lengthLabel = null;
    // featureNameLabel = null;
    transcriptComboBox = null;

    szap = null;
    transformer = null;
    scrollListener = null;
    indicatorColor = null;
    colorSwatch = null;
    // changeListener = null;
    // removeWindowListener(windowListener);
    // windowListener = null;
    getController().removeListener(this);
    // getController() = null;
    // view = null;

    findButton = null;
    clearFindsButton = null;
    goToButton = null;
    upstream_button = null;
    downstream_button = null;

    super.dispose();
  }
 @Override
 public void dispose() {
   saveLocation(getBounds());
   super.dispose();
   Disposer.dispose(myScreen);
   WelcomeFrame.resetInstance();
 }
예제 #18
0
  void save() {

    PrintWriter writer = null;

    try {
      writer = new PrintWriter("settings.txt");
    } catch (FileNotFoundException ex) {
      Logger.getLogger(OptFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    writer.println(interp_text.getText());
    writer.println(size_panel_x.getText());
    writer.println(size_panel_y.getText());
    writer.println(sizePx.getText());
    writer.println(sizePy.getText());
    writer.println(distP.getText());

    if (saveLogs_check.isSelected()) writer.println("true");
    else writer.println("false");
    writer.println(seedInfoPath_field.getText());
    writer.println(saveDest_text.getText());

    writer.close();
    optWind.dispose();
  }
예제 #19
0
 public static void displaySplash(String[] args) {
   if (args == null) {
     if (splash != null) {
       splash.dispose();
     }
     if (start > 0) {
       Debug.log(3, "Sikuli-Script startup: " + ((new Date()).getTime() - start));
       start = 0;
     }
     return;
   }
   if (args[0].contains("-testSetup") || args[0].startsWith("-i")) {
     start = (new Date()).getTime();
     String[] splashArgs =
         new String[] {
           "splash",
           "#",
           "#" + Settings.SikuliVersionScript,
           "",
           "#",
           "#... starting - please wait ..."
         };
     for (String e : args) {
       splashArgs[3] += e + " ";
     }
     splashArgs[3] = splashArgs[3].trim();
     splash = new MultiFrame(splashArgs);
   }
 }
예제 #20
0
파일: CGUI.java 프로젝트: schdomin/zep
  // 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();
    }
  }
 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;
   }
 }
예제 #22
0
  @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();
    }
  }
예제 #23
0
  @Override
  public void run() {
    final Path path = this.pathOption.getValue();
    final String value;
    if (path == null) {
      value = null;
    } else {
      value = path.toString();
    }
    final JFileChooser fileChooser = new JFileChooser(value);
    final JFrame frame = new JFrame();
    fileChooser.setFileFilter(this.pathOption.filter);
    fileChooser.setDialogTitle(this.pathOption.getDescription());
    fileChooser.setFileSelectionMode(this.pathOption.selectionMode);

    try {
      final int ret = fileChooser.showOpenDialog(frame);
      if (ret == JFileChooser.APPROVE_OPTION) {
        this.pathOption.value(fileChooser.getSelectedFile());
        this.textField.setText(this.pathOption.getValue().toString());
        this.textField.setForeground(Color.BLACK);
        this.textField.setBackground(Color.WHITE);
      } else {
        this.pathOption.value((File) null);
        this.textField.setText(this.pathOption.getTooltip());
        this.textField.setForeground(Color.GRAY);
        this.textField.setBackground(Color.WHITE);
      }
    } finally {
      frame.setVisible(false);
      frame.dispose();
    }
  }
예제 #24
0
 /** Displays the inventory window */
 public void inventoryWindow() {
   if (inventoryWin != null) {
     inventoryWin.dispose();
   }
   inventoryWin = new JFrame("Inventory");
   inventoryWin.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   Inventory inv = player.getInventory();
   int y = inv.getSize();
   if (y == 0) {
     displayMessage("Inventory is empty");
     return;
   }
   int cols = 2;
   int rows = (y - y % cols) / cols;
   if (y % cols != 0) rows = rows + 1;
   inventoryWin.setLayout(new GridLayout(0, cols * 2));
   for (int i = 0; i < y; i++) {
     JButton b = new JButton(inv.getItem(i).getName());
     inventoryWin.add(b);
     b.addActionListener(this);
     JButton d = new JButton("drop " + inv.getItem(i).getName());
     inventoryWin.add(d);
     d.addActionListener(this);
   }
   // inventoryWin.setBounds(350, 0, 300, 80*rows);
   inventoryWin.setLocation(mainWindow.getX(), mainWindow.getY() + mainWindow.getHeight());
   inventoryWin.pack();
   inventoryWin.setVisible(true);
 }
예제 #25
0
  // Plots the values in x
  // If bAutoClose is specified, the figure is closed after milliSecondsToClose milliseconds
  // milliSecondsToClose: has no effect if bAutoClose is false
  public static void plot(
      double[] xIn,
      int startInd,
      int endInd,
      String strTitle,
      boolean bAutoClose,
      int milliSecondsToClose) {
    if (xIn != null) {
      endInd = MathUtils.CheckLimits(endInd, 0, xIn.length - 1);
      startInd = MathUtils.CheckLimits(startInd, 0, endInd);

      double[] x = new double[endInd - startInd + 1];
      System.arraycopy(xIn, startInd, x, 0, x.length);

      FunctionGraph graph = new FunctionGraph(400, 200, 0, 1, x);
      JFrame frame = graph.showInJFrame(strTitle, 500, 300, true, false);

      if (bAutoClose) {
        try {
          Thread.sleep(milliSecondsToClose);
        } catch (InterruptedException e) {
        }
        frame.dispose();
      }
    }
  }
예제 #26
0
 // {{{ dispose() method
 @Override
 public void dispose() {
   instance = null;
   EditBus.removeFromBus(this);
   EditBus.removeFromBus(installer);
   super.dispose();
 } // }}}
  public static void main(String[] args) throws Exception {
    final ArduinoSerialListener a = new ArduinoSerialListener();
    JFrame f = new JFrame();
    String p =
        (String)
            JOptionPane.showInputDialog(
                f,
                "",
                "",
                JOptionPane.OK_CANCEL_OPTION,
                null,
                a.getPortMap().keySet().toArray(),
                null);

    try {
      if (p != null) {
        a.connect(p);
      } else {
        // cancelled
        a.disconnect();
      }
    } finally {
      f.dispose();
    }
  }
예제 #28
0
파일: Lookup.java 프로젝트: egonw/BridgeDb
 public void actionPerformed(ActionEvent ae) {
   if (ae.getSource() == btnCancel) {
     frame.dispose();
   } else if (ae.getSource() == btnGo) {
     JOptionPane.showMessageDialog(frame, "Not implemented");
   }
 }
예제 #29
0
파일: Game.java 프로젝트: cpetosky/o2d-lib
  // --------------------------------actionQuit---------------------------------
  private void actionQuit() {
    int nResult =
        JOptionPane.showConfirmDialog(
            frame, "Are you sure you wish to quit?", "Are you sure?", JOptionPane.YES_NO_OPTION);

    if (nResult == JOptionPane.YES_OPTION) frame.dispose();
  }
예제 #30
0
  /** Displays the character window */
  public void characterWindow() {
    if (characterWindow != null) {
      characterWindow.dispose();
    }
    characterWindow = new JFrame("Character");
    characterWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JTextField health = new JTextField(player.health());
    health.setEditable(false);

    JButton weapon = new JButton(player.weapon().split(" ")[1]);
    if (player.weapon().split(" ")[1].equals("none")) {
      weapon.setEnabled(false);
    }
    weapon.addActionListener(this);

    JButton armor = new JButton(player.armor().split(" ")[1]);
    if (player.armor().split(" ")[1].equals("none")) {
      armor.setEnabled(false);
    }
    armor.addActionListener(this);

    characterWindow.setBounds(
        mainWindow.getX() + mainWindow.getWidth(), mainWindow.getY(), 200, 150);
    characterWindow.setResizable(false);
    characterWindow.setLayout(new GridLayout(3, 1));
    characterWindow.add(health);
    characterWindow.add(weapon);
    characterWindow.add(armor);

    characterWindow.setVisible(true);
  }