private void initActions() { Action defaultAction = createCloseAction(); putAction(CLOSE_ACTION_COMMAND, defaultAction); putAction(EXECUTE_ACTION_COMMAND, defaultAction); }
/** * The callback method executed when closing the dialog. <p> * Here: calls dispose. * */ public void doClose() { dispose(); }
/** * Returns a potentially localized value from the UIManager. The given key * is prefixed by this component|s <code>UIPREFIX</code> before doing the * lookup. The lookup respects this table's current <code>locale</code> * property. Returns the key, if no value is found. * * @param key the bare key to look up in the UIManager. * @return the value mapped to UIPREFIX + key or key if no value is found. */ protected String getUIString(String key) { return getUIString(key, getLocale()); }
if ((topLevel != null) && (topLevel.getOwner().equals(frame))) { findDialog = topLevel; Point location = hideSharedFindPanel(true); if (frame instanceof Frame) { findDialog = new JXDialog((Frame) frame, getSharedFindPanel()); } else if (frame instanceof Dialog) { findDialog = new JXDialog((Dialog) frame, getSharedFindPanel()); } else { findDialog = new JXDialog(JOptionPane.getRootFrame(), getSharedFindPanel()); findDialog.pack(); if (location == null) { findDialog.setLocationRelativeTo(frame); } else { findDialog.setLocation(location); findDialog.setLocale(target.getLocale()); findDialog.setVisible(true);
/** * PENDING: widen access - this could be public to make the content really * pluggable? * * @param content */ private void setContent(JComponent content) { if (this.content != null) { throw new IllegalStateException("content must not be set more than once"); } initActions(); Action contentCloseAction = content.getActionMap().get(CLOSE_ACTION_COMMAND); if (contentCloseAction != null) { putAction(CLOSE_ACTION_COMMAND, contentCloseAction); } Action contentExecuteAction = content.getActionMap().get(EXECUTE_ACTION_COMMAND); if (contentExecuteAction != null) { putAction(EXECUTE_ACTION_COMMAND, contentExecuteAction); } this.content = content; build(); setTitleFromContent(); }
/** * Updates this dialog's locale-dependent state. * * Here: updates title and actions. * <p> * * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { setTitleFromContent(); for (Object key : getRootPane().getActionMap().allKeys()) { if (key instanceof String) { Action contentAction = content.getActionMap().get(key); Action rootPaneAction = getAction(key); if ((!rootPaneAction.equals(contentAction))) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { rootPaneAction.putValue(Action.NAME, keyString); } } } } }
/** * Sets the status bar property on the underlying {@code JXRootPane}. * * @param statusBar * the {@code JXStatusBar} which is to be the status bar * @see #getStatusBar() * @see JXRootPane#setStatusBar(JXStatusBar) */ public void setStatusBar(JXStatusBar statusBar) { getRootPane().setStatusBar(statusBar); }
/** * pre: content != null. * */ private void build() { JComponent contentBox = new Box(BoxLayout.PAGE_AXIS); contentBox.add(content); JComponent buttonPanel = createButtonPanel(); contentBox.add(buttonPanel); contentBox.setBorder(BorderFactory.createEmptyBorder(14, 14, 14, 14)); // content.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); // fieldPanel.setAlignmentX(); // buttonPanel.setAlignmentX(Component.RIGHT_ALIGNMENT); add(contentBox); }
/** * create the dialog button controls. * * * @return panel containing button controls */ protected JComponent createButtonPanel() { // PENDING: this is a hack until we have a dedicated ButtonPanel! JPanel panel = new JPanel(new BasicOptionPaneUI.ButtonAreaLayout(true, 6)) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; panel.setBorder(BorderFactory.createEmptyBorder(9, 0, 0, 0)); Action executeAction = getAction(EXECUTE_ACTION_COMMAND); Action closeAction = getAction(CLOSE_ACTION_COMMAND); JButton defaultButton = new JButton(executeAction); panel.add(defaultButton); getRootPane().setDefaultButton(defaultButton); if (executeAction != closeAction) { JButton b = new JButton(closeAction); panel.add(b); getRootPane().setCancelButton(b); } return panel; }
if ((topLevel != null) && (topLevel.getOwner().equals(frame))) { findDialog = topLevel; Point location = hideSharedFindPanel(true); if (frame instanceof Frame) { findDialog = new JXDialog((Frame) frame, getSharedFindPanel()); } else if (frame instanceof Dialog) { findDialog = new JXDialog((Dialog) frame, getSharedFindPanel()); } else { findDialog = new JXDialog(JOptionPane.getRootFrame(), getSharedFindPanel()); findDialog.pack(); if (location == null) { findDialog.setLocationRelativeTo(frame); } else { findDialog.setLocation(location); findDialog.setLocale(target.getLocale()); findDialog.setVisible(true);
/** * PENDING: widen access - this could be public to make the content really * pluggable? * * @param content */ private void setContent(JComponent content) { if (this.content != null) { throw new IllegalStateException("content must not be set more than once"); } initActions(); Action contentCloseAction = content.getActionMap().get(CLOSE_ACTION_COMMAND); if (contentCloseAction != null) { putAction(CLOSE_ACTION_COMMAND, contentCloseAction); } Action contentExecuteAction = content.getActionMap().get(EXECUTE_ACTION_COMMAND); if (contentExecuteAction != null) { putAction(EXECUTE_ACTION_COMMAND, contentExecuteAction); } this.content = content; build(); setTitleFromContent(); }
/** * Updates this dialog's locale-dependent state. * * Here: updates title and actions. * <p> * * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { setTitleFromContent(); for (Object key : getRootPane().getActionMap().allKeys()) { if (key instanceof String) { Action contentAction = content.getActionMap().get(key); Action rootPaneAction = getAction(key); if ((!rootPaneAction.equals(contentAction))) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { rootPaneAction.putValue(Action.NAME, keyString); } } } } }
/** * Returns the value of the tool bar property from the underlying * {@code JXRootPane}. * * @return the {@code JToolBar} which is the current tool bar * @see #setToolBar(JToolBar) * @see JXRootPane#getToolBar() */ public JToolBar getToolBar() { return getRootPane().getToolBar(); }
/** * pre: content != null. * */ private void build() { JComponent contentBox = new Box(BoxLayout.PAGE_AXIS); contentBox.add(content); JComponent buttonPanel = createButtonPanel(); contentBox.add(buttonPanel); contentBox.setBorder(BorderFactory.createEmptyBorder(14, 14, 14, 14)); // content.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); // fieldPanel.setAlignmentX(); // buttonPanel.setAlignmentX(Component.RIGHT_ALIGNMENT); add(contentBox); }
Action executeAction = getAction(EXECUTE_ACTION_COMMAND); Action closeAction = getAction(CLOSE_ACTION_COMMAND); KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); inputMap.put(enterKey, EXECUTE_ACTION_COMMAND); inputMap.put(escapeKey, CLOSE_ACTION_COMMAND); getRootPane().setDefaultButton(findButton); return panel;
if ((topLevel != null) && (topLevel.getOwner().equals(frame))) { findDialog = topLevel; Point location = hideSharedFindPanel(true); if (frame instanceof Frame) { findDialog = new JXDialog((Frame) frame, getSharedFindPanel()); } else if (frame instanceof Dialog) { findDialog = new JXDialog((Dialog) frame, getSharedFindPanel()); } else { findDialog = new JXDialog(JOptionPane.getRootFrame(), getSharedFindPanel()); findDialog.pack(); if (location == null) { findDialog.setLocationRelativeTo(frame); } else { findDialog.setLocation(location); findDialog.setLocale(target.getLocale()); findDialog.setVisible(true);
/** * PENDING: widen access - this could be public to make the content really * pluggable? * * @param content */ private void setContent(JComponent content) { if (this.content != null) { throw new IllegalStateException("content must not be set more than once"); } initActions(); Action contentCloseAction = content.getActionMap().get(CLOSE_ACTION_COMMAND); if (contentCloseAction != null) { putAction(CLOSE_ACTION_COMMAND, contentCloseAction); } Action contentExecuteAction = content.getActionMap().get(EXECUTE_ACTION_COMMAND); if (contentExecuteAction != null) { putAction(EXECUTE_ACTION_COMMAND, contentExecuteAction); } this.content = content; build(); setTitleFromContent(); }
/** * Updates this dialog's locale-dependent state. * * Here: updates title and actions. * <p> * * * @see #setLocale(Locale) */ protected void updateLocaleState(Locale locale) { setTitleFromContent(); for (Object key : getRootPane().getActionMap().allKeys()) { if (key instanceof String) { Action contentAction = content.getActionMap().get(key); Action rootPaneAction = getAction(key); if ((!rootPaneAction.equals(contentAction))) { String keyString = getUIString((String) key, locale); if (!key.equals(keyString)) { rootPaneAction.putValue(Action.NAME, keyString); } } } } }
/** * Returns the value of the tool bar property from the underlying * {@code JXRootPane}. * * @return the {@code JToolBar} which is the current tool bar * @see #setToolBar(JToolBar) * @see JXRootPane#getToolBar() */ public JToolBar getToolBar() { return getRootPane().getToolBar(); }
/** * Returns a potentially localized value from the UIManager. The given key * is prefixed by this component|s <code>UIPREFIX</code> before doing the * lookup. The lookup respects this table's current <code>locale</code> * property. Returns the key, if no value is found. * * @param key the bare key to look up in the UIManager. * @return the value mapped to UIPREFIX + key or key if no value is found. */ protected String getUIString(String key) { return getUIString(key, getLocale()); }