info.aduna.swing.config
Class ConfigPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by info.aduna.swing.config.ConfigPanel
All Implemented Interfaces:
ConfigSheetListener, ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TreeSelectionListener
Direct Known Subclasses:
ClusterConfigPanel, LinkConfigPanel

public class ConfigPanel
extends JPanel
implements ConfigSheetListener, ActionListener, TreeSelectionListener

ConfigPanel is a generic user preferences component that shows a collection of ConfigSheets, selectable through a tree. ConfigPanel has been inspired by/modeled after Netscape/Mozilla's Preferences window and KDE's Control Center.

The ConfigSheets can be added one-by-one by using the two add methods. However, the ConfigSheets are not visible until the finishAdditions methods has been invoked. After that it is no longer possible to add ConfigSheets to the ConfigPanel.

ConfigPanel contains three buttons for its main operation. The apply and default buttons are for setting or resetting the settings of the current ConfigSheet. The apply button is initially disabled but is enabled automatically as soon as something changes in the current ConfigSheet (detected through the ConfigSheetListener interface). Finally, the close button sends a closeRequested event to the ConfigPanelListeners, which should then take an appropriate action.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ConfigPanel()
          Create a new ConfigPanel showing an empty sheet selection browser and sheet display.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Dispatches the pressing of the Apply, Default or Close button to either the apply, default or the close method respectively.
 void add(ConfigSheet sheet)
          Adds a ConfigSheet as a leaf node without a parent in the sheet browser.
 void add(ConfigSheet sheet, ConfigSheet parent)
          Adds a ConfigSheet beneath the specified parent ConfigSheet in the sheet browser.
 void addConfigPanelListener(ConfigPanelListener l)
           
 void contentsChanged(ConfigSheet sheet)
          If this event originates from the current ConfigSheet, the apply button will be enabled.
 void finishAdditions()
          Indicates that the last ConfigSheet has been added and that the sheet browser can now be populated.
 JButton getApplyButton()
           
 JButton getCloseButton()
           
 ConfigSheet getCurrentSheet()
          Returns the ConfigSheet that is currently visible in the ConfigPanel.
 JButton getDefaultButton()
           
 void removeConfigPanelListener(ConfigPanelListener l)
           
 void setTitleText(String text)
          Sets the text of the title label in the upper part of the ConfigPanel.
 void valueChanged(TreeSelectionEvent e)
          Switches to another ConfigSheet, based on the new selection in the sheet browser, and sends a corresponding event to all ConfigPanelListeners.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigPanel

public ConfigPanel()
Create a new ConfigPanel showing an empty sheet selection browser and sheet display.

Method Detail

getApplyButton

public JButton getApplyButton()

getDefaultButton

public JButton getDefaultButton()

getCloseButton

public JButton getCloseButton()

getCurrentSheet

public ConfigSheet getCurrentSheet()
Returns the ConfigSheet that is currently visible in the ConfigPanel.


setTitleText

public void setTitleText(String text)
Sets the text of the title label in the upper part of the ConfigPanel.


add

public void add(ConfigSheet sheet)
         throws IllegalArgumentException
Adds a ConfigSheet as a leaf node without a parent in the sheet browser.

Throws:
IllegalArgumentException - when there is already a ConfigSheet added with the specified name.

add

public void add(ConfigSheet sheet,
                ConfigSheet parent)
         throws IllegalArgumentException
Adds a ConfigSheet beneath the specified parent ConfigSheet in the sheet browser. If the parent was not already registered, it is registered here also.

Throws:
IllegalArgumentException - when there is already a ConfigSheet added with the name of the specified sheet or parent.

finishAdditions

public void finishAdditions()
Indicates that the last ConfigSheet has been added and that the sheet browser can now be populated. Adding sheets after invoking this method may result in unexpected results.


contentsChanged

public void contentsChanged(ConfigSheet sheet)
If this event originates from the current ConfigSheet, the apply button will be enabled.

Specified by:
contentsChanged in interface ConfigSheetListener

actionPerformed

public void actionPerformed(ActionEvent e)
Dispatches the pressing of the Apply, Default or Close button to either the apply, default or the close method respectively.

Specified by:
actionPerformed in interface ActionListener

valueChanged

public void valueChanged(TreeSelectionEvent e)
Switches to another ConfigSheet, based on the new selection in the sheet browser, and sends a corresponding event to all ConfigPanelListeners. If the current ConfigSheet still has unapplied changes, a popup will be shown allowing the user to apply or forget the changes or to cancel the switch operation. In the latter case the current ConfigSheet will remain current.

Specified by:
valueChanged in interface TreeSelectionListener

addConfigPanelListener

public void addConfigPanelListener(ConfigPanelListener l)

removeConfigPanelListener

public void removeConfigPanelListener(ConfigPanelListener l)


Copyright © 1997-2008 Aduna. All Rights Reserved.