org.jscroll
Class JScrollDesktopPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.jscroll.JScrollDesktopPane
All Implemented Interfaces:
Accessible, DesktopConstants, ImageObserver, MenuContainer, Serializable

public class JScrollDesktopPane
extends JPanel
implements DesktopConstants

The main scrollable desktop class.

JScrollDesktopPane builds upon JDesktopPane and JScrollPane to provide a complete virtual desktop environment that enables easy access to internal frames that may have been positioned offscreen. This access is made possible via real-time creation and manipulation of the desktop preferred size.

A toolbar provides a set of buttons along the top of the screen, with each button matched to a corresponding internal frame. When one of these buttons is clicked, the associated frame is centered upon the virtual desktop and selected. The buttons within the toolbar automatically resize as more buttons are added beyond the width of the container.

A JMenuBar may be registered with the scrollable desktop so that the application can provide access to the internal frames via its own menu bar. When the registration is complete, a new JMenu entitled "Window" is added to the supplied JMenuBar, a menu containing Tile, Cascade, and Close options along with dynamically updated shortcuts to any internal frames currently upon the scrollable desktop. The Tile and Cascade options provided by the "Window" menu affect the positions of the internal frames upon the scrollable desktop. Cascade positions each internal frame one after the other in a diagonal sequence crosswise the screen, while Tile positions and resizes the internal frames to fill up all available screen real estate, with no single frame overlapping any other.

JScrollDesktopPane is simply a JPanel and as such may be added to any suitable JPanel container, such as a JFrame. The addition of new internal frames to the JScrollDesktopPane and the registration of menu bars for use by the scrollable desktop is relatively simple: The add method creates a new internal frame and returns a reference to the JInternalFrame instance that was created, while the registerMenuBar method registers the menubar for use by the scrollable desktop. A JMenuBar object may also be registered by passing it as a constructor parameter to the JScrollDesktopPane.

An example usage follows:

    JFrame f = new JFrame("Scrollable Desktop");
    f.setSize(300,300);
    // prepare the menuBar
    JMenuBar menuBar = new JMenuBar();
    f.setJMenuBar(menuBar);

    // create the scrollable desktop instance and add it to the JFrame
    JScrollDesktopPane scrollableDesktop =
          new JScrollDesktopPane(menuBar);
    f.getContentPane().add(scrollableDesktop);
    f.setVisible(true);

    // add a frame to the scrollable desktop
    JPanel frameContents = new JPanel();
    frameContents.add(
          new JLabel("Hello and welcome to JScrollDesktopPane."));

    scrollableDesktop.add(frameContents);
 
JScrollDesktopPane has been tested under Java 2 JDK versions 1.3.1-b24 on Linux and jdk1.3.0_02 on Windows and Intel Solaris. As of March 14, 2003 it has also been tested on JDK 1.4.1 for Windows.

Version:
1.0 12-Aug-2001
Author:
Tom Tessier
See Also:
Serialized Form

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 org.jscroll.widgets.DesktopConstants
CONTENTS_CHANGED_COLOR, MAX_FRAMES, MAXIMUM_BUTTON_WIDTH, MINIMUM_BUTTON_WIDTH, X_OFFSET, Y_OFFSET
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JScrollDesktopPane()
          creates the JScrollDesktopPane object.
JScrollDesktopPane(JMenuBar mb)
          creates the JScrollDesktopPane object and registers a menubar.
JScrollDesktopPane(JMenuBar mb, ImageIcon defaultFrameIcon)
          creates the JScrollDesktopPane object, registers a menubar, and assigns a default internal frame icon.
 
Method Summary
 void add(JInternalFrame f)
          adds a JInternalFrame to the scrollable desktop.
 void add(JInternalFrame f, int x, int y)
          adds a JInternalFrame to the scrollable desktop.
 JInternalFrame add(JPanel frameContents)
          adds an internal frame to the scrollable desktop
 JInternalFrame add(String title, ImageIcon icon, JPanel frameContents, boolean isClosable)
          adds an internal frame to the scrollable desktop
 JInternalFrame add(String title, ImageIcon icon, JPanel frameContents, boolean isClosable, int x, int y)
          adds an internal frame to the scrollable desktop.
 JInternalFrame add(String title, JPanel frameContents)
          adds an internal frame to the scrollable desktop
 JInternalFrame add(String title, JPanel frameContents, boolean isClosable)
          adds an internal frame to the scrollable desktop
 void flagContentsChanged(JInternalFrame f)
          flags the specified internal frame as "contents changed." Used to notify the user when the contents of an inactive internal frame have changed.
 JInternalFrame getSelectedFrame()
          returns the internal frame currently selected upon the virtual desktop.
 void registerDefaultFrameIcon(ImageIcon defaultFrameIcon)
          registers a default icon for display in the title bars of internal frames
 void registerMenuBar(JMenuBar mb)
          registers a menubar to which the "Window" menu may be applied.
 void remove(JInternalFrame f)
          removes the specified internal frame from the scrollable desktop
 void setSelectedFrame(JInternalFrame f)
          selects the specified internal frame upon the virtual desktop.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

JScrollDesktopPane

public JScrollDesktopPane(JMenuBar mb,
                          ImageIcon defaultFrameIcon)
creates the JScrollDesktopPane object, registers a menubar, and assigns a default internal frame icon.

Parameters:
mb - the menubar with which to register the scrollable desktop
defaultFrameIcon - the default icon to use within the title bar of internal frames.

JScrollDesktopPane

public JScrollDesktopPane(JMenuBar mb)
creates the JScrollDesktopPane object and registers a menubar.

Parameters:
mb - the menubar with which to register the scrollable desktop

JScrollDesktopPane

public JScrollDesktopPane()
creates the JScrollDesktopPane object.

Method Detail

add

public JInternalFrame add(JPanel frameContents)
adds an internal frame to the scrollable desktop

Parameters:
frameContents - the contents of the internal frame
Returns:
the JInternalFrame that was created

add

public JInternalFrame add(String title,
                          JPanel frameContents)
adds an internal frame to the scrollable desktop

Parameters:
title - the title displayed in the title bar of the internal frame
frameContents - the contents of the internal frame
Returns:
the JInternalFrame that was created

add

public JInternalFrame add(String title,
                          JPanel frameContents,
                          boolean isClosable)
adds an internal frame to the scrollable desktop

Parameters:
title - the title displayed in the title bar of the internal frame
frameContents - the contents of the internal frame
isClosable - boolean indicating whether internal frame is closable
Returns:
the JInternalFrame that was created

add

public JInternalFrame add(String title,
                          ImageIcon icon,
                          JPanel frameContents,
                          boolean isClosable)
adds an internal frame to the scrollable desktop

Parameters:
title - the title displayed in the title bar of the internal frame
icon - the icon displayed in the title bar of the internal frame
frameContents - the contents of the internal frame
isClosable - boolean indicating whether internal frame is closable
Returns:
the JInternalFrame that was created

add

public JInternalFrame add(String title,
                          ImageIcon icon,
                          JPanel frameContents,
                          boolean isClosable,
                          int x,
                          int y)
adds an internal frame to the scrollable desktop.

Propogates the call to DesktopMediator.

Parameters:
title - the title displayed in the title bar of the internal frame
icon - the icon displayed in the title bar of the internal frame
frameContents - the contents of the internal frame
isClosable - boolean indicating whether internal frame is closable
x - x coordinates of internal frame within the scrollable desktop.
y - y coordinates of internal frame within the scrollable desktop
Returns:
the JInternalFrame that was created

add

public void add(JInternalFrame f)
adds a JInternalFrame to the scrollable desktop.

Parameters:
f - the internal frame of class JScrollInternalFrame to add

add

public void add(JInternalFrame f,
                int x,
                int y)
adds a JInternalFrame to the scrollable desktop.

Parameters:
f - the internal frame of class JScrollInternalFrame to add
x - x coordinates of internal frame within the scrollable desktop.
y - y coordinates of internal frame within the scrollable desktop

remove

public void remove(JInternalFrame f)
removes the specified internal frame from the scrollable desktop

Parameters:
f - the internal frame to remove

registerMenuBar

public void registerMenuBar(JMenuBar mb)
registers a menubar to which the "Window" menu may be applied.

Propogates the call to DesktopMediator.

Parameters:
mb - the menubar to register

registerDefaultFrameIcon

public void registerDefaultFrameIcon(ImageIcon defaultFrameIcon)
registers a default icon for display in the title bars of internal frames

Parameters:
defaultFrameIcon - the default icon

getSelectedFrame

public JInternalFrame getSelectedFrame()
returns the internal frame currently selected upon the virtual desktop.

Propogates the call to DesktopMediator.

Returns:
a reference to the active JInternalFrame

setSelectedFrame

public void setSelectedFrame(JInternalFrame f)
selects the specified internal frame upon the virtual desktop.

Propogates the call to DesktopMediator.

Parameters:
f - the internal frame to select

flagContentsChanged

public void flagContentsChanged(JInternalFrame f)
flags the specified internal frame as "contents changed." Used to notify the user when the contents of an inactive internal frame have changed.

Propogates the call to DesktopMediator.

Parameters:
f - the internal frame to flag as "contents changed"


Copyright © 2001-2003 JScroll.org. All Rights Reserved.