public Properties getProperties() { Properties prop = new Properties(); String name = saName.getText(); String interval = saInt.getText(); boolean opt = saYes.isSelected(); prop.put("name", name); prop.put("suppressInt", interval); prop.put("suppressAll", opt + ""); return prop; }
private void updateLogo() { ignoreEvent_ = true; if (pane_ != null) pane_.setBatch(true, "LogoDialog"); // // options // logo_.setVisible(labelVisibleCheckBox.isSelected()); logo_.setSelectable(labelSelectableCheckBox.isSelected()); // // Location // double x = Double.valueOf(xPosTextField.getText()).doubleValue(); double y = Double.valueOf(yPosTextField.getText()).doubleValue(); Point2D.Double locp = new Point2D.Double(x, y); logo_.setLocationP(locp); // // alignment // logo_.setHAlign(horizComboBox.getSelectedIndex()); logo_.setVAlign(vertComboBox.getSelectedIndex()); if (pane_ != null) pane_.setBatch(false, "LogoDialog"); ignoreEvent_ = false; }
// Code behind the buttons. This is called when the 4 buttons are clicked @Override public void actionPerformed(ActionEvent e) { // play button if (e.getActionCommand() == "PLAY") { Board gameBoard = new Board(); frame2.setVisible(true); frame.setVisible(false); } else if (e.getActionCommand() == "HOW TO PLAY") { Icon Instructions = new ImageIcon(getClass().getClassLoader().getResource("images/instructions.jpg")); JOptionPane.showMessageDialog( null, "<html><body><h1>How to play the game</h1><h3>| Roll the dice </h3><h3>| Answer questions </h3><h3>| Earn skills</h3><h3>--- Repeat until you graduate</h3><h3>--- Get career prospects based on your skills</h3><h3>--- Save the career prospects for further use</h3></body></html>", "Game Instructions", JOptionPane.INFORMATION_MESSAGE, Instructions); } else if (e.getActionCommand() == "QUIT") { int input = JOptionPane.showOptionDialog( null, "Are you sure you want to exit?", "Are you sure?", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (input == JOptionPane.OK_OPTION) { System.exit(0); } } else if (e.getActionCommand() == "Quit education") { doCareerProspects(); frame.setVisible(false); frame2.setVisible(false); frame3.setVisible(true); } else if (e.getActionCommand() == "Save career prospects") { try { Formatter output = new Formatter("Career.txt"); StringBuilder myCareersToBeSaved = new StringBuilder(); myCareersToBeSaved.append( "You might enjoy and be successful in one of the following careers: " + "\n\n"); myCareersToBeSaved.append(mathematicsCareer[getMathematicsValue()] + "\n"); myCareersToBeSaved.append(historyCareer[getHistoryValue()] + "\n"); myCareersToBeSaved.append(geographyCareer[getGeographyValue()] + "\n"); myCareersToBeSaved.append(computerScienceCareer[getComputerScienceValue()] + "\n"); myCareersToBeSaved.append(scienceCareer[getScienceValue()] + "\n"); output.format(myCareersToBeSaved.toString()); output.close(); } catch (Exception ex) { System.err.println(ex); } Icon saved = new ImageIcon(getClass().getClassLoader().getResource("images/saved.png")); int input = JOptionPane.showOptionDialog( null, "Career prospects have been saved! \n Do you want to exit?", "Career prospects saved", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, saved, null, null); if (input == JOptionPane.OK_OPTION) { System.exit(0); } } else if (e.getActionCommand() == "Exit application") { Icon leaving = new ImageIcon(getClass().getClassLoader().getResource("images/leaving.png")); int input = JOptionPane.showOptionDialog( null, "Press CANCEL or OK to exit!", "Are you sure?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, leaving, null, null); if (input == JOptionPane.OK_OPTION) { System.exit(0); } } else if (e.getActionCommand() == "ROLL THE DICE") { String name = playerName.getText(); int randomNumber; randomNumber = rollDice(); doMove(randomNumber); final ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource("images/dices.gif")); String fullDetail = "Hi " + name + "," + "\n You rolled a " + randomNumber; JOptionPane.showMessageDialog( null, fullDetail, "Rolled dice", JOptionPane.INFORMATION_MESSAGE, icon); Quiz(); if (getPlayerPosition() >= 72) { doCareerProspects(); frame.setVisible(false); frame2.setVisible(false); frame3.setVisible(true); } } }