@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == restart) { map.clean(); start(); } if (e.getSource() == exit) { if (random.nextInt(2) == 0) { exit.setLabel("No!, wurm's hungry"); } else { exit.setLabel("More Food!!!"); } } if (e.getSource() == reset) { if (reset.getLabel() == "Reset Record") { reset.setSize(180, 20); reset.setLocation(220, 10); reset.setLabel("Realy? All that hard work.."); } else { try { this.resetRecord(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } record.setText("The record is: " + (int) this.readRecord()); } } }
@Override public void paint(Graphics g) { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); if (self == null) { self = new Self(1000, maxX, maxY); } drawCells(g, self); if (testing.isView()) { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); drawCells(g, antigen); drawCells(g, testing); button.setLabel(testing.printAccuracy(antigen)); // drawStepCells(g); antigen = null; testing.setView(false); } if (antigen != null) { if (antigen.isLastView()) { drawCells(g, antigen); antigen.setLastView(false); testing.setView(true); button.setLabel("Calculating Accuracy"); testing.countAccuracy(antigen); button.setLabel("Viewing Accuracy"); // antigen = null; } else { drawStepCells(g); } } }
public void actionPerformed(ActionEvent evt) { if (evt.getSource() == Rubric) { Rubric.setLabel("Loading..."); try { Thread.sleep((1000)); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } removeAll(); @SuppressWarnings("unused") RubricEditor_GUI RE = new RubricEditor_GUI(); } else if (evt.getSource() == GradeSheet) { // Change the text on the button for fun GradeSheet.setLabel("Loading..."); try { Thread.sleep((1000)); } catch (InterruptedException e) { e.printStackTrace(); } removeAll(); @SuppressWarnings("unused") GradeSheetEditor_GUI GSE = new GradeSheetEditor_GUI(); } }
private void startGame() { timer.setDelay(INITIAL_DELAY); timer.setPaused(false); start_newgame_butt.setLabel("Start New Game"); pause_resume_butt.setEnabled(true); pause_resume_butt.setLabel("Pause"); pause_resume_butt.validate(); sounds.playSoundtrack(); }
public D(String title) { super(title); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); int frameWidth = 410; int frameHeight = 319; setSize(frameWidth, frameHeight); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); int x = (d.width - getSize().width) / 2; int y = (d.height - getSize().height) / 2; setLocation(x, y); setResizable(false); Container cp = getContentPane(); cp.setLayout(null); label1.setBounds(8, 8, 275, 76); label1.setText("Würfel"); label1.setAlignment(Label.CENTER); label1.setFont(new Font("Dialog", Font.PLAIN, 60)); cp.add(label1); l_1.setBounds(8, 88, 275, 145); l_1.setText(""); l_1.setAlignment(Label.CENTER); l_1.setFont(new Font("Dialog", Font.PLAIN, 100)); cp.add(l_1); b_1.setBounds(8, 248, 275, 25); b_1.setLabel("Würfeln"); b_1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { b_1_ActionPerformed(evt); } }); cp.add(b_1); tf_von.setBounds(336, 80, 49, 25); cp.add(tf_von); tf_bis.setBounds(336, 120, 49, 25); cp.add(tf_bis); l_von.setBounds(296, 80, 35, 25); l_von.setText("Von:"); cp.add(l_von); l_bis.setBounds(296, 120, 35, 25); l_bis.setText("Bis:"); cp.add(l_bis); b_a.setBounds(296, 160, 89, 49); b_a.setLabel("Annehmen"); b_a.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { b_a_ActionPerformed(evt); } }); cp.add(b_a); setVisible(true); }
public void actionPerformed(ActionEvent e) { firstTime = false; if (e.getSource().equals(start)) { if (t != null) { stop(); start.setLabel("START"); } else { start(); start.setLabel("STOP"); } } }
private void deathStuff() { float rec = readRecord(); if (rec < points) { try { textOutput(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } record.setText("The record is: " + (int) rec); add(record); add(score); add(tips); add(restart); add(reset); reset.setLabel("Reset Record"); reset.addActionListener(this); reset.setSize(100, 20); reset.setLocation(300, 10); restart.addActionListener(this); restart.setSize(100, 20); restart.setLocation(150, 200); add(exit); exit.addActionListener(this); exit.setSize(160, 20); exit.setLocation(120, 250); }
void jbInit() throws Exception { panel1.setLayout(borderLayout1); panel2.setBackground(Color.yellow); panel2.setLayout(borderLayout2); ButtonOK.setLabel("OK"); ButtonOK.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(MouseEvent e) { ButtonOK_mouseClicked(e); } }); String s1 = CallingApp.MotherApplet.GetName(); textArea1.setBackground(SystemColor.control); textArea1.setEditable(false); panel1.add(panel2, BorderLayout.CENTER); panel2.add(textArea1, BorderLayout.CENTER); panel1.add(panel3, BorderLayout.SOUTH); panel3.add(ButtonOK, null); String s = s1 + " v:" + CallingApp.MotherApplet.GetVersionNum() + "\n" + CallingApp.MotherApplet.GetInfos(); textArea1.setText(s); }
public void startRecording() { statusLabel.setText("Status: Recording..."); statusLabel.setFont(new Font("Helvetica", Font.BOLD, 12)); statusLabel.setForeground(Color.red); recordButton.setLabel("Stop recording"); recording = true; viewer.setRecordingStatus(fnameField.getText()); }
public void stopRecording() { statusLabel.setText("Status: Not recording."); statusLabel.setFont(new Font("Helvetica", Font.PLAIN, 12)); statusLabel.setForeground(Color.black); recordButton.setLabel("Record"); recording = false; viewer.setRecordingStatus(null); }
public LinearDistanceInteractiveMenuStrip( int lineDistancePx, int offSetPx, int markLenPx, Boolean dirY, ImagePlus image, String[] resTable, boolean[] doRes, ResultsTable restable) { infoLabel = new Label(); infoLabel.setText("Left: Add. Right: Remove."); countLabel = new Label(); countLabel.setText("Marks: 0"); okButton = new Button(); okButton.setLabel("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(this); cancelButton = new Button(); cancelButton.setLabel("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); clearButton = new Button(); clearButton.setLabel("Clear"); clearButton.setActionCommand("Clear"); clearButton.addActionListener(this); this.add(infoLabel); this.add(countLabel); this.add(okButton); this.add(cancelButton); this.add(clearButton); interactionHandler = new LinearDistanceInteractiveHandler( lineDistancePx, offSetPx, markLenPx, dirY, image, resTable, doRes, restable, this); }
// Close socket and IO streams, change appearance/functionality of some components private void closeAll() throws IOException { displayArea.append("\nConnection closing"); output.close(); input.close(); connection.close(); // We are no longer connected connection = null; // Change components serverField.setEditable(true); connectButton.setLabel("Connect to server above"); enterField.setEnabled(false); }
public Bai2() { lbNumber1.setText("a ="); lbNumber2.setText("b ="); lbResult.setText("Kết quả:"); txtNumber1.setText("0"); txtNumber2.setText("0"); txtResult.setText("0"); btResult.setLabel("Thực hiện"); choCalculator.add("Cộng"); choCalculator.add("Trừ"); choCalculator.add("Nhân"); choCalculator.add("Chia"); choCalculator.add("UCLN"); choCalculator.add("BCNN"); frMain.setBounds(100, 100, 400, 300); frMain.setBackground(Color.LIGHT_GRAY); frMain.setLayout(null); lbNumber1.setBounds(30, 50, 50, 20); lbNumber2.setBounds(30, 70, 50, 20); lbResult.setBounds(30, 140, 50, 20); choCalculator.setBounds(300, 70, 60, 20); btResult.setBounds(100, 100, 100, 20); txtNumber1.setBounds(100, 50, 150, 20); txtNumber2.setBounds(100, 70, 150, 20); txtResult.setBounds(100, 140, 150, 20); frMain.add(lbNumber1); frMain.add(lbNumber2); frMain.add(lbResult); frMain.add(txtNumber1); frMain.add(txtNumber2); frMain.add(txtResult); frMain.add(btResult); frMain.add(choCalculator); btResult.addActionListener(new ProcessButton()); frMain.addWindowListener( new WindowAdapter() { public void windowsClosing(WindowEvent evt) { System.exit(0); } }); }
/* WARNING: THIS METHOD WILL BE REGENERATED. */ private java.awt.Button getaddButton() { if (ivjaddButton == null) { try { ivjaddButton = new java.awt.Button(); ivjaddButton.setName("addButton"); ivjaddButton.setLabel("Add"); // user code begin {1} // user code end } catch (java.lang.Throwable ivjExc) { // user code begin {2} // user code end handleException(ivjExc); } } return ivjaddButton; }
public void start() { gameOver = false; inerGO = false; map = new mapC(size); map.map(); snake = new Snake(map.getMap()[10][10]); food = new Food(map.getMap()[13][10]); foodEaten = 0; points = 0; exit.setLabel("Exit"); remove(reset); remove(restart); remove(exit); remove(score); remove(record); remove(tips); dt = 1; }
/* WARNING: THIS METHOD WILL BE REGENERATED. */ private java.awt.Button getDetailsButton() { if (ivjDetailsButton == null) { try { ivjDetailsButton = new java.awt.Button(); ivjDetailsButton.setName("DetailsButton"); ivjDetailsButton.setLocation(33, 170); ivjDetailsButton.setBackground(java.awt.SystemColor.control); ivjDetailsButton.setSize(23, 23); ivjDetailsButton.setFont(new java.awt.Font("dialog", 0, 8)); ivjDetailsButton.setActionCommand("..."); ivjDetailsButton.setLabel("..."); // user code begin {1} // user code end } catch (java.lang.Throwable ivjExc) { // user code begin {2} // user code end handleException(ivjExc); } } ; return ivjDetailsButton; }
// swing gui / constructor public Main(final Field f) { super("Sudoku Solver"); URL iconURL = getClass().getResource("icon.png"); ImageIcon img = new ImageIcon(iconURL); jFrame.setIconImage(img.getImage()); Color darkBlue = new Color(51, 102, 153); Color lightBlue = new Color(18, 61, 104); grid = new JTextField[9][9]; jGrid.setLayout(new GridLayout(9, 9)); jGrid.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, darkBlue)); jGrid.setBackground(darkBlue); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { grid[i][j] = new JTextField(); grid[i][j].setDocument(new JTextFieldLimit(1)); grid[i][j].setFont(new Font("Arial", Font.PLAIN, 20)); grid[i][j].setHorizontalAlignment(JTextField.CENTER); grid[i][j].setText(""); grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, lightBlue)); if (j == 2 || j == 5) { grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 5, lightBlue)); } if (i == 2 || i == 5) { grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 1, lightBlue)); } if (i == 2 && j == 2) { grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue)); } if (i == 5 && j == 2) { grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue)); } if (i == 2 && j == 5) { grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue)); } if (i == 5 && j == 5) { grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue)); } jGrid.add(grid[i][j]); } } jButton.setLayout(new FlowLayout()); jButton.setBackground(darkBlue); jButton.setPreferredSize(new Dimension(420, 45)); jButton.add(solve); solve.setLabel("Solve"); solve.setVisible(true); solve.setFont(new Font("HelveticaNeue", Font.PLAIN, 20)); solve.setForeground(Color.BLACK); jButton.add(upload); upload.setLabel("Upload"); upload.setVisible(true); upload.setFont(new Font("Arial", Font.PLAIN, 20)); upload.setForeground(Color.BLACK); jButton.add(clear); clear.setLabel("Clear"); clear.setVisible(true); clear.setFont(new Font("Arial", Font.PLAIN, 20)); clear.setForeground(Color.BLACK); jGrid.setPreferredSize(new Dimension(400, 400)); jFrame.setResizable(false); jFrame.setVisible(true); jFrame.setLocationRelativeTo(null); jFrame.setSize(420, 480); jFrame.setBackground(darkBlue); jFrame.add(jGrid, BorderLayout.PAGE_START); jFrame.add(jButton, BorderLayout.PAGE_END); ActionListener solvedClicked = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { makeGridWhite(); gridToModel(f); if (!errorFound(f)) { runSolve(f); makeGrid(f, false); solve.setEnabled(false); } } }; ActionListener uploadClicked = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { makeGridWhite(); f.clearModel(); makeGrid(f, true); solve.setEnabled(true); f.fromFile(); makeGrid(f, true); } }; ActionListener clearClicked = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { makeGridWhite(); f.clearModel(); makeGrid(f, true); solve.setEnabled(true); } }; solve.addActionListener(solvedClicked); upload.addActionListener(uploadClicked); clear.addActionListener(clearClicked); }
public void setYesButtonLabel(String label) { yesButton.setLabel(label); }
public void setNoButtonLabel(String label) { noButton.setLabel(label); }
private void pauseGame() { timer.setPaused(true); pause_resume_butt.setLabel("Resume"); sounds.stopSoundtrack(); }
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); // Client pressed enter in the message entry field-send it if (source == enterField) { // Get the message message = e.getActionCommand(); try { // Encipher the message if (message.length() > plaintextBlockSize) message = message.substring(0, plaintextBlockSize); byte[] ciphertext = Ciphers.RSAEncipherWSalt(message.getBytes(), BigIntegerMath.THREE, recipModulus, sr); // Send to the server output.write(ciphertext); output.flush(); // Display same message in client output area displayArea.append("\n" + message); enterField.setText(""); } catch (IOException ioe) { displayArea.append("\nError writing message"); } } else if (source == connectButton) { if (connection != null) { // Already connected-button press now means disconnect try { // Send final message of 0 byte[] lastMsg = new byte[1]; lastMsg[0] = 0; output.write(Ciphers.RSAEncipherWSalt(lastMsg, BigIntegerMath.THREE, recipModulus, sr)); output.flush(); // close connection and IO streams, change some components closeAll(); } catch (IOException ioe) { displayArea.append("\nError closing connection"); } } else { // Not connected-connect // Get name of server to connect to chatServer = serverField.getText(); displayArea.setText("Attempting connection to " + chatServer); try { // Set up the socket connection = new Socket(chatServer, 55555); displayArea.append("\nConnected to: " + connection.getInetAddress().getHostName()); // Set up the IO streams output = new DataOutputStream(connection.getOutputStream()); output.flush(); input = new DataInputStream(connection.getInputStream()); // Exchange public keys with the server-send yours, get theirs exchangeKeys(); // Change appearance/functionality of some components serverField.setEditable(false); connectButton.setLabel("Disconnect from server above"); enterField.setEnabled(true); // Set up a thread to listen for the connection listener = new Thread( new Runnable() { public void run() { go(); } }); listener.start(); } catch (IOException ioe) { displayArea.append("\nError connecting to " + chatServer); } } } }
private void resumeGame() { timer.setPaused(false); pause_resume_butt.setLabel("Pause"); sounds.playSoundtrack(); }
public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (bLogin) { if (source == incMagSm) { if (imageCanvas.screenMode == 4) sendNetCmd("2013"); else sendNetCmd("2002"); add_in("Zoom In Small"); } else if (source == incMagLg) { if (imageCanvas.screenMode == 4) sendNetCmd("2015"); else sendNetCmd("2004"); add_in("Zoom In Large"); } else if (source == decMagSm) { if (imageCanvas.screenMode == 4) sendNetCmd("2012"); else sendNetCmd("2001"); add_in("Zoom Out Small"); } else if (source == decMagLg) { if (imageCanvas.screenMode == 4) sendNetCmd("2014"); else sendNetCmd("2003"); add_in("Zoom Out Large"); } else if (source == incBrightSm) { sendNetCmd("4002"); add_in("Increase Brightness Small"); } else if (source == incBrightLg) { sendNetCmd("4004"); add_in("Increase Brightness Large"); } else if (source == decBrightSm) { sendNetCmd("4001"); add_in("Decrease Brightness Small"); } else if (source == decBrightLg) { sendNetCmd("4003"); add_in("Decrease Brightness Large"); } else if (source == incContrastSm) { sendNetCmd("4006"); add_in("Increase Contrast Small"); } else if (source == incContrastLg) { sendNetCmd("4008"); add_in("Increase Contrast Large"); } else if (source == decContrastSm) { sendNetCmd("4005"); add_in("Decrease Contrast Small"); } else if (source == decContrastLg) { sendNetCmd("4007"); add_in("Decrease Contrast Large"); } else if (source == autoFocus) { sendNetCmd("3003"); add_in("Running AutoFocus"); } else if (source == reFresh) { if (imageCanvas.screenMode == 2) sendNetCmd("5001"); else if (imageCanvas.screenMode == 4) sendNetCmd("5002"); else if (imageCanvas.screenMode == 5) sendNetCmd("5003"); add_in("Refreshing Screen"); } else if (source == xyMove) { sendNetCmd("1009 " + xValue + " " + yValue); // Unfinished } else if (source == xrayLabel) { if (xRay) { xrayLabel.setLabel("Xray Map (off)"); xRay = false; sendNetCmd("8001"); } else { xrayLabel.setLabel("Xray Map (on)"); xRay = true; sendNetCmd("8002"); } add_in("Switching to XRay Map"); } else if (source == xrayStart) { if (xRay) { sendNetCmd("8101"); } add_in("Starting XRay"); } else if (source == xrayStop) { if (xRay) { sendNetCmd("8102"); } add_in("Stopping XRay"); } else if (source == savePic) { // Unfinished add_in("Launching Save"); } } else { wServer.connect(); sendNetCmd(userName.getText() + "@@" + passWord.getText()); bLogin = true; } }
/** * 新增視窗物件 設定物件屬性 內容 * * @param o 物件instances * @param reg 物件位置 * @param name 物件名稱 * @param value 物件標籤 或 內容 */ protected void addObject(Object o, Rectangle reg, String name, String value) { if (o instanceof Label) { ((Label) o).setText(value); ((Label) o).setName(name); ((Label) o).setBounds(reg); ((Label) o).addMouseListener(this); this.add((Label) o); } else if (o instanceof TextField) { ((TextField) o).setText(value); ((TextField) o).setName(name); ((TextField) o).setBounds(reg); ((TextField) o).addMouseListener(this); ((TextField) o).addTextListener(this); ((TextField) o).addKeyListener(this); if (value.equalsIgnoreCase("password")) ((TextField) o).setEchoChar('*'); this.add((TextField) o); } else if (o instanceof Button) { int len = (int) ((float) reg.width / FONTWIDTH); ((Button) o).setLabel(StringUtil_.splitStringSpace(value, len)); ((Button) o).setName(name); ((Button) o).setBounds(reg); ((Button) o).addMouseListener(this); this.add((Button) o); } else if (o instanceof TextArea) { ((TextArea) o).setText(value); ((TextArea) o).setName(name); ((TextArea) o).setBounds(reg); ((TextArea) o).addMouseListener(this); ((TextArea) o).addTextListener(this); ((TextArea) o).addKeyListener(this); this.add((TextArea) o); } else if (o instanceof Choice) { String[] values = value.split(","); for (int ii = 0; ii < values.length; ii++) ((Choice) o).addItem(values[ii]); ((Choice) o).setName(name); ((Choice) o).setBounds(reg); ((Choice) o).addMouseListener(this); ((Choice) o).addItemListener(this); this.add((Choice) o); } else if (o instanceof Checkbox) { ((Checkbox) o).setLabel(value); ((Checkbox) o).setName(name); ((Checkbox) o).setBounds(reg); ((Checkbox) o).addMouseListener(this); ((Checkbox) o).addItemListener(this); this.add((Checkbox) o); } else if (o instanceof CheckboxGroup) { String[] values = value.split(","); for (int ii = 0; ii < values.length; ii++) { Checkbox chk = new Checkbox(); chk.setLabel(values[ii]); chk.setName(name + ii); chk.setBounds(reg); reg.y += 25; chk.addMouseListener(this); chk.addItemListener(this); chk.setCheckboxGroup((CheckboxGroup) o); this.add(chk); } } else if (o instanceof List) { String[] values = value.split(","); ((List) o).setName(name); ((List) o).setBounds(reg); ((List) o).addMouseListener(this); ((List) o).addItemListener(this); for (int ii = 0; ii < values.length; ii++) ((List) o).add(values[ii]); this.add(((List) o)); } }