List of usage examples for java.awt.event ActionEvent ActionEvent
public ActionEvent(Object source, int id, String command)
From source file:MainClass.java
public KeyTextComponent() { setBackground(Color.CYAN);//w w w. ja v a 2 s. c o m KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);/*from ww w. j av a2 s . co m*/ KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_LAST, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.CYAN);/*from w ww .j ava 2 s . c o m*/ KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_FIRST, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:KeyTextTester2.java
public KeyTextComponent2() { setBackground(Color.cyan);// w ww . java 2 s . c o m KeyListener internalKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (actionListenerList != null) { int keyCode = keyEvent.getKeyCode(); String keyText = KeyEvent.getKeyText(keyCode); ActionEvent actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, keyText); fireActionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocus(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:ColorComboBoxEditor.java
protected void fireActionEvent(Color color) { Object listeners[] = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ActionListener.class) { ActionEvent actionEvent = new ActionEvent(editor, ActionEvent.ACTION_PERFORMED, color.toString()); ((ActionListener) listeners[i + 1]).actionPerformed(actionEvent); }// ww w. j a v a2 s . c om } }
From source file:ShowAddListeners.java
public void init() { NameL nameListener = new NameL(); name.addActionListener(nameListener); JPanel top = new JPanel(); top.add(new JLabel("Swing class name (press ENTER):")); top.add(name);/*w ww . j ava 2 s . c o m*/ Container cp = getContentPane(); cp.add(BorderLayout.NORTH, top); cp.add(new JScrollPane(results)); // Initial data and test: name.setText("JTextArea"); nameListener.actionPerformed(new ActionEvent("", 0, "")); }
From source file:org.jajuk.ui.actions.TestPreparePartyAction.java
/** * Test method for.//from www . j a v a2s. c o m * * @throws Exception the exception * {@link org.jajuk.ui.actions.PreparePartyAction#PreparePartyAction()}. */ public void testPreparePartyAction() throws Exception { PreparePartyAction action = new PreparePartyAction(); // once with empty properties, this is called from the menu try { action.perform(new ActionEvent(new JButton(), 1, null)); } catch (HeadlessException e) { // happens when tests are run on servers without ui } // then with a single and with a list of playlists, this is called from the // PlaylistView JButton button = new JButton(); button.putClientProperty(Const.DETAIL_SELECTION, getPlaylist(10, false)); try { action.perform(new ActionEvent(button, 1, null)); // once with empty // properties } catch (HeadlessException e) { // happens when tests are run on servers without ui } List<Playlist> list = new ArrayList<Playlist>(); list.add(getPlaylist(11, false)); button.putClientProperty(Const.DETAIL_SELECTION, list); try { action.perform(new ActionEvent(button, 1, null)); // once with empty // properties } catch (HeadlessException e) { // happens when tests are run on servers without ui } }
From source file:DualListener.java
protected void fireAChanged() { Object[] listeners = events.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ActionListener.class) { if (actionEvent == null) { actionEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "a"); }/*from www.ja va2 s . c o m*/ ((ActionListener) listeners[i + 1]).actionPerformed(actionEvent); } } }
From source file:maltcms.ui.fileHandles.serialized.JFCPanel.java
/** * */// w ww.j a v a 2 s. c o m public JFCPanel() { this.chartPanel = new ChartPanel(new JFreeChart(new XYPlot())); initComponents(); jToggleButton1ActionPerformed(new ActionEvent(this, 0, "")); toggleYAxisFix = new JToggleButton(new AbstractAction("Fix y") { @Override public void actionPerformed(ActionEvent ae) { chartPanel.getChart().getXYPlot().getRangeAxis() .setAutoRange(!chartPanel.getChart().getXYPlot().getRangeAxis().isAutoRange()); } }); this.jToolBar2.add(toggleYAxisFix); toggleXAxisFix = new JToggleButton(new AbstractAction("Fix x") { @Override public void actionPerformed(ActionEvent ae) { chartPanel.getChart().getXYPlot().getDomainAxis() .setAutoRange(!chartPanel.getChart().getXYPlot().getDomainAxis().isAutoRange()); } }); this.jToolBar2.add(toggleXAxisFix); toggleAnnotations = new JToggleButton(new AbstractAction("Annotations") { @Override public void actionPerformed(ActionEvent ae) { if (chartPanel.getChart().getXYPlot().getAnnotations().isEmpty()) { Logger.getLogger(getClass().getName()).info("Adding annotations"); for (XYAnnotation xya : annotations) { chartPanel.getChart().getXYPlot().addAnnotation(xya); } chartPanel.getChart().fireChartChanged(); toggleAnnotations.setSelected(true); } else { Logger.getLogger(getClass().getName()).info("Removing annotations"); List<?> l = chartPanel.getChart().getXYPlot().getAnnotations(); if (!l.isEmpty()) { annotations.clear(); for (Object o : l) { annotations.add((XYAnnotation) o); } } chartPanel.getChart().getXYPlot().clearAnnotations(); } } }); this.jToolBar2.add(toggleAnnotations); toggleAnnotations.setSelected(true); }
From source file:org.gitools.ui.app.welcome.WelcomeEditor.java
@Override protected void performAction(String name, Map<String, String> params) { switch (name) { case "open": { switch (params.get("ref")) { case "filesystem": new OpenFromFilesystemBrowseAction().actionPerformed(new ActionEvent(this, 0, name)); break; case "genomespace": new OpenFromGenomeSpaceAction().actionPerformed(new ActionEvent(this, 0, name)); break; case "shortcuts": new ShortcutsAction().actionPerformed(new ActionEvent(this, 0, name)); break; }//from ww w .j ava 2 s . co m break; } case "reload": navigate(getWelcomeURL()); break; } }