List of usage examples for java.awt.event ActionEvent getSource
public Object getSource()
From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java
private void jcbTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbTypeActionPerformed // Add your handling code here: JComboBox s = (JComboBox) evt.getSource(); pref.putInt("xyitemrenderer", s.getSelectedIndex() + 1); }
From source file:AlternateAppearanceScopeTest.java
public void actionPerformed(ActionEvent e) { Object target = e.getSource(); if (target == altAppMaterialColor) { altMat.setDiffuseColor(colors[altAppMaterialColor.getSelectedIndex()]); } else if (target == altAppScoping) { for (int i = 0; i < altApp.numScopes(); i++) { altApp.removeScope(0);/*from w w w. j ava 2 s .c o m*/ } if (altAppScoping.getSelectedIndex() == 0) { altApp.addScope(content1); } else if (altAppScoping.getSelectedIndex() == 1) { altApp.addScope(content2); } } else if (target == override) { int i; if (override.getSelectedIndex() == 0) { if (!shape1Enabled) { for (i = 0; i < shapes1.length; i++) shapes1[i].setAppearanceOverrideEnable(true); shape1Enabled = true; } if (shape2Enabled) { for (i = 0; i < shapes2.length; i++) shapes2[i].setAppearanceOverrideEnable(false); shape2Enabled = false; } } else if (override.getSelectedIndex() == 1) { if (!shape2Enabled) { for (i = 0; i < shapes2.length; i++) shapes2[i].setAppearanceOverrideEnable(true); shape2Enabled = true; } if (shape1Enabled) { for (i = 0; i < shapes1.length; i++) shapes1[i].setAppearanceOverrideEnable(false); shape1Enabled = false; } } else if (override.getSelectedIndex() == 2) { if (!shape1Enabled) { for (i = 0; i < shapes1.length; i++) shapes1[i].setAppearanceOverrideEnable(true); shape1Enabled = true; } if (!shape2Enabled) { for (i = 0; i < shapes2.length; i++) shapes2[i].setAppearanceOverrideEnable(true); shape2Enabled = true; } } else { if (shape1Enabled) { for (i = 0; i < shapes1.length; i++) shapes1[i].setAppearanceOverrideEnable(false); shape1Enabled = false; } if (shape2Enabled) { for (i = 0; i < shapes2.length; i++) shapes2[i].setAppearanceOverrideEnable(false); shape2Enabled = false; } } } else if (target == appMaterialColor) { mat1.setDiffuseColor(colors[appMaterialColor.getSelectedIndex()]); } }
From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java
private void lastUserCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lastUserCheckBoxActionPerformed // Add your handling code here: JCheckBox s = (JCheckBox) evt.getSource(); pref.putBoolean("rememberlastconnection", s.isSelected()); }
From source file:de.codesourcery.eve.skills.ui.components.impl.ItemChooserComponent.java
private JPanel createListViewPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); // create button panel final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); final JButton addButton = new JButton("====>"); final JButton removeButton = new JButton("<===="); final ActionListener buttonListener = new ActionListener() { @Override// w ww . j av a 2 s.c o m public void actionPerformed(ActionEvent e) { if (e.getSource() == addButton) { addButtonClicked(); } else if (e.getSource() == removeButton) { removeButtonClicked(); } else { throw new RuntimeException("Unhandled event source " + e.getSource()); } } }; addButton.addActionListener(buttonListener); removeButton.addActionListener(buttonListener); buttonPanel.add(addButton, constraints(0, 0).noResizing().end()); buttonPanel.add(removeButton, constraints(0, 1).noResizing().end()); // create list panel itemTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); itemTable.setModel(selectedItemsModel); itemTable.setRowSorter(selectedItemsModel.getRowSorter()); result.add(buttonPanel, constraints(0, 0).useRelativeWidth().resizeBoth().end()); result.add(new JScrollPane(itemTable), constraints(1, 0).useRemainingWidth().resizeBoth().end()); return result; }
From source file:MainFrame.MainFrame.java
public MainFrame() { //Create menu this.menuBar = new JMenuBar(); this.menuProxy = new JMenu("Proxy"); this.menuBar.add(menuProxy); this.cbMenuItem = new JCheckBoxMenuItem("? proxy"); this.cbMenuItem.setMnemonic(KeyEvent.VK_C); ActionListener aListener = new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); if (selected) { SingleDataHolder.getInstance().isProxyActivated = true; SingleDataHolder.getInstance().proxyIpAdress = MainFrame.this.proxyIpAdress.getText(); SingleDataHolder.getInstance().proxyPort = Integer.parseInt(MainFrame.this.proxyPort.getText()); SingleDataHolder.getInstance().proxyLogin = MainFrame.this.proxyLogin.getText(); SingleDataHolder.getInstance().proxyPassword = String .valueOf(MainFrame.this.proxyPassword.getPassword()); } else { SingleDataHolder.getInstance().isProxyActivated = false; }/* w w w. j ava2 s . c o m*/ } }; this.cbMenuItem.addActionListener(aListener); this.proxyIpAdress = new JTextField(); this.proxyPort = new JTextField(); this.proxyLogin = new JTextField(); ; this.proxyPassword = new JPasswordField(); this.menuProxy.add(this.cbMenuItem); this.menuProxy.add(new JLabel("IP ?")); this.menuProxy.add(this.proxyIpAdress); this.menuProxy.add(new JLabel("? ")); this.menuProxy.add(this.proxyPort); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyLogin); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyPassword); this.setJMenuBar(this.menuBar); communicator = new HttpCommunicator(); myActionListener = new mainFrameActionListener(); mainPanel = new JPanel(new BorderLayout()); this.setContentPane(mainPanel); JPanel P = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5)); mainPanel.add(P, BorderLayout.NORTH); //Create Group label labelGroup = new JLabel(""); P.add(labelGroup); //Create Group combo comboGroup = new JComboBox(); comboGroup.addItem("?"); comboGroup.addActionListener(myActionListener); P.add(comboGroup); //Create Date label labelDate = new JLabel(""); P.add(labelDate); //Create Date combo comboDate = new JComboBox(); comboDate.addItem("?"); comboDate.addActionListener(myActionListener); P.add(comboDate); //Create Delete button buttonDelete = new JButton(""); buttonDelete.setEnabled(false); buttonDelete.addActionListener(myActionListener); P.add(buttonDelete); //this.checkConnection = new CheckConnection(buttonDelete); buttonPasswordsManager = new JButton(" "); buttonPasswordsManager.addActionListener(myActionListener); P.add(buttonPasswordsManager); try { Image img = ImageIO.read(getClass().getResource("resources/table_refresh.png")); this.buttonRefresh = new JButton(new ImageIcon(img)); this.buttonRefresh.addActionListener(myActionListener); this.buttonRefresh.setToolTipText(" "); P.add(buttonRefresh); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateLessonTableModel lessonTableModel = new LessonTableModel(); try { communicator.setCombos(comboGroup, comboDate, lessonTableModel); } catch (IOException ex) { JOptionPane.showMessageDialog(null, " ? ? ."); Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateTable table = new JTable(lessonTableModel); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); JScrollPane scrollP = new JScrollPane(table); mainPanel.add(scrollP, BorderLayout.CENTER); //Create Table sorter sorter = new TableRowSorter<LessonTableModel>(lessonTableModel); table.setRowSorter(sorter); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); TableModel model = (TableModel) e.getSource(); for (int i = 0; i < model.getRowCount(); i++) { if ((boolean) model.getValueAt(i, 2) == true) { buttonDelete.setEnabled(true); return; } } buttonDelete.setEnabled(false); } }); //Standart block this.setSize(700, 400); this.setTitle(" "); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { System.exit(0); } }); try { Image img = ImageIO.read(getClass().getResource("resources/appIcon.png")); this.setIconImage(img); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } this.setVisible(true); }
From source file:dk.dma.epd.common.prototype.gui.notification.MsiNmNotificationPanel.java
/** * Called when the MSI-NM service selection changes * @param ae the action event//from ww w .ja v a 2s . c om */ @Override public void actionPerformed(ActionEvent ae) { if (ae.getSource() == msiNmServiceComboBox) { MsiNmServiceItem selItem = (MsiNmServiceItem) msiNmServiceComboBox.getSelectedItem(); if (selItem != null) { EPD.getInstance().getMsiNmHandler().setSelectedMsiNmServiceId(selItem.getId()); } } }
From source file:net.sourceforge.doddle_owl.ui.GeneralOntologySelectionPanel.java
public void actionPerformed(ActionEvent e) { DODDLEProject project = DODDLE_OWL.getCurrentProject(); if (e.getSource() == removeGeneralOntologyDirButton) { int result = JOptionPane.showConfirmDialog(this, Translator.getTerm("RemoveGeneralOntologyDirectoryButton") + ": " + System.lineSeparator() + Utils.TEMP_DIR); if (result == JOptionPane.YES_OPTION) { String tmpDirName = "net.sourceforge.doddle-owl"; // tmpDirName??????????? File tmpDir = new File(Utils.TEMP_DIR); if (tmpDir.getAbsolutePath().contains(tmpDirName)) { deleteFile(tmpDir); // ??????? }/*ww w . j a v a2 s . c o m*/ } } else if (e.getSource() == edrCheckBox) { enableEDRDic(edrCheckBox.isSelected()); project.addLog("GenericEDRCheckBox", edrCheckBox.isSelected()); } else if (e.getSource() == edrtCheckBox) { enableEDRTDic(edrtCheckBox.isSelected()); project.addLog("TechnicalEDRCheckBox", edrtCheckBox.isSelected()); } else if (e.getSource() == wnCheckBox) { enableWordNetDic(wnCheckBox.isSelected()); wnVersionSelectionPanel.setEnabled(wnCheckBox.isSelected()); project.addLog("WordNetCheckBox", wnCheckBox.isSelected()); } else if (e.getSource() == jpnWnCheckBox) { enableJpnWordNetDic(jpnWnCheckBox.isSelected()); project.addLog("JpnWordNetCheckBox", jpnWnCheckBox.isSelected()); } else if (e.getSource() == jwoCheckBox) { if (jwoCheckBox.isSelected()) { File jwoDir = new File(JWO_HOME); if (!jwoDir.exists()) { jwoDir.mkdir(); } String[] tdbFiles = { "GOSP.dat", "GOSP.idn", "GOSP.info", "GPOS.dat", "GPOS.idn", "GPOS.info", "GSPO.dat", "GSPO.idn", "GSPO.info", "node2id.dat", "node2id.idn", "node2id.info", "nodes.dat", "nodes.info", "OSP.dat", "OSP.idn", "OSP.info", "OSPG.dat", "OSPG.idn", "OSPG.info", "POS.dat", "POS.idn", "POS.info", "POSG.dat", "POSG.idn", "POSG.info", "prefix2id.dat", "prefix2id.idn", "prefix2id.info", "prefixes.dat", "prefixes.info", "prefixIdx.dat", "prefixIdx.idn", "prefixIdx.info", "SPO.dat", "SPO.idn", "SPO.info", "SPOG.dat", "SPOG.idn", "SPOG.info", "this.info" }; for (String fname : tdbFiles) { File f = new File(JWO_HOME + File.separator + fname); if (!f.exists()) { URL url = DODDLE_OWL.class.getClassLoader() .getResource(Utils.RESOURCE_DIR + "jwo/" + f.getName()); try { if (url != null) { FileUtils.copyURLToFile(url, f); DODDLE_OWL.getLogger().log(Level.INFO, "copy: " + f.getAbsolutePath()); } } catch (IOException ioe) { ioe.printStackTrace(); } } } if (OWLOntologyManager.getRefOntology(jwoDir.getAbsolutePath()) == null) { dataset = TDBFactory.createDataset(jwoDir.getAbsolutePath()); Model ontModel = dataset.getDefaultModel(); ReferenceOWLOntology refOnt = new ReferenceOWLOntology(ontModel, jwoDir.getAbsolutePath(), nameSpaceTable); OWLOntologyManager.addRefOntology(refOnt.getURI(), refOnt); } } } }
From source file:J3dSwingFrame.java
/** * An mouse action has occurred. Used to process menu item selection. * /*from www.j a v a2 s .c o m*/ * @param evt * The event that caused this method to be called. */ public void actionPerformed(ActionEvent evt) { Object src = evt.getSource(); if (src == close_menu) System.exit(0); }
From source file:es.emergya.ui.gis.popups.RouteDialog.java
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(search)) { notification.setForeground(Color.WHITE); notification.updateUI();//from w w w . j ava 2 s .c o m progressIcon.setIcon(iconEnviando); search.setEnabled(false); clear.setEnabled(false); new SwingWorker<Boolean, Object>() { List<Way> route = null; protected void done() { if (route != null && route.size() > 0) { setRoute(route); } else { notification.setText(i18n.getString("window.route.notification.noRoute")); notification.setForeground(Color.RED); } progressIcon.setIcon(iconTransparente); clear.setEnabled(true); search.setEnabled(true); notification.updateUI(); } @Override protected Boolean doInBackground() throws Exception { try { route = getRoute(); return true; } catch (Throwable t) { log.error("Error al calcular la ruta", t); notification.setText(i18n.getString("progress.route.error")); notification.setForeground(Color.RED); return false; } } }.execute(); } else { from = null; fx.setText(""); fy.setText(""); to = null; tx.setText(""); ty.setText(""); search.setEnabled(false); clear.setEnabled(false); clearRoute(); instance.notification.setText(i18n.getString("progress.route.nopoints")); instance.notification.setForeground(Color.RED); notification.updateUI(); if (!e.getSource().equals(clear)) { setVisible(false); } } }
From source file:Main.java
public void actionPerformed(ActionEvent e) { Locale locale = Locale.getDefault(); Date date = new Date(e.getWhen()); String s = DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(date); if (!model.isEmpty()) { model.clear();/*w w w . j av a 2 s. c o m*/ } if (e.getID() == ActionEvent.ACTION_PERFORMED) { model.addElement(" Event Id: ACTION_PERFORMED"); } model.addElement("Time: " + s); String source = e.getSource().getClass().getName(); int mod = e.getModifiers(); StringBuffer buffer = new StringBuffer("Modifiers: "); if ((mod & ActionEvent.ALT_MASK) > 0) { buffer.append("Alt "); } if ((mod & ActionEvent.SHIFT_MASK) > 0) { buffer.append("Shift "); } if ((mod & ActionEvent.META_MASK) > 0) { buffer.append("Meta "); } if ((mod & ActionEvent.CTRL_MASK) > 0) { buffer.append("Ctrl "); } model.addElement(buffer); }