/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user changed the service filter option if (e.getSource() == service_box) { service_list.setEnabled(service_box.isSelected()); service_list.clearSelection(); remove_service_button.setEnabled(false); add_service_field.setEnabled(service_box.isSelected()); add_service_field.setText(""); add_service_button.setEnabled(false); } // Check if the user pressed the add service button if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) { String text = add_service_field.getText(); if ((text != null) && (text.length() > 0)) { service_data.addElement(text); service_list.setListData(service_data); } add_service_field.setText(""); add_service_field.requestFocus(); } // Check if the user pressed the remove service button if (e.getSource() == remove_service_button) { Object[] sels = service_list.getSelectedValues(); for (int i = 0; i < sels.length; i++) { service_data.removeElement(sels[i]); } service_list.setListData(service_data); service_list.clearSelection(); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the ok button if (e.getSource() == ok_button) { filter_include_list = include_panel.getServiceList(); filter_exclude_list = exclude_panel.getServiceList(); if (status_box.isSelected()) { filter_active = status_active.isSelected(); filter_complete = status_complete.isSelected(); } else { filter_active = false; filter_complete = false; } ok_pressed = true; dialog.dispose(); } // Check if the user pressed the cancel button if (e.getSource() == cancel_button) { dialog.dispose(); } // Check if the user changed the status filter option if (e.getSource() == status_box) { status_active.setEnabled(status_box.isSelected()); status_complete.setEnabled(status_box.isSelected()); } }
public void actionPerformed(ActionEvent ae) { String cmd = ae.getActionCommand(); if (cmd.equals("Close")) { cmdDisconnect(); } }
public void actionPerformed(ActionEvent ae) { JButton b = (JButton) ae.getSource(); // System.out.println("NumberEar: button="+b.getText()); int i = new Integer(b.getText()).intValue() - 1; number[date].setForeground(Color.BLUE); date = i; number[i].setForeground(Color.CYAN); }
/** handle button events. */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("run")) { if (animator.isAnimating()) stop(); else start(); } else if (cmd.equals("transparancy")) { if (drawable != null) drawable.setOpaque(!checkBox.isSelected()); } }
public void actionPerformed(ActionEvent e) { beta = Double.parseDouble(betaval.getText()); updatebeta(); if (e.getSource() == fitavgbutton) { fitavg(); } if (e.getSource() == fitglobalbutton) { fitglobal(); } if (e.getSource() == clearparamsbutton) { resetparams(); } if (e.getSource() == undobutton) { undoglobalfit(); } if (e.getSource() == geterrorsbutton) { geterrors(); } }
/** Listener to handle button actions */ public void actionPerformed(ActionEvent e) { // Check if the user pressed the remove button if (e.getSource() == remove_button) { int row = table.getSelectedRow(); model.removeRow(row); table.clearSelection(); table.repaint(); valueChanged(null); } // Check if the user pressed the remove all button if (e.getSource() == remove_all_button) { model.clearAll(); table.setRowSelectionInterval(0, 0); table.repaint(); valueChanged(null); } // Check if the user pressed the filter button if (e.getSource() == filter_button) { filter.showDialog(); if (filter.okPressed()) { // Update the display with new filter model.setFilter(filter); table.repaint(); } } // Check if the user pressed the start button if (e.getSource() == start_button) { start(); } // Check if the user pressed the stop button if (e.getSource() == stop_button) { stop(); } // Check if the user wants to switch layout if (e.getSource() == layout_button) { details_panel.remove(details_soap); details_soap.removeAll(); if (details_soap.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT); } else { details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); } details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.validate(); details_panel.repaint(); } // Check if the user is changing the reflow option if (e.getSource() == reflow_xml) { request_text.setReflowXML(reflow_xml.isSelected()); response_text.setReflowXML(reflow_xml.isSelected()); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == submit) { if (rb1.isSelected()) { JFrame frame = Application.getFrame(); if (typeCodes.isEmpty()) { JOptionPane.showMessageDialog( frame, "Please select at least one toponym type.", "Error", JOptionPane.ERROR_MESSAGE); } else { Application.getMainCitiesPanel(this, typeCodes, 0, 0.0); } } else if (rb2.isSelected()) { JFrame frame = Application.getFrame(); try { nCities = new Integer(nCitiesField.getText()); if (nCities <= 0) throw new NumberFormatException(); typeCodes = new ArrayList<String>(); Application.getMainCitiesPanel(this, typeCodes, nCities, 0.0); } catch (NumberFormatException ex) { JOptionPane.showMessageDialog( frame, "Please enter a positive integer number.", "Error", JOptionPane.ERROR_MESSAGE); } } else { JFrame frame = Application.getFrame(); try { Double dist = new Double(distField.getText()); if (dist <= 0) throw new NumberFormatException(); typeCodes = new ArrayList<String>(); Application.getMainCitiesPanel(this, typeCodes, 0, dist); } catch (NumberFormatException ex) { JOptionPane.showMessageDialog( frame, "Please enter a positive number.", "Error", JOptionPane.ERROR_MESSAGE); } } } else { Application.getOptionPanel(this, countryName); } }
public void actionPerformed(ActionEvent e) { ((JCalendar) e.getSource()).setDate(null); }
public void actionPerformed(ActionEvent e) { ((JCalendar) e.getSource()).monthForward(); }
public void actionPerformed(ActionEvent e) { ((JCalendar) e.getSource()).yearBackward(); }
/** Handle the button presses */ public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == quit) System.exit(0); else if (o == print) printDemoPage(); }
/** * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel. */ public void actionPerformed(ActionEvent evt) { JButton button = (JButton) evt.getSource(); String buttonName = button.getName(); if (buttonName.equals("call")) { Component selectedPanel = mainFrame.getSelectedTab(); // call button is pressed over an already open call panel if (selectedPanel != null && selectedPanel instanceof CallPanel && ((CallPanel) selectedPanel).getCall().getCallState() == CallState.CALL_INITIALIZATION) { NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); CallPanel callPanel = (CallPanel) selectedPanel; Iterator participantPanels = callPanel.getParticipantsPanels(); while (participantPanels.hasNext()) { CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next(); panel.setState("Connecting"); } Call call = callPanel.getCall(); answerCall(call); } // call button is pressed over the call list else if (selectedPanel != null && selectedPanel instanceof CallListPanel && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) { CallListPanel callListPanel = (CallListPanel) selectedPanel; GuiCallParticipantRecord callRecord = (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue(); String stringContact = callRecord.getParticipantName(); createCall(stringContact); } // call button is pressed over the contact list else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) { // call button is pressed when a meta contact is selected if (isCallMetaContact) { Object[] selectedContacts = mainFrame.getContactListPanel().getContactList().getSelectedValues(); Vector telephonyContacts = new Vector(); for (int i = 0; i < selectedContacts.length; i++) { Object o = selectedContacts[i]; if (o instanceof MetaContact) { Contact contact = ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class); if (contact != null) telephonyContacts.add(contact); else { new ErrorDialog( this.mainFrame, Messages.getI18NString("warning").getText(), Messages.getI18NString( "contactNotSupportingTelephony", new String[] {((MetaContact) o).getDisplayName()}) .getText()) .showDialog(); } } } if (telephonyContacts.size() > 0) createCall(telephonyContacts); } else if (!phoneNumberCombo.isComboFieldEmpty()) { // if no contact is selected checks if the user has chosen // or has // writen something in the phone combo box String stringContact = phoneNumberCombo.getEditor().getItem().toString(); createCall(stringContact); } } else if (selectedPanel != null && selectedPanel instanceof DialPanel) { String stringContact = phoneNumberCombo.getEditor().getItem().toString(); createCall(stringContact); } } else if (buttonName.equalsIgnoreCase("hangup")) { Component selectedPanel = this.mainFrame.getSelectedTab(); if (selectedPanel != null && selectedPanel instanceof CallPanel) { NotificationManager.stopSound(NotificationManager.BUSY_CALL); NotificationManager.stopSound(NotificationManager.INCOMING_CALL); NotificationManager.stopSound(NotificationManager.OUTGOING_CALL); CallPanel callPanel = (CallPanel) selectedPanel; Call call = callPanel.getCall(); if (removeCallTimers.containsKey(callPanel)) { ((Timer) removeCallTimers.get(callPanel)).stop(); removeCallTimers.remove(callPanel); } removeCallPanel(callPanel); if (call != null) { ProtocolProviderService pps = call.getProtocolProvider(); OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps); Iterator participants = call.getCallParticipants(); while (participants.hasNext()) { try { // now we hang up the first call participant in the // call telephony.hangupCallParticipant((CallParticipant) participants.next()); } catch (OperationFailedException e) { logger.error("Hang up was not successful: " + e); } } } } } else if (buttonName.equalsIgnoreCase("minimize")) { JCheckBoxMenuItem hideCallPanelItem = mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem(); if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true); this.setCallPanelVisible(false); } else if (buttonName.equalsIgnoreCase("restore")) { JCheckBoxMenuItem hideCallPanelItem = mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem(); if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false); this.setCallPanelVisible(true); } }
public void actionPerformed(ActionEvent ae) { String s = ae.getActionCommand(); if (s.equals("Dodawanie")) { tekst = ""; tekst2 = ""; wynik = ""; tekst += textField1.getText(); wynik += "1"; textField1.setText(""); } else if (s.equals("Odejmowanie")) { tekst = ""; tekst2 = ""; wynik = ""; tekst += textField1.getText(); wynik += "2"; textField1.setText(""); } else if (s.equals("Mnozenie")) { tekst = ""; tekst2 = ""; wynik = ""; tekst += textField1.getText(); wynik += "3"; textField1.setText(""); } else if (s.equals("Dzielenie")) { tekst = ""; tekst2 = ""; wynik = ""; tekst += textField1.getText(); wynik += "4"; textField1.setText(""); } else if (s.equals("Potegowanie")) { tekst = ""; tekst2 = ""; wynik = ""; tekst += textField1.getText(); wynik += "5"; textField1.setText(""); } else if (s.equals("Pierwiastek")) { tekst = ""; tekst2 = ""; wynik = ""; tekst += textField1.getText(); int a = Integer.parseInt(tekst); f = (double) Math.sqrt(a); textField1.setText("" + zao.format(f)); } else if (s.equals("Wynik")) { tekst2 += textField1.getText(); int a = Integer.parseInt(tekst); int b = Integer.parseInt(tekst2); int w = Integer.parseInt(wynik); if (w == 1) { c = a + b; textField1.setText("" + c); } if (w == 2) { c = a - b; textField1.setText("" + c); } if (w == 3) { c = a * b; textField1.setText("" + c); } if (w == 4) { c = a / b; textField1.setText("" + c); } if (w == 5) { c = (int) Math.pow(a, b); textField1.setText("" + c); } } else if (s.equals("Czysc")) { tekst = ""; tekst2 = ""; wynik = ""; textField1.setText(""); } }
public void actionPerformed(ActionEvent e) { Object src = e.getSource(); if (src == timer) { for (int i = 0; i < speed; i++) // integrate a few steps md.vv(); repaint(); return; } boolean adjCanvasScale = false; if (src == bTstat) md.thermostat = !md.thermostat; if (src == bPot) { md.ljPotential = !md.ljPotential; md.clearData(); if (timer.isRunning()) timer.stop(); bStart.setSelected(false); bStart.setText("Start"); md.init(md.rho); } if (src == tTemp || src == bReset) { double kT = Double.parseDouble(tTemp.getText().trim()); if (kT < 1e-8) { kT = 1e-8; tTemp.setText(" " + kT); } md.kT = kT; md.clearData(); } if (src == tRho || src == bReset) { double rho = Double.parseDouble(tRho.getText().trim()); if (rho < 1e-3) { rho = 1e-3; tRho.setText(" " + rho); } if (rho > 1.2) { rho = 1.2; tRho.setText(" " + rho); } md.setDensity(rho); md.clearData(); adjCanvasScale = true; } if (src == tSpeed || src == bReset) { speed = Integer.parseInt(tSpeed.getText().trim()); if (speed < 1) { speed = 1; tSpeed.setText(" " + speed); } } if (src == bRetime) md.clearData(); if (src == bStart) { boolean on = bStart.isSelected(); if (on) { timer.restart(); bStart.setText("Pause"); } else { timer.stop(); bStart.setText("Resume"); } } if (src == tNum) { int n = Integer.parseInt(tNum.getText().trim()); if (n < 2) { n = 2; tNum.setText(" " + n); } md.N = n; md.init(md.rho); adjCanvasScale = true; } if (src == bReset) { if (timer.isRunning()) timer.stop(); bStart.setSelected(false); bStart.setText("Start"); md.init(md.rho); } canvas.refresh(md.getXWrap(), md.N, true, adjCanvasScale); repaint(); }