List of usage examples for java.awt Checkbox getLabel
public String getLabel()
From source file:AlphaTest.java
/** * Replots the Alpha function based on the contents of the UI */// ww w . j a va2 s .c om protected void updateAlpha() { m_Alpha.setTriggerTime(Long.parseLong(getField(m_knTrigger).getText())); m_Alpha.setPhaseDelayDuration(Long.parseLong(getField(m_knPhaseDelay).getText())); m_Alpha.setIncreasingAlphaDuration(Long.parseLong(getField(m_knIncreasingAlpha).getText())); m_Alpha.setIncreasingAlphaRampDuration(Long.parseLong(getField(m_knIncreasingRamp).getText())); m_Alpha.setAlphaAtOneDuration(Long.parseLong(getField(m_knAtOne).getText())); m_Alpha.setDecreasingAlphaDuration(Long.parseLong(getField(m_knDecreasingAlpha).getText())); m_Alpha.setDecreasingAlphaRampDuration(Long.parseLong(getField(m_knDecreasingRamp).getText())); m_Alpha.setAlphaAtZeroDuration(Long.parseLong(getField(m_knAtZero).getText())); m_Alpha.setLoopCount(Integer.parseInt(getField(m_knLoopCount).getText())); Checkbox b = m_checkboxGrp.getSelectedCheckbox(); if (b.getLabel().equals("INCREASING_ENABLE")) { m_Alpha.setMode(Alpha.INCREASING_ENABLE); } else if (b.getLabel().equals("DECREASING_ENABLE")) { m_Alpha.setMode(Alpha.DECREASING_ENABLE); } else // "BOTH" { m_Alpha.setMode(Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE); } }
From source file:FourByFour.java
public void actionPerformed(ActionEvent event) { Object target = event.getSource(); // Process the button events. if (target == skill_return_button) { skill_panel.setVisible(false);//from ww w .jav a 2s . c o m skill_return_button.setVisible(false); c_container.setVisible(true); b_container.setVisible(true); newGame(); } else if (target == winner_return_button) { if (winner_flag) { String name = winner_name.getText(); String tmp_name = new String(""); int tmp_score = 0; boolean insert_flag = false; winner_flag = false; for (int i = 0; i < 20; i++) { if (insert_flag) { name = names[i]; score = scores[i]; names[i] = tmp_name; scores[i] = tmp_score; tmp_name = name; tmp_score = score; } if (!insert_flag && score > scores[i]) { tmp_name = names[i]; tmp_score = scores[i]; scores[i] = score; names[i] = name; insert_flag = true; } high_names[i].setText(names[i]); high_scores[i].setText(Integer.toString(scores[i])); } scoresString = new String(""); int place; for (int i = 0; i < 20; i++) { place = (int) places[i]; scoresString += Integer.toString(place); scoresString += "\t"; scoresString += names[i]; scoresString += " "; scoresString += Integer.toString(scores[i]); scoresString += "\n"; } if (appletFlag) { // Use this section of code when writing the high // scores file back to a server. Requires the use // of a deamon on the server to receive the socket // connection. // // Create the output stream. // try { // Socket socket = new Socket(host, port); // outStream = new BufferedOutputStream // (socket.getOutputStream(), 8192); // } // catch(IOException ioe) { // System.out.println("Error: " + ioe.toString()); // } // System.out.println("Output stream opened"); // // Write the scores to the file back on the server. // outText = scoresString.getBytes(); // try { // outStream.write(outText); // outStream.flush(); // outStream.close(); // outStream = null; // } // catch (IOException ioe) { // System.out.println("Error: " + ioe.toString()); // } // System.out.println("Output stream written"); try { OutputStreamWriter outFile = new OutputStreamWriter(new FileOutputStream("scores.txt")); outFile.write(scoresString); outFile.flush(); outFile.close(); outFile = null; } catch (IOException ioe) { System.out.println("Error: " + ioe.toString()); } catch (Exception e) { System.out.println("Error: " + e.toString()); } } else { try { OutputStreamWriter outFile = new OutputStreamWriter(new FileOutputStream("scores.txt")); outFile.write(scoresString); outFile.flush(); outFile.close(); outFile = null; } catch (IOException ioe) { System.out.println("Error: " + ioe.toString()); } } } winner_panel.setVisible(false); winner_return_button.setVisible(false); winner_label.setVisible(false); winner_score_label.setVisible(false); winner_name_label.setVisible(false); winner_top_label.setVisible(false); winner_name.setVisible(false); c_container.setVisible(true); b_container.setVisible(true); } else if (target == high_return_button) { high_return_button.setVisible(false); high_panel.setVisible(false); c_container.setVisible(true); b_container.setVisible(true); } else if (target == instruct_return_button) { instruct_text.setVisible(false); instruct_return_button.setVisible(false); instruct_text.repaint(); c_container.setVisible(true); b_container.setVisible(true); } else if (target == undo_button) { board.undo_move(); canvas2D.repaint(); } else if (target == instruct_button) { c_container.setVisible(false); b_container.setVisible(false); instruct_text.setVisible(true); instruct_return_button.setVisible(true); } else if (target == new_button) { newGame(); } else if (target == skill_button) { c_container.setVisible(false); b_container.setVisible(false); skill_panel.setVisible(true); skill_return_button.setVisible(true); } else if (target == high_button) { // Read the high scores file. if (appletFlag) { try { inStream = new BufferedInputStream(new URL(getCodeBase(), "scores.txt").openStream(), 8192); Reader read = new BufferedReader(new InputStreamReader(inStream)); StreamTokenizer st = new StreamTokenizer(read); st.whitespaceChars(32, 44); st.eolIsSignificant(false); int count = 0; int token = st.nextToken(); boolean scoreFlag = true; String string; while (count < 20) { places[count] = (int) st.nval; string = new String(""); token = st.nextToken(); while (token == StreamTokenizer.TT_WORD) { string += st.sval; string += " "; token = st.nextToken(); } names[count] = string; scores[count] = (int) st.nval; token = st.nextToken(); count++; } inStream.close(); } catch (Exception ioe) { System.out.println("Error: " + ioe.toString()); } } else { try { inStream = new BufferedInputStream(new FileInputStream("scores.txt")); Reader read = new BufferedReader(new InputStreamReader(inStream)); StreamTokenizer st = new StreamTokenizer(read); st.whitespaceChars(32, 44); st.eolIsSignificant(false); int count = 0; int token = st.nextToken(); boolean scoreFlag = true; String string; while (count < 20) { places[count] = (int) st.nval; string = new String(""); token = st.nextToken(); while (token == StreamTokenizer.TT_WORD) { string += st.sval; string += " "; token = st.nextToken(); } names[count] = string; scores[count] = (int) st.nval; token = st.nextToken(); count++; } inStream.close(); } catch (Exception ioe) { System.out.println("Error: " + ioe.toString()); } } c_container.setVisible(false); b_container.setVisible(false); high_panel.setVisible(true); high_return_button.setVisible(true); } Checkbox box = group.getSelectedCheckbox(); String label = box.getLabel(); if (label.equals("Babe in the Woods ")) { board.set_skill_level(0); } else if (label.equals("Walk and Chew Gum ")) { board.set_skill_level(1); } else if (label.equals("Jeopardy Contestant ")) { board.set_skill_level(2); } else if (label.equals("Rocket Scientist ")) { board.set_skill_level(3); } else if (label.equals("Be afraid, be very afraid")) { board.set_skill_level(4); } }