Class JXDialog

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

@JavaBean public class JXDialog extends JDialog
First cut for enhanced Dialog. The idea is to have a pluggable content from which the dialog auto-configures all its "dialogueness".
  • accepts a content and configures itself from content's properties - replaces the execute action from the appropriate action in content's action map (if any) and set's its title from the content's name.
  • registers stand-in actions for close/execute with the dialog's RootPane
  • registers keyStrokes for esc/enter to trigger the close/execute actions
  • takes care of building the button panel using the close/execute actions.
  • TODO: add link to forum discussion, wiki summary?
  • PENDING: add support for vetoing the close.
  • PENDING: add complete set of constructors
  • PENDING: add windowListener to delegate to close action
Author:
Jeanette Winzenburg, Karl Schaefer
See Also:
  • Field Details

  • Constructor Details

    • JXDialog

      public JXDialog(JComponent content)
      Creates a non-modal dialog with the given component as content and without specified owner. A shared, hidden frame will be set as the owner of the dialog.
      Parameters:
      content - the component to show and to auto-configure from.
    • JXDialog

      public JXDialog(Frame frame, JComponent content)
      Creates a non-modal dialog with the given component as content and the specified Frame as owner.
      Parameters:
      frame - the owner
      content - the component to show and to auto-configure from.
    • JXDialog

      public JXDialog(Dialog dialog, JComponent content)
      Creates a non-modal dialog with the given component as content and the specified Dialog as owner.
      Parameters:
      dialog - the owner
      content - the component to show and to auto-configure from.
    • JXDialog

      public JXDialog(Window window, JComponent content)
      Creates a non-modal dialog with the given component as content and the specified Window as owner.
      Parameters:
      window - the owner
      content - the component to show and to auto-configure from.
  • Method Details

    • createRootPane

      protected JXRootPane createRootPane()
      Overrides:
      createRootPane in class JDialog
    • getRootPane

      public JXRootPane getRootPane()
      Specified by:
      getRootPane in interface RootPaneContainer
      Overrides:
      getRootPane in class JDialog
    • setStatusBar

      public void setStatusBar(JXStatusBar statusBar)
      Sets the status bar property on the underlying JXRootPane.
      Parameters:
      statusBar - the JXStatusBar which is to be the status bar
      See Also:
    • getStatusBar

      public JXStatusBar getStatusBar()
      Returns the value of the status bar property from the underlying JXRootPane.
      Returns:
      the JXStatusBar which is the current status bar
      See Also:
    • setToolBar

      public void setToolBar(JToolBar toolBar)
      Sets the tool bar property on the underlying JXRootPane.
      Parameters:
      toolBar - the JToolBar which is to be the tool bar
      See Also:
    • getToolBar

      public JToolBar getToolBar()
      Returns the value of the tool bar property from the underlying JXRootPane.
      Returns:
      the JToolBar which is the current tool bar
      See Also:
    • setTitleFromContent

      protected void setTitleFromContent()
      Infers and sets this dialog's title from the the content. Does nothing if content is null. Here: uses the content's name as title.
    • setVisible

      public void setVisible(boolean visible)
      Overridden to check if content is available.

      PENDING: doesn't make sense - the content is immutable and guaranteed to be not null.

      Overrides:
      setVisible in class Dialog
    • setLocale

      public void setLocale(Locale l)

      Overridden to set the content's Locale and then updated this dialog's internal state.

      Overrides:
      setLocale in class Component
    • updateLocaleState

      protected void updateLocaleState(Locale locale)
      Updates this dialog's locale-dependent state. Here: updates title and actions.
      Parameters:
      locale - Locale
      See Also:
    • doClose

      public void doClose()
      The callback method executed when closing the dialog.

      Here: calls dispose.

    • createButtonPanel

      protected JComponent createButtonPanel()
      create the dialog button controls.
      Returns:
      panel containing button controls
    • getUIString

      protected String getUIString(String key)
      Returns a potentially localized value from the UIManager. The given key is prefixed by this component|s UIPREFIX before doing the lookup. The lookup respects this table's current locale property. Returns the key, if no value is found.
      Parameters:
      key - the bare key to look up in the UIManager.
      Returns:
      the value mapped to UIPREFIX + key or key if no value is found.
    • getUIString

      protected String getUIString(String key, Locale locale)
      Returns a potentially localized value from the UIManager for the given locale. The given key is prefixed by this component's UIPREFIX before doing the lookup. Returns the key, if no value is found.
      Parameters:
      key - the bare key to look up in the UIManager.
      locale - the locale use for lookup
      Returns:
      the value mapped to UIPREFIX + key in the given locale, or key if no value is found.