Class JPseudoFrame
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- diva.gui.toolbox.JPseudoFrame
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
public abstract class JPseudoFrame extends javax.swing.JComponent
JPseudoFrame is not a Frame at all, but a widget that enables a JInternalFrame to be maximized in the manner exhibited by Windows applications. By default, if you use a JDesktopPane and maximize one of the internal frames, the internal frame becomes the size of the desktop pane, but it still has a full title bar. Not to put too fine a point on it, this sucks, especially since Swing (as of JDK1.2.1) completely screws up if the desktop pane happens to be inside of a JSplitPane.Instead, what you want is for the contents of the internal frame to replace the desktop pane, and to have the window iconify, minimize, and close buttons appear on the right-hand end of the menu bar. (Look at Word, Visio etc on Windows.) So what JPseudoFrame does is give you a means to do exactly that. The actual setup is a little complicated because the pseudo-frame is not part of the containment hierarchy, and the method setContent() must be overridden to place a component in the correct place in the hierarchy.
To be notified of events occurring in the frame, attach an action listener. Pressing the buttons will cause action events to be fired with the command strings "iconified", "minimized", or "closed." By the time that these events are generated, the pseudo-frame will already have removed itself from the menu bar. (Although we could perhaps generate InternalFrameEvents, this is not really necessary and so we decided against on on the grounds of getting this done....)
- Version:
- $Id$
- Author:
- John Reekie
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description JPseudoFrame(javax.swing.JDesktopPane desktopPane, javax.swing.JMenuBar menubar)
Construct a new PseudoFrame which will steal layout from the given desktop and draw itself in the given JMenuBar.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addActionListener(java.awt.event.ActionListener l)
Add an action listenerprotected void
fireInternalAction(java.lang.String name)
Fire an action eventjava.awt.Dimension
getMaximumSize()
Return a fixed sizejava.awt.Dimension
getMinimumSize()
Return a fixed sizejava.awt.Dimension
getPreferredSize()
Return a fixed sizevoid
hideFrame()
Hide the pseudo-frame.boolean
isClosed()
Test if the frame is closed.boolean
isIconified()
Test if the frame is iconified.boolean
isMaximum()
Test if the frame is maximized.void
removeActionListener(java.awt.event.ActionListener l)
Remove an action listenerprotected abstract void
removeComponent(javax.swing.JComponent component)
Remove the given component from its position in the displayvoid
setClosed(boolean flag)
Close the frame if the argument is true.protected abstract void
setComponent(javax.swing.JComponent component)
Place the given component into the displayvoid
setIcon(boolean flag)
Iconify the frame if the argument is true.void
setMaximum(boolean flag)
Minimize the frame if the argument is false.void
showFrame(javax.swing.JInternalFrame frame)
Show the pseudo-frame with the contents of the given internal frame.-
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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateUI
-
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, 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
addActionListener
public void addActionListener(java.awt.event.ActionListener l)
Add an action listener
-
fireInternalAction
protected void fireInternalAction(java.lang.String name)
Fire an action event
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
Return a fixed size- Overrides:
getMinimumSize
in classjavax.swing.JComponent
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Return a fixed size- Overrides:
getPreferredSize
in classjavax.swing.JComponent
-
getMaximumSize
public java.awt.Dimension getMaximumSize()
Return a fixed size- Overrides:
getMaximumSize
in classjavax.swing.JComponent
-
hideFrame
public void hideFrame()
Hide the pseudo-frame. This method removes the current content pane from its container and puts it back into its internal frame. Then it puts the desktop pane back to where its supposed to go. If no component is already shown, do nothing.
-
removeComponent
protected abstract void removeComponent(javax.swing.JComponent component)
Remove the given component from its position in the display
-
setComponent
protected abstract void setComponent(javax.swing.JComponent component)
Place the given component into the display
-
showFrame
public void showFrame(javax.swing.JInternalFrame frame)
Show the pseudo-frame with the contents of the given internal frame. This method removes the content pane from the internal frame, removes the desktop pane from its container and then puts the content pane where the desktop pane was. If a component is already shown, do nothing.
-
isClosed
public boolean isClosed()
Test if the frame is closed. Inverse of isMaximum().
-
isIconified
public boolean isIconified()
Test if the frame is iconified. Inverse of isMaximum().
-
isMaximum
public boolean isMaximum()
Test if the frame is maximized. Return true if the frame has a content pane displayed.
-
removeActionListener
public void removeActionListener(java.awt.event.ActionListener l)
Remove an action listener
-
setClosed
public void setClosed(boolean flag) throws java.beans.PropertyVetoException
Close the frame if the argument is true. In this base class, move the content pane from the view and put it back into its internal frame. Then close the internal frame. If the argument is false, then do nothing. Subclasses may override this method to do something different to close the frame. This is often useful if further management is necessary.- Throws:
java.beans.PropertyVetoException
- See Also:
DesktopContext
-
setIcon
public void setIcon(boolean flag) throws java.beans.PropertyVetoException
Iconify the frame if the argument is true. In this base class, remove the content pane from the view and put it back into its internal frame. Then iconify the internal frame. If the argument is false, do nothing. Subclasses may override this method to do something different to iconify the frame. This is often useful if further management is necessary.- Throws:
java.beans.PropertyVetoException
- See Also:
DesktopContext
-
setMaximum
public void setMaximum(boolean flag) throws java.beans.PropertyVetoException
Minimize the frame if the argument is false. In this base class, remove the content pane from the view and put it back into its internal frame. If the argument is true, do nothing. Subclasses may override this method to do something different to undo maximization of the frame. This is often useful if further management is necessary.- Throws:
java.beans.PropertyVetoException
- See Also:
DesktopContext
-
-