Java Code Examples for javax.swing.JRootPane#registerKeyboardAction()

The following examples show how to use javax.swing.JRootPane#registerKeyboardAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtractDialog.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
@Override
protected JRootPane createRootPane() {
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			escapeKeyProc();
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

	return rootPane;
}
 
Example 2
Source File: RequestDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
protected JRootPane createRootPane() {
	KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane=new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
                   doClose();
			}
		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	
	return rootPane;
}
 
Example 3
Source File: MailDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
protected JRootPane createRootPane() {
	KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane=new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
				setVisible(false);
                   dispose();
			}
		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	
	return rootPane;
}
 
Example 4
Source File: AddUserDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
protected JRootPane createRootPane() {
	KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane=new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
				setVisible(false);
			}
		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	
	return rootPane;
}
 
Example 5
Source File: DetailsDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
protected JRootPane createRootPane() {
	KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane=new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
				setVisible(false);
                   dispose();
			}
		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	
	return rootPane;
}
 
Example 6
Source File: PassDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
protected JRootPane createRootPane() {
	KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane=new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent) {
				setVisible(false);
                   dispose();
			}
		}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	
	return rootPane;
}
 
Example 7
Source File: LoginDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Make dialog close on ESCAPE
 */
protected JRootPane createRootPane() {
    KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane=new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                jCancelButton.doClick();
            }
        }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    
    return rootPane;
}
 
Example 8
Source File: Preferences.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Make dialog close on ESCAPE
 */
protected JRootPane createRootPane() {
    KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane=new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                setVisible(false);
                dispose();
            }
        }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    
    return rootPane;
}
 
Example 9
Source File: SubmissionTree.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Make dialog close on ESCAPE
 */
protected JRootPane createRootPane() {
    KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane=new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
            	setVisible(false);
                dispose();
        		gui.previewClosed();
            }
        }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    
    return rootPane;
}
 
Example 10
Source File: OptionPanel.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Make dialog close on ESCAPE
 */
protected JRootPane createRootPane() {
    KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane=new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
            	jCancelButton.doClick();
            }
        }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    
    return rootPane;
}
 
Example 11
Source File: AboutDialog.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Make dialog close on ESCAPE
 */
protected JRootPane createRootPane() {
    KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane=new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                setVisible(false);
                dispose();
            }
        }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    
    return rootPane;
}
 
Example 12
Source File: ParserLogWindow.java    From jplag with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Make dialog close on ESCAPE
 */
protected JRootPane createRootPane() {
    KeyStroke stroke=KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    JRootPane rootPane=new JRootPane();
    rootPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                setVisible(false);
                dispose();
            }
        }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    
    return rootPane;
}
 
Example 13
Source File: EscapeDialog.java    From DominionSim with MIT License 5 votes vote down vote up
protected JRootPane createRootPane() {
  ActionListener actionListener = new ActionListener() {
    public void actionPerformed(ActionEvent actionEvent) {
      dispose();
    }
  };
  JRootPane rootPane = new JRootPane();
  KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
  rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
  return rootPane;
}
 
Example 14
Source File: AboutDialog.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
@Override
protected JRootPane createRootPane() {
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			escapeKeyProc();
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

	return rootPane;
}
 
Example 15
Source File: ExtractDialog.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
@Override
protected JRootPane createRootPane() {
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			escapeKeyProc();
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

	return rootPane;
}
 
Example 16
Source File: AboutDialog.java    From SubTitleSearcher with Apache License 2.0 5 votes vote down vote up
@Override
protected JRootPane createRootPane() {
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			escapeKeyProc();
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

	return rootPane;
}
 
Example 17
Source File: EditorAboutFrame.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * Overrides {@link JDialog#createRootPane()} to return a root pane that
 * hides the window when the user presses the ESCAPE key.O
 */
protected JRootPane createRootPane()
{
	KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = new JRootPane();
	rootPane.registerKeyboardAction(new ActionListener()
	{
		public void actionPerformed(ActionEvent actionEvent)
		{
			setVisible(false);
		}
	}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	return rootPane;
}
 
Example 18
Source File: ABaseDialog.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
protected JRootPane createRootPane() {
	KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	JRootPane rootPane = super.createRootPane();
	rootPane.registerKeyboardAction(closeDialogActionListener(), keyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
	return rootPane;
}
 
Example 19
Source File: AbstractModalDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
protected void registerEscapeKey(ActionListener cancelActionListener) {
    JRootPane rootPane = getJDialog().getRootPane();
    KeyStroke escapeKey = getEscapeKeyPressed();
    rootPane.registerKeyboardAction(cancelActionListener, escapeKey, JComponent.WHEN_IN_FOCUSED_WINDOW);
}