protected JRootPane createRootPane() { KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); JRootPane rootPane = new JRootPane(); rootPane.registerKeyboardAction(this, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); rootPane.registerKeyboardAction(this, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
@Override public JRootPane getRootPane() { if (rootPane == null) { rootPane = new JRootPane(); } return rootPane; } }
protected JRootPane createRootPane() { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }; JRootPane rootPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
/** * Creates spy root pane for spy dialog. */ protected JRootPane createSpyRootPane() { JRootPane rootPane = new JRootPane(); KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { spyGlass.setVisible(false); spyDialog.setVisible(false); } }, escapeKeyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
/** * Override createRootPane so that "escape" key can be used to * close this window. */ protected JRootPane createRootPane() { ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { setVisible(false); dispose(); } }; JRootPane rootPane = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
protected JRootPane createRootPane() { KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); JRootPane rootPane = new JRootPane(); rootPane.registerKeyboardAction(this, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); rootPane.registerKeyboardAction(this, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW); return rootPane; }
@Override protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); Action escapeAction = new AbstractAction("ESCAPE") { private static final long serialVersionUID = 2208129319916921772L; @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }; InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME)); rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction); return rootPane; }
/** * Called by the constructor to set up the <code>JRootPane</code>. * * @return a new <code>JRootPane</code> * @see javax.swing.JRootPane */ protected JRootPane createRootPane() { JRootPane pane = new JRootPane(); // by default, the subclass BorderLayout cause memory leak if isPopupVolatile in AbstractComboBox. pane.getContentPane().setLayout(new BorderLayout()); pane.setOpaque(false); // on Nimbus L&F, JRootPane is opaque by default. So we have to set it to false explicitly. return pane; }
protected JRootPane createRootPane() { final JRootPane rootPane = new JRootPane(); final KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE"); final Action actionListener = new AbstractAction() { public void actionPerformed(final ActionEvent actionEvent) { setVisible(false); } }; final InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(stroke, "ESCAPE"); rootPane.getActionMap().put("ESCAPE", actionListener); return rootPane; } }
@Override protected JRootPane createRootPane() { JRootPane root = new JRootPane(); KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE"); Action actionListener = new AbstractAction() { private static final long serialVersionUID = -1L; @Override public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }; InputMap inputMap = root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(stroke, "ESCAPE"); root.getActionMap().put("ESCAPE", actionListener); return root; }
public static void setJPanelMenuBar(JPanel parent, JPanel child, JMenuBar menuBar) { parent.removeAll(); parent.setLayout(new BorderLayout()); JRootPane root = new JRootPane(); parent.add(root, BorderLayout.CENTER); root.setJMenuBar(menuBar); root.getContentPane().add(child); parent.putClientProperty("root", root); //if you need later }
@Override protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); // Escape key closes dialogs KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "escapeKey"); rootPane.getActionMap().put("escapeKey", new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); } }); return rootPane; } }
@Override protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); // Hide Window on ESC Action escapeAction = new AbstractAction("ESCAPE") { private static final long serialVersionUID = -6543764044868772971L; @Override public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }; ActionMap actionMap = rootPane.getActionMap(); actionMap.put(escapeAction.getValue(Action.NAME), escapeAction); InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME)); return rootPane; }
@Override protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); // Escape key closes dialogs KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "escapeKey"); rootPane.getActionMap().put("escapeKey", new AbstractAction() { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); } }); return rootPane; } }
/** * Allow Dialog to be closed by ESC key */ @Override protected JRootPane createRootPane() { JRootPane rootPane = new JRootPane(); javax.swing.Action escapeAction = new AbstractAction("ESCAPE") { private static final long serialVersionUID = -4036804004190858925L; @Override public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }; rootPane.getActionMap().put(escapeAction.getValue(Action.NAME), escapeAction); InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStrokes.ESC, escapeAction.getValue(Action.NAME)); return rootPane; }
@Override JRootPane initSwingComponent() { // We always need a rootPane, even for undecorated windows, otherwise // we cannot have menu support... Window window = (Window) getAWTComponent(); JRootPane jrootpane = new JRootPane(); jrootpane.setDoubleBuffered(false); return jrootpane; }
final JPanel panel1 = ...; final JPanel panel2 = ...; boolean showingPanel1 = true; final JRootPane rootPane = new JRootPane(); rootPane.setContentPane(panel1); JButton switchButton = new JButton("Switch"); switchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (showingPanel1) { rootPane.setContentPane(panel2); } else { rootPane.setContentPane(panel1); } showingPanel = !showingPanel; } });
Composite composite_tree = new Composite(unitPriceChngeComposite12, SWT.EMBEDDED); composite_tree.setBounds(20, 207, 230, 398); Frame frame = SWT_AWT.new_Frame(composite_tree); Panel panel = new Panel(); frame.add(panel); panel.setLayout(new BorderLayout(0, 0)); JRootPane rootPane = new JRootPane(); panel.add(rootPane); tree_unitPrice = new JTree(); rootPane.getContentPane().add(tree_unitPrice, BorderLayout.NORTH);
public EnhancedPanel() { root = new JRootPane(); glassPane = new GlassPane(); widgetRoot = new WidgetRoot(); super.setLayout(new BorderLayout()); super.add(root); setLayout(new FlowLayout()); root.getLayeredPane().add(widgetRoot, JLayeredPane.MODAL_LAYER); root.setGlassPane(glassPane); }
public static void main(String[] args) { JFrame jf = new JFrame(); Component c = jf.getContentPane(); // <= a JPanel with a JRootPane$1 layout manager. Component c2 = jf.getRootPane().getContentPane(); boolean isEqual = (c == c2); JRootPane jrp = new JRootPane(); LayoutManager lm = jrp.getLayout(); LayoutManager lm1 = jf.getContentPane().getLayout(); // <= a hcak to get a JRootPane$1 instance. Maybe not neccessary? final Frame frame = new Frame(); frame.setSize(400, 300); final JRootPane rootPane = new JRootPane(); rootPane.setSize(frame.getSize()); //rootPanel.setBackground(Color.blue); rootPane.setLayout(new BorderLayout()); rootPane.add(new TestPanel()); frame.add(rootPane); frame.setVisible(true); }