[multiple changes]

2004-05-25  David Jee  <djee@redhat.com>

	* java/awt/Container.java
	(remove): Set component's parent to null only after we removed the
	component from its parent's layout manager.

2004-05-25  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(GtkComponentPeer): Set bounds regardless of whether awtComponent
	is valid.
	* gnu/java/awt/peer/gtk/GtkListPeer.java
	(getSize): Change native method declaration.
	(minimumSize): Pass visible row count into getSize().
	(preferredSize): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkListPeer_getSize): Use scroll window's
	natural size. Use visible row count to determine the final height
	value to return.

2004-05-21  Graydon Hoare  <graydon@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(setClip): Minor correction to order of operations.

	* javax/swing/JScrollPane.java: Extend sketchy implementation.
	* javax/swing/ScrollPaneLayout.java: Likewise.
	* javax/swing/JViewPort.java: Likewise.
	* javax/swing/ViewportLayout.java: Likewise.

	* javax/swing/JComponent.java: Rewrite.
	* javax/swing/RepaintManager.java: Likewise.

	* javax/swing/JLayeredPane.java: Change validate() to revalidate().
	* javax/swing/JList.java
	(setSelectedIndices):
	(getSelectedIndices):
	(getSelectedValues): New functions.
	(getPreferredScrollableViewportSize): Return preferred size.
	(getScrollableUnitIncrement):
	(getScrollableBlockIncrement): Initial implementations.
	* javax/swing/JRootPane.java: Clean up slightly.
	(getUI):
	(setUI):
	(updateUI):
	(getUIClassID):
	(isValidateRoot): Add overrides from JComponent.
	* javax/swing/JScrollBar.java: Set default orientation to VERTICAL.
	* javax/swing/UIManager.java (getDimension): Return the dimension.

	* javax/swing/plaf/basic/BasicButtonUI.java: Set component opaque.
	* javax/swing/plaf/basic/BasicLabelUI.java: Likewise.
	* javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise.
	* javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise.
	* javax/swing/plaf/basic/BasicSeparatorUI.java: Likewise.
	* javax/swing/plaf/basic/BasicSliderUI.java: Likewise.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise.
	* javax/swing/plaf/basic/BasicRootPaneUI.java:
	Likewise, and set background.
	* javax/swing/plaf/basic/BasicListUI.java:
	Likewise, and improve a bit.
	* javax/swing/plaf/basic/BasicScrollBarUI.java:
	Likewise, and adjust calculations.
	* javax/swing/plaf/basic/BasicViewportUI.java:
	Likewise, and improve a bit.
	* javax/swing/plaf/basic/BasicLookAndFeel.java
	(Button.margin): Shrink.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGlyphVector.c:
	Hack to set horizontal always, workaround pango.

	* jni/gtk-peer/gtkcairopeer.h: Change to match pattern API.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c:
	Synchronize more often, check cairo status after ops,
	handle changes to cairo pattern API, check for disposal.

2004-05-21  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(BasicMenuItemUI): Create propertyChangeListener.
	(getPath):Implemented.
	(installListeners): Add propertyChangeListener to menuItem.
	(uninstallListeners): Remove propertyChangeListener from menuItem.
	(update): Implemented.
	* javax/swing/plaf/basic/BasicMenuUI.MouseInputHandler:
	(mouseEntered): Take insets of popup menu into account when
	calculating position of popup menu.

2004-05-18  Olga Rodimina  <rodimina@redhat.com>

	* Makefile.am: Added new file.
	* Makefile.in: Regenerate.
	* javax/swing/JMenuBar.java:
	Started implementation.
	* javax/swing/JPopupMenu.java:
	(setVisible): Fixed location of lightweight/mediumweight
	popup menu.
	(show): Fixed location of PopupMenu.
	* javax/swing/plaf/basic/BasicMenuBarUI.java:
	New file. UI Delegate for JMenuBar.
	* javax/swing/plaf/basic/BasicMenuUI.MouseInputHandler:
	(mouseEntered): Corrected position of the submenu.

2004-05-18  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Remove calls
	to _gtk_accel_group_attach.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
	Likewise.

	* gnu/java/awt/peer/gtk/GtkButtonPeer.java: Give gtkSetFont
	package access.  Don't override setFont.
	* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java: Likewise.
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Give
	gtkWidgetRequestFocus package access.
	* gnu/java/awt/peer/gtk/GtkLabelPeer.java: Don't override
	setFont.
	* gnu/java/awt/peer/gtk/GtkListPeer.java: Override gtkSetFont.
	Give gtkWidgetRequestFocus package access.
	* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java: Give
	gtkWidgetRequestFocus package access.  Don't override setFont.
	* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Don't override
	setFont.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
	(gtkSetLabel): Move call to gtk_bin_get_child into GDK critical
	region.
	(gtkSetFont): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c (gtkSetFont):
	Implement.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
	(gtkSetFont): Whitespace fix.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(gtkWidgetSetUsize): Remove method.

2004-05-18  David Jee  <djee@redhat.com>

	* java/awt/image/MemoryImageSource.java
	(newPixels(int,int,int,int,boolean)): Set only the specified
	rectangle of pixels.
	(newPixels(byte[],ColorModel,int,int)): Implement.
	(newPixels(int[],ColorModel,int,int)): Implement.

2004-05-18  Olga Rodimina  <rodimina@redhat.com>

	* Makefile.am: Added new file.
	* Makefile.in: Regenerate.
	* javax/swing/JMenu.java: Started
	implementation.
	* javax/swing/JPopupMenu.java:
	(insert): If specified index is -1, then
	add component at the end.
	(isPopupTrigger): Reimplemented.
	(JPopupMenu.LightWeightPopup): setBounds
	of the lightWeightPopup before adding it
	to the layeredPane.
	(javax/swing/plaf/basic/BasicIconFactory.java):
	(getMenuArrowIcon): Implemented.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(getPreferredSize): Add size of the arrow icon
	if this menu item is instance of JMenu.
	(paintMenuItem): Paint arrow icon if this
	menu item is a submenu.
	* javax/swing/plaf/basic/BasicMenuUI.java:
	New File. UI Delegate for JMenu.

2004-05-17  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java (postKeyEvent):
	Post KEY_TYPED events.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(generates_key_typed_event): Remove function.

2004-05-17  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JRootPane.java
	(JRootPane.RootLayout): Reimplemented to
	set bounds of contentPane and menuBar.
	(setJMenuBar): Add menu bar to the layered pane.
	(createLayeredPane): Set layout of layeredPane
	to null.
	* javax/swing/JLayeredPane.java:
	(addImpl): Calculate index of the component in the
	layeredPane according to the specified position within
	the layer.

2004-05-17  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkImagePainter.java
	(setPixels): Change color model to the default model after
	converting pixels.
	* java/awt/image/MemoryImageSource.java
	(newPixels): Set only the specified rectangle of pixels.

2004-05-13  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* libgcj.spec.in (lib): Add -l-java-awt -l-java-applet
	-l-java-beans -l-javax-accessibility -l-javax-swing.

	* java/awt/AWTEvent.java (toString): Print source's name rather
	than the source itself.

2004-05-12  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkToolkit.java (loadSystemColors): Make
	native.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
	(gdk_color_to_java_color): New function.
	* jni/gtk-peer/gtkpeer.h: Add SystemColor defines.

2004-05-12  David Jee  <djee@redhat.com>

	* java/awt/image/RGBImageFilter.java:
	Initialize origmodel as null.
	(makeColor): Fix pixel component order.
	(filterRGBPixels): Fix pixel iteration.
	(setPixels): Add extra checks for index color model. Convert pixels
	to default color model if necessary.
	(convertColorModelToDefault): New override method for byte pixels.
	(convertColorModelToDefault): For int pixels, fix pixel iteration.
	(makeColorbyDefaultCM): New override method for byte pixels.
	(makeColorbyDefaultCM): For int pixel, add color model as argument.
	(makeColor): Fix pixel component order.

2004-05-11  Kim Ho  <kho@redhat.com>

	* javax/swing/Box.java:
	Comment out more parts of Box.Filler.

2004-05-11  Kim Ho  <kho@redhat.com>

	* javax/swing/Box.java:
	Remove reference to AccessibleAWTComponent so
	it compiles again.

2004-05-10  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkListPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Update
	implementation of list peer to use GtkTreeView instead of
	deprecated GtkCList.

2004-05-07  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(gtkWidgetDispatchKeyEvent): Remove keyChar parameter.
	(handleEvent): Remove keyChar argument to
	gtkWidgetDispatchKeyEvent calls.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Fix
	compiler warnings.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c:
	Likewise.

2004-05-06  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(gtkWidgetRequestFocus): Mark protected.
	(GtkComponentPeer): Only set the peer's bounds if its component
	is valid.
	* java/awt/Component.java (static): Set the default keyboard
	focus manager.
	(requestFocus(), requestFocus(boolean), requestFocusInWindow(),
	requestFocusInWindow(temporary)): Don't request focus if the
	component is not showing.  Get tree lock before traversing
	component hierarchy.
	* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
	Only set the global focus owner if it is not a Window.
	(processKeyEvent): Consume keystrokes associated with the focus
	traversal keystroke.
	(focusPreviousComponent, focusNextComponent, upFocusCycle,
	downFocusCycle): Call requestFocusInWindow instead of
	requestFocus.
	* java/awt/EventDispatchThread.java (run): Move setting of
	default keyboard focus manager to Component.java.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(awt_keycode_to_keysym): New function.
	(gtkWidgetDispatchKeyEvent): Finish implementation.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(pre_event_handler): Add FIXME comment.

	* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
	(gtkWidgetRequestFocus): New method.
	* java/awt/TextArea.java (TextArea): Set focus traversal keys to
	disable Tab and Shift-Tab keystrokes.
	(addNotify, appendText, insertText, replaceText): Simplify peer
	retrieval code.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
	(connectSignals): Remove connections to "commit" signals.
	Remove C++-style comments.

	* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
	(handleEvent): Activate GTK button when the space bar key is
	pressed.
	(gtkActivate): New method.

2004-05-06  David Jee  <djee@redhat.com>

	* java/awt/image/CropImageFilter.java
	(setPixels): Implement for byte array pixels.
	* java/awt/image/ReplicateScaleFilter.java
	(setPixels): Implement for byte array pixels.
	(replicatePixels): Overload for byte array pixels.

2004-05-06  Kim Ho  <kho@redhat.com>

	* javax/swing/Box.java:
	(getAccessibleContext): Return an instance of the
	correct class.

2004-05-05  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics.java
	(drawImage): When component is null, use SystemColor.window as
	the default bgcolor.
	* gnu/java/awt/peer/gtk/GtkImage.java
	(setPixels): We can avoid iterating through the pixel rows only
	when height is 1.
	* java/awt/Image.java
	(getScaledInstance): Partially implement.
	* java/awt/image/CropImageFilter.java
	(setProperties): Fix "filter" property.
	(setPixels): Implement.
	* java/awt/image/ReplicateScaleFilter.java
	(setDimensions): Use scaled dimensions.
	(setPixels): Implement.
	(replicatePixels): New method.

2004-05-05  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkImagePainter.java
	(convertPixels): If either pixels or model is null, return null.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c
	(Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels): If jpixels
	is null, do nothing and return.

2004-05-03  Kim Ho  <kho@redhat.com>

	* gnu/java/awt/peer/gtk/GtkDialogPeer.java:
	(getGraphics): Like GtkFramePeer, the Graphics
	object needs to be translate to account for
	window decorations.
	(postMouseEvent): New method. Account for
	translation.
	(postExposeEvent): ditto.
	* javax/swing/Box.java: Stubbed.
	* javax/swing/JDialog.java: Ran through jalopy
	to fix indentation.
	(JDialog): Call SwingUtilities' getOwnerFrame
	for null owners.
	(setLayout): Check isRootPaneCheckingEnabled
	* javax/swing/JOptionPane.java: Re-implemented.
	* javax/swing/SwingUtilities.java:
	(getOwnerFrame): Static method to grab a default
	owner frame for Dialogs that don't specify owners.
	* javax/swing/event/SwingPropertyChangeSupport.java:
	(firePropertyChange): Fix early exit condition.
	* javax/swing/plaf/basic/BasicLabelUI.java:
	(paint): Avoid painting text if it is null
	or empty.
	* javax/swing/plaf/basic/BasicOptionPaneUI.java:
	Implement.

2004-05-03  Olga Rodimina  <rodimina@redhat.com>

	* Makefile.am: Added new file.
	* Makefile.in: Regenerate.
	* javax/swing/JPopupMenu.java:
	Started implementation.
	* javax/swing/JWindow.java
	(JWindow): call super() if parent for window
	is not specified.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	New File. UI Delegate for JPopupMenu.

2004-04-30  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JApplet.java: Indicated that JApplet
	implements RootPaneContainer and made method of this
	interface public.
	* javax/swing/JFrame.java: Ditto.
	* javax/swing/JWindow.java: Ditto.

2004-04-29  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(nativeSetBounds): Call gdk_window_move in addition to
	gtk_window_move.

	* java/applet/Applet.java (preferredSize): Call parent's
	preferredSize if the applet stub is null.
	(minimumSize): Likewise for parent's minimumSize.

2004-04-27  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JMenuItem.java
	(createActionPropertyChangeListener): Implemented.
	(processMouseEvent): Ditto.
	(fireMenuDragMouseEntered): Ditto.
	(fireMenuDragMouseExited): Ditto.
	(fireMenuDragMouseDragged): Ditto.
	(fireMenuDragMouseReleased): Ditto.
	(menuSelectionChanged): Ditto.
	(getSubElements): Ditto.
	(getComponent): Ditto.
	(addMenuDragMouseListener): Ditto.
	(removeMenuDragMouseListener):Ditto.
	(addMenuKeyListener): Ditto.
	(removeMenuKeyListener): Ditto.
	* javax/swing/plaf/basic/BasicMenuItemUI.java
	(doClick): Imlemented.
	* javax/swing/plaf/basic/BasicMenuItemUI.MouseInputHandler:
	Don't handle mouse events here. Pass them to
	MenuSelectionManager.

2004-04-26  Olga Rodimina  <rodimina@redhat.com>
	Used correct version of jalopy configuration
	file to fix style in the files below.

2004-04-26  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JCheckBoxMenuItem.java:
	Fixed style and removed unnecessary comments.
	* javax/swing/JMenuItem.java: Ditto.
	* javax/swing/JRadioButtonMenuItem.java: Ditto.
	* javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java: Ditto.
	* javax/swing/plaf/basic/BasicMenuItemUI.java: Ditto.
	* javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java: Ditto.

2004-04-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu_java_awt_peer_gtk_GtkWindowPeer.c: Change FIXME comment to
	C-style.

	* gnu_java_awt_peer_gtk_GtkWindowPeer.c: Add FIXME comment.

	* java/awt/ContainerOrderFocusTraversalPolicy.java
	(getComponentAfter): Start from current component and work up
	the component hierarchy until an acceptable component is found.
	Synchronize on tree lock.
	(getComponentBefore): Likewise.

2004-04-22  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java: Remove
	focus-related debugging messages.
	* java/awt/DefaultKeyboardFocusManager.java: Likewise.
	* java/awt/EventDispatchThread.java: Likewise.
	* java/awt/KeyboardFocusManager.java: Likewise.
	* java/awt/Window.java: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Change
	new C++-style comments to C-style comments.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Likewise.

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(handleEvent): Dispatch key press and key release events to
	backing widget.
	(requestFocus): Post a FOCUS_GAINED event to the event queue.
	(gtkWidgetRequestFocus): New method.
	(gtkWidgetDispatchKeyEvent): Likewise.
	* java/awt/Component.java (requestFocus, requestFocus(boolean),
	requestFocusInWindow, requestFocusInWindow(boolean),
	getFocusCycleRootAncestor, nextFocus, transferFocus,
	transferFocusBackward, transferFocusUpCycle, hasFocus,
	isFocusOwner): Implement and document focus-handling methods.
	(setFocusTraversalKeys): Inherit focus traversal keys when
	keystrokes argument is null.  Fix focus-handling documentation
	throughout class.
	* java/awt/Container.java (setFocusTraversalKeys,
	getFocusTraversalKeys, areFocusTraversalKeysSet,
	isFocusCycleRoot, setFocusTraversalPolicy,
	getFocusTraversalPolicy, isFocusTraversalPolicySet,
	setFocusCycleRoot, isFocusCycleRoot, transferFocusDownCycle):
	Implement and document focus-handling methods.
	(transferFocusBackward): Remove method.
	(readObject, writeObject): Implement and document serialization
	methods.
	* java/awt/ContainerOrderFocusTraversalPolicy.java: Implement
	and document.
	* java/awt/DefaultFocusTraversalPolicy.java: Implement and
	document.
	* java/awt/DefaultKeyboardFocusManager.java: Implement and
	partially document.
	* java/awt/EventDispatchThread.java (run): Set default keyboard
	focus manager.  Attempt to dispatch each event to the keyboard
	focus manager before normal dispatch.
	* java/awt/KeyboardFocusManager.java: Implement and partially
	document.
	* java/awt/Window.java (Window): Set focusCycleRoot to true.
	(show): Focus initial component when window is shown for the
	first time.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(pre_event_handler): Replace complex key press and key release
	logic with simple callbacks into GtkComponentPeer.
	* jni/gtk-peer/gtkpeer.h: Fix FOCUS_GAINED/FOCUS_LOST reversal.

2004-04-21  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/MenuSelectionManager.java
	(componentForPoint): Added new method.
	(defaultManager): New Method. Implemented.
	(getSelectedPath): Ditto.
	(isComponentPartOfCurrentMenu): Ditto.
	(processKeyEvent): Added new method.
	(processMouseEvent): New Method. Implemented.
	(setSelectedPath): Ditto.
	(getPath): Ditto.

2004-04-19  Kim Ho  <kho@redhat.com>

	* java/awt/Container.java:
	(remove): Set the component's parent to null.
	(getComponentAt): Implement.
	* javax/swing/JComponent.java:
	(JComponent): Initialize defaultLocale
	(getDefaultLocale): Implement.
	(setDefaultLocale): ditto.
	* javax/swing/JSlider.java:
	(JSlider): Fix calculation of value.
	* javax/swing/JSplitPane.java: Implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Change SplitPane's default divider size.
	* javax/swing/plaf/basic/BasicScrollBarUI.java:
	(paint): Remove unused code.
	* javax/swing/plaf/basic/BasicSplitPaneDivider.java:
	Added comments and ran through jalopy.
	(setBasicSplitPaneUI): Get reference to hidden divider
	and set up one touch buttons if necessary.
	(setBorder): Fire propertyChangeEvent only if
	borders are different.
	(getPreferredSize): Defer to layout manager.
	(propertyChange): Implement.
	(oneTouchExpandableChanged): ditto.
	(createLeftOneTouchButton): Use BasicArrowButton.
	(createRightOneTouchButton): ditto.
	(moveDividerTo): New method. Moves the divider
	to a set location based on the last divider location.
	(BasicSplitPaneDivider::MouseHandler): Implement.
	(BasicSplitPaneDivider::OneTouchButton): Removed.
	(BasicSplitPaneDivider::DragController): Implement.
	(BasicSplitPaneDivider::VerticalDragController):
	ditto.
	(BasicSplitPaneDivider::DividerLayout): ditto.
	* javax/swing/plaf/basic/BasicSplitPaneUI.java: Reimplement.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java:
	(calculateLayoutInfo): Don't show component if it's
	null.
	(paintTab): Fix title paint logic.

From-SVN: r82314
This commit is contained in:
Graydon Hoare 2004-05-27 06:17:44 +00:00
parent e314a036a8
commit c5d2de6b4c
97 changed files with 17329 additions and 5544 deletions

View file

@ -39,6 +39,12 @@ exception statement from your version. */
package javax.swing;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import java.awt.LayoutManager;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.AWTError;
/**
* Needs some work I guess....
@ -49,8 +55,127 @@ public class Box extends JComponent implements Accessible
{
private static final long serialVersionUID = 1525417495883046342L;
public Box(int a)
protected class AccessibleBox extends AccessibleAWTContainer
{
setLayout(new BoxLayout(this, a));
protected AccessibleBox()
{
}
public AccessibleRole getAccessibleRole()
{
return null;
}
}
public static class Filler extends JComponent implements Accessible
{
protected class AccessibleBoxFiller// extends AccessibleAWTComponent
{
protected AccessibleBoxFiller()
{
}
public AccessibleRole getAccessibleRole()
{
return null;
}
}
protected AccessibleContext accessibleContext;
private transient Dimension min, pref, max;
public Filler(Dimension min, Dimension pref, Dimension max)
{
changeShape(min, pref, max);
}
public void changeShape(Dimension min, Dimension pref, Dimension max)
{
this.min = min;
this.pref = pref;
this.max = max;
}
public AccessibleContext getAccessibleContext()
{
// if (accessibleContext == null)
// accessibleContext = new AccessibleBoxFiller();
return accessibleContext;
}
public Dimension getMaximumSize()
{
return max;
}
public Dimension getMinimumSize()
{
return min;
}
public Dimension getPreferredSize()
{
return pref;
}
}
public Box(int axis)
{
setLayout(new BoxLayout(this, axis));
}
public static Component createGlue()
{
return null;
}
public static Box createHorizontalBox()
{
return null;
}
public static Component createHorizontalGlue()
{
return null;
}
public static Component createHorizontalStrut(int width)
{
return null;
}
public static Component createRigidArea(Dimension d)
{
return null;
}
public static Box createVerticalBox()
{
return null;
}
public static Component createVerticalGlue()
{
return null;
}
public static Component createVerticalStrut(int height)
{
return null;
}
public void setLayout(LayoutManager l)
{
throw new AWTError("Not allowed to set layout managers for boxes.");
}
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleBox();
return accessibleContext;
}
}

View file

@ -49,7 +49,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import javax.accessibility.AccessibleContext;
public class JApplet extends Applet
public class JApplet extends Applet implements RootPaneContainer
{
public final static int HIDE_ON_CLOSE = 0;
@ -87,20 +87,20 @@ public class JApplet extends Applet
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
@ -109,19 +109,19 @@ public class JApplet extends Applet
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
public JRootPane createRootPane()
{ return new JRootPane(); }
Container getContentPane()
public Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
public void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
public Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }

View file

@ -39,135 +39,210 @@ package javax.swing;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.3 $
*/
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
Accessible
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private static final String uiClassID = "CheckBoxMenuItemUI";
private boolean state;
private Object[] selectedObjects;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new JCheckBoxMenuItem object.
*/
public JCheckBoxMenuItem()
{
this(null, null);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param icon DOCUMENT ME!
*/
public JCheckBoxMenuItem(Icon icon)
{
this(null, icon);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text)
{
this(text, null);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param action DOCUMENT ME!
*/
public JCheckBoxMenuItem(Action action)
{
this();
setAction(action);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text, Icon icon)
{
this(text, icon, false);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
* @param state DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text, boolean state)
{
this(text, null, state);
} // JCheckBoxMenuItem()
}
/**
* Creates a new JCheckBoxMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param state DOCUMENT ME!
*/
public JCheckBoxMenuItem(String text, Icon icon, boolean state)
{
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
this.state = state;
} // JCheckBoxMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public String getUIClassID()
{
return uiClassID;
} // getUIClassID()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public boolean getState()
{
return state;
} // getState()
}
/**
* DOCUMENT ME!
*
* @param state DOCUMENT ME!
*/
public synchronized void setState(boolean state)
{
this.state = state;
} // setState()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public Object[] getSelectedObjects()
{
return selectedObjects;
} // getSelectedObjects()
}
/**
* DOCUMENT ME!
*/
public void requestFocus()
{
// TODO
} // requestFocus()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String paramString()
{
return "JCheckBoxMenuItem";
} // paramString()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
{
accessibleContext = new AccessibleJCheckBoxMenuItem(this);
}
accessibleContext = new AccessibleJCheckBoxMenuItem(this);
return accessibleContext;
} // getAccessibleContext()
}
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.3 $
*/
protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new AccessibleJCheckBoxMenuItem object.
*
* @param component DOCUMENT ME!
*/
protected AccessibleJCheckBoxMenuItem(JCheckBoxMenuItem component)
{
super(component);
// TODO
} // AccessibleJCheckBoxMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.CHECK_BOX;
} // getAccessibleRole()
} // AccessibleJCheckBoxMenuItem
} // JCheckBoxMenuItem
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
import java.awt.BorderLayout;
@ -45,251 +44,518 @@ import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.LayoutManager;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.awt.IllegalComponentStateException;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
/**
* Unlike JComponent derivatives, JDialog inherits from
* java.awt.Dialog. But also lets a look-and-feel component to its work.
* Unlike JComponent derivatives, JDialog inherits from java.awt.Dialog. But
* also lets a look-and-feel component to its work.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
* @author Ronald Veldema (rveldema_AT_cs.vu.nl)
*/
public class JDialog extends Dialog implements Accessible, WindowConstants
public class JDialog extends Dialog implements Accessible, WindowConstants,
RootPaneContainer
{
protected AccessibleContext accessibleContext;
private int close_action = HIDE_ON_CLOSE;
/** DOCUMENT ME! */
protected AccessibleContext accessibleContext;
/***************************************************
*
*
* constructors
*
*
*************/
/** The single RootPane in the Dialog. */
protected JRootPane rootPane;
public JDialog(Frame owner)
{
this(owner, "dialog");
}
public JDialog(Frame owner,
String s)
{
this(owner, s, true);
}
public JDialog(Frame owner,
String s,
boolean modeld)
{
super(owner, s, modeld);
}
/** Whether checking is enabled on the RootPane */
protected boolean rootPaneCheckingEnabled = true;
public JDialog(Frame owner,
// String s,
boolean modeld)
{
super(owner, "JDialog", modeld);
}
/** The default action taken when closed. */
private int close_action = HIDE_ON_CLOSE;
/** Whether JDialogs are decorated by the L&F. */
private static boolean decorated = false;
/**
* Creates a new non-modal JDialog with no title
* using a shared Frame as the owner.
*/
public JDialog()
{
this(SwingUtilities.getOwnerFrame(), "", false, null);
}
/**
* Creates a new non-modal JDialog with no title
* using the given owner.
*
* @param owner The owner of the JDialog.
*/
public JDialog(Dialog owner)
{
this(owner, "dialog");
this(owner, "", false, null);
}
public JDialog(Dialog owner,
String s)
{
this(owner, s, true);
}
public JDialog(Dialog owner,
String s,
boolean modeld)
{
super(owner, s, modeld);
}
/**
* Creates a new JDialog with no title using the
* given modal setting and owner.
*
* @param owner The owner of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Dialog owner, boolean modal)
{
this(owner, "", modal, null);
}
/***************************************************
*
*
* methods, this part is shared with JDialog, JFrame
*
*
*************/
/**
* Creates a new non-modal JDialog using the
* given title and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
*/
public JDialog(Dialog owner, String title)
{
this(owner, title, false, null);
}
private boolean checking;
protected JRootPane rootPane;
/**
* Creates a new JDialog using the given modal
* settings, title, and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Dialog owner, String title, boolean modal)
{
this(owner, title, modal, null);
}
void setLocationRelativeTo(Component c)
{
}
/**
* Creates a new JDialog using the given modal
* settings, title, owner and graphics configuration.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
* @param gc The Graphics Configuration to use.
*/
public JDialog(Dialog owner, String title, boolean modal,
GraphicsConfiguration gc)
{
super(owner, title, modal, gc);
dialogInit();
}
/**
* Creates a new non-modal JDialog with no title
* using the given owner.
*
* @param owner The owner of the JDialog.
*/
public JDialog(Frame owner)
{
this(owner, "", false, null);
}
protected void frameInit()
{
super.setLayout(new BorderLayout(1, 1));
getRootPane(); // will do set/create
}
/**
* Creates a new JDialog with no title using the
* given modal setting and owner.
*
* @param owner The owner of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Frame owner, boolean modal)
{
this(owner, "", modal, null);
}
/**
* Creates a new non-modal JDialog using the
* given title and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
*/
public JDialog(Frame owner, String title)
{
this(owner, title, false, null);
}
/**
* Creates a new JDialog using the given modal
* settings, title, and owner.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
*/
public JDialog(Frame owner, String title, boolean modal)
{
this(owner, title, modal, null);
}
/**
* Creates a new JDialog using the given modal
* settings, title, owner and graphics configuration.
*
* @param owner The owner of the JDialog.
* @param title The title of the JDialog.
* @param modal Whether the JDialog is modal.
* @param gc The Graphics Configuration to use.
*/
public JDialog(Frame owner, String title, boolean modal,
GraphicsConfiguration gc)
{
super((owner == null) ? SwingUtilities.getOwnerFrame() : owner,
title, modal, gc);
dialogInit();
}
/**
* This method is called to initialize the
* JDialog. It sets the layout used, the locale,
* and creates the RootPane.
*/
protected void dialogInit()
{
// FIXME: Do a check on GraphicsEnvironment.isHeadless()
setRootPaneCheckingEnabled(false);
setLocale(JComponent.getDefaultLocale());
getRootPane(); // will do set/create
setRootPaneCheckingEnabled(true);
invalidate();
}
/**
* This method returns whether JDialogs will have their
* window decorations provided by the Look and Feel.
*
* @return Whether the window decorations are L&F provided.
*/
public static boolean isDefaultLookAndFeelDecorated()
{
return decorated;
}
/**
* This method sets whether JDialogs will have their
* window decorations provided by the Look and Feel.
*
* @param defaultLookAndFeelDecorated Whether the window
* decorations are L&F provided.
*/
public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
{
decorated = defaultLookAndFeelDecorated;
}
/**
* This method returns the preferred size of
* the JDialog.
*
* @return The preferred size.
*/
public Dimension getPreferredSize()
{
Dimension d = super.getPreferredSize();
return d;
}
JMenuBar getJMenuBar()
{ return getRootPane().getJMenuBar(); }
void setJMenuBar(JMenuBar menubar)
{ getRootPane().setJMenuBar(menubar); }
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
rootPane = root;
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
{ return new JRootPane(); }
Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }
protected void addImpl(Component comp, Object constraints, int index)
{ super.addImpl(comp, constraints, index); }
public void remove(Component comp)
{ getContentPane().remove(comp); }
protected boolean isRootPaneCheckingEnabled()
{ return checking; }
protected void setRootPaneCheckingEnabled(boolean enabled)
{ checking = enabled; }
public void update(Graphics g)
{ paint(g); }
protected void processKeyEvent(KeyEvent e)
{ super.processKeyEvent(e); }
/////////////////////////////////////////////////////////////////////////////////
protected void processWindowEvent(WindowEvent e)
{
super.processWindowEvent(e);
switch (e.getID())
{
case WindowEvent.WINDOW_CLOSING:
{
switch(close_action)
{
case EXIT_ON_CLOSE:
{
System.exit(0);
break;
}
case DISPOSE_ON_CLOSE:
{
dispose();
break;
}
case HIDE_ON_CLOSE:
{
setVisible(false);
break;
}
case DO_NOTHING_ON_CLOSE:
break;
}
break;
}
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_ICONIFIED:
case WindowEvent.WINDOW_DEICONIFIED:
case WindowEvent.WINDOW_ACTIVATED:
case WindowEvent.WINDOW_DEACTIVATED:
break;
}
}
/**
* This method returns the JMenuBar used
* in this JDialog.
*
* @return The JMenuBar in the JDialog.
*/
public JMenuBar getJMenuBar()
{
return getRootPane().getJMenuBar();
}
/**
* Defines what happens when this frame is closed. Can be one off
* <code>EXIT_ON_CLOSE</code>,
* <code>DISPOSE_ON_CLOSE</code>,
* <code>HIDE_ON_CLOSE</code> or
* <code>DO_NOTHING_ON_CLOSE</code>.
* The default is <code>HIDE_ON_CLOSE</code>.
* When <code>EXIT_ON_CLOSE</code> is specified this method calls
* <code>SecurityManager.checkExit(0)</code> which might throw a
* <code>SecurityException</code>. When the specified operation is
* not one of the above a <code>IllegalArgumentException</code> is
* thrown.
* This method sets the JMenuBar used
* in this JDialog.
*
* @param menubar The JMenuBar to use.
*/
public void setJMenuBar(JMenuBar menubar)
{
getRootPane().setJMenuBar(menubar);
}
/**
* This method sets the LayoutManager used in the JDialog.
* This method will throw an Error if rootPaneChecking is
* enabled.
*
* @param manager The LayoutManager to use.
*/
public void setLayout(LayoutManager manager)
{
if (isRootPaneCheckingEnabled())
throw new Error("rootPaneChecking is enabled - cannot set layout.");
super.setLayout(manager);
}
/**
* This method sets the JLayeredPane used in the JDialog.
* If the given JLayeredPane is null, then this method
* will throw an Error.
*
* @param layeredPane The JLayeredPane to use.
*/
public void setLayeredPane(JLayeredPane layeredPane)
{
if (layeredPane == null)
throw new IllegalComponentStateException("layeredPane cannot be null.");
getRootPane().setLayeredPane(layeredPane);
}
/**
* This method returns the JLayeredPane used with this JDialog.
*
* @return The JLayeredPane used with this JDialog.
*/
public JLayeredPane getLayeredPane()
{
return getRootPane().getLayeredPane();
}
/**
* This method returns the JRootPane used with this JDialog.
*
* @return The JRootPane used with this JDialog.
*/
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
/**
* This method sets the JRootPane used with this JDialog.
*
* @param root The JRootPane to use.
*/
protected void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
rootPane = root;
rootPane.show();
add(rootPane);
}
/**
* This method creates a new JRootPane.
*
* @return A new JRootPane.
*/
protected JRootPane createRootPane()
{
return new JRootPane();
}
/**
* This method returns the ContentPane
* in the JRootPane.
*
* @return The ContentPane in the JRootPane.
*/
public Container getContentPane()
{
return getRootPane().getContentPane();
}
/**
* This method sets the ContentPane to use with this
* JDialog. If the ContentPane given is null, this method
* will throw an exception.
*
* @param contentPane The ContentPane to use with the JDialog.
*/
public void setContentPane(Container contentPane)
{
if (contentPane == null)
throw new IllegalComponentStateException("contentPane cannot be null.");
getRootPane().setContentPane(contentPane);
}
/**
* This method returns the GlassPane for this JDialog.
*
* @return The GlassPane for this JDialog.
*/
public Component getGlassPane()
{
return getRootPane().getGlassPane();
}
/**
* This method sets the GlassPane for this JDialog.
*
* @param glassPane The GlassPane for this JDialog.
*/
public void setGlassPane(Component glassPane)
{
getRootPane().setGlassPane(glassPane);
}
/**
* This method is called when a component is added to the
* the JDialog. Calling this method with rootPaneCheckingEnabled
* will cause an Error to be thrown.
*
* @param comp The component to add.
* @param constraints The constraints.
* @param index The position of the component.
*/
protected void addImpl(Component comp, Object constraints, int index)
{
if (isRootPaneCheckingEnabled())
throw new Error("rootPaneChecking is enabled - adding components disallowed.");
super.addImpl(comp, constraints, index);
}
/**
* This method removes a component from the JDialog.
*
* @param comp The component to remove.
*/
public void remove(Component comp)
{
// The path changes if the component == root.
if (comp == rootPane)
super.remove(rootPane);
else
getContentPane().remove(comp);
}
/**
* This method returns whether rootPane checking is enabled.
*
* @return Whether rootPane checking is enabled.
*/
protected boolean isRootPaneCheckingEnabled()
{
return rootPaneCheckingEnabled;
}
/**
* This method sets whether rootPane checking is enabled.
*
* @param enabled Whether rootPane checking is enabled.
*/
protected void setRootPaneCheckingEnabled(boolean enabled)
{
rootPaneCheckingEnabled = enabled;
}
/**
* This method simply calls paint and returns.
*
* @param g The Graphics object to paint with.
*/
public void update(Graphics g)
{
paint(g);
}
/**
* This method handles window events. This allows the JDialog
* to honour its default close operation.
*
* @param e The WindowEvent.
*/
protected void processWindowEvent(WindowEvent e)
{
// System.out.println("PROCESS_WIN_EV-1: " + e);
super.processWindowEvent(e);
// System.out.println("PROCESS_WIN_EV-2: " + e);
switch (e.getID())
{
case WindowEvent.WINDOW_CLOSING:
{
switch (getDefaultCloseOperation())
{
case DISPOSE_ON_CLOSE:
{
dispose();
break;
}
case HIDE_ON_CLOSE:
{
setVisible(false);
break;
}
case DO_NOTHING_ON_CLOSE:
break;
}
break;
}
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_ICONIFIED:
case WindowEvent.WINDOW_DEICONIFIED:
case WindowEvent.WINDOW_ACTIVATED:
case WindowEvent.WINDOW_DEACTIVATED:
break;
}
}
/**
* This method sets the action to take
* when the JDialog is closed.
*
* @param operation The action to take.
*/
public void setDefaultCloseOperation(int operation)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null && operation == EXIT_ON_CLOSE)
sm.checkExit(0);
if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE
&& operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE)
throw new IllegalArgumentException("operation = " + operation);
close_action = operation;
if (operation == DO_NOTHING_ON_CLOSE ||
operation == HIDE_ON_CLOSE ||
operation == DISPOSE_ON_CLOSE)
close_action = operation;
else
throw new IllegalArgumentException("Default close operation must be one of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
}
/**
* This method returns the action taken when
* the JDialog is closed.
*
* @return The action to take.
*/
public int getDefaultCloseOperation()
{ return close_action; }
{
return close_action;
}
protected String paramString()
{ return "JDialog"; }
/**
* This method returns a String describing the JDialog.
*
* @return A String describing the JDialog.
*/
protected String paramString()
{
return "JDialog";
}
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
}

View file

@ -57,7 +57,7 @@ import javax.accessibility.AccessibleContext;
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JFrame extends Frame implements WindowConstants
public class JFrame extends Frame implements WindowConstants, RootPaneContainer
{
protected AccessibleContext accessibleContext;
@ -121,20 +121,20 @@ public class JFrame extends Frame implements WindowConstants
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
@ -143,19 +143,19 @@ public class JFrame extends Frame implements WindowConstants
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
public JRootPane createRootPane()
{ return new JRootPane(); }
public Container getContentPane()
public Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
public void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
public Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }

View file

@ -329,7 +329,7 @@ public class JLayeredPane extends JComponent implements Accessible
throw new IllegalArgumentException ();
super.swapComponents (curr, targ);
validate();
revalidate();
repaint();
}
@ -537,7 +537,7 @@ public class JLayeredPane extends JComponent implements Accessible
{
componentToLayer.put (c, getObjectForLayer (layer));
setPosition(c, position);
validate();
revalidate();
repaint();
}
@ -562,13 +562,13 @@ public class JLayeredPane extends JComponent implements Accessible
else
layer = DEFAULT_LAYER;
int newIdx = insertIndexForLayer(layer.intValue (), -1);
int newIdx = insertIndexForLayer(layer.intValue (), index);
componentToLayer.put (comp, layer);
incrLayer (layer);
super.addImpl(comp, null, newIdx);
validate();
revalidate();
repaint();
}
}

View file

@ -40,6 +40,7 @@ package javax.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.Vector;
import javax.accessibility.Accessible;
@ -531,6 +532,19 @@ public class JList extends JComponent implements Accessible, Scrollable
selectionModel.setSelectionInterval(a, a);
}
/**
* For each element <code>a[i]</code> of the provided array
* <code>a</code>, calls {@link #setSelectedIndex} on <code>a[i]</code>.
*
* @see #setSelectionMode
* @see #selectionModel
*/
public void setSelectedIndices(int [] a)
{
for (int i = 0; i < a.length; ++i)
setSelectedIndex(a[i]);
}
/**
* Returns the minimum index of an element in the list which is currently
* selected.
@ -545,6 +559,32 @@ public class JList extends JComponent implements Accessible, Scrollable
return selectionModel.getMinSelectionIndex();
}
/**
* Returns the indices of values in the {@link #model} property which are
* selected.
*
* @return An array of model indices, each of which is selected according
* to the {@link #selection} property
*/
public int[] getSelectedIndices()
{
int lo, hi, n, i, j;
if (selectionModel.isSelectionEmpty())
return new int[0];
lo = selectionModel.getMinSelectionIndex();
hi = selectionModel.getMaxSelectionIndex();
n = 0;
for (i = lo; i < hi; ++i)
if (selectionModel.isSelectedIndex(i))
n++;
int [] v = new int[n];
j = 0;
for (i = lo; i < hi; ++i)
if (selectionModel.isSelectedIndex(i))
v[j++] = i;
return v;
}
/**
* Indicates whether the list element at a given index value is
* currently selected.
@ -568,6 +608,8 @@ public class JList extends JComponent implements Accessible, Scrollable
*
* @return The first selected element, or <code>null</code> if no element
* is selected.
*
* @see getSelectedValues
*/
public Object getSelectedValue()
{
@ -577,6 +619,23 @@ public class JList extends JComponent implements Accessible, Scrollable
return getModel().getElementAt(index);
}
/**
* Returns all the values in the list's {@link #model} property which
* are selected, according to the list's {@link #selectionModel} property.
*
* @return An array containing all the selected values
*
* @see getSelectedValue
*/
public Object[] getSelectedValues()
{
int [] idx = getSelectedIndices();
Object [] v = new Object[idx.length];
for (int i = 0; i < idx.length; ++i)
v[i] = getModel().getElementAt(i);
return v;
}
/**
* Gets the value of the {@link #selectionBackground} property.
*
@ -720,6 +779,8 @@ public class JList extends JComponent implements Accessible, Scrollable
if (model != null)
model.addListDataListener(listListener);
firePropertyChange(MODEL_PROPERTY_CHANGED, old, m);
revalidate();
repaint();
}
@ -744,6 +805,8 @@ public class JList extends JComponent implements Accessible, Scrollable
if (selectionModel != null)
selectionModel.addListSelectionListener(listListener);
firePropertyChange(SELECTION_MODEL_PROPERTY_CHANGED, old, l);
revalidate();
repaint();
}
/**
@ -842,11 +905,11 @@ public class JList extends JComponent implements Accessible, Scrollable
* {@link Scrollable} interface, which interacts with {@link
* ScrollPaneLayout} and {@link Viewport} to define scrollable objects.
*
* @return The preferred size, or <code>null</code>
* @return The preferred size
*/
public Dimension getPreferredScrollableViewportSize()
{
return null;
return getPreferredSize();
}
/**
@ -875,6 +938,71 @@ public class JList extends JComponent implements Accessible, Scrollable
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction)
{
ListUI lui = this.getUI();
if (orientation == SwingConstants.VERTICAL)
{
if (direction > 0)
{
// Scrolling down
Point bottomLeft = new Point(visibleRect.x,
visibleRect.y + visibleRect.height);
int curIdx = lui.locationToIndex(this, bottomLeft);
Rectangle curBounds = lui.getCellBounds(this, curIdx, curIdx);
if (curBounds.y + curBounds.height == bottomLeft.y)
{
// we are at the exact bottom of the current cell, so we
// are being asked to scroll to the end of the next one
if (curIdx + 1 < model.getSize())
{
// there *is* a next item in the list
Rectangle nxtBounds = lui.getCellBounds(this, curIdx + 1, curIdx + 1);
return nxtBounds.height;
}
else
{
// no next item, no advance possible
return 0;
}
}
else
{
// we are part way through an existing cell, so we are being
// asked to scroll to the bottom of it
return (curBounds.y + curBounds.height) - bottomLeft.y;
}
}
else
{
// scrolling up
Point topLeft = new Point(visibleRect.x, visibleRect.y);
int curIdx = lui.locationToIndex(this, topLeft);
Rectangle curBounds = lui.getCellBounds(this, curIdx, curIdx);
if (curBounds.y == topLeft.y)
{
// we are at the exact top of the current cell, so we
// are being asked to scroll to the top of the previous one
if (curIdx > 0)
{
// there *is* a previous item in the list
Rectangle nxtBounds = lui.getCellBounds(this, curIdx - 1, curIdx - 1);
return -nxtBounds.height;
}
else
{
// no previous item, no advance possible
return 0;
}
}
else
{
// we are part way through an existing cell, so we are being
// asked to scroll to the top of it
return curBounds.y - topLeft.y;
}
}
}
// FIXME: handle horizontal scrolling (also wrapping?)
return 1;
}
@ -904,7 +1032,10 @@ public class JList extends JComponent implements Accessible, Scrollable
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction)
{
return 1;
if (orientation == VERTICAL)
return visibleRect.height * direction;
else
return visibleRect.width * direction;
}
/**

File diff suppressed because it is too large Load diff

View file

@ -35,13 +35,392 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleSelection;
import javax.accessibility.AccessibleStateSet;
import javax.accessibility.AccessibleValue;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.MenuBarUI;
import javax.swing.plaf.MenuItemUI;
public class JMenuBar extends JComponent
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.2.18.1 $
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement
{
JMenuBar()
{
}
private transient SingleSelectionModel selectionModel;
private boolean paintBorder;
private Insets margin;
/**
* Creates a new JMenuBar object.
*/
public JMenuBar()
{
selectionModel = new DefaultSingleSelectionModel();
paintBorder = true;
updateUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenu add(JMenu c)
{
c.setAlignmentX(Component.LEFT_ALIGNMENT);
super.add(c);
return c;
}
/**
* DOCUMENT ME!
*/
public void addNotify()
{
// FIXME: Should register this menu bar with the keyboard manager
super.addNotify();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Component getComponent()
{
return this;
}
/**
* DOCUMENT ME!
*
* @param i DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Component getComponentAtIndex(int i)
{
return getComponentAt(i);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getComponentIndex(Component c)
{
Component[] comps = getComponents();
int index = -1;
for (int i = 0; i < comps.length; i++)
{
if (comps[i].equals(c))
{
index = i;
break;
}
}
return index;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenu getHelpMenu()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Insets getMargin()
{
if (margin == null)
return new Insets(0, 0, 0, 0);
else
return margin;
}
/**
* DOCUMENT ME!
*
* @param index DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenu getMenu(int index)
{
if (getComponentAtIndex(index) instanceof JMenu)
return (JMenu) getComponentAtIndex(index);
else
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getMenuCount()
{
return getComponentCount();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public SingleSelectionModel getSelectionModel()
{
return selectionModel;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public MenuElement[] getSubElements()
{
MenuElement[] subElements = new MenuElement[getComponentCount()];
for (int i = 0; i < getComponentCount(); i++)
subElements[i] = (MenuElement) getMenu(i);
return subElements;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public MenuBarUI getUI()
{
return (MenuBarUI) ui;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getUIClassID()
{
return "MenuBarUI";
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isBorderPainted()
{
return paintBorder;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isManagingFocus()
{
return true;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isSelected()
{
return false;
}
/**
* DOCUMENT ME!
*
* @param isIncluded DOCUMENT ME!
*/
public void menuSelectionChanged(boolean isIncluded)
{
// Do nothing - needed for implementation of MenuElement interface
}
/**
* DOCUMENT ME!
*
* @param g DOCUMENT ME!
*/
protected void paintBorder(Graphics g)
{
if (paintBorder)
getBorder().paintBorder(this, g, 0, 0, getSize(null).width,
getSize(null).height);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected String paramString()
{
return "JMenuBar";
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent e, MenuElement[] path,
MenuSelectionManager manager)
{
// Do nothing - needed for implementation of MenuElement interface
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// Do nothing - needed for implementation of MenuElement interface
}
/**
* DOCUMENT ME!
*/
public void removeNotify()
{
// Must unregister this menu bar with the current keyboard manager.
super.removeNotify();
}
/**
* DOCUMENT ME!
*
* @param b DOCUMENT ME!
*/
public void setBorderPainted(boolean b)
{
paintBorder = b;
}
/**
* DOCUMENT ME!
*
* @param menu DOCUMENT ME!
*/
public void setHelpMenu(JMenu menu)
{
}
/**
* DOCUMENT ME!
*
* @param m DOCUMENT ME!
*/
public void setMargin(Insets m)
{
this.margin = m;
}
/**
* DOCUMENT ME!
*
* @param sel DOCUMENT ME!
*/
public void setSelected(Component sel)
{
}
/**
* DOCUMENT ME!
*
* @param model DOCUMENT ME!
*/
public void setSelectionModel(SingleSelectionModel model)
{
}
/**
* DOCUMENT ME!
*
* @param ui DOCUMENT ME!
*/
public void setUI(MenuBarUI ui)
{
super.setUI(ui);
}
/**
* DOCUMENT ME!
*/
public void updateUI()
{
MenuBarUI ui = ((MenuBarUI) UIManager.getUI(this));
setUI(ui);
invalidate();
}
}

View file

@ -35,20 +35,22 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.EventListener;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
@ -57,48 +59,79 @@ import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.2.18.4 $
*/
public class JMenuItem extends AbstractButton implements Accessible,
MenuElement
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private static final String uiClassID = "MenuItemUI";
private KeyStroke accelerator;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new JMenuItem object.
*/
public JMenuItem()
{
this(null, null);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param icon DOCUMENT ME!
*/
public JMenuItem(Icon icon)
{
this(null, icon);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
*/
public JMenuItem(String text)
{
this(text, null);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param action DOCUMENT ME!
*/
public JMenuItem(Action action)
{
// TODO
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
public JMenuItem(String text, Icon icon)
{
super(text, icon);
} // JMenuItem()
}
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
* @param mnemonic DOCUMENT ME!
*/
public JMenuItem(String text, int mnemonic)
{
super(text, null);
setMnemonic(mnemonic);
} // JMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
@ -107,60 +140,116 @@ public class JMenuItem extends AbstractButton implements Accessible,
throws IOException, ClassNotFoundException
{
// TODO
} // readObject()
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* DOCUMENT ME!
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
protected void init(String text, Icon icon)
{
// TODO
} // init()
}
/**
* DOCUMENT ME!
*
* @param ui DOCUMENT ME!
*/
public void setUI(MenuItemUI ui)
{
super.setUI(ui);
} // setUI()
}
/**
* DOCUMENT ME!
*/
public void updateUI()
{
MenuItemUI mi = ((MenuItemUI) UIManager.getUI(this));
setUI(mi);
invalidate();
} // updateUI()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public String getUIClassID()
{
return uiClassID;
} // getUIClassID()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public boolean isArmed()
{
return getModel().isArmed();
} // isArmed()
}
/**
* DOCUMENT ME!
*
* @param armed DOCUMENT ME!
*/
public void setArmed(boolean armed)
{
getModel().setArmed(armed);
} // setArmed()
}
/**
* DOCUMENT ME!
*
* @param enabled DOCUMENT ME!
*/
public void setEnabled(boolean enabled)
{
setEnabled(enabled);
} // setEnabled()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public KeyStroke getAccelerator()
{
return accelerator;
} // getAccelerator()
}
/**
* DOCUMENT ME!
*
* @param keystroke DOCUMENT ME!
*/
public void setAccelerator(KeyStroke keystroke)
{
this.accelerator = keystroke;
} // setAccelerator()
}
/**
* DOCUMENT ME!
*
* @param action DOCUMENT ME!
*/
protected void configurePropertiesFromAction(Action action)
{
super.configurePropertiesFromAction(action);
@ -169,147 +258,371 @@ public class JMenuItem extends AbstractButton implements Accessible,
setAccelerator(null);
else
setAccelerator((KeyStroke) (action.getValue(Action.ACCELERATOR_KEY)));
} // configurePropertiesFromAction()
}
/**
* DOCUMENT ME!
*
* @param action DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
{
return null;
} // createActionPropertyChangeListener()
return new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent e)
{
Action act = (Action) (e.getSource());
configurePropertiesFromAction(act);
}
};
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// TODO
} // processMouseEvent()
switch (event.getID())
{
case MouseEvent.MOUSE_CLICKED:
doClick();
break;
case MouseEvent.MOUSE_ENTERED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(true);
if (model.isPressed()
&& (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
model.setArmed(true);
else
model.setArmed(false);
}
break;
case MouseEvent.MOUSE_EXITED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(false);
model.setArmed(false);
}
break;
case MouseEvent.MOUSE_PRESSED:
if (event.getSource() instanceof JMenuItem)
{
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
model.setArmed(true);
model.setPressed(true);
}
}
break;
case MouseEvent.MOUSE_RELEASED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
model.setPressed(false);
model.setArmed(false);
manager.clearSelectedPath();
}
}
break;
case MouseEvent.MOUSE_MOVED:
break;
case MouseEvent.MOUSE_DRAGGED:
MenuDragMouseEvent e = new MenuDragMouseEvent((Component) event
.getSource(),
event.getID(),
event.getWhen(),
event.getModifiers(),
event.getX(),
event.getY(),
event.getClickCount(),
event.isPopupTrigger(),
path, manager);
processMenuDragMouseEvent(e);
break;
}
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// TODO
} // processKeyEvent()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void processMenuDragMouseEvent(MenuDragMouseEvent event)
{
} // processMenuDragMouseEvent()
switch (event.getID())
{
case MouseEvent.MOUSE_ENTERED:
fireMenuDragMouseEntered(event);
break;
case MouseEvent.MOUSE_EXITED:
fireMenuDragMouseExited(event);
break;
case MouseEvent.MOUSE_DRAGGED:
fireMenuDragMouseDragged(event);
break;
case MouseEvent.MOUSE_RELEASED:
fireMenuDragMouseReleased(event);
break;
}
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void processMenuKeyEvent(MenuKeyEvent event)
{
// TODO
} // processMenuKeyEvent()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseEntered()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseEntered(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseExited(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseExited()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseExited(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseDragged()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseDragged(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event)
{
// TODO
} // fireMenuDragMouseReleased()
EventListener[] ll = listenerList.getListeners(MenuDragMouseListener.class);
for (int i = 0; i < ll.length; i++)
((MenuDragMouseListener) ll[i]).menuDragMouseReleased(event);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuKeyPressed(MenuKeyEvent event)
{
// TODO
} // fireMenuKeyPressed()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuKeyReleased(MenuKeyEvent event)
{
// TODO
} // fireMenuKeyReleased()
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireMenuKeyTyped(MenuKeyEvent event)
{
// TODO
} // fireMenuKeyTyped()
}
/**
* DOCUMENT ME!
*
* @param changed DOCUMENT ME!
*/
public void menuSelectionChanged(boolean changed)
{
// TODO
} // menuSelectionChanged()
if (changed)
model.setArmed(true);
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public MenuElement[] getSubElements()
{
return null; // TODO
} // getSubElements()
return new MenuElement[0];
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public Component getComponent()
{
return null; // TODO
} // getComponent()
return this;
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void addMenuDragMouseListener(MenuDragMouseListener listener)
{
// TODO
} // addMenuDragMouseListener()
listenerList.add(MenuDragMouseListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void removeMenuDragMouseListener(MenuDragMouseListener listener)
{
} // removeMenuDragMouseListener()
listenerList.remove(MenuDragMouseListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void addMenuKeyListener(MenuKeyListener listener)
{
} // addMenuKeyListener()
listenerList.add(MenuKeyListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void removeMenuKeyListener(MenuKeyListener listener)
{
} // removeMenuKeyListener()
listenerList.remove(MenuKeyListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String paramString()
{
return "JMenuItem";
} // paramString()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
{
accessibleContext = new AccessibleJMenuItem(this);
}
accessibleContext = new AccessibleJMenuItem(this);
return accessibleContext;
} // getAccessibleContext()
}
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.2.18.4 $
*/
protected class AccessibleJMenuItem extends AccessibleAbstractButton
implements ChangeListener
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new AccessibleJMenuItem object.
*
* @param component DOCUMENT ME!
*/
AccessibleJMenuItem(JMenuItem component)
{
super(component);
// TODO
} // AccessibleJMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void stateChanged(ChangeEvent event)
{
// TODO
} // stateChanged()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.MENU_ITEM;
} // getAccessibleRole()
} // AccessibleJMenuItem
} // JMenuItem
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -39,118 +39,188 @@ package javax.swing;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.4 $
*/
public class JRadioButtonMenuItem extends JMenuItem implements Accessible
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
private static final String uiClassID = "RadioButtonMenuItemUI";
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new JRadioButtonMenuItem object.
*/
public JRadioButtonMenuItem()
{
this(null, null);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param icon DOCUMENT ME!
*/
public JRadioButtonMenuItem(Icon icon)
{
this(null, icon);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text)
{
this(text, null);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param action DOCUMENT ME!
*/
public JRadioButtonMenuItem(Action action)
{
this();
setAction(action);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text, Icon icon)
{
this(text, icon, false);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
* @param selected DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text, boolean selected)
{
this(text, null, selected);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param icon DOCUMENT ME!
* @param selected DOCUMENT ME!
*/
public JRadioButtonMenuItem(Icon icon, boolean selected)
{
this(null, icon, selected);
} // JRadioButtonMenuItem()
}
/**
* Creates a new JRadioButtonMenuItem object.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param selected DOCUMENT ME!
*/
public JRadioButtonMenuItem(String text, Icon icon, boolean selected)
{
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
super(text, icon);
setModel(new JToggleButton.ToggleButtonModel());
model.setSelected(selected);
} // JRadioButtonMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public String getUIClassID()
{
return uiClassID;
} // getUIClassID()
}
/**
* DOCUMENT ME!
*/
public void requestFocus()
{
// TODO
} // requestFocus()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String paramString()
{
return "JRadioButtonMenuItem";
} // paramString()
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
{
accessibleContext = new AccessibleJRadioButtonMenuItem(this);
}
return accessibleContext;
} // getAccessibleContext()
accessibleContext = new AccessibleJRadioButtonMenuItem(this);
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
return accessibleContext;
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.3.8.4 $
*/
protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem
{
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new AccessibleJRadioButtonMenuItem object.
*
* @param component DOCUMENT ME!
*/
protected AccessibleJRadioButtonMenuItem(JRadioButtonMenuItem component)
{
super(component);
// TODO
} // AccessibleJRadioButtonMenuItem()
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.RADIO_BUTTON;
} // getAccessibleRole()
} // AccessibleJRadioButtonMenuItem
} // JRadioButtonMenuItem
}
}
}

View file

@ -43,6 +43,8 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.LayoutManager2;
import javax.swing.plaf.RootPaneUI;
/**
* This class is where JComponents are added to.
@ -64,42 +66,164 @@ public class JRootPane extends JComponent
static protected class AccessibleJRootPane
{
}
//A custom layout manager
static protected class RootLayout extends BorderLayout
// Custom Layout Manager for JRootPane. It positions contentPane and
// menuBar withing its layeredPane.
protected class RootLayout extends Object implements LayoutManager2
{
public Dimension preferredLayoutSize ( Container c )
{
Dimension p = super.preferredLayoutSize(c);
return p;
}
public void addLayoutComponent(Component comp, Object constraints)
{
}
public void addLayoutComponent(String name, Component comp)
{
}
public float getLayoutAlignmentX(Container target)
{
return target.getAlignmentX();
}
public float getLayoutAlignmentY(Container target)
{
return target.getAlignmentY();
}
public void invalidateLayout(Container target)
{
}
public void layoutContainer(Container c)
{
Dimension menuBarSize;
Dimension containerSize = c.getSize(null);
Dimension contentPaneSize = contentPane.getPreferredSize();
/*
if size of top-level window wasn't set then just set
contentPane and menuBar to its preferred sizes.
Otherwise, if the size of top-level window was specified then
set menuBar to its preferred size and make content pane
to fit into the remaining space
+-------------------------------+
| JLayeredPane |
| +--------------------------+ |
| | menuBar | |
| +--------------------------+ |
| +--------------------------+ |
| |contentPane | |
| | | |
| | | |
| | | |
| +--------------------------+ |
+-------------------------------+
*/
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
contentPane.setBounds(0, menuBarSize.height, maxWidth,
contentPaneSize.height);
layeredPane.setSize(maxWidth,
menuBarSize.height + contentPaneSize.height);
}
else
{
contentPane.setBounds(0, 0, contentPaneSize.width,
contentPaneSize.height);
layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
}
}
else
{
if (menuBar != null)
{
menuBarSize = menuBar.getPreferredSize();
if (menuBarSize.height > containerSize.height)
menuBarSize.height = containerSize.height;
menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
int remainingHeight = containerSize.height - menuBarSize.height;
contentPane.setBounds(0, menuBarSize.height,
containerSize.width,
(containerSize.height - menuBarSize.height));
}
else
contentPane.setBounds(0, 0, containerSize.width,
containerSize.height);
layeredPane.setSize(containerSize.width, containerSize.height);
}
}
public Dimension maximumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension minimumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension preferredLayoutSize(Container c)
{
Dimension menuBarSize;
Dimension prefSize;
Dimension containerSize = c.getSize();
Dimension contentPaneSize = contentPane.getPreferredSize();
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
prefSize = new Dimension(maxWidth,
contentPaneSize.height
+ menuBarSize.height);
}
else
prefSize = contentPaneSize;
}
else
prefSize = c.getSize();
return prefSize;
}
public void removeLayoutComponent(Component comp)
{
}
}
/***********************************************************/
//The glass pane that overlays the menu bar and content pane, so it can intercept mouse movements and such.
protected Component glassPane;
//The layered pane that manages the menu bar and content pane.
protected JLayeredPane layeredPane;
// The menu bar.
protected JMenuBar menuBar;
protected JLayeredPane layeredPane;
protected JMenuBar menuBar;
protected Container contentPane;
/********************************************************/
public String getUIClassID()
{ return "RootPaneUI"; }
void setJMenuBar(JMenuBar m)
{ menuBar = m; }
{
menuBar = m;
getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
}
JMenuBar getJMenuBar()
{ return menuBar; }
public boolean isValidateRoot()
{
return true;
}
public Container getContentPane()
@ -122,7 +246,6 @@ public class JRootPane extends JComponent
int index)
{
super.addImpl(comp, constraints, index);
//System.out.println("don't do that !");
}
public Component getGlassPane()
@ -159,16 +282,12 @@ public class JRootPane extends JComponent
}
/********************************************************/
JRootPane()
{
setLayout(createRootLayout());
setBackground(UIManager.getColor("control"));
getGlassPane();
getLayeredPane();
getContentPane();
setDoubleBuffered(true);
updateUI();
}
@ -182,9 +301,6 @@ public class JRootPane extends JComponent
JPanel p = new JPanel();
p.setName(this.getName()+".contentPane");
p.setLayout(new BorderLayout());
// p.setVisible(true);
System.out.println("Created ContentPane: " + p);
return p;
}
@ -194,14 +310,34 @@ public class JRootPane extends JComponent
p.setName(this.getName()+".glassPane");
p.setLayout(new BorderLayout());
p.setVisible(false);
System.out.println("created the glasspane: "+p);
return p;
}
JLayeredPane createLayeredPane()
{
JLayeredPane l = new JLayeredPane();
l.setLayout(null);
return l;
}
public RootPaneUI getUI()
{
return (RootPaneUI) ui;
}
public void setUI(RootPaneUI ui)
{
super.setUI(ui);
}
public void updateUI()
{
setUI((RootPaneUI) UIManager.getUI(this));
}
public String getUIClassID()
{
return "RootPaneUI";
}
}

View file

@ -169,7 +169,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
protected BoundedRangeModel model;
/** The orientation of the scroll bar. */
protected int orientation = SwingConstants.HORIZONTAL;
protected int orientation = SwingConstants.VERTICAL;
/** How much the thumb moves when moving in a unit. */
protected int unitIncrement = 1;
@ -186,7 +186,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
*/
public JScrollBar()
{
this(SwingConstants.HORIZONTAL, 0, 10, 0, 100);
this(SwingConstants.VERTICAL, 0, 10, 0, 100);
}
/**

View file

@ -40,6 +40,8 @@ package javax.swing;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
@ -50,6 +52,7 @@ import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ScrollPaneUI;
import javax.swing.plaf.UIResource;
/**
* <table>
@ -430,7 +433,11 @@ public class JScrollPane
{
JViewport old = viewport;
removeNonNull(old);
if (old != null)
old.removeChangeListener(scrollListener);
viewport = v;
if (v != null)
v.addChangeListener(scrollListener);
addNonNull(v);
revalidate();
repaint();
@ -467,29 +474,64 @@ public class JScrollPane
ChangeListener createScrollListener()
{
return new ChangeListener() {
return new ChangeListener()
{
public void stateChanged(ChangeEvent event)
{
int xpos = 0;
int ypos = 0;
JScrollBar vsb = JScrollPane.this.getVerticalScrollBar();
JScrollBar hsb = JScrollPane.this.getHorizontalScrollBar();
if (vsb != null)
{
BoundedRangeModel vmod = vsb.getModel();
if (vmod != null)
ypos = vmod.getValue();
}
JViewport vp = JScrollPane.this.getViewport();
if (hsb != null)
if (vp != null && event.getSource() == vp)
{
BoundedRangeModel hmod = hsb.getModel();
if (hmod != null)
xpos = hmod.getValue();
// if the viewport changed, we should update the VSB / HSB
// models according to the new vertical and horizontal sizes
Rectangle vr = vp.getViewRect();
Dimension vs = vp.getViewSize();
// System.err.println("got change from viewport, vr=" + vr + ", vs=" + vs);
if (vsb != null
&& (vsb.getMinimum() != 0
|| vsb.getMaximum() != vs.height
|| vsb.getValue() != vr.y
|| vsb.getVisibleAmount() != vr.height))
{
// System.err.println("setting vsb to "
// + "pos=" + vr.y
// + ", ext=" + vr.height
// + ", min=0"
// + ", max=" + vs.height);
vsb.setValue(vr.y, vr.height, 0, vs.height);
}
if (hsb != null
&& (hsb.getMinimum() != 0
|| hsb.getMaximum() != vs.width
|| hsb.getValue() != vr.width
|| hsb.getVisibleAmount() != vr.height))
hsb.setValue(vr.x, vr.width, 0, vs.width);
}
else
{
// otherwise we got a change update from either the VSB or
// HSB model, and we need to update the viewport position to
// match.
int xpos = 0;
int ypos = 0;
if (vsb != null)
ypos = vsb.getValue();
if (hsb != null)
xpos = hsb.getValue();
Point pt = new Point(xpos, ypos);
if (vp != null
&& vp.getViewPosition() != pt)
vp.setViewPosition(pt);
}
if (JScrollPane.this.viewport != null)
JScrollPane.this.viewport.setViewPosition(new Point(xpos, ypos));
}
};
}
@ -528,12 +570,12 @@ public class JScrollPane
public JScrollBar createHorizontalScrollBar()
{
return new JScrollBar(SwingConstants.HORIZONTAL);
return new ScrollBar(SwingConstants.HORIZONTAL);
}
public JScrollBar createVerticalScrollBar()
{
return new JScrollBar(SwingConstants.VERTICAL);
return new ScrollBar(SwingConstants.VERTICAL);
}
public JViewport createViewport()
@ -553,7 +595,7 @@ public class JScrollPane
setUI(b);
}
/*
class ScrollBar
extends JScrollBar
implements UIResource
@ -561,17 +603,37 @@ public class JScrollPane
public ScrollBar(int orientation)
{
super(orientation);
Component view = this.JScrollPane.getViewportView();
if (view == null)
return;
if (! view instanceof Scrollable)
}
public int getBlockIncrement(int direction)
{
Component view = JScrollPane.this.getViewport().getView();
if (view == null || (! (view instanceof Scrollable)))
return super.getBlockIncrement(direction);
else
{
Scrollable s = (Scrollable) view;
s.
return s.getScrollableBlockIncrement(JScrollPane.this.getViewport().getViewRect(),
this.getOrientation(),
direction);
}
}
}
*/
public int getUnitIncrement(int direction)
{
Component view = JScrollPane.this.getViewport().getView();
if (view == null || (! (view instanceof Scrollable)))
return super.getUnitIncrement(direction);
else
{
Scrollable s = (Scrollable) view;
return s.getScrollableUnitIncrement(JScrollPane.this.getViewport().getViewRect(),
this.getOrientation(),
direction);
}
}
}
}

View file

@ -304,7 +304,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
public JSlider(int minimum, int maximum)
{
this(HORIZONTAL, minimum, maximum, (maximum - minimum) / 2);
this(HORIZONTAL, minimum, maximum, (maximum + minimum) / 2);
}
/**

File diff suppressed because it is too large Load diff

View file

@ -114,7 +114,13 @@ public class JViewport extends JComponent
*
* @see #toViewCoordinates
*/
Dimension viewExtent;
Dimension extentSize;
/**
* The width and height of the view in its own coordinate space.
*/
Dimension viewSize;
Point lastPaintPosition;
@ -124,17 +130,35 @@ public class JViewport extends JComponent
updateUI();
}
public Dimension getViewSize()
public Dimension getExtentSize()
{
if (viewExtent == null)
if (extentSize == null)
return getPreferredSize();
else
return viewExtent;
return extentSize;
}
public void setExtentSize(Dimension newSize)
{
extentSize = newSize;
fireStateChanged();
}
public Dimension getViewSize()
{
if (viewSize == null)
return getView().getPreferredSize();
else
return viewSize;
}
public void setViewSize(Dimension newSize)
{
viewExtent = newSize;
viewSize = newSize;
Component view = getView();
if (view != null)
view.setSize(newSize);
fireStateChanged();
}
@ -166,7 +190,7 @@ public class JViewport extends JComponent
public Rectangle getViewRect()
{
return new Rectangle(getViewPosition(),
getViewSize());
getExtentSize());
}
public boolean isBackingStoreEnabled()
@ -207,7 +231,24 @@ public class JViewport extends JComponent
add(v);
fireStateChanged();
}
public void revalidate()
{
fireStateChanged();
super.revalidate();
}
public void reshape(int x, int y, int w, int h)
{
boolean changed =
(x != getX())
|| (y != getY())
|| (w != getWidth())
|| (h != getHeight());
super.reshape(x, y, w, h);
if (changed)
fireStateChanged();
}
public void addImpl(Component comp, Object constraints, int index)
{

View file

@ -58,7 +58,7 @@ import javax.accessibility.AccessibleContext;
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JWindow extends Window implements Accessible
public class JWindow extends Window implements Accessible, RootPaneContainer
{
public final static int HIDE_ON_CLOSE = 0;
public final static int EXIT_ON_CLOSE = 1;
@ -79,8 +79,8 @@ public class JWindow extends Window implements Accessible
*************/
public JWindow()
{
this(null);
{
super();
}
// huuu ?
@ -124,20 +124,20 @@ public class JWindow extends Window implements Accessible
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }
void setLayeredPane(JLayeredPane layeredPane)
public void setLayeredPane(JLayeredPane layeredPane)
{ getRootPane().setLayeredPane(layeredPane); }
JLayeredPane getLayeredPane()
public JLayeredPane getLayeredPane()
{ return getRootPane().getLayeredPane(); }
JRootPane getRootPane()
public JRootPane getRootPane()
{
if (rootPane == null)
setRootPane(createRootPane());
return rootPane;
}
void setRootPane(JRootPane root)
public void setRootPane(JRootPane root)
{
if (rootPane != null)
remove(rootPane);
@ -146,19 +146,19 @@ public class JWindow extends Window implements Accessible
add(rootPane, BorderLayout.CENTER);
}
JRootPane createRootPane()
public JRootPane createRootPane()
{ return new JRootPane(); }
Container getContentPane()
public Container getContentPane()
{ return getRootPane().getContentPane(); }
void setContentPane(Container contentPane)
public void setContentPane(Container contentPane)
{ getRootPane().setContentPane(contentPane); }
Component getGlassPane()
public Component getGlassPane()
{ return getRootPane().getGlassPane(); }
void setGlassPane(Component glassPane)
public void setGlassPane(Component glassPane)
{ getRootPane().setGlassPane(glassPane); }

View file

@ -1,5 +1,5 @@
/* MenuSelectionManager.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,6 +38,15 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Vector;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
@ -48,6 +57,10 @@ public class MenuSelectionManager
protected EventListenerList listenerList = new EventListenerList ();
private static final MenuSelectionManager manager = new MenuSelectionManager();
private Vector selection = new Vector();
protected void fireStateChanged ()
{
ChangeListener[] listeners = getChangeListeners ();
@ -73,4 +86,213 @@ public class MenuSelectionManager
{
return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
}
/**
* Unselects all the menu elements on the selection path
*/
public void clearSelectedPath ()
{
for (int i = 0; i < selection.size (); i++)
((MenuElement) selection.get (i)).menuSelectionChanged (false);
selection.clear ();
}
public Component componentForPoint (Component source, Point sourcePoint)
{
throw new UnsupportedOperationException("not implemented");
}
/**
* Returns shared instance of MenuSelection Manager
*
* @return default Manager
*/
public static MenuSelectionManager defaultManager ()
{
return manager;
}
/**
* Returns path representing current menu selection
*
* @return Current selection path
*/
public MenuElement[] getSelectedPath ()
{
MenuElement[] path = new MenuElement[selection.size ()];
for (int i = 0; i < path.length; i++)
path[i] = (MenuElement) selection.get (i);
return path;
}
/**
* Returns true if specified component is part of current menu
* heirarchy and false otherwise
*
* @param c Component for which to check
* @return True if specified component is part of current menu
*/
boolean isComponentPartOfCurrentMenu (Component c)
{
MenuElement[] subElements;
for (int i = 0; i < selection.size (); i++)
{
subElements = ((MenuElement) selection.get (i)).getSubElements ();
for (int j = 0; j < subElements.length; j++)
{
if ((subElements[j].getComponent ()).equals (c))
return true;
}
}
return false;
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void processKeyEvent (KeyEvent e)
{
throw new UnsupportedOperationException("not implemented");
}
/**
* Forwards given mouse event to all of the source subcomponents.
*
* @param event Mouse event
*/
public void processMouseEvent (MouseEvent event)
{
Component c = ((MenuElement) event.getSource ()).getComponent ();
if (selection.size () == 0)
{
((MenuElement) event.getSource ()).processMouseEvent (event,
getPath (c),
manager);
return;
}
// find the index of the source component in the current menu hierarchy
int i = 0;
for (i = 0; i < selection.size (); i++)
{
MenuElement me = (MenuElement) selection.get (i);
if (me.getComponent ().equals (c))
break;
}
// Forward event to all subcomponents of the source
Component subComp;
for (int j = i; j < selection.size (); j++)
{
subComp = ((MenuElement)selection.get (j)).getComponent ();
((MenuElement) selection.get (j)).processMouseEvent (event,
getPath (subComp),
manager);
}
}
/**
* Sets menu selection to the specified path
*
* @param path new selection path
*/
public void setSelectedPath (MenuElement[] path)
{
if (path == null)
{
clearSelectedPath ();
return;
}
int i;
int minSize = path.length; // size of the smaller path.
if (path.length > selection.size ())
{
// if new selected path contains more elements then current
// selection then first add all elements at
// the indexes > selection.size
for (i = selection.size (); i < path.length; i++)
{
selection.add (path[i]);
path[i].menuSelectionChanged (true);
}
minSize = selection.size ();
}
else if (path.length < selection.size ())
{
// if new selected path contains less elements then current
// selection then first remove all elements from the selection
// at the indexes > path.length
for (i = selection.size () - 1; i >= path.length; i--)
{
((MenuElement) selection.get (i)).menuSelectionChanged (false);
selection.remove (i);
}
minSize = path.length;
}
// Now compare elements in new and current selection path at the
// same location and adjust selection until
// same menu elements will be encountered at the
// same index in both current and new selection path.
MenuElement oldSelection;
for (i = minSize - 1; i >= 0; i--)
{
oldSelection = (MenuElement) selection.get (i);
if (path[i].equals (oldSelection))
break;
oldSelection.menuSelectionChanged (false);
path[i].menuSelectionChanged (true);
selection.setElementAt (path[i], i);
}
}
/**
* Returns path to the specified component
*
* @param c component for which to find path for
*
* @return path to the specified component
*/
private MenuElement[] getPath (Component c)
{
Vector path = new Vector();
path.add (c);
Component parent = c.getParent ();
while (parent instanceof JMenu
|| parent instanceof JPopupMenu
|| parent instanceof JMenuItem
|| parent instanceof JMenuBar)
{
path.add (parent);
parent = parent.getParent ();
}
MenuElement[] pathArray = new MenuElement[path.size ()];
for (int i = 0; i < path.size (); i++)
pathArray[i] = (MenuElement) path.get (path.size () - i - 1);
return pathArray;
}
} // class MenuSelectionManager

View file

@ -35,248 +35,496 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.util.AbstractMap;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
/**
* RepaintManager
* @author Andrew Selkirk
* @version 1.0
* <p>The repaint manager holds a set of dirty regions, invalid components,
* and a double buffer surface. The dirty regions and invalid components
* are used to coalesce multiple revalidate() and repaint() calls in the
* component tree into larger groups to be refreshed "all at once"; the
* double buffer surface is used by root components to paint
* themselves.</p>
*
* <p>In general, painting is very confusing in swing. see <a
* href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">this
* document</a> for more details.</p>
*
* @author Graydon Hoare (graydon@redhat.com)
*/
public class RepaintManager {
public class RepaintManager
{
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* <p>A helper class which is placed into the system event queue at
* various times in order to facilitate repainting and layout. There is
* typically only one of these objects active at any time. When the
* {@link RepaintManager} is told to queue a repaint, it checks to see if
* a {@link RepaintWorker} is "live" in the system event queue, and if
* not it inserts one using {@link SwingUtilities.invokeLater}.</p>
*
* <p>When the {@link RepaintWorker} comes to the head of the system
* event queue, its {@link RepaintWorker#run} method is executed by the
* swing paint thread, which revalidates all invalid components and
* repaints any damage in the swing scene.</p>
*/
/**
* dirtyComponents
*/
Hashtable dirtyComponents;
protected class RepaintWorker
implements Runnable
{
boolean live;
public RepaintWorker()
{
live = false;
}
public synchronized void setLive(boolean b)
{
live = b;
}
public synchronized boolean isLive()
{
return live;
}
public void run()
{
RepaintManager rm = RepaintManager.globalManager;
setLive(false);
rm.validateInvalidComponents();
rm.paintDirtyRegions();
}
}
/**
* tmpDirtyComponents
*/
Hashtable tmpDirtyComponents;
/**
* A table storing the dirty regions of components. The keys of this
* table are components, the values are rectangles. Each component maps
* to exactly one rectangle. When more regions are marked as dirty on a
* component, they are union'ed with the existing rectangle.
*
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
Hashtable dirtyComponents;
/**
* invalidComponents
*/
Vector invalidComponents;
/**
* A single, shared instance of the helper class. Any methods which mark
* components as invalid or dirty eventually activate this instance. It
* is added to the event queue if it is not already active, otherwise
* reused.
*
* @see #addDirtyRegion
* @see #addInvalidComponent
*/
RepaintWorker repaintWorker;
/**
* doubleBufferingEnabled
*/
boolean doubleBufferingEnabled;
/**
* The set of components which need revalidation, in the "layout" sense.
* There is no additional information about "what kind of layout" they
* need (as there is with dirty regions), so it is just a vector rather
* than a table.
*
* @see #addInvalidComponent
* @see #removeInvalidComponent
* @see #validateInvalidComponents
*/
Vector invalidComponents;
/**
* doubleBuffer
*/
Image doubleBuffer;
/**
* Whether or not double buffering is enabled on this repaint
* manager. This is merely a hint to clients; the RepaintManager will
* always return an offscreen buffer when one is requested.
*
* @see #getDoubleBufferingEnabled
* @see #setDoubleBufferingEnabled
*/
boolean doubleBufferingEnabled;
/**
* doubleBufferSize
*/
Dimension doubleBufferSize;
/**
* The current offscreen buffer. This is reused for all requests for
* offscreen drawing buffers. It grows as necessary, up to {@link
* #doubleBufferMaximumSize}, but there is only one shared instance.
*
* @see #getOffscreenBuffer
* @see #doubleBufferMaximumSize
*/
Image doubleBuffer;
/**
* doubleBufferMaxSize
*/
private Dimension doubleBufferMaxSize;
/**
* resetDoubleBuffer
*/
private boolean resetDoubleBuffer;
/**
* repaintManagerKey
*/
private static final Object repaintManagerKey = null; // TODO
/**
* tmp
*/
Rectangle tmp;
/**
* The maximum width and height to allocate as a double buffer. Requests
* beyond this size are ignored.
*
* @see #paintDirtyRegions
* @see #getDoubleBufferMaximumSize
* @see #setDoubleBufferMaximumSize
*/
Dimension doubleBufferMaximumSize;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* The global, shared RepaintManager instance. This is reused for all
* components in all windows.
*
* @see #currentManager
* @see #setCurrentManager
*/
private static RepaintManager globalManager;
/**
* Constructor RepaintManager
*/
public RepaintManager() {
// TODO
} // RepaintManager()
/**
* Create a new RepaintManager object.
*/
public RepaintManager()
{
dirtyComponents = new Hashtable();
invalidComponents = new Vector();
repaintWorker = new RepaintWorker();
doubleBufferMaximumSize = new Dimension(2000,2000);
doubleBufferingEnabled = true;
}
/**
* Get the value of the shared {@link #globalManager} instance, possibly
* returning a special manager associated with the specified
* component. The default implementaiton ignores the component parameter.
*
* @param component A component to look up the manager of
*
* @return The current repaint manager
*
* @see #setCurrentManager
*/
public static RepaintManager currentManager(Component component)
{
if (globalManager == null)
globalManager = new RepaintManager();
return globalManager;
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Get the value of the shared {@link #globalManager} instance, possibly
* returning a special manager associated with the specified
* component. The default implementaiton ignores the component parameter.
*
* @param component A component to look up the manager of
*
* @return The current repaint manager
*
* @see #setCurrentManager
*/
public static RepaintManager currentManager(JComponent component)
{
return currentManager((Component)component);
}
/**
* toString
* @returns String
*/
public synchronized String toString() {
return null; // TODO
} // toString()
/**
* Set the value of the shared {@link #globalManager} instance.
*
* @param manager The new value of the shared instance
*
* @see #currentManager
*/
public static void setCurrentManager(RepaintManager manager)
{
globalManager = manager;
}
/**
* currentManager
* @param component TODO
* @returns RepaintManager
*/
public static RepaintManager currentManager(Component component) {
return null; // TODO
} // currentManager()
/**
* Add a component to the {@link #invalidComponents} vector. If the
* {@link #repaintWorker} class is not active, insert it in the system
* event queue.
*
* @param component The component to add
*
* @see #removeInvalidComponent
*/
public synchronized void addInvalidComponent(JComponent component)
{
while ((component.getParent() != null)
&& (component.getParent() instanceof JComponent)
&& (component.isValidateRoot()))
component = (JComponent) component.getParent();
if (invalidComponents.contains(component))
return;
/**
* currentManager
* @param component TODO
* @returns RepaintManager
*/
public static RepaintManager currentManager(JComponent component) {
return null; // TODO
} // currentManager()
invalidComponents.add(component);
component.invalidate();
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
SwingUtilities.invokeLater(repaintWorker);
}
}
/**
* setCurrentManager
* @param manager TODO
*/
public static void setCurrentManager(RepaintManager manager) {
// TODO
} // setCurrentManager()
/**
* Remove a component from the {@link #invalidComponents} vector.
*
* @param component The component to remove
*
* @see #addInvalidComponent
*/
public synchronized void removeInvalidComponent(JComponent component)
{
invalidComponents.removeElement(component);
}
/**
* addInvalidComponent
* @param component TODO
*/
public synchronized void addInvalidComponent(JComponent component) {
// TODO
} // addInvalidComponent()
/**
* Add a region to the set of dirty regions for a specified component.
* This involves union'ing the new region with any existing dirty region
* associated with the component. If the {@link #repaintWorker} class
* is not active, insert it in the system event queue.
*
* @param component The component to add a dirty region for
* @param x The left x coordinate of the new dirty region
* @param y The top y coordinate of the new dirty region
* @param w The width of the new dirty region
* @param h The height of the new dirty region
*
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
public synchronized void addDirtyRegion(JComponent component, int x, int y,
int w, int h)
{
Rectangle r = new Rectangle(x, y, w, h);
if (dirtyComponents.containsKey(component))
r = r.union((Rectangle)dirtyComponents.get(component));
dirtyComponents.put(component, r);
if (! repaintWorker.isLive())
{
repaintWorker.setLive(true);
SwingUtilities.invokeLater(repaintWorker);
}
}
/**
* Get the dirty region associated with a component, or <code>null</code>
* if the component has no dirty region.
*
* @param component The component to get the dirty region of
*
* @return The dirty region of the component
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
* @see #markCompletelyDirty
*/
public Rectangle getDirtyRegion(JComponent component)
{
return (Rectangle) dirtyComponents.get(component);
}
/**
* Mark a component as dirty over its entire bounds.
*
* @param component The component to mark as dirty
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
*/
public void markCompletelyDirty(JComponent component)
{
Rectangle r = component.getBounds();
addDirtyRegion(component, r.x, r.y, r.width, r.height);
}
/**
* removeInvalidComponent
* @param component TODO
*/
public synchronized void removeInvalidComponent(JComponent component) {
// TODO
} // removeInvalidComponent()
/**
* Remove all dirty regions for a specified component
*
* @param component The component to mark as clean
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyDirty
*/
public void markCompletelyClean(JComponent component)
{
dirtyComponents.remove(component);
}
/**
* addDirtyRegion
* @param component TODO
* @param x TODO
* @param y TODO
* @param w TODO
* @param h TODO
*/
public synchronized void addDirtyRegion(JComponent component, int x,
int y, int w, int h) {
// TODO
} // addDirtyRegion()
/**
* Return <code>true</code> if the specified component is completely
* contained within its dirty region, otherwise <code>false</code>
*
* @param component The component to check for complete dirtyness
*
* @return Whether the component is completely dirty
*
* @see #dirtyComponents
* @see #addDirtyRegion
* @see #getDirtyRegion
* @see #isCompletelyDirty
* @see #markCompletelyClean
*/
public boolean isCompletelyDirty(JComponent component)
{
Rectangle dirty = (Rectangle) dirtyComponents.get(component);
if (dirty == null)
return false;
Rectangle r = component.getBounds();
if (r == null)
return true;
return dirty.contains(r);
}
/**
* getDirtyRegion
* @param component TODO
* @returns Rectangle
*/
public Rectangle getDirtyRegion(JComponent component) {
return null; // TODO
} // getDirtyRegion()
/**
* Validate all components which have been marked invalid in the {@link
* #invalidComponents} vector.
*/
public void validateInvalidComponents()
{
for (Enumeration e = invalidComponents.elements(); e.hasMoreElements(); )
{
JComponent comp = (JComponent) e.nextElement();
if (! (comp.isVisible() && comp.isShowing()))
continue;
comp.validate();
}
invalidComponents.clear();
}
/**
* markCompletelyDirty
* @param component TODO
*/
public void markCompletelyDirty(JComponent component) {
// TODO
} // markCompletelyDirty()
/**
* Repaint all regions of all components which have been marked dirty in
* the {@link #dirtyComponents} table.
*/
public void paintDirtyRegions()
{
// step 1: pull out roots and calculate spanning damage
/**
* markCompletelyClean
* @param component TODO
*/
public void markCompletelyClean(JComponent component) {
// TODO
} // markCompletelyClean()
HashMap roots = new HashMap();
for (Enumeration e = dirtyComponents.keys(); e.hasMoreElements(); )
{
JComponent comp = (JComponent) e.nextElement();
if (! (comp.isVisible() && comp.isShowing()))
continue;
Rectangle damaged = getDirtyRegion(comp);
if (damaged.width == 0 || damaged.height == 0)
continue;
JRootPane root = comp.getRootPane();
Rectangle rootDamage = SwingUtilities.convertRectangle(comp, damaged, root);
if (! roots.containsKey(root))
{
roots.put(root, rootDamage);
}
else
{
roots.put(root, ((Rectangle)roots.get(root)).union(rootDamage));
}
}
dirtyComponents.clear();
/**
* isCompletelyDirty
* @param component TODO
* @returns boolean
*/
public boolean isCompletelyDirty(JComponent component) {
return false; // TODO
} // isCompletelyDirty()
// step 2: paint those roots
Iterator i = roots.iterator(AbstractMap.ENTRIES);
while(i.hasNext())
{
AbstractMap.BasicMapEntry ent = (AbstractMap.BasicMapEntry) i.next();
JRootPane root = (JRootPane) ent.getKey();
Rectangle rect = (Rectangle) ent.getValue();
root.paintImmediately(rect);
}
}
/**
* validateInvalidComponents
*/
public void validateInvalidComponents() {
// TODO
} // validateInvalidComponents()
/**
* Get an offscreen buffer for painting a component's image. This image
* may be smaller than the proposed dimensions, depending on the value of
* the {@link #doubleBufferMaximumSize} property.
*
* @param component The component to return an offscreen buffer for
* @param proposedWidth The proposed width of the offscreen buffer
* @param proposedHeight The proposed height of the offscreen buffer
*
* @return A shared offscreen buffer for painting
*
* @see #doubleBuffer
*/
public Image getOffscreenBuffer(Component component, int proposedWidth,
int proposedHeight)
{
if (doubleBuffer == null
|| (((doubleBuffer.getWidth(null) < proposedWidth)
|| (doubleBuffer.getHeight(null) < proposedHeight))
&& (proposedWidth < doubleBufferMaximumSize.width)
&& (proposedHeight < doubleBufferMaximumSize.height)))
{
doubleBuffer = component.createImage(proposedWidth, proposedHeight);
}
return doubleBuffer;
}
/**
* paintDirtyRegions
*/
public void paintDirtyRegions() {
// TODO
} // paintDirtyRegions()
/**
* Get the value of the {@link #doubleBufferMaximumSize} property.
*
* @return The current value of the property
*
* @see #setDoubleBufferMaximumSize
*/
public Dimension getDoubleBufferMaximumSize()
{
return doubleBufferMaximumSize;
}
/**
* getOffscreenBuffer
* @param component TODO
* @param proposedWidth TODO
* @param proposedHeight TODO
* @returns Image
*/
public Image getOffscreenBuffer(Component component,
int proposedWidth, int proposedHeight) {
return null; // TODO
} // getOffscreenBuffer()
/**
* Set the value of the {@link #doubleBufferMaximumSize} property.
*
* @param size The new value of the property
*
* @see #getDoubleBufferMaximumSize
*/
public void setDoubleBufferMaximumSize(Dimension size)
{
doubleBufferMaximumSize = size;
}
/**
* getDoubleBufferMaximumSize
* @returns Dimension
*/
public Dimension getDoubleBufferMaximumSize() {
return null; // TODO
} // getDoubleBufferMaximumSize()
/**
* Set the value of the {@link #doubleBufferingEnabled} property.
*
* @param buffer The new value of the property
*
* @see #getDoubleBufferingEnabled
*/
public void setDoubleBufferingEnabled(boolean buffer)
{
doubleBufferingEnabled = buffer;
}
/**
* setDoubleBufferMaximumSize
* @param size TODO
*/
public void setDoubleBufferMaximumSize(Dimension size) {
// TODO
} // setDoubleBufferMaximumSize()
/**
* setDoubleBufferingEnabled
* @param buffer TODO
*/
public void setDoubleBufferingEnabled(boolean buffer) {
// TODO
} // setDoubleBufferingEnabled()
/**
* isDoubleBufferingEnabled
* @returns boolean
*/
public boolean isDoubleBufferingEnabled() {
return false; // TODO
} // isDoubleBufferingEnabled()
} // RepaintManager
/**
* Get the value of the {@link #doubleBufferingEnabled} property.
*
* @return The current value of the property
*
* @see #setDoubleBufferingEnabled
*/
public boolean isDoubleBufferingEnabled()
{
return doubleBufferingEnabled;
}
public String toString()
{
return "RepaintManager";
}
}

View file

@ -227,7 +227,17 @@ public class ScrollPaneLayout
if (horizontalScrollBar != null)
horizontalScrollBarSize.setSize(horizontalScrollBar.getPreferredSize());
/*
System.err.println("widths: [vp=" + viewportSize.width +
", h=" + columnHeaderSize.width +
", sc=" + horizontalScrollBarSize.width + "]");
System.err.println("heights: [vp=" + viewportSize.height +
", h=" + rowHeaderSize.height +
", sc=" + verticalScrollBarSize.height + "]");
*/
return new Dimension(insetsSize.width
+ viewportSize.width
+ viewportInsetsSize.width
@ -336,9 +346,9 @@ public class ScrollPaneLayout
synchronized (sc.getTreeLock ())
{
Rectangle scrollPaneBounds = sc.getBounds();
Dimension viewportSize = new Dimension(0,0);
Dimension viewSize = new Dimension(0,0);
JViewport viewport = sc.getViewport();
Dimension viewportSize = viewport.getSize();
Dimension viewSize = viewport.getView().getSize();
int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
int y1 = 0, y2 = 0, y3 = 0, y4 = 0;
@ -395,7 +405,7 @@ public class ScrollPaneLayout
rowHeader.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));
if (showVsb)
verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
if (showHsb)
horizontalScrollBar.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));

View file

@ -43,6 +43,7 @@ import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
@ -64,6 +65,8 @@ import java.lang.reflect.InvocationTargetException;
public class SwingUtilities implements SwingConstants
{
private static Frame ownerFrame;
/**
* Calculates the portion of the base rectangle which is inside the
* insets.
@ -830,5 +833,18 @@ public class SwingUtilities implements SwingConstants
paintComponent(g, c, p, r.x, r.y, r.width, r.height);
}
/**
* This method returns the common Frame owner used in JDialogs
* when no owner is provided.
*
* @return The common Frame
*/
static Frame getOwnerFrame()
{
if (ownerFrame == null)
ownerFrame = new Frame();
return ownerFrame;
}
}

View file

@ -178,8 +178,7 @@ public class UIManager implements Serializable
*/
public static Dimension getDimension(Object key)
{
System.out.println("UIManager.getDim");
return new Dimension(200,100);
return (Dimension) getLookAndFeel().getDefaults().get(key);
}
/**

View file

@ -41,37 +41,62 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.Serializable;
/**
* ViewportLayout
* @author Andrew Selkirk
* @version 1.0
* @author Graydon Hoare
*/
public class ViewportLayout implements LayoutManager, Serializable
{
static final long serialVersionUID = -788225906076097229L;
public ViewportLayout() {
}
public void addLayoutComponent(String name, Component c) {
// ignore
}
public void removeLayoutComponent(Component c) {
// ignore
}
public Dimension preferredLayoutSize(Container parent) {
return null;
}
public Dimension minimumLayoutSize(Container parent) {
return null;
}
public void layoutContainer(Container parent) {
if (parent.countComponents() == 1)
{
// This should usually be true, but if it's not it is
// probably nicer if we do not panic.
Component c = parent.getComponent(0);
}
}
public ViewportLayout()
{
}
public void addLayoutComponent(String name, Component c)
{
}
public void removeLayoutComponent(Component c)
{
}
public Dimension preferredLayoutSize(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
if (view instanceof Scrollable)
{
Scrollable sc = (Scrollable) view;
Dimension d = sc.getPreferredScrollableViewportSize();
// System.err.println(this + ".preferredLayoutSize() : scrollable -> " + d);
return d;
}
else
return view.getPreferredSize();
}
public Dimension minimumLayoutSize(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
return view.getMinimumSize();
}
public void layoutContainer(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
Rectangle portBounds = vp.getBounds();
Dimension viewMinimum = view.getMinimumSize();
int width = Math.max(portBounds.width,
viewMinimum.width);
int height = Math.max(portBounds.height,
viewMinimum.height);
int x = Math.min(0, portBounds.width - width);
int y = Math.min(0, portBounds.height - height);
// System.err.println(this + ".layoutContainer() : width = " + width + ", height = " + height);
vp.setViewPosition(new Point(x, y));
vp.setViewSize(new Dimension(width, height));
}
}

View file

@ -210,8 +210,9 @@ public final class SwingPropertyChangeSupport
PropertyChangeListener listener;
// Check Values if they are equal
if (event.getOldValue() == null || event.getNewValue() == null ||
event.getOldValue().equals(event.getNewValue()) == true) {
if (event.getOldValue() == null && event.getNewValue() == null ||
(event.getOldValue() != null && event.getNewValue() != null &&
event.getOldValue().equals(event.getNewValue()))) {
return;
} // if

View file

@ -92,6 +92,7 @@ public class BasicButtonUI extends ButtonUI
b.setBackground(defaults.getColor("Button.background"));
b.setMargin(defaults.getInsets("Button.margin"));
b.setBorder(defaults.getBorder("Button.border"));
b.setOpaque(true);
}
protected void uninstallDefaults(AbstractButton b)

View file

@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
@ -48,18 +47,39 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
{
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public static ComponentUI createUI(final JComponent c)
{
return new BasicCheckBoxMenuItemUI();
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null; // TODO
}
/**
* DOCUMENT ME!
*/
protected void installDefaults()
{
super.installDefaults();
@ -68,6 +88,14 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
checkIcon = defaults.getIcon("CheckBoxMenuItem.checkIcon");
}
/**
* DOCUMENT ME!
*
* @param item DOCUMENT ME!
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement[] path,
MenuSelectionManager manager)
{

View file

@ -82,7 +82,34 @@ public class BasicIconFactory implements Serializable
}
public static Icon getMenuArrowIcon()
{
return new DummyIcon();
return new Icon()
{
public int getIconHeight()
{
return 12;
}
public int getIconWidth()
{
return 12;
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.translate(x, y);
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.fillPolygon(new Polygon(new int[] { 3, 9, 3 },
new int[] { 2, 6, 10 },
3));
g.setColor(saved);
g.translate(-x, -y);
}
};
}
public static Icon getCheckBoxIcon()

View file

@ -168,23 +168,20 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
vr.width = 0;
if (vr.height < 0)
vr.height = 0;
Icon icon = (b.isEnabled()) ? b.getIcon() : b.getDisabledIcon();
String text = layoutCL(b, fm, b.getText(), icon, vr, ir, tr);
if (b.isOpaque())
{
g.setColor(b.getBackground());
g.fillRect(vr.x, vr.y, vr.width, vr.height);
}
if (icon != null)
icon.paintIcon(b, g, ir.x, ir.y);
if (b.isEnabled())
paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
else
paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
if (text != null && ! text.equals(""))
{
if (b.isEnabled())
paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
else
paintDisabledText(b, g, text, tr.x, tr.y + fm.getAscent());
}
g.setFont(saved_font);
}
@ -354,6 +351,7 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
c.setBackground(defaults.getColor("Label.background"));
c.setFont(defaults.getFont("Label.font"));
c.setBorder(defaults.getBorder("Label.border"));
c.setOpaque(true);
//XXX: There are properties we don't use called disabledForeground
//and disabledShadow.
}

View file

@ -502,6 +502,7 @@ public class BasicListUI extends ListUI
list.setBackground(defaults.getColor("List.background"));
list.setSelectionForeground(defaults.getColor("List.selectionForeground"));
list.setSelectionBackground(defaults.getColor("List.selectionBackground"));
list.setOpaque(true);
}
/**
@ -620,7 +621,8 @@ public class BasicListUI extends ListUI
maybeUpdateLayoutState();
if (list.getModel().getSize() == 0)
return new Dimension(0, 0);
Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1);
int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize());
Rectangle bounds = getCellBounds(list, 0, nrows - 1);
return bounds.getSize();
}
@ -696,11 +698,11 @@ public class BasicListUI extends ListUI
public int locationToIndex(JList list, Point location)
{
throw new Error("Not implemented");
return convertYToRow(location.y);
}
public Point indexToLocation(JList list, int index)
{
throw new Error("Not implemented");
return new Point(0, convertRowToY(index));
}
}

View file

@ -249,7 +249,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Button.foreground", new ColorUIResource(Color.black),
"Button.highlight", new ColorUIResource(Color.white),
"Button.light", new ColorUIResource(Color.lightGray.brighter()),
"Button.margin", new InsetsUIResource(2, 14, 2, 14),
"Button.margin", new InsetsUIResource(2, 2, 2, 2),
"Button.shadow", new ColorUIResource(Color.gray),
"Button.textIconGap", new Integer(4),
"Button.textShiftOffset", new Integer(0),
@ -694,7 +694,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"SplitPane.background", new ColorUIResource(Color.lightGray),
"SplitPane.border", new BasicBorders.SplitPaneBorder(null, null),
"SplitPane.dividerSize", new Integer(7),
"SplitPane.dividerSize", new Integer(10),
"SplitPane.highlight", new ColorUIResource(Color.white),
"SplitPane.shadow", new ColorUIResource(Color.gray),
"TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {

View file

@ -0,0 +1,277 @@
/* BasicMenuUI.java
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.awt.Dimension;
import javax.swing.BoxLayout;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MenuListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuBarUI;
import javax.swing.plaf.MenuItemUI;
import java.awt.Insets;
import java.awt.GridLayout;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
public class BasicMenuBarUI extends MenuBarUI
{
protected ChangeListener changeListener;
protected ContainerListener containerListener;
protected PropertyChangeListener propertyChangeListener;
protected JMenuBar menuBar;
/**
* Creates a new BasicMenuBarUI object.
*/
public BasicMenuBarUI()
{
changeListener = createChangeListener();
containerListener = createContainerListener();
propertyChangeListener = new PropertyChangeHandler();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected ChangeListener createChangeListener()
{
return new ChangeHandler();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected ContainerListener createContainerListener()
{
return new ContainerHandler();
}
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent x)
{
return new BasicMenuBarUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMaximumSize(JComponent c)
{
// let layout manager calculate its size
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMinimumSize(JComponent c)
{
// let layout manager calculate its size
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getPreferredSize(JComponent c)
{
// let layout manager calculate its size
return null;
}
/**
* DOCUMENT ME!
*/
protected void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
menuBar.setBackground(defaults.getColor("MenuBar.background"));
menuBar.setBorder(defaults.getBorder("MenuBar.border"));
menuBar.setFont(defaults.getFont("MenuBar.font"));
menuBar.setForeground(defaults.getColor("MenuBar.foreground"));
}
/**
* DOCUMENT ME!
*/
protected void installKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void installListeners()
{
menuBar.addContainerListener(containerListener);
menuBar.addPropertyChangeListener(propertyChangeListener);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void installUI(JComponent c)
{
super.installUI(c);
menuBar = (JMenuBar) c;
menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.X_AXIS));
installDefaults();
installListeners();
}
/**
* DOCUMENT ME!
*/
protected void uninstallDefaults()
{
menuBar.setBackground(null);
menuBar.setBorder(null);
menuBar.setFont(null);
menuBar.setForeground(null);
}
/**
* DOCUMENT ME!
*/
protected void uninstallKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallListeners()
{
menuBar.removeContainerListener(containerListener);
menuBar.removePropertyChangeListener(propertyChangeListener);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void uninstallUI(JComponent c)
{
uninstallDefaults();
uninstallListeners();
menuBar= null;
}
protected class ChangeHandler implements ChangeListener
{
public void stateChanged(ChangeEvent event)
{
}
}
protected class ContainerHandler implements ContainerListener
{
public void componentAdded(ContainerEvent e)
{
}
public void componentRemoved(ContainerEvent e)
{
}
}
protected class PropertyChangeHandler implements PropertyChangeListener
{
public void propertyChange(PropertyChangeEvent e)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,357 @@
/* BasicMenuUI.java
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MenuListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
public class BasicMenuUI extends BasicMenuItemUI
{
protected ChangeListener changeListener;
protected MenuListener menuListener;
protected PropertyChangeListener propertyChangeListener;
/**
* Creates a new BasicMenuUI object.
*/
public BasicMenuUI()
{
mouseInputListener = createMouseInputListener(menuItem);
menuListener = createMenuListener(menuItem);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected ChangeListener createChangeListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MenuKeyListener createMenuKeyListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MenuListener createMenuListener(JComponent c)
{
return new MenuHandler();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected MouseInputListener createMouseInputListener(JComponent c)
{
return new MouseInputHandler();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected PropertyChangeListener createPropertyChangeListener(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent x)
{
return new BasicMenuUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMaximumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null;
}
/**
* DOCUMENT ME!
*/
protected void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
menuItem.setBackground(defaults.getColor("Menu.background"));
menuItem.setBorder(defaults.getBorder("Menu.border"));
menuItem.setFont(defaults.getFont("Menu.font"));
menuItem.setForeground(defaults.getColor("Menu.foreground"));
menuItem.setMargin(defaults.getInsets("Menu.margin"));
acceleratorFont = defaults.getFont("Menu.acceleratorFont");
acceleratorForeground = defaults.getColor("Menu.acceleratorForeground");
acceleratorSelectionForeground = defaults.getColor("Menu.acceleratorSelectionForeground");
arrowIcon = defaults.getIcon("Menu.arrowIcon");
oldBorderPainted = defaults.getBoolean("Menu.borderPainted");
}
/**
* DOCUMENT ME!
*/
protected void installKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void installListeners()
{
((JMenu) menuItem).addMouseListener(mouseInputListener);
((JMenu) menuItem).addMenuListener(menuListener);
}
/**
* DOCUMENT ME!
*
* @param menu DOCUMENT ME!
*/
protected void setupPostTimer(JMenu menu)
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallDefaults()
{
menuItem.setBackground(null);
menuItem.setBorder(null);
menuItem.setFont(null);
menuItem.setForeground(null);
menuItem.setMargin(null);
acceleratorFont = null;
acceleratorForeground = null;
acceleratorSelectionForeground = null;
arrowIcon = null;
}
/**
* DOCUMENT ME!
*/
protected void uninstallKeyboardActions()
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallListeners()
{
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
protected class MouseInputHandler implements MouseInputListener
{
protected MouseInputHandler()
{
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseDragged(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
}
public void mouseEntered(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(manager.getPath((Component) e.getSource()));
manager.processMouseEvent(e);
JMenu subMenu = (JMenu) menuItem;
int x = 0;
int y = 0;
// location of the popup menu is relative to the invoker
if (subMenu.isTopLevelMenu())
{
JMenuBar mb = (JMenuBar) subMenu.getParent();
// Subtract menuBar's insets.bottom and popupMenu's insets.top,
// s.t. the space between menu bar and its popup menu is equal to
// menuBar's margin. By default menuBar's margin is Insets(0,0,0,0).
y = subMenu.getHeight() - mb.getInsets().bottom
- subMenu.getPopupMenu().getInsets().top + mb.getMargin().bottom;
}
else
x = subMenu.getWidth();
subMenu.getPopupMenu().show(subMenu, x, y);
}
public void mouseExited(MouseEvent e)
{
}
public void mouseMoved(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
}
}
protected class MenuHandler implements MenuListener
{
public void menuCanceled(MenuEvent e)
{
}
public void menuDeselected(MenuEvent e)
{
}
public void menuSelected(MenuEvent e)
{
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,362 @@
/* BasicPopupMenuUI.java
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.AWTKeyStroke;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EventListener;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.MenuDragMouseEvent;
import javax.swing.event.MenuDragMouseListener;
import javax.swing.event.MenuKeyEvent;
import javax.swing.event.MenuKeyListener;
import javax.swing.event.MouseInputListener;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuItemUI;
import javax.swing.plaf.PopupMenuUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
public class BasicPopupMenuUI extends PopupMenuUI
{
protected JPopupMenu popupMenu;
private static transient MouseInputListener mouseInputListener;
private transient PopupMenuListener popupMenuListener;
/**
* Creates a new BasicPopupMenuUI object.
*/
public BasicPopupMenuUI()
{
popupMenuListener = new PopupMenuHandler();
mouseInputListener = new MouseInputHandler();
}
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent x)
{
return new BasicPopupMenuUI();
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void installUI(JComponent c)
{
super.installUI(c);
popupMenu = (JPopupMenu) c;
popupMenu.setLayout(new GridBagLayout());
popupMenu.setBorderPainted(true);
popupMenu.setDefaultLightWeightPopupEnabled(true);
installDefaults();
installListeners();
}
/**
* DOCUMENT ME!
*/
public void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
popupMenu.setBackground(defaults.getColor("PopupMenu.background"));
popupMenu.setBorder(defaults.getBorder("PopupMenu.border"));
popupMenu.setFont(defaults.getFont("PopupMenu.font"));
popupMenu.setForeground(defaults.getColor("PopupMenu.foreground"));
}
/**
* DOCUMENT ME!
*/
protected void installListeners()
{
popupMenu.addMouseListener(mouseInputListener);
popupMenu.addMouseMotionListener(mouseInputListener);
popupMenu.addPopupMenuListener(popupMenuListener);
}
/**
* DOCUMENT ME!
*/
protected void installKeyboardActions()
{
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void uninstallUI(JComponent c)
{
uninstallListeners();
uninstallDefaults();
popupMenu = null;
}
/**
* DOCUMENT ME!
*/
protected void uninstallDefaults()
{
popupMenu.setBackground(null);
popupMenu.setBorder(null);
popupMenu.setFont(null);
popupMenu.setForeground(null);
}
/**
* DOCUMENT ME!
*/
protected void uninstallListeners()
{
}
/**
* DOCUMENT ME!
*/
protected void uninstallKeyboardActions()
{
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMinimumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getPreferredSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension getMaximumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isPopupTrigger(MouseEvent e)
{
return false;
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
protected class PopupMenuHandler implements PopupMenuListener
{
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void popupMenuCanceled(PopupMenuEvent event)
{
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
{
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent event)
{
}
}
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.1 $
*/
protected class MouseInputHandler implements MouseInputListener
{
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseClicked(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseDragged(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseEntered(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseExited(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseMoved(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mousePressed(MouseEvent e)
{
}
/**
* DOCUMENT ME!
*
* @param e DOCUMENT ME!
*/
public void mouseReleased(MouseEvent e)
{
}
}
}

View file

@ -712,6 +712,7 @@ public class BasicProgressBarUI extends ProgressBarUI
progressBar.setForeground(defaults.getColor("ProgressBar.foreground"));
progressBar.setBackground(defaults.getColor("ProgressBar.background"));
progressBar.setBorder(defaults.getBorder("ProgressBar.border"));
progressBar.setOpaque(true);
selectionForeground = defaults.getColor("ProgressBar.selectionForeground");
selectionBackground = defaults.getColor("ProgressBar.selectionBackground");

View file

@ -48,27 +48,55 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
/**
* DOCUMENT ME!
*
* @author $author$
* @version $Revision: 1.1.2.3 $
*/
public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
{
/**
* Creates a new BasicRadioButtonMenuItemUI object.
*/
public BasicRadioButtonMenuItemUI()
{
{
super();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
checkIcon = defaults.getIcon("RadioButtonMenuItem.checkIcon");
}
/**
* DOCUMENT ME!
*
* @param b DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public static ComponentUI createUI(JComponent b)
{
return new BasicRadioButtonMenuItemUI();
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null;
// TODO
}
/**
* DOCUMENT ME!
*
* @param item DOCUMENT ME!
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement[] path,
MenuSelectionManager manager)
{

View file

@ -52,6 +52,8 @@ public class BasicRootPaneUI extends RootPaneUI
public void installUI(JComponent c)
{
c.setOpaque(true);
c.setBackground(javax.swing.UIManager.getColor("control"));
super.installUI(c);
}
}

View file

@ -125,6 +125,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void stateChanged(ChangeEvent e)
{
// System.err.println(this + ".stateChanged()");
calculatePreferredSize();
layoutContainer(scrollbar);
getThumbBounds();
scrollbar.repaint();
}
@ -734,6 +737,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
private void calculatePreferredSize()
{
// System.err.println(this + ".calculatePreferredSize()");
int height;
int width;
height = width = 0;
@ -743,7 +748,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
width += incrButton.getPreferredSize().getWidth();
width += decrButton.getPreferredSize().getWidth();
width += Math.max(200, scrollbar.getVisibleAmount());
width += (scrollbar.getMaximum() - scrollbar.getMinimum());
height = Math.max(incrButton.getPreferredSize().height,
decrButton.getPreferredSize().height);
@ -756,7 +761,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
height += incrButton.getPreferredSize().getHeight();
height += decrButton.getPreferredSize().getHeight();
height += Math.max(200, scrollbar.getVisibleAmount());
height += (scrollbar.getMaximum() - scrollbar.getMinimum());
width = Math.max(incrButton.getPreferredSize().width,
decrButton.getPreferredSize().width);
@ -804,6 +809,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
int value = scrollbar.getValue();
int extent = scrollbar.getVisibleAmount();
// System.err.println(this + ".getThumbBounds()");
if (max == min)
{
thumbRect.x = trackRect.x;
@ -892,8 +899,8 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollbar.setForeground(defaults.getColor("ScrollBar.foreground"));
scrollbar.setBackground(defaults.getColor("ScrollBar.background"));
scrollbar.setBorder(defaults.getBorder("ScrollBar.border"));
scrollbar.setOpaque(true);
maximumThumbSize = defaults.getDimension("ScrollBar.maximumThumbSize");
minimumThumbSize = defaults.getDimension("ScrollBar.minimumThumbSize");
@ -1046,14 +1053,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
public void paint(Graphics g, JComponent c)
{
layoutContainer(scrollbar);
// Rectangle r = incrButton.getBounds();
// SwingUtilities.paintComponent(g, incrButton, scrollbar, r.x, r.y, r.width,
// r.height);
// r = decrButton.getBounds();
// SwingUtilities.paintComponent(g, decrButton, scrollbar, r.x, r.y, r.width,
// r.height);
paintTrack(g, c, getTrackBounds());
paintThumb(g, c, getThumbBounds());

View file

@ -123,6 +123,7 @@ public class BasicSeparatorUI extends SeparatorUI
shadow = defaults.getColor("Separator.shadow");
highlight = defaults.getColor("Separator.highlight");
s.setOpaque(true);
}
/**

View file

@ -681,6 +681,7 @@ public class BasicSliderUI extends SliderUI
highlightColor = defaults.getColor("Slider.highlight");
focusColor = defaults.getColor("Slider.focus");
slider.setBorder(defaults.getBorder("Slider.border"));
slider.setOpaque(true);
thumbHeight = defaults.getInt("Slider.thumbHeight");
thumbWidth = defaults.getInt("Slider.thumbWidth");

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -223,10 +223,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
Component visible = getVisibleComponent();
Insets insets = getContentBorderInsets(tabPane.getTabPlacement());
visible.setBounds(contentRect.x + insets.left,
contentRect.y + insets.top,
contentRect.width - insets.left - insets.right,
contentRect.height - insets.top - insets.bottom);
if (visible != null)
visible.setBounds(contentRect.x + insets.left,
contentRect.y + insets.top,
contentRect.width - insets.left - insets.right,
contentRect.height - insets.top - insets.bottom);
}
}
@ -1510,6 +1511,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabPane.setFont(defaults.getFont("TabbedPane.font"));
tabPane.setForeground(defaults.getColor("TabbedPane.foreground"));
tabPane.setBackground(defaults.getColor("TabbedPane.background"));
tabPane.setOpaque(true);
highlight = defaults.getColor("TabbedPane.highlight");
lightHighlight = defaults.getColor("TabbedPane.lightHighlight");
@ -1790,7 +1792,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
// FIXME: Paint little folding corner and jagged edge clipped tab.
if (icon != null)
paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
if (title == null || ! title.equals(""))
if (title != null && ! title.equals(""))
paintText(g, tabPlacement, tabPane.getFont(), fm, tabIndex, title,
textRect, isSelected);
}

View file

@ -47,6 +47,7 @@ import java.awt.Rectangle;
import java.awt.image.ImageObserver;
import javax.swing.JComponent;
import javax.swing.JViewport;
import javax.swing.ViewportLayout;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI;
@ -70,7 +71,8 @@ public class BasicViewportUI extends ViewportUI
}
void installDefaults(JComponent c)
{
{
c.setOpaque(true);
}
void uninstallDefaults(JComponent c)
@ -100,6 +102,7 @@ public class BasicViewportUI extends ViewportUI
public void installUI(JComponent c)
{
super.installUI(c);
c.setLayout(new ViewportLayout());
installListeners(c);
}
@ -111,9 +114,8 @@ public class BasicViewportUI extends ViewportUI
public Dimension getPreferredSize(JComponent c)
{
// FIXME: integrate with Scrollable
Dimension d = new Dimension(100,100);
return d;
// let the ViewportLayout decide
return null;
}
public void paint(Graphics g, JComponent c)
@ -129,6 +131,12 @@ public class BasicViewportUI extends ViewportUI
Rectangle viewBounds = view.getBounds();
Rectangle portBounds = v.getBounds();
if (viewBounds.width == 0
|| viewBounds.height == 0
|| portBounds.width == 0
|| portBounds.height == 0)
return;
if (backingStoreImage == null
|| backingStoreWidth != viewBounds.width
|| backingStoreHeight != viewBounds.height)