List of usage examples for java.awt.event ActionEvent ActionEvent
public ActionEvent(Object source, int id, String command)
From source file:KeyUtils.java
public static void pressKey(Component component) { if (component.getKeyListeners().length > 0) { KeyEvent event = new KeyEvent(component, KeyEvent.KEY_PRESSED, 0, 1, 32, (char) 32); for (int i = 0; i < component.getKeyListeners().length; i++) { KeyListener keyListener = component.getKeyListeners()[i]; keyListener.keyPressed(event); }/*from w w w . j a v a 2 s . c om*/ } if (JComponent.class.isInstance(component)) { KeyStroke keyStroke = KeyStroke.getKeyStroke(32, 1); final ActionListener actionForKeyStroke = ((JComponent) component).getActionForKeyStroke(keyStroke); if (actionForKeyStroke != null) { actionForKeyStroke.actionPerformed(new ActionEvent(component, KeyEvent.KEY_PRESSED, "")); } } }
From source file:MyLabel.java
public MyLabel(String msg) { super(msg);/* w w w . ja v a 2 s .c om*/ addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { fireActionPerformed(new ActionEvent(MyLabel.this, ActionEvent.ACTION_PERFORMED, "SecretMessage")); } }); }
From source file:KeyTextComponent.java
public KeyTextComponent() { setBackground(Color.CYAN);/*from ww w. j a 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); actionListenerList.actionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocusInWindow(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }
From source file:launcher.DownloadCountingOutputStream.java
@Override protected void afterWrite(int n) throws IOException { super.afterWrite(n); if (listener != null) { listener.actionPerformed(new ActionEvent(this, 0, null)); }/*w w w .ja v a 2 s . c o m*/ }
From source file:com.microsoft.alm.plugin.idea.ui.checkout.CheckoutPageControllerTest.java
/** * This test was added to cover the bit of the tfs controller that wasn't already covered *//* w ww . j a v a 2 s .c o m*/ @Test public void testActionPerformed() { MockCheckoutPageModel tfsModel = new MockCheckoutPageModel(null, ServerContextTableModel.VSO_REPO_COLUMNS); MockCheckoutPage tfsPage = new MockCheckoutPage(); CheckoutPageController tcc = new CheckoutPageController(null, tfsModel, tfsPage); // Trigger the controller to do connect tcc.actionPerformed(new ActionEvent(this, 1, LoginForm.CMD_SIGN_IN)); assertEquals(true, tfsModel.isLoadRepositoriesCalled()); tfsModel.clearInternals(); // Trigger the controller to do sign out assertEquals(true, tfsModel.isConnected()); tcc.actionPerformed(new ActionEvent(this, 1, UserAccountPanel.CMD_SIGN_OUT)); assertEquals(false, tfsModel.isConnected()); tfsModel.clearInternals(); // Trigger the controller to do filter changed assertTrue(StringUtils.isEmpty(tfsModel.getRepositoryFilter())); tfsPage.setRepositoryFilter("filter"); tcc.actionPerformed(new ActionEvent(this, 1, CheckoutForm.CMD_REPO_FILTER_CHANGED)); assertEquals("filter", tfsModel.getRepositoryFilter()); tfsModel.clearInternals(); }
From source file:com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutPageControllerTest.java
/** * This test was added to cover the bit of the tfs controller that wasn't already covered *///from w ww . jav a 2 s . co m @Test public void testActionPerformed() { MockCheckoutPageModel tfsModel = new MockCheckoutPageModel(null, ServerContextTableModel.VSO_GIT_REPO_COLUMNS); MockCheckoutPage tfsPage = new MockCheckoutPage(); CheckoutPageController tcc = new CheckoutPageController(null, tfsModel, tfsPage); // Trigger the controller to do connect tcc.actionPerformed(new ActionEvent(this, 1, LoginForm.CMD_SIGN_IN)); assertEquals(true, tfsModel.isLoadRepositoriesCalled()); tfsModel.clearInternals(); // Trigger the controller to do sign out assertEquals(true, tfsModel.isConnected()); tcc.actionPerformed(new ActionEvent(this, 1, UserAccountPanel.CMD_SIGN_OUT)); assertEquals(false, tfsModel.isConnected()); tfsModel.clearInternals(); // Trigger the controller to do filter changed assertTrue(StringUtils.isEmpty(tfsModel.getRepositoryFilter())); tfsPage.setRepositoryFilter("filter"); tcc.actionPerformed(new ActionEvent(this, 1, CheckoutForm.CMD_REPO_FILTER_CHANGED)); assertEquals("filter", tfsModel.getRepositoryFilter()); tfsModel.clearInternals(); }
From source file:net.chris54721.infinitycubed.utils.DownloadCountingOutputStream.java
@Override protected void afterWrite(int n) throws IOException { super.afterWrite(n); if (listener != null) listener.actionPerformed(new ActionEvent(this, 0, null)); }
From source file:net.CountingStream.java
@Override protected void afterWrite(int n) throws IOException { super.afterWrite(n); if (l != null) { l.actionPerformed(new ActionEvent(this, 0, null)); }/*w w w . j ava 2 s .c o m*/ }
From source file:SecretTest.java
public SecretLabel(String msg) { super(msg);//from w w w .j av a 2 s .com addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { fireActionPerformed( new ActionEvent(SecretLabel.this, ActionEvent.ACTION_PERFORMED, "SecretMessage")); } }); }
From source file:Main.java
public KeyTextComponent() { setBackground(Color.cyan);//from w w w .j a v a2s . 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_PERFORMED, keyText); actionListenerList.actionPerformed(actionEvent); } } }; MouseListener internalMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { requestFocus(); } }; addKeyListener(internalKeyListener); addMouseListener(internalMouseListener); }