[multiple changes]

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JTextArea.java
	(setLineWrap): Fire property change event after new value is set.
	(setTabSize): Likewise.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JTable.java
	(autoCreateColumnsFromModel): New field.
	(autoResizeMode): Likewise.
	(cellEditor): Likewise.
	(cellSelectionEnabled): Likewise.
	(columnModel): Likewise.
	(dataModel): Likewise.
	(defaultEditorsByColumnClass): Likewise.
	(defaultRenderersByColumnClass): Likewise.
	(editingColumn): Likewise.
	(editingRow): Likewise.
	(gridColor): Likewise.
	(preferredViewportSize): Likewise.
	(rowHeight): Likewise.
	(rowMargin): Likewise.
	(rowSelectionAllowed): Likewise.
	(selectionBackground): Likewise.
	(selectionForeground): Likewise.
	(selectionModel): Likewise.
	(showHorizontalLines): Likewise.
	(showVerticalLines): Likewise.
	(tableHeader): Likewise.
	(JTable): Implemented.
	(getColumnModel): Likewise.
	(getSelectedRow): Likewise.
	(getSelectionModel): Likewise.
	(setModel): Likewise.
	(setSelectionModel): Likewise.
	(createScrollPaneForTable): New method.
	(createDefaultDataModel): Likewise.
	(createDefaultListSelectionModel): Likewise.
	(getModel): Likewise.
	(getTableHeader): Likewise.
	(setTableHeader): Likewise.
	(getColumnSelectionAllowed): Likewise.
	(setColumnSelectionAllowed): Likewise.
	(getRowSelectionAllowed): Likewise.
	(setRowSelectionAllowed): Likewise.
	(getAutoResizeMode): Likewise.
	(setAutoResizeMode): Likewise.
	(getColumnCount): Likewise.
	(getRowCount): Likewise.
	(getCellRenderer): Likewise.
	* javax/swing/JTree.java
	(cellRenderer): New field.
	(editable): Likewise.
	(rootVisible): Likewise.
	(showsRootHandles): Likewise.
	(getModel): New method.
	(setModel): Likewise.
	(isEditable): Likewise.
	(setEditable): Likewise.
	(isRootVisbile): Likewise.
	(setRootVisible): Likewise.
	(getShowsRootHandles): Likewise.
	(setShowRootHandles): Likewise.
	(getCellRenderer): Likewise.
	(setCellRenderer): Likewise.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JFormattedTextField.java
	(setDocument): Implemented.
	* javax/swing/JRootPane.java:
	Fixed javadocs.
	* javax/swing/JTable.java
	(getDefaultRenderer): New method.
	* javax/swing/JTextField.java
	(setFont): Likewise.
	(getPreferredSize): Likewise.
	* javax/swing/JToggleButton.java
	(getAccessibleContext): Fix javadoc.
	* javax/swing/JTree.java:
	Add some javadocs.
	* javax/swing/JViewport.java:
	Likewise.

2004-07-21  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java:
	Collect all native method declaration at the top.
	(create): Set the filename filter if necessary.
	(setDirectory): Call nativeSetDirectory().
	(setFilenameFilter): Implement.
	(filenameFilterCallback): New method.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
	(create): Configure dialog to show hidden files.
	(filenameFilterCallback): New function.
	(nativeSetFilenameFilter): New function.
	(nativeSetDirectory): New function.

2004-07-21  Kim Ho  <kho@redhat.com>

	* javax/swing/plaf/basic/BasicSliderUI.java:
	Ran Jalopy.
	(paintTrack): Fill the track before painting
	the borders.

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

	patch from Roman Kennke <roman@ontographics.com>
	* javax/swing/Spring.java: New file.
	* javax/swing/SpringLayout.java: New file.
	* Makefile.am: Add new files.
	* Makefile.in: Regenerate.

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

	* javax/swing/plaf/basic/BasicSplitPaneUI.java: Minor layout fixes.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java: Likewise.
	* javax/swing/ScrollPaneLayout.java: Likewise.

2004-07-21  Kim Ho  <kho@redhat.com>

	* javax/swing/DefaultDesktopManager.java:
	(findMinimum): Removed.
	(resizeFrame): Trust the UI to pass valid
	bounds.
	* javax/swing/JOptionPane.java:
	Implemented showInternalXXXDialog methods.
	(startModal): New method.
	* javax/swing/plaf/basic/BasicInternalFrameUI.java:
	(BorderListener::mouseDragged): Verify that the new
	bounds are valid before passing them to the DesktopManager.
	(preferredLayoutSize): Delegate
	to getSize.
	(minimumLayoutSize): Ditto.
	(getSize): New method.
	(GlassPaneDispatcher): Reimplemented by copying
	a stripped down LightweightDispatcher from Container.
	(getMinimumSize): Call minimumLayoutSize.
	* javax/swing/plaf/basic/BasicOptionPaneUI.java:
	Ran Jalopy.
	(mousePressed): Add ability to properly close
	JInternalFrames.
	* javax/swing/plaf/basic/BasicToolBarUI.java:
	(DragWindow): Set owner for DragWindow.

2004-07-21  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/image/ShortLookupTable.java: New file.
	* java/awt/image/ByteLookupTable.java: New file.
	* Makefile.am: Added new files.
	* Makefile.in: Regenerated.

2004-07-21  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
	(create(GtkContainerPeer)): New native method.
	(create()): Call native create(), passing in the parent frame
	as the paramter. Natively set the current file and directory.
	(setFile): Construct an absolute filename before passing it to
	the native peer.
	(nativeGetDirectory): New method.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
	(window_closed): Removed.
	(ok_clicked): Likewise.
	(cancel_clicked): Likewise.
	(handle_response): New method.
	(create): Use GtkFileChooserDialog.
	(connectSignals): Connect to handle_response.
	(nativeGetDirectory): New method.
	(nativeSetFile): Use GtkFileChooserDialog.

2004-07-21  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/image/LookupTable.java: New file.
	* Makefile.am: Added new file.
	* Makefile.in: Regenerated.

2004-07-21  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/image/Kernel.java: New file.
	* Makefile.am: Added new file.
	* Makefile.in: Regenerated.

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

	* javax/swing/JCheckBoxMenuItem.java: Fixed Javadocs.
	* javax/swing/JMenu.java: Likewise.
	* javax/swing/JMenuBar.java: Likewise.
	(MARGIN_CHANGED_PROPERTY): New property.
	(setMargin): Implemented.
	* javax/swing/JMenuItem.java: Fixed javadocs.
	* javax/swing/JPopupMenuUI.java: Fixed javadocs.
	(LABEL_CHANGED_PROPERTY): New property.
	(add): changed to use createActionComponent.
	(createActionComponent): Implemented.
	(setLabel): Fire PropertyChangeEvent if label property
	changes.
	* javax/swing/JRadioButtonMenuItem.java: Fixed javadocs.
	* javax/swing/plaf/basic/BasicMenuBarUI.java: Likewise.
	(ContainerHandler): Repaint if margin property has changed.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(installUI): Call installComponents().
	(uninstallUI): Call uinstallComponents().
	* javax/swing/plaf/basic/BasicMenuUI.java:
	Fixed javadocs.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	Likewise.

2004-07-21  Kim Ho  <kho@redhat.com>

	* javax/swing/plaf/basic/BasicToolBarUI.java:
	(DragWindow): Use the right constructor.

2004-07-21  Kim Ho  <kho@redhat.com>

	* javax/swing/JToolBar.java:
	(layoutContainer): Use getComponents.
	* javax/swing/plaf/basic/BasicToolBarUI.java:
	(DragWindow): Don't use SwingUtilities'
	getOwnerFrame
	(ToolBarDialog): ditto.

2004-07-21  Kim Ho  <kho@redhat.com>

	* javax/swing/JRootPane.java:
	Ran jalopy.
	(layoutContainer): Set the glasspane's size to
	be the same as the content pane.
	(createGlassPane): Set opaque property to false.

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

	* java/awt/Component.java (requestFocus()): Don't handle Panels
	specially.
	(requestFocus(boolean)): Likewise.
	(requestFocusInWindow(boolean)): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPanelPeer.c (create):
	Set GTK_CAN_FOCUS flag.

2004-07-21  Kim Ho  <kho@redhat.com>

	* Makefile.am: Added new file.
	* Makefile.in: Regenerated.
	* gcj/Makefile.in: Regenerated.
	* include/Makefile.in: Regenerated.
	* javax/swing/AbstractButton.java:
	Add rollOverEnabled property.
	(setRolloverEnabled): Use new property.
	(isRolloverEnabled): Use new property.
	* javax/swing/JTabbedPane.java:
	(setComponent): Remove useless JTabbedPane.this.
	* javax/swing/JToolBar.java: Finish implementation.
	* javax/swing/plaf/basic/BasicArrowButton.java:
	(paint): Moved border painting to a border.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Change JToolBar look and feel defaults.
	* javax/swing/plaf/basic/BasicOptionPaneUI.java
	(actionPerformed): Return Integer index instead of name.
	(addButtonComponents): Check to see if component is
	JButton last.
	(createMessageArea): Don't use components that are not
	completed yet.
	(getIconForType): Use temporary icons.
	* javax/swing/plaf/basic/BasicSliderUI.java:
	(mousePressed): Do not return if it's on thumb.
	(paintMinorTickForHorizSlider): Use BLACK to paint ticks.
	(paintMinorTickForVertSlider): ditto.
	(paintMajorTickForHorizSlider): ditto.
	(paintMajorTickForVertSlider): ditto.
	* javax/swing/plaf/basic/BasicSplitPaneDivider.java:
	Add a border around the SplitPaneDivider.
	* javax/swing/plaf/basic/BasicSplitPaneUI.java:
	Remove comments.
	* javax/swing/plaf/basic/BasicToolBarSeparatorUI.java:
	New file. Implemented.
	* javax/swing/plaf/basic/BasicToolBarUI.java:
	Implemented.
	* testsuite/Makefile.in: Regenerated.

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

	* javax/swing/Timer.java (run): Queue events each time cycle.

2004-07-21  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkImagePainter.java
	(imageComplete): Call image.imageComplete().
	* java/awt/image/MemoryImageSource.java:
	Reimplement consumers as a Vector instead of a Hashtable.  This is
	because enumeration on a Hashtable is not thread-safe.
	(addConsumer): Adapt to Vector consumers.
	(isConsumer): Adapt to Vector consumers.
	(removeConsumer): Adapt to Vector consumers.
	(startProduction): Adapt to Vector consumers. Call imageComplete()
	with STATICIMAGEDONE flag instead of SINGLEFRAME flag.
	(newPixels): Adapt to Vector consumers.
	(sendPicture): Set the color model of the image consumer.
	(newPixels(IIII)): Adapt to Vector consumers.
	(newPixels(IIIIB)): Adapt to Vector consumers.

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

	* java/awt/Component.java (deliverEvent): Implement.
	(postEvent): Implement.
	(handleEvent): Implement.
	(translateEvent): New method.
	(dispatchEventImpl): Document.  Add AWT 1.0 event handling.
	* java/awt/Container.java (deliverEvent): Implement.
	* java/awt/Event.java (paramString): Fix formatting.
	* java/awt/Font.java (toString): Likewise.
	* java/awt/Window.java (postEvent): Implement.

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

	* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
	Set window's focus owner upon receiving a FOCUS_LOST event.
	* java/awt/Window.java (Window()): Refocus the previously
	focused component within the window when the window regains the
	top-level focus.
	(setFocusOwner): New method.
	* java/awt/Component.java (requestFocus): Add FIXME.

	* libgcj.pc.in: Remove library flags.

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

	* gnu/java/awt/peer/gtk/GtkPanelPeer.java (handleEvent): Handle
	MOUSE_PRESSED event.
	* java/awt/Component.java (requestFocus()): Handle Panel
	specially.  Post FOCUS_LOST event on opposite component.
	(requestFocus(boolean)): Likewise.
	(requestFocusInWindow(boolean)): Likewise.
	(paramString): Reorder dimension fields.
	* java/awt/Container.java (paramString): Fix string format.
	* java/awt/DefaultKeyboardFocusManager.java (dispatchEvent):
	Handle FOCUS_LOST events.  Don't handle Windows specially.  Only
	process key events if the focus owner is non-null.
	(dispatchKeyEvent): Likewise.
	* java/awt/Frame.java (paramString): Fix formatting.
	(generateName): New method.
	(getUniqueLong): Likewise.
	* java/awt/KeyboardFocusManager.java (getFocusOwner): Check if
	the temporary focus owner is null.  If so, return the permanent
	focus owner.
	* java/awt/Panel.java (generateName): New method.
	(getUniqueLong): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c: Rework
	signal handling to make callbacks more specific.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/Position.java
	(Bias): Implemented.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/LookAndFeel.java
	(provideErrorFeedback): New method.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JTextArea.java
	(tabSize): New field.
	(getTabSize): New method.
	(setTabSize): Likewise.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ActionMap.java:
	Fixed javadocs all over.
	(serialVersionUID): Made private.
	(parent): Don't explicitely initialize with default value.
	(get): SImplified.
	(keys): Reimplemented.
	(allKeys): Likewise.
	(convertSet): Removed.
	* javax/swing/ComponentInputMap.java:
	Fixed javadocs all over.
	(ComponentInputMap): Implemented.
	(put): Likewise.
	(clear): Likewise.
	(remove): Likewise.
	(SetParent): Likewise.
	(getComponent): Likewise.
	* javax/swing/InputMap.java:
	Fixed javadocs all over.
	(serialVersionUID): Made private.
	(parent): Don't explicitely initialize with default value.
	(get): SImplified.
	(keys): Reimplemented.
	(allKeys): Likewise.
	(convertSet): Removed.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ActionMap.java,
	javax/swing/ComponentInputMap.java,
	javax/swing/InputMap.java,
	javax/swing/table/DefaultTableColumnModel.java,
	javax/swing/table/TableColumn.java,
	javax/swing/table/TableColumnModel.java,
	javax/swing/table/TableModel.java,
	javax/swing/text/AbstractDocument.java,
	javax/swing/text/TextAction.java:
	Reformated.

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

	* gnu/java/awt/peer/gtk/GtkToolkit.java (bufferedImageOrError):
	Make method non-static.
	* javax/swing/AbstractButton.java:
	Rename fields to match property names where possible.
	(iconTextGap): New property.
	* javax/swing/JCheckBox.java: Match AbstractButton changes.
	(init) New method, call from after various constructors.
	* javax/swing/JComponent.java (revalidate):
	Invalidate before queueing repair.
	* javax/swing/JList.java (getPreferredScrollableViewportSize):
	Reimplement in terms of visibleRowCount property.
	* javax/swing/JMenuButton.java: Match AbstractButton changes.
	* javax/swing/JScrollPane.java (createScrollListener):
	Remove tracing chatter.
	* javax/swing/JToggleButton.java: Match AbstractButton changes.
	* javax/swing/RepaintManager.java (addInvalidComponent):
	Don't invalidate.
	* javax/swing/ScrollPaneLayout.java: Various corrections to layout
	calculations.
	* javax/swing/SwingUtilities.java (layoutCompoundLabel):
	Mimic sun behavior on top left/right positioning.
	* javax/swing/ViewportLayout.java (preferredLayoutSize):
	Remove mistaken use of preferredScrollableViewportSize here.
	(layoutContainer): Use view's preferred size as basis.
	* javax/swing/plaf/basic/BasicButtonUI.java:
	Set, get, and use textIconGap property.
	(paint) Paint text returned from layout (with ellipsis).
	* javax/swing/plaf/basic/BasicListUI.java:
	Remove tracing chatter, correct various minor calculations.
	(getCellBounds): Update layout state before calculating.
	* javax/swing/plaf/basic/BasicLookAndFeel.java (Button.Margin):
	Use margin default similar to sun's.
	* javax/swing/plaf/basic/BasicScrollBarUI.java (ArrowIcon):
	(createIncreaseIcon): Center icon, minimize margins.
	(createDecreaseIcon): Likewise.
	* javax/swing/plaf/basic/BasicScrollPaneUI.java (installDefaults):
	Implement.
	(installUI): Call it.
	(uninstallDefaults): Implement.
	(uninstallUI): Call it.
	* javax/swing/plaf/basic/BasicToolBarUI.java (DragWindow):
	Call existing Window constructor.
	* javax/swing/plaf/basic/BasicViewportUI.java (paint):
	Set clip before painting.

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

	* javax/swing/JMenuItem.java:
	(processMouseEvent): Reimplemented to deal with
	mouse drag events.
	(createMenuDragMouseEvent): New private helper method.
	Creates MenuDragMouseEvent.
	* javax/swing/MenuSelectionManager.java
	(componentForPoint): Implemented.
	(isComponentPartOfCurrentMenu): Made public.
	(processMouseEvent): Reimplemented to deal with
	mouse drag events.
	(setSelectedPath): Corrected small mistake that caused
	path to be set incorrectly.
	(getPath): If given component is JMenu then also add this
	menu's popup menu to the selected path.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(getPath): Ditto.
	(getPreferredSize): Call getPreferredMenuItemSize().
	(getPreferredItemSize): Moved code from getPreferredSize to here.
	(installListeners): Install MouseMotionListeners.
	(MouseInputHandler): Pass mouse release event to MenuSelectionManager
	if mouse wasn't released in the bounds of this menu item.
	(MenuDragMouseHandler): Implemented.
	* javax/swing/plaf/basic/BasicMenuUI.java:
	(installListeners): Install MouseMotionListener and
	MenuDrageMouseListener.
	(MenuDragMouseHandler): Implemented.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	(uninstallListeners): Implemented.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JCheckBox.java: Reformated.
        (JCheckBox): Fixed all constructors.
        (isBorderPaintedFlat): New method.
        (setBorderPaintedFlat): New method.
	* javax/swing/JEditorPane.java
        (createEditorKitForContentType): Made public.
        (scrollToReference): Likewise.
	* javax/swing/JTextArea.java
        (setLineWrap): Fire property change.
	* javax/swing/JToggleButton.java
        (JToggleButton): New constructor.
        (JToggleButton): Simplified.
	* javax/swing/text/AttributeSet.java
        (FontAttribute): Renamed from FontCharacterAttribute.
	* javax/swing/text/JTextComponent.java
        (KeyBinBinding): Added javadoc.
        (JTextComponent): Likewise.
        (getAccessibleContext): Fixed javadoc.
	* javax/swing/text/View.java
        (View): Added javadoc.
	* javax/swing/text/TabableView.java: New file.
	* Makefile.am: Added javax/swing/text/TabableView.java.
	* Makefile.in: Regenerated.

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

	* java/awt/image/BufferedImage.java (getSource): Remove tracing chatter.
	* gnu/java/awt/peer/gtk/GtkToolkit.java
	(GtkErrorImage): New helper class.
	(bufferedImageOrError): New helper method.
	(createImage): Use it.

2004-07-21  David Jee  <djee@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c
	(setCaretPosition): Scroll the text view so the new caret position
	is visible on screen.

2004-07-21  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkContainerPeer.java
	(setBounds): Do not validate awtComponent here.
	* gnu/java/awt/peer/gtk/GtkScrollPanePeer.java
	(getPreferredSize): New method.
	* java/awt/ScrollPane.java
	(ScrollPane): Set default size to 100x100.
	(addNotify): If child is not a Panel, wrap it with a new Panel.
	(paramString): Implement.

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

	* javax/swing/JMenu.java:
	(setSelected): Display popup menu only if this menu
	is showing on the screen.
	* javax/swing/JPopupMenu.java:
	(processMouseEvent): Added comment.
	(processKeyEvent): Likewise.
	* javax/swing/MenuSelectionManager.java:
	(clearSelectedPath): Only fireStateChanged() after
	selected path was changed, not before.
	(setSelectedPath): Likewise.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(paintMenuItem): Corrected position of menu item's
	icon.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	(installUI): Correct setDefaultLightWeightPopupEnabled call.
	(popupMenuCanceled): Reimplemented.
	(popupMenuWillBecomeVisible): Select first menu item by default
	when displaying free floating popup menus.
	(TopWindowListener): Reimplemented.

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

	* java/awt/Panel.java (dispatchEventImpl): Override to prevent
	Panel from being painted twice when it is first shown.

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

	* java/awt/Window.java: Reverted changes from my
	previous patch for creating window without an owner.
	* javax/swing/SwingUtilities.java:
	(SwingUtilities.OwnerFrame): made static.
	(OwnerFrame.setVisible): New method. Overridden with
	empty implementation.
	(OwnerFrame.isShowing): New method. Ovverridden
	to return always true.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(GtkComponentPeer): Remove temporary try/catch block.
	(setVisible): Call show and hide.
	(show): Make native.
	(hide): Likewise.
	(getArgs): Don't add "visible" argument.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(property_notify_predicate): Return Bool instead of int.
	(find_layout): New function.
	(connectJObject): Call find_layout.
	(connectSignals): Likewise.
	(moveLayout): Likewise.
	(gtkLayoutSetVisible): Likewise.

2004-07-21  Mark Wielaard  <mark@klomp.org>

	* java/awt/event/InvocationEvent.java (dispatch): Synchronize
	on notifier object before calling notifyAll().

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

	* java/awt/Window.java: Changed constructors to use new
	method that is described below. Constructors call this
	methods only if newly created window should have an owner.
	(setWindowOwner): New method. Implementation for
	this method is moved from this(owner,configuration).
	* javax/swing/JWindow.java:
	(JWindow): Reimplement to use SwingUtilities.ownerFrame
	instead of owner.
	* javax/swing/SwingUtilities.java:
	(ownerFrame): Change type of this field to OwnerFrame.
	(getOwnerFrame): Changed to return object of type OwnerFrame.
	(SwingUtilities.OwnerFrame): New class. Represents owner
	of a Window that is not provided with one.

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

	*  javax/swing/AbstractButton.java:
	(configurePropertiesFromAction): Set action command
	to button's text by default if action command is not
	explicitely specified.
	* javax/swing/JMenu.java: Remove unnecessary listener
	and methods relevant to it.
	(setSelected): Reimplemented.
	(menuSelectionChanged): Moved most part of implementation to
	setSelected() and call it instead.
	* javax/swing/JMenuItem.java:
	(init): Comment out statement that sets paint_border to false.
	(configurePropertiesFromAction): Do not set accelerator
	for JMenu.
	(menuSelectionChanged): Change selected index in the selection
	model of menu item's parent.
	* javax/swing/JPopupMenu.java:
	(remove): Set constraints.fill field to GridBagConstraints.BOTH
	instead of GridBagConstraints.HORIZONTAL.
	(insert): Likewise.
	(createActionChangeListener): Implemented.
	(setVisible): Correct location of HeavyWeightMenu and
	don't firePopupMenuCanceled().
	(menuSelectionChanged): Implemented.
	(ActionChangeListener): New Listener. Implemented.
	* javax/swing/plaf/basic/BasicMenuBarUI.java:
	(BasicMenuBarUI.ContainerHandler): Implemented.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(paintMenuItem): Uncommented out code that paints
	icon, now that icons are working properly.
	(PropertyChangeListener): Implemented.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	Added javadocs.
	(topWindowListener): New field.
	(Constructor): initialize topWindowListener.
	(BasicPopupMenuUI.TopWindowListener): Implemented.
	(BasicPopupMenuUI.PopupMenuHandler): Implemented.
	(BasicPopupMenuUI.TopWindowListener): New ComponentListener.
	Implemented.



2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicButtonUI.java
	(paintFocus): Fixed method signature.
	(paintButtonPressed): Likewise.
	(paintButtonNormal): Likewise.
	(paintText): New method.
	* javax/swing/plaf/basic/BasicLabelUI.java
	(paint): Re-indented.
	* javax/swing/plaf/basic/BasicTextUI.java
	(installUI): Set parent textComponent to opaque.
	* javax/swing/text/DefaultHighlighter.java
	(checkPositions): New helper method.
	(addHighlight): Throws BadLocationException, check positions.
	(changeHighlight): Likewise.
	* javax/swing/text/EditorKit.java
	(EditorKit): Implements Serializable.
	* javax/swing/text/JTextComponent.java
	(getUI): Added javadoc.
	(setUI): Likewise.
	(upadteUI): Added javadoc, don't revalidate and repaint.

2004-07-21  David Jee  <djee@redhat.com>

	* java/awt/GridBagLayout.java
	(ArrangeGrid): Use PREFERREDSIZE instead of MINSIZE.
	* javax/swing/AbstractButton.java
	(setText): Reindent.
	* javax/swing/RepaintManager.java
	(addInvalidComponent): Find the first ancestor that isValidateRoot().

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JFormattedTextField.java
	(value): New field.
	(JFormattedTextField): Implemented.
	(getValue): Likewise.
	(setValue): Likewise.
	* javax/swing/LookAndFeel.java
	(getSupportsWindowDecorations): New method.
	* javax/swing/UIDefaults.java:
	Use java.beans.PropertyChangeSupport instead of doing all ourself.
	(addPropertyChangeListener): Made public.
	(addResourceBundle): Likewise.
	(removeResourceBundle): Likewise.
	(setDefaultLocale): Likewise.
	* javax/swing/plaf/basic/BasicRootPaneUI.java
	(BasicRootPaneUI): Implements PropertyChangeListener.
	(propertyChange): New method.
	* javax/swing/plaf/basic/BasicTextUI.java
	(BasicHighlighter): New inner class.
	(createHighlighter): New method.
	* javax/swing/plaf/basic/BasicToolBarUI.java
	(DragWindow): Extends java.awt.Window.
	* javax/swing/text/JTextComponent.java
	(getDocument): Removed debug output.
	* javax/swing/plaf/basic/BasicTextFieldUI.java,
	javax/swing/text/DefaultHighlighter.java,
	javax/swing/text/FieldView.java,
	javax/swing/text/PlainView.java: New files.
	* Makefile.am: Added new files.
	* Makefile.in: Regenerated.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JEditorPane.java
	(createDefaultEditorKit): Use javax.swing.text.DefaultEditorKit.
	(createEditorKitForContentType): Likewise.
	* javax/swing/text/DefaultEditorKit.java
	(serialVersionUID): Added constant field.
	(EndOfLineStringPropery): Fixed typo.
	(DefaultEditorKit): New constructor.
	* javax/swing/text/Segment.java:
	Import java.text.CharacterIterator.
	* javax/swing/text/CharacterIterator.java,
	javax/swing/text/PlainEditorKit.java: Removed.
	* Makefile.am: Removed javax/swing/text/CharacterIterator.java and
	javax/swing/text/PlainEditorKit.java.
	* Makefile.in: Regenerated.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JButton.java,
	javax/swing/text/DefaultEditorKit.java,
	javax/swing/text/EditorKit.java,
	javax/swing/text/Segment.java,
	javax/swing/text/StyledEditorKit.java:
	Reformatted.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ImageIcon.java
	(file): Removed.
	(description): Renamed from descr.
	(ImageIcon): Added missing constructors.
	(setParent): Removed.
	(setImageObserver): New method.
	(getImageObserver): New method.
	(paintIcon): Handle observer = null.
	* javax/swing/JButton.java
	(removeNotify): Fixed javadoc.
	(updateUI): Simplified.
	* javax/swing/JRootPane.java
	(serialVersionUID): New constant field.
	* javax/swing/UIManager.java:
	Fixed javadocs all over.
	(setLookAndFeel): Throws UnsupportedLookAndFeelException.
	* javax/swing/text/AbstractDocument.java
	(createPosition): Throws BadLocationException.
	(getText): Likewise.
	(remove): Likewise.
	* javax/swing/text/ComponentView.java
	(modelToView): Likewise.
	* javax/swing/text/DefaultEditorKit.java:
	Made all public methods public.
	(read): Throws BadLocationException and IOException.
	(write): Likewise.
	* javax/swing/text/EditorKit.java:
	Made all public methods public.
	(serialVersionUID): New constant field.
	(clone): New method.
	(read): Throws BadLocationException and IOException.
	(write): Likewise.
	* javax/swing/text/Segment.java
	(array): Made public.
	(count): Likewise.
	(offset): Likewise.
	(Segment): New constructors.
	(clone): Reimplemented.
	* javax/swing/text/StyledEditorKit.java
	(serialVersionUID): New constant field.

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

	* java/awt/image/BufferedImage.java
	(getSource): Implement.
	* javax/swing/ImageIcon.java
	(ImageIcon): Implement ctor.
	* javax/swing/ScrollPaneLayout.java
	(preferredLayoutSize): Be more careful about nulls.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AttributeSet.java
	(CharacterAttribute): New interface
	(ColorAttribute): Likewise.
	(FontCharacterAttribute): Likewise.
	(ParagraphAttribute): Likewise.
	* javax/swing/text/DefaultCaret.java
	(moveCaret): New method.
	(positionCaret): Likewise.
	(repaint): Made protected.
	* javax/swing/text/JTextComponent.java
	(KeyBinding): Made it static.
	* javax/swing/text/View.java
	(getContainer): Honor parent == null.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AbstractDocument.java:
	Reformatted.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicRootPaneUI.java:
	Import javax.swing.UIManager explicitely.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java
	(ScrollingButton): Made it static.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/UIDefaults.java
	(ActiveValue): Made public.
	(LazyValue): Likewise.
	* javax/swing/plaf/basic/BasicTextUI.java
	(RootView): Reintroduced.
	(view): Removed.
	(rootView): New field.
	(installUI): Create document if needed, initialize rootView.
	(uninstallUI): Hanle rootView.
	(paint): Likewise.
	(getRootView): Likewise.
	(setView): Likewise.
	* javax/swing/text/DefaultCaret.java:
	Renamed all "evt" variables to "event".

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

	* libgcj.spec.in: Add -l-java-util-logging.

2004-07-21  Andreas Tobler  <a.tobler@schweiz.ch>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
	(init_dpi_conversion_factor): Check for int_dpi < 0 in case
	gtk-xft-dpi can no calculate the right value.
	(dpi_changed_cb): Mark *pspec as unsused.

2004-07-21  David Jee  <djee@redhat.com>

	* java/awt/Component.java
	(move): Delegate to setBounds().
	(resize): Likewise.
	(reshape): Fix so it repaints parent and self only when necessary.

2004-07-21  David Jee  <djee@redhat.com>

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(GtkComponentPeer): Revert previous patch from 2004-06-22.
	(setVisible): Likewise.
	(show): Likewise.
	(hide): Likewise.
	(getArgs): Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(property_notify_predicate): Likewise.
	(find_layout): Likewise.
	(connectJObject): Likewise.
	(connectSignals): Likewise.
	(moveLayout): Likewise.
	(gtkLayoutSetVisible): Likewise.

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

	* Makefile.am
	(jv_convert_LDADD):
	(gij_LDADD):
	(rmic_LDADD):
	(rmiregistry_LDADD): Add lib-java-util-logging.la
	* Makefile.in: Regenerate.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AbstractDocument.java
	(replace): Dont use protected method of java.util.Vector directly.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicTextUI.java
	(installUI): Call specialized install methods.
	(installDefaults): New method.
	(installListeners): Likewise.
	(installKeyboardActions): Likewise.
	(uninstallUI): Likewise.
	(uninstallDefaults): New method.
	(uninstallListeners): Likewise.
	(uninstallKeyboardActions): Likewise.
	(getPropertyPrefix): New abstract method.
	(paint): Made final, just call paintSafely().
	(paintSavely): New method.
	(paintBackground): Likewise.
	(getVisibleEditorRect): Likewise.
	* javax/swing/text/LayeredHighlighter.java,
	javax/swing/text/TabExpander.java: New files.
	* Makefile.am: Added javax/swing/text/LayeredHighlighter.java
	and javax/swing/text/TabExpander.java.
	* Makefile.in: Regenerated.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicTextUI.java
	(BasicTextUI): Made abstract.
	(BasicCaret): New inner class.
	(view): Don't explicitely initialize with "null".
	(textComponent): New field.
	(textColor): Removed.
	(disabledTextColor): Removed.
	(normalBackgroundColor): Removed.
	(RootView): Removed commented out inner class.
	(createUI): Removed.
	(createCaret): New method.
	(getComponent): Likewise.
	(installUI): Initialize textComponent only.
	(getPreferredSize): Use installed JTextComponent.
	(setView): New method.
	(create): Likewise.
	* javax/swing/text/JTextComponent.java
	(highlighter): New field.
	(caretColor): Likewise.
	(disabledTextColor): Likewise.
	(seletedTextColor): Likewise.
	(selectionColor): Likewise.
	(setUI): New method.
	(getCaretColor): Likewise.
	(setCaretColor): Likewise.
	(getDisabledColor): Likewise.
	(setDisabledColor): Likewise.
	(getSelectedTextColor): Likewise.
	(setSelectedTextColor): Likewise.
	(getSelectionColor): Likewise.
	(setSelectionColor): Likewise.
	(getHighlighter): Likewise.
	(setHighlighter): Likewise.
	(replaceSelection): Likewise.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicScrollPaneUI.java
	(BasicScrollPaneUI): Implements ScrollPaneConstants.
	* javax/swing/plaf/basic/BasicToolBarUI.java
	(BasicToolBarUI): Implements SwingConstants.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JPopupMenu.java: Removed CVS tags.
	* javax/swing/UIDefaults.java: Reformatted.
	* javax/swing/plaf/basic/BasicRootPaneUI.java:
	Explicitely import used classes.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(GtkComponentPeer): Remove temporary try/catch block.
	(setVisible): Call show and hide.
	(show): Make native.
	(hide): Likewise.
	(getArgs): Don't add "visible" argument.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(property_notify_predicate): Return Bool instead of int.
	(find_layout): New function.
	(connectJObject): Call find_layout.
	(connectSignals): Likewise.
	(moveLayout): Likewise.
	(gtkLayoutSetVisible): Likewise.

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

	* javax/swing/AbstractButton.java:
	(setDisplayedMnemonicIndex): Check if button
	text is not null before checking its length.
	* javax/swing/JMenuItem.java:
	(processMouseEvent): Disarm menu item if mouse has
	exited it.
	* javax/swing/plaf/basic/BasicMenuUI.java:
	(MouseInputHandler.mouseEntered): Do not raise
	popup menu if this menu is already selected.
	(MouseInputHandler.mousePressed): Do not fire
	MenuEvents.
	(MenuHandler): Implemented.

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

	* javax/swing/JCheckBoxMenuItem.java: Added Javadoc.
	(getSelectedObjects): Implemented.
	* javax/swing/JRadioButtonMenuItem.java: Added Javadoc.
	* javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java:
	Added javadoc for few methods.
	(processMouseEvent): Made public.
	* javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
	(processMouseEvent): Likewise.

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

	* javax/swing/AbstractButton.java:
	(init): Set display mnemonic index to -1.
	(setMnemonic(char)): Use setMnemonic(int).
	(setMnemonic(int)): Set display mnemonic index.
	(getDisplayedMnemonicIndex): Change method signature
	by removing 'index' parameter.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Added default for Menu.selectionBackground.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:
	(paintMenuItem): Change background color of the selected
	menu item.
	(paintText): Paint differently when menu item is disabled.
	Also paint mnemonic if it appears in the menu item's label.
	(paintAccelerator): Paint accelerator differently
	if menu item is disabled.
	* javax/swing/plaf/basic/BasicMenuUI.java:
	(installDefaults): Install defaults for
	selectionForeground and selectionBackground.
	(uninstallDefaults): Uninstall defauls for
	selectionForeground and selectionBackground.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AbstractDocument.java
	(BranchElement): Implemented.
	(LeafElement): Implemented.
	* javax/swing/text/DefaultCaret.java:
	Import used classes.
	(serialVersionUID): New constant.
	* javax/swing/text/JTextComponent.java
	(AccessibleJTextComponent): Removed dead declaration.
	(caretPos): Removed.
	(setCaret): New method.
	* javax/swing/text/PlainDocument.java
	(rootElement): New field.
	(PlainDocument): Initialize rootElement.
	(createDefaultRoot): New method.
	(getDefaultRootElement): Implemented.
	* javax/swing/text/View.java: Reformatted.
	* javax/swing/text/ViewFactory.java
	(create): Added javadoc.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ToolTipManager.java: Reformatted.

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

	* javax/swing/AbstractButton.java
	(changeEvent): New field.
	(fireItemStateChanged): Change source of the event
	to 'this' before firing it to button listeners.
	(fireActionPerformed): Likewise.
	(fireStateChanged): Likewise.
	(createActionListener): Do not set source
	of the event to AbstractButton.
	* javax/swing/plaf/basic/BasicMenuBarUI.java:
	(ContainerHandler.componentAdded): Removed
	print out statement.
	(ContainerHandler.componentRemoved): Likewise.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/Highlighter.java: New file.
	* Makefile.am: Added javax/swing/text/Highlighter.java.
	* Makefile.in: Regenerated.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ToolTipManager.java
	(stillInsideTimerAction): Fixed constructor arguments.
	(outsideTimerAction): Likewise.
	(insideTimerAction): Likewise.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JButton.java: Reformatted.
	* javax/swing/JFormattedTextField.java
	(getUIClassID): Implemented.
	* javax/swing/JRootPane.java
	(serialVersionUID): New constant.
	* javax/swing/JTextField.java
	(align): New field.
	(JTextField): Simplified.
	(getUIClassID): New method.
	(getActionListeners): Added @since tag.
	(setColumns): Invalidate layout and repaint.
	(getHorizontalAlignment): New method.
	(setHorizontalAlignment): New method.
	(selectAll): Removed.
	* javax/swing/SwingUtilities.java
	(getAncestorOfClass): Removed redundant @see tag.
	(isLeftMouseButton): Fixed implementation.
	(isMiddleMouseButton): Likewise.
	(isRightMouseButton): Likewise.
	* javax/swing/text/AbstractDocument.java
	(AttributeContext.addAttribute): New method.
	(AttributeContext.addAttributes): New method.
	(AttributeContext.getEmptySet): New method.
	(AttributeContext.reclaim): New method.
	(AttributeContext.removeAttribute): New method.
	(AttributeContext.removeAttributes): New method.
	* javax/swing/text/Document.java
	(createPosition): Throws BadLocationException.
	(getText): Likewise.
	(remove): Likewise.
	* javax/swing/text/JTextComponent.java
	(getText): Return null if no document is set. Catch
	BadLocationException.
	(getUI): Return ui.
	(updateUI): Simplified.

2004-07-21  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JButton.java
	(removeNotify): Fixed javadoc.
	(updateUI): Simplified.

2004-07-21  David Jee  <djee@redhat.com>

	* gnu/java/awt/image/ImageDecoder.java
	(startProduction): Only add consumer if it's not added yet.
	* gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
	(GdkPixbufDecoder): Don't call initState() here.
	(produce): Call initState() here, to ensure area_prepared and
	area_updated signals are properly connected.
	* gnu/java/awt/peer/gtk/GtkImage.java
	(setColorModel): Use equals() to compare ColorModel objects.
	(setPixels): Likewise.
	* java/awt/image/ColorModel.java
	(equals): Fix typo. Use Arrays.equals() to compare int arrays.
	* java/awt/image/RGBImageFilter.java
	(setColorModel): Set consumer's color model.
	(setPixels): Use equals() to compare ColorModel objects.

From-SVN: r85051
This commit is contained in:
Graydon Hoare 2004-07-22 15:36:05 +00:00
parent 4261159083
commit 8e99fb4f70
131 changed files with 10875 additions and 3281 deletions

File diff suppressed because it is too large Load diff

View file

@ -1102,6 +1102,7 @@ java/awt/geom/GeneralPath.java \
java/awt/geom/QuadCurve2D.java \
java/awt/image/AffineTransformOp.java \
java/awt/image/BufferedImage.java \
java/awt/image/ByteLookupTable.java \
java/awt/image/ColorModel.java \
java/awt/image/ComponentColorModel.java \
java/awt/image/ComponentSampleModel.java \
@ -1117,11 +1118,14 @@ java/awt/image/ImageConsumer.java \
java/awt/image/ImageObserver.java \
java/awt/image/ImageProducer.java \
java/awt/image/IndexColorModel.java \
java/awt/image/Kernel.java \
java/awt/image/LookupTable.java \
java/awt/image/PackedColorModel.java \
java/awt/image/PixelInterleavedSampleModel.java \
java/awt/image/Raster.java \
java/awt/image/RasterOp.java \
java/awt/image/SampleModel.java \
java/awt/image/ShortLookupTable.java \
java/awt/image/SinglePixelPackedSampleModel.java \
java/awt/image/WritableRaster.java \
java/awt/image/AreaAveragingScaleFilter.java \
@ -1344,8 +1348,10 @@ javax/swing/plaf/basic/BasicSliderUI.java \
javax/swing/plaf/basic/BasicSplitPaneDivider.java \
javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
javax/swing/plaf/basic/BasicTextFieldUI.java \
javax/swing/plaf/basic/BasicTextUI.java \
javax/swing/plaf/basic/BasicToggleButtonUI.java \
javax/swing/plaf/basic/BasicToolBarSeparatorUI.java \
javax/swing/plaf/basic/BasicToolBarUI.java \
javax/swing/plaf/basic/BasicTreeUI.java \
javax/swing/plaf/basic/BasicViewportUI.java \
@ -1459,6 +1465,8 @@ javax/swing/ListModel.java \
javax/swing/ListSelectionModel.java \
javax/swing/LookAndFeel.java \
javax/swing/Scrollable.java \
javax/swing/Spring.java \
javax/swing/SpringLayout.java \
javax/swing/SwingConstants.java \
javax/swing/SwingUtilities.java \
javax/swing/Timer.java \
@ -1513,29 +1521,34 @@ javax/swing/text/AbstractDocument.java \
javax/swing/text/AttributeSet.java \
javax/swing/text/BadLocationException.java \
javax/swing/text/Caret.java \
javax/swing/text/CharacterIterator.java \
javax/swing/text/ComponentView.java \
javax/swing/text/DefaultCaret.java \
javax/swing/text/DefaultEditorKit.java \
javax/swing/text/DefaultHighlighter.java \
javax/swing/text/Document.java \
javax/swing/text/DocumentFilter.java \
javax/swing/text/EditorKit.java \
javax/swing/text/Element.java \
javax/swing/text/FieldView.java \
javax/swing/text/GapContent.java \
javax/swing/text/Highlighter.java \
javax/swing/text/JTextComponent.java \
javax/swing/text/Keymap.java \
javax/swing/text/LayeredHighlighter.java \
javax/swing/text/MutableAttributeSet.java \
javax/swing/text/NavigationFilter.java \
javax/swing/text/PlainDocument.java \
javax/swing/text/PlainEditorKit.java \
javax/swing/text/PlainView.java \
javax/swing/text/Position.java \
javax/swing/text/Segment.java \
javax/swing/text/Style.java \
javax/swing/text/View.java \
javax/swing/text/ViewFactory.java \
javax/swing/text/MutableAttributeSet.java \
javax/swing/text/NavigationFilter.java \
javax/swing/text/StyledDocument.java \
javax/swing/text/StyledEditorKit.java \
javax/swing/text/TabExpander.java \
javax/swing/text/TabableView.java \
javax/swing/text/TextAction.java \
javax/swing/text/View.java \
javax/swing/text/ViewFactory.java \
javax/swing/text/html/HTML.java \
javax/swing/text/html/parser/ParserDelegator.java \
javax/swing/tree/TreeNode.java \

View file

@ -792,6 +792,7 @@ java/awt/geom/GeneralPath.java \
java/awt/geom/QuadCurve2D.java \
java/awt/image/AffineTransformOp.java \
java/awt/image/BufferedImage.java \
java/awt/image/ByteLookupTable.java \
java/awt/image/ColorModel.java \
java/awt/image/ComponentColorModel.java \
java/awt/image/ComponentSampleModel.java \
@ -807,11 +808,14 @@ java/awt/image/ImageConsumer.java \
java/awt/image/ImageObserver.java \
java/awt/image/ImageProducer.java \
java/awt/image/IndexColorModel.java \
java/awt/image/Kernel.java \
java/awt/image/LookupTable.java \
java/awt/image/PackedColorModel.java \
java/awt/image/PixelInterleavedSampleModel.java \
java/awt/image/Raster.java \
java/awt/image/RasterOp.java \
java/awt/image/SampleModel.java \
java/awt/image/ShortLookupTable.java \
java/awt/image/SinglePixelPackedSampleModel.java \
java/awt/image/WritableRaster.java \
java/awt/image/AreaAveragingScaleFilter.java \
@ -1034,8 +1038,10 @@ javax/swing/plaf/basic/BasicSliderUI.java \
javax/swing/plaf/basic/BasicSplitPaneDivider.java \
javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
javax/swing/plaf/basic/BasicTextFieldUI.java \
javax/swing/plaf/basic/BasicTextUI.java \
javax/swing/plaf/basic/BasicToggleButtonUI.java \
javax/swing/plaf/basic/BasicToolBarSeparatorUI.java \
javax/swing/plaf/basic/BasicToolBarUI.java \
javax/swing/plaf/basic/BasicTreeUI.java \
javax/swing/plaf/basic/BasicViewportUI.java \
@ -1149,6 +1155,8 @@ javax/swing/ListModel.java \
javax/swing/ListSelectionModel.java \
javax/swing/LookAndFeel.java \
javax/swing/Scrollable.java \
javax/swing/Spring.java \
javax/swing/SpringLayout.java \
javax/swing/SwingConstants.java \
javax/swing/SwingUtilities.java \
javax/swing/Timer.java \
@ -1203,29 +1211,34 @@ javax/swing/text/AbstractDocument.java \
javax/swing/text/AttributeSet.java \
javax/swing/text/BadLocationException.java \
javax/swing/text/Caret.java \
javax/swing/text/CharacterIterator.java \
javax/swing/text/ComponentView.java \
javax/swing/text/DefaultCaret.java \
javax/swing/text/DefaultEditorKit.java \
javax/swing/text/DefaultHighlighter.java \
javax/swing/text/Document.java \
javax/swing/text/DocumentFilter.java \
javax/swing/text/EditorKit.java \
javax/swing/text/Element.java \
javax/swing/text/FieldView.java \
javax/swing/text/GapContent.java \
javax/swing/text/Highlighter.java \
javax/swing/text/JTextComponent.java \
javax/swing/text/Keymap.java \
javax/swing/text/LayeredHighlighter.java \
javax/swing/text/MutableAttributeSet.java \
javax/swing/text/NavigationFilter.java \
javax/swing/text/PlainDocument.java \
javax/swing/text/PlainEditorKit.java \
javax/swing/text/PlainView.java \
javax/swing/text/Position.java \
javax/swing/text/Segment.java \
javax/swing/text/Style.java \
javax/swing/text/View.java \
javax/swing/text/ViewFactory.java \
javax/swing/text/MutableAttributeSet.java \
javax/swing/text/NavigationFilter.java \
javax/swing/text/StyledDocument.java \
javax/swing/text/StyledEditorKit.java \
javax/swing/text/TabExpander.java \
javax/swing/text/TabableView.java \
javax/swing/text/TextAction.java \
javax/swing/text/View.java \
javax/swing/text/ViewFactory.java \
javax/swing/text/html/HTML.java \
javax/swing/text/html/parser/ParserDelegator.java \
javax/swing/tree/TreeNode.java \
@ -3070,7 +3083,7 @@ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DATA = $(jar_DATA) $(pkgconfig_DATA) $(toolexecmainlib_DATA)
DIST_COMMON = README COPYING ChangeLog Makefile.am Makefile.in NEWS \
THANKS TODO acinclude.m4 aclocal.m4 configure configure.in \
THANKS acinclude.m4 aclocal.m4 configure configure.in \
libgcj-test.spec.in libgcj.pc.in libgcj.spec.in
@ -3669,6 +3682,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/image/BufferStrategy.P \
.deps/java/awt/image/BufferedImage.P \
.deps/java/awt/image/BufferedImageOp.P \
.deps/java/awt/image/ByteLookupTable.P \
.deps/java/awt/image/ColorModel.P \
.deps/java/awt/image/ComponentColorModel.P \
.deps/java/awt/image/ComponentSampleModel.P \
@ -3685,7 +3699,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/image/ImageObserver.P \
.deps/java/awt/image/ImageProducer.P \
.deps/java/awt/image/ImagingOpException.P \
.deps/java/awt/image/IndexColorModel.P \
.deps/java/awt/image/IndexColorModel.P .deps/java/awt/image/Kernel.P \
.deps/java/awt/image/LookupTable.P \
.deps/java/awt/image/MemoryImageSource.P \
.deps/java/awt/image/PackedColorModel.P \
.deps/java/awt/image/PixelGrabber.P \
@ -3695,6 +3710,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/awt/image/RasterOp.P .deps/java/awt/image/RenderedImage.P \
.deps/java/awt/image/ReplicateScaleFilter.P \
.deps/java/awt/image/SampleModel.P \
.deps/java/awt/image/ShortLookupTable.P \
.deps/java/awt/image/SinglePixelPackedSampleModel.P \
.deps/java/awt/image/TileObserver.P \
.deps/java/awt/image/VolatileImage.P \
@ -4587,6 +4603,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/ScrollPaneLayout.P .deps/javax/swing/Scrollable.P \
.deps/javax/swing/SingleSelectionModel.P \
.deps/javax/swing/SizeRequirements.P .deps/javax/swing/SizeSequence.P \
.deps/javax/swing/Spring.P .deps/javax/swing/SpringLayout.P \
.deps/javax/swing/SwingConstants.P .deps/javax/swing/SwingUtilities.P \
.deps/javax/swing/Timer.P .deps/javax/swing/ToolTipManager.P \
.deps/javax/swing/UIDefaults.P .deps/javax/swing/UIManager.P \
@ -4717,8 +4734,10 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/plaf/basic/BasicSplitPaneDivider.P \
.deps/javax/swing/plaf/basic/BasicSplitPaneUI.P \
.deps/javax/swing/plaf/basic/BasicTabbedPaneUI.P \
.deps/javax/swing/plaf/basic/BasicTextFieldUI.P \
.deps/javax/swing/plaf/basic/BasicTextUI.P \
.deps/javax/swing/plaf/basic/BasicToggleButtonUI.P \
.deps/javax/swing/plaf/basic/BasicToolBarSeparatorUI.P \
.deps/javax/swing/plaf/basic/BasicToolBarUI.P \
.deps/javax/swing/plaf/basic/BasicTreeUI.P \
.deps/javax/swing/plaf/basic/BasicViewportUI.P \
@ -4736,23 +4755,26 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/text/AbstractDocument.P \
.deps/javax/swing/text/AttributeSet.P \
.deps/javax/swing/text/BadLocationException.P \
.deps/javax/swing/text/Caret.P \
.deps/javax/swing/text/CharacterIterator.P \
.deps/javax/swing/text/ComponentView.P \
.deps/javax/swing/text/Caret.P .deps/javax/swing/text/ComponentView.P \
.deps/javax/swing/text/DefaultCaret.P \
.deps/javax/swing/text/DefaultEditorKit.P \
.deps/javax/swing/text/DefaultHighlighter.P \
.deps/javax/swing/text/Document.P \
.deps/javax/swing/text/DocumentFilter.P \
.deps/javax/swing/text/EditorKit.P .deps/javax/swing/text/Element.P \
.deps/javax/swing/text/GapContent.P \
.deps/javax/swing/text/FieldView.P .deps/javax/swing/text/GapContent.P \
.deps/javax/swing/text/Highlighter.P \
.deps/javax/swing/text/JTextComponent.P .deps/javax/swing/text/Keymap.P \
.deps/javax/swing/text/LayeredHighlighter.P \
.deps/javax/swing/text/MutableAttributeSet.P \
.deps/javax/swing/text/NavigationFilter.P \
.deps/javax/swing/text/PlainDocument.P \
.deps/javax/swing/text/PlainEditorKit.P \
.deps/javax/swing/text/Position.P .deps/javax/swing/text/Segment.P \
.deps/javax/swing/text/Style.P .deps/javax/swing/text/StyledDocument.P \
.deps/javax/swing/text/PlainView.P .deps/javax/swing/text/Position.P \
.deps/javax/swing/text/Segment.P .deps/javax/swing/text/Style.P \
.deps/javax/swing/text/StyledDocument.P \
.deps/javax/swing/text/StyledEditorKit.P \
.deps/javax/swing/text/TabExpander.P \
.deps/javax/swing/text/TabableView.P \
.deps/javax/swing/text/TextAction.P .deps/javax/swing/text/View.P \
.deps/javax/swing/text/ViewFactory.P .deps/javax/swing/text/html/HTML.P \
.deps/javax/swing/text/html/parser/ParserDelegator.P \

View file

@ -98,7 +98,9 @@ public abstract class ImageDecoder implements ImageProducer
public void startProduction (ImageConsumer ic)
{
if (!isConsumer(ic))
addConsumer (ic);
Vector list = (Vector) consumers.clone ();
try
{

View file

@ -77,19 +77,16 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
public GdkPixbufDecoder (String filename)
{
super (filename);
initState ();
}
public GdkPixbufDecoder (URL url)
{
super (url);
initState ();
}
public GdkPixbufDecoder (byte[] imagedata, int imageoffset, int imagelength)
{
super (imagedata, imageoffset, imagelength);
initState ();
}
// called back by native side
@ -135,6 +132,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
byte bytes[] = new byte[4096];
int len = 0;
initState();
while ((len = is.read (bytes)) != -1)
pumpBytes (bytes, len);

View file

@ -115,8 +115,6 @@ public class GtkComponentPeer extends GtkGenericPeer
this.awtComponent = awtComponent;
insets = new Insets (0, 0, 0, 0);
/* temporary try/catch block until all peers use this creation method */
try {
create ();
GtkArgList args = new GtkArgList ();
@ -147,7 +145,7 @@ public class GtkComponentPeer extends GtkGenericPeer
Rectangle bounds = awtComponent.getBounds ();
setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
} catch (RuntimeException ex) { ; }
setVisible (awtComponent.isVisible ());
}
public int checkImage (Image image, int width, int height,
@ -449,18 +447,14 @@ public class GtkComponentPeer extends GtkGenericPeer
public void setVisible (boolean b)
{
set ("visible", b);
}
public void hide ()
{
setVisible (false);
if (b)
show ();
else
hide ();
}
public void show ()
{
setVisible (true);
}
public native void hide ();
public native void show ();
protected void postMouseEvent(int id, long when, int mods, int x, int y,
int clickCount, boolean popupTrigger)
@ -514,7 +508,6 @@ public class GtkComponentPeer extends GtkGenericPeer
public void getArgs (Component component, GtkArgList args)
{
args.add ("visible", component.isVisible ());
args.add ("sensitive", component.isEnabled ());
ComponentPeer p;

View file

@ -90,7 +90,6 @@ public class GtkContainerPeer extends GtkComponentPeer
public void setBounds (int x, int y, int width, int height)
{
super.setBounds (x, y, width, height);
awtComponent.validate ();
}
public void setFont(Font f)

View file

@ -45,6 +45,7 @@ import java.awt.Graphics;
import java.awt.event.WindowEvent;
import java.awt.peer.FileDialogPeer;
import java.io.FilenameFilter;
import java.io.File;
public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
{
@ -52,18 +53,34 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
private String currentFile = null;
private String currentDirectory = null;
private FilenameFilter filter;
native void create ();
native void create (GtkContainerPeer parent);
native void connectJObject ();
native void connectSignals ();
native void nativeSetFile (String file);
native public String nativeGetDirectory();
native public void nativeSetDirectory(String directory);
native void nativeSetFilenameFilter (FilenameFilter filter);
public void create() {
create((GtkContainerPeer) awtComponent.getParent().getPeer());
FileDialog fd = (FileDialog) awtComponent;
setDirectory(fd.getDirectory());
setFile(fd.getFile());
FilenameFilter filter = fd.getFilenameFilter();
if (filter != null)
setFilenameFilter(filter);
}
public GtkFileDialogPeer (FileDialog fd)
{
super (fd);
}
native void connectJObject ();
native void connectSignals ();
native void nativeSetFile (String file);
public void setFile (String fileName)
{
/* If nothing changed do nothing. This usually happens because
@ -80,26 +97,16 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
return;
}
// Remove any directory path from the filename
int sepIndex = fileName.lastIndexOf (FS);
if (sepIndex < 0)
{
// GtkFileChooser requires absolute filenames. If the given filename
// is not absolute, let's construct it based on current directory.
currentFile = fileName;
if (fileName.indexOf(FS) == 0)
{
nativeSetFile (fileName);
}
else
{
if (fileName.length() > (sepIndex + 1))
{
String fn = fileName.substring (sepIndex + 1);
currentFile = fn;
nativeSetFile (fn);
}
else
{
currentFile = "";
nativeSetFile ("");
}
nativeSetFile (nativeGetDirectory() + FS + fileName);
}
}
@ -120,20 +127,25 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
}
currentDirectory = directory;
// Gtk expects the directory to end with a file separator
if (directory.substring (directory.length () - 1).equals (FS))
nativeSetFile (directory);
else
nativeSetFile (directory + FS);
nativeSetDirectory (directory);
}
public void setFilenameFilter (FilenameFilter filter)
{
/* GTK has no filter callbacks yet. It works by setting a pattern
* (see gtk_file_selection_complete), which we can't convert
* to the callback paradigm. With GTK-2.4 there will be a
* gtk_file_filter_add_custom function that we can use. */
this.filter = filter;
nativeSetFilenameFilter(filter);
}
/* This method interacts with the native callback function of the
same name. The native function will extract the filename from the
GtkFileFilterInfo object and send it to this method, which will
in turn call the filter's accept() method and give back the return
value. */
boolean filenameFilterCallback (String fullname) {
String filename = fullname.substring(fullname.lastIndexOf(FS) + 1);
String dirname = fullname.substring(0, fullname.lastIndexOf(FS));
File dir = new File(dirname);
return filter.accept(dir, filename);
}
public Graphics getGraphics ()

View file

@ -202,7 +202,7 @@ public class GtkImage extends Image implements ImageConsumer
public synchronized void
setColorModel (ColorModel model)
{
if (this.model == null || this.model == model)
if (this.model == null || this.model.equals(model))
this.model = model;
else
isCacheable = false;
@ -235,7 +235,7 @@ public class GtkImage extends Image implements ImageConsumer
if (!isCacheable)
return;
if (cm != model || pixelCache == null)
if (!cm.equals(model) || pixelCache == null)
{
isCacheable = false;
return;

View file

@ -246,5 +246,6 @@ public class GtkImagePainter implements Runnable, ImageConsumer
public void
imageComplete (int status)
{
image.imageComplete(status);
}
}

View file

@ -38,7 +38,9 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.AWTEvent;
import java.awt.Panel;
import java.awt.event.MouseEvent;
import java.awt.peer.PanelPeer;
public class GtkPanelPeer extends GtkContainerPeer
@ -51,4 +53,17 @@ public class GtkPanelPeer extends GtkContainerPeer
{
super (p);
}
public void handleEvent (AWTEvent event)
{
int id = event.getID();
switch (id)
{
case MouseEvent.MOUSE_PRESSED:
awtComponent.requestFocusInWindow ();
break;
}
super.handleEvent (event);
}
}

View file

@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Adjustable;
import java.awt.Dimension;
import java.awt.ScrollPane;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ScrollPanePeer;
@ -87,10 +88,10 @@ public class GtkScrollPanePeer extends GtkContainerPeer
native public int getVScrollbarWidth ();
native public void setScrollPosition (int x, int y);
// public Dimension getPreferredSize ()
// {
// return new Dimension (60, 60);
// }
public Dimension getPreferredSize ()
{
return awtComponent.getSize();
}
public void setUnitIncrement (Adjustable adj, int u)
{

View file

@ -44,13 +44,17 @@ import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageProducer;
import java.awt.GraphicsEnvironment;
import java.awt.peer.*;
import java.net.URL;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Properties;
@ -127,10 +131,102 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return status;
}
/**
* A helper class to return to clients in cases where a BufferedImage is
* desired but its construction fails.
*/
private class GtkErrorImage extends Image
{
public GtkErrorImage()
{
}
public int getWidth(ImageObserver observer)
{
return -1;
}
public int getHeight(ImageObserver observer)
{
return -1;
}
public ImageProducer getSource()
{
return new ImageProducer()
{
HashSet consumers = new HashSet();
public void addConsumer(ImageConsumer ic)
{
consumers.add(ic);
}
public boolean isConsumer(ImageConsumer ic)
{
return consumers.contains(ic);
}
public void removeConsumer(ImageConsumer ic)
{
consumers.remove(ic);
}
public void startProduction(ImageConsumer ic)
{
consumers.add(ic);
Iterator i = consumers.iterator();
while(i.hasNext())
{
ImageConsumer c = (ImageConsumer) i.next();
c.imageComplete(ImageConsumer.IMAGEERROR);
}
}
public void requestTopDownLeftRightResend(ImageConsumer ic)
{
startProduction(ic);
}
};
}
public Graphics getGraphics()
{
return null;
}
public Object getProperty(String name, ImageObserver observer)
{
return null;
}
public Image getScaledInstance(int width, int height, int flags)
{
return new GtkErrorImage();
}
public void flush()
{
}
}
/**
* Helper to return either a BufferedImage -- the argument -- or a
* GtkErrorImage if the argument is null.
*/
private Image bufferedImageOrError(BufferedImage b)
{
if (b == null)
return new GtkErrorImage();
else
return b;
}
public Image createImage (String filename)
{
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (filename);
return bufferedImageOrError(GdkPixbufDecoder.createBufferedImage (filename));
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (filename);
@ -143,7 +239,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public Image createImage (URL url)
{
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (url);
return bufferedImageOrError(GdkPixbufDecoder.createBufferedImage (url));
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (url);
@ -156,7 +252,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public Image createImage (ImageProducer producer)
{
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (producer);
return bufferedImageOrError(GdkPixbufDecoder.createBufferedImage (producer));
else
{
GtkImage image = new GtkImage (producer, null);
@ -169,9 +265,9 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
int imagelength)
{
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (imagedata,
return bufferedImageOrError(GdkPixbufDecoder.createBufferedImage (imagedata,
imageoffset,
imagelength);
imagelength));
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (imagedata,

View file

@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
@ -48,6 +49,7 @@ import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.MouseEvent;
@ -1175,30 +1177,7 @@ public abstract class Component
*/
public void move(int x, int y)
{
int oldx = this.x;
int oldy = this.y;
if (this.x == x && this.y == y)
return;
invalidate ();
this.x = x;
this.y = y;
if (peer != null)
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight() && width != 0 && height !=0)
{
parent.repaint(oldx, oldy, width, height);
repaint();
}
if (oldx != x || oldy != y)
{
ComponentEvent ce = new ComponentEvent(this,
ComponentEvent.COMPONENT_MOVED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
setBounds(x, y, this.width, this.height);
}
/**
@ -1262,32 +1241,7 @@ public abstract class Component
*/
public void resize(int width, int height)
{
int oldwidth = this.width;
int oldheight = this.height;
if (this.width == width && this.height == height)
return;
invalidate ();
this.width = width;
this.height = height;
if (peer != null)
peer.setBounds (x, y, width, height);
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight())
{
if (oldwidth != 0 && oldheight != 0 && parent != null)
parent.repaint(x, y, oldwidth, oldheight);
if (width != 0 && height != 0)
repaint();
}
if (oldwidth != width || oldheight != height)
{
ComponentEvent ce =
new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
setBounds(this.x, this.y, width, height);
}
/**
@ -1395,9 +1349,25 @@ public abstract class Component
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight())
{
if (oldwidth != 0 && oldheight != 0 && parent != null)
boolean shouldRepaintParent = false;
boolean shouldRepaintSelf = false;
if (parent != null)
{
Rectangle parentBounds = parent.getBounds();
Rectangle oldBounds = new Rectangle(parent.getX() + oldx,
parent.getY() + oldy,
oldwidth, oldheight);
Rectangle newBounds = new Rectangle(parent.getX() + x,
parent.getY() + y,
width, height);
shouldRepaintParent = parentBounds.intersects(oldBounds);
shouldRepaintSelf = parentBounds.intersects(newBounds);
}
if (shouldRepaintParent)
parent.repaint(oldx, oldy, oldwidth, oldheight);
if (width != 0 && height != 0)
if (shouldRepaintSelf)
repaint();
}
@ -2255,14 +2225,17 @@ public abstract class Component
}
/**
* AWT 1.0 event dispatcher.
* AWT 1.0 event delivery.
*
* @param e the event to dispatch
* Deliver an AWT 1.0 event to this Component. This method simply
* calls {@link #postEvent}.
*
* @param e the event to deliver
* @deprecated use {@link #dispatchEvent(AWTEvent)} instead
*/
public void deliverEvent(Event e)
{
// XXX Add backward compatibility handling.
postEvent (e);
}
/**
@ -2284,16 +2257,24 @@ public abstract class Component
}
/**
* AWT 1.0 event dispatcher.
* AWT 1.0 event handler.
*
* @param e the event to dispatch
* @return false: since the method was deprecated, the return has no meaning
* This method simply calls handleEvent and returns the result.
*
* @param e the event to handle
* @return the result of handling <code>e</code>
* @deprecated use {@link #dispatchEvent(AWTEvent)} instead
*/
public boolean postEvent(Event e)
{
// XXX Add backward compatibility handling.
return false;
boolean handled = handleEvent (e);
if (!handled)
// FIXME: need to translate event coordinates to parent's
// coordinate space.
handled = getParent ().postEvent (e);
return handled;
}
/**
@ -3170,20 +3151,61 @@ public abstract class Component
}
/**
* AWT 1.0 event processor.
* AWT 1.0 event handler.
*
* This method calls one of the event-specific handler methods. For
* example for key events, either {@link #keyDown (Event evt, int
* key)} or {@link keyUp (Event evt, int key)} is called. A derived
* component can override one of these event-specific methods if it
* only needs to handle certain event types. Otherwise it can
* override handleEvent itself and handle any event.
*
* @param evt the event to handle
* @return false: since the method was deprecated, the return has no meaning
* @return true if the event was handled, false otherwise
* @deprecated use {@link #processEvent(AWTEvent)} instead
*/
public boolean handleEvent(Event evt)
{
// XXX Add backward compatibility handling.
switch (evt.id)
{
// Handle key events.
case Event.KEY_ACTION:
case Event.KEY_PRESS:
return keyDown (evt, evt.key);
case Event.KEY_ACTION_RELEASE:
case Event.KEY_RELEASE:
return keyUp (evt, evt.key);
// Handle mouse events.
case Event.MOUSE_DOWN:
return mouseDown (evt, evt.x, evt.y);
case Event.MOUSE_UP:
return mouseUp (evt, evt.x, evt.y);
case Event.MOUSE_MOVE:
return mouseMove (evt, evt.x, evt.y);
case Event.MOUSE_DRAG:
return mouseDrag (evt, evt.x, evt.y);
case Event.MOUSE_ENTER:
return mouseEnter (evt, evt.x, evt.y);
case Event.MOUSE_EXIT:
return mouseExit (evt, evt.x, evt.y);
// Handle focus events.
case Event.GOT_FOCUS:
return gotFocus (evt, evt.arg);
case Event.LOST_FOCUS:
return lostFocus (evt, evt.arg);
// Handle action event.
case Event.ACTION_EVENT:
return action (evt, evt.arg);
}
// Unknown event.
return false;
}
/**
* AWT 1.0 mouse event.
* AWT 1.0 mouse event handler.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
@ -3686,7 +3708,20 @@ public abstract class Component
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED));
synchronized (eq)
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
if (currentFocusOwner != null)
{
eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
false, this));
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false,
currentFocusOwner));
}
else
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false));
}
}
}
else
@ -3759,9 +3794,25 @@ public abstract class Component
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
synchronized (eq)
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
if (currentFocusOwner != null)
{
eq.postEvent (new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
temporary, this));
eq.postEvent (new FocusEvent(this,
FocusEvent.FOCUS_GAINED,
temporary,
currentFocusOwner));
}
else
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
}
}
}
else
// FIXME: need to add a focus listener to our top-level
// ancestor, so that we can post this event when it becomes
@ -3852,7 +3903,8 @@ public abstract class Component
// Check if top-level ancestor is currently focused window.
if (focusedWindow == toplevel)
{
if (peer != null)
if (peer != null
&& !(this instanceof Window))
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
@ -3863,9 +3915,21 @@ public abstract class Component
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
synchronized (eq)
{
Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
if (currentFocusOwner != null)
{
eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
temporary, this));
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary,
currentFocusOwner));
}
else
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
}
}
}
else
return false;
}
@ -4041,8 +4105,8 @@ public abstract class Component
String name = getName();
if (name != null)
param.append(name).append(",");
param.append(width).append("x").append(height).append("+").append(x)
.append("+").append(y);
param.append(x).append(",").append(y).append(",").append(width)
.append("x").append(height);
if (! isValid())
param.append(",invalid");
if (! isVisible())
@ -4410,13 +4474,212 @@ p * <li>the set of backward traversal keys
}
/**
* Implementation of dispatchEvent. Allows trusted package classes to
* dispatch additional events first.
* Translate an AWT 1.1 event ({@link AWTEvent}) into an AWT 1.0
* event ({@link Event}).
*
* @param e an AWT 1.1 event to translate
*
* @return an AWT 1.0 event representing e
*/
private Event translateEvent (AWTEvent e)
{
Component target = (Component) e.getSource ();
Event translated = null;
if (e instanceof InputEvent)
{
InputEvent ie = (InputEvent) e;
long when = ie.getWhen ();
int oldID = 0;
int id = e.getID ();
int oldMods = 0;
int mods = ie.getModifiers ();
if ((mods & InputEvent.BUTTON2_MASK) != 0)
oldMods |= Event.META_MASK;
else if ((mods & InputEvent.BUTTON3_MASK) != 0)
oldMods |= Event.ALT_MASK;
if ((mods & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0)
oldMods |= Event.SHIFT_MASK;
if ((mods & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0)
oldMods |= Event.CTRL_MASK;
if ((mods & (InputEvent.META_MASK | InputEvent.META_DOWN_MASK)) != 0)
oldMods |= Event.META_MASK;
if ((mods & (InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0)
oldMods |= Event.ALT_MASK;
if (e instanceof MouseEvent)
{
if (id == MouseEvent.MOUSE_PRESSED)
oldID = Event.MOUSE_DOWN;
else if (id == MouseEvent.MOUSE_RELEASED)
oldID = Event.MOUSE_UP;
else if (id == MouseEvent.MOUSE_MOVED)
oldID = Event.MOUSE_MOVE;
else if (id == MouseEvent.MOUSE_DRAGGED)
oldID = Event.MOUSE_DRAG;
else if (id == MouseEvent.MOUSE_ENTERED)
oldID = Event.MOUSE_ENTER;
else if (id == MouseEvent.MOUSE_EXITED)
oldID = Event.MOUSE_EXIT;
else
// No analogous AWT 1.0 mouse event.
return null;
MouseEvent me = (MouseEvent) e;
translated = new Event (target, when, oldID,
me.getX (), me.getY (), 0, oldMods);
}
else if (e instanceof KeyEvent)
{
if (id == KeyEvent.KEY_PRESSED)
oldID = Event.KEY_PRESS;
else if (e.getID () == KeyEvent.KEY_RELEASED)
oldID = Event.KEY_RELEASE;
else
// No analogous AWT 1.0 key event.
return null;
int oldKey = 0;
int newKey = ((KeyEvent) e).getKeyCode ();
switch (newKey)
{
case KeyEvent.VK_BACK_SPACE:
oldKey = Event.BACK_SPACE;
break;
case KeyEvent.VK_CAPS_LOCK:
oldKey = Event.CAPS_LOCK;
break;
case KeyEvent.VK_DELETE:
oldKey = Event.DELETE;
break;
case KeyEvent.VK_DOWN:
case KeyEvent.VK_KP_DOWN:
oldKey = Event.DOWN;
break;
case KeyEvent.VK_END:
oldKey = Event.END;
break;
case KeyEvent.VK_ENTER:
oldKey = Event.ENTER;
break;
case KeyEvent.VK_ESCAPE:
oldKey = Event.ESCAPE;
break;
case KeyEvent.VK_F1:
oldKey = Event.F1;
break;
case KeyEvent.VK_F10:
oldKey = Event.F10;
break;
case KeyEvent.VK_F11:
oldKey = Event.F11;
break;
case KeyEvent.VK_F12:
oldKey = Event.F12;
break;
case KeyEvent.VK_F2:
oldKey = Event.F2;
break;
case KeyEvent.VK_F3:
oldKey = Event.F3;
break;
case KeyEvent.VK_F4:
oldKey = Event.F4;
break;
case KeyEvent.VK_F5:
oldKey = Event.F5;
break;
case KeyEvent.VK_F6:
oldKey = Event.F6;
break;
case KeyEvent.VK_F7:
oldKey = Event.F7;
break;
case KeyEvent.VK_F8:
oldKey = Event.F8;
break;
case KeyEvent.VK_F9:
oldKey = Event.F9;
break;
case KeyEvent.VK_HOME:
oldKey = Event.HOME;
break;
case KeyEvent.VK_INSERT:
oldKey = Event.INSERT;
break;
case KeyEvent.VK_LEFT:
case KeyEvent.VK_KP_LEFT:
oldKey = Event.LEFT;
break;
case KeyEvent.VK_NUM_LOCK:
oldKey = Event.NUM_LOCK;
break;
case KeyEvent.VK_PAUSE:
oldKey = Event.PAUSE;
break;
case KeyEvent.VK_PAGE_DOWN:
oldKey = Event.PGDN;
break;
case KeyEvent.VK_PAGE_UP:
oldKey = Event.PGUP;
break;
case KeyEvent.VK_PRINTSCREEN:
oldKey = Event.PRINT_SCREEN;
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_KP_RIGHT:
oldKey = Event.RIGHT;
break;
case KeyEvent.VK_SCROLL_LOCK:
oldKey = Event.SCROLL_LOCK;
break;
case KeyEvent.VK_TAB:
oldKey = Event.TAB;
break;
case KeyEvent.VK_UP:
case KeyEvent.VK_KP_UP:
oldKey = Event.UP;
break;
default:
oldKey = newKey;
}
translated = new Event (target, when, oldID,
0, 0, oldKey, oldMods);
}
}
else if (e instanceof ActionEvent)
translated = new Event (target, Event.ACTION_EVENT,
((ActionEvent) e).getActionCommand ());
return translated;
}
/**
* Implementation of dispatchEvent. Allows trusted package classes
* to dispatch additional events first. This implementation first
* translates <code>e</code> to an AWT 1.0 event and sends the
* result to {@link #postEvent}. If the AWT 1.0 event is not
* handled, and events of type <code>e</code> are enabled for this
* component, e is passed on to {@link #processEvent}.
*
* @param e the event to dispatch
*/
void dispatchEventImpl(AWTEvent e)
{
Event oldEvent = translateEvent (e);
if (oldEvent != null)
postEvent (oldEvent);
if (eventTypeEnabled (e.id))
processEvent(e);
}

View file

@ -856,6 +856,16 @@ public class Container extends Component
*/
public void deliverEvent(Event e)
{
if (!handleEvent (e))
{
synchronized (getTreeLock ())
{
Component parent = getParent ();
if (parent != null)
parent.deliverEvent (e);
}
}
}
/**
@ -1027,7 +1037,7 @@ public class Container extends Component
{
String param = super.paramString();
if (layoutMgr != null)
param = param + "," + layoutMgr.getClass().getName();
param = param + ",layout=" + layoutMgr.getClass().getName();
return param;
}

View file

@ -162,16 +162,41 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
Component target = (Component) e.getSource ();
if (e.id == FocusEvent.FOCUS_GAINED
&& !(target instanceof Window))
if (e.id == FocusEvent.FOCUS_GAINED)
{
if (((FocusEvent) e).isTemporary ())
setGlobalFocusOwner (target);
else
setGlobalPermanentFocusOwner (target);
}
else if (e.id == FocusEvent.FOCUS_LOST)
{
// We need to set the window's focus owner here; we can't
// set it when the window loses focus because by that time
// the previous focus owner has already lost focus
// (FOCUS_LOST events are delivered before
// WINDOW_LOST_FOCUS events).
// Find the target Component's top-level ancestor.
Container parent = target.getParent ();
while (parent != null
&& !(parent instanceof Window))
parent = parent.getParent ();
Window toplevel = parent == null ?
(Window) target : (Window) parent;
Component focusOwner = getFocusOwner ();
if (focusOwner != null)
toplevel.setFocusOwner (focusOwner);
if (((FocusEvent) e).isTemporary ())
setGlobalFocusOwner (null);
else
setGlobalPermanentFocusOwner (null);
}
if (!(target instanceof Window))
target.dispatchEvent (e);
return true;
@ -192,6 +217,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
// processKeyEvent checks if this event represents a focus
// traversal key stroke.
Component focusOwner = getGlobalPermanentFocusOwner ();
if (focusOwner != null)
processKeyEvent (focusOwner, (KeyEvent) e);
if (e.isConsumed ())
@ -230,6 +257,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
Component focusOwner = getGlobalPermanentFocusOwner ();
if (focusOwner != null)
focusOwner.dispatchEvent (e);
// Loop through all registered KeyEventPostProcessors, giving

View file

@ -163,7 +163,8 @@ public class Event implements java.io.Serializable
protected String paramString ()
{
return "id=" + id + ",x=" + x + ",y=" + y + "target=" + target;
return "id=" + id + ",x=" + x + ",y=" + y
+ ",target=" + target + ",arg=" + arg;
}
public boolean shiftDown()

View file

@ -1268,10 +1268,9 @@ toString()
return(getClass().getName()
+ "(logical=" + getName ()
+ ",family=" + getFamily ()
+ ",face=" + getFontName ()
+ ",name=" + getFontName ()
+ ",style=" + getStyle ()
+ ",size=" + getSize ()
+ ",transform=" + getTransform () + ")");
+ ",size=" + getSize ());
}

View file

@ -50,11 +50,6 @@ import java.util.Vector;
*/
public class Frame extends Window implements MenuContainer
{
/*
* Static Variables
*/
/**
* Constant for the default cursor.
* @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
@ -148,12 +143,6 @@ public static final int NORMAL = 0;
// Serialization version constant
private static final long serialVersionUID = 2673458971256075116L;
/*************************************************************************/
/*
* Instance Variables
*/
/**
* @serial The version of the class data being serialized
* // FIXME: what is this value?
@ -208,11 +197,10 @@ private String title = "";
*/
private boolean undecorated = false;
/*************************************************************************/
/*
* Constructors
* The number used to generate the name returned by getName.
*/
private static transient long next_frame_number = 0;
/**
* Initializes a new instance of <code>Frame</code> that is not visible
@ -224,8 +212,6 @@ Frame()
this("");
}
/*************************************************************************/
/**
* Initializes a new instance of <code>Frame</code> that is not visible
* and has the specified title.
@ -256,12 +242,6 @@ Frame(String title, GraphicsConfiguration gc)
visible = false;
}
/*************************************************************************/
/*
* Instance Methods
*/
/**
* Returns this frame's title string.
*
@ -273,8 +253,6 @@ getTitle()
return(title);
}
/*************************************************************************/
/*
* Sets this frame's title to the specified value.
*
@ -288,8 +266,6 @@ setTitle(String title)
((FramePeer) peer).setTitle(title);
}
/*************************************************************************/
/**
* Returns this frame's icon.
*
@ -302,8 +278,6 @@ getIconImage()
return(icon);
}
/*************************************************************************/
/**
* Sets this frame's icon to the specified value.
*
@ -317,8 +291,6 @@ setIconImage(Image icon)
((FramePeer) peer).setIconImage(icon);
}
/*************************************************************************/
/**
* Returns this frame's menu bar.
*
@ -331,8 +303,6 @@ getMenuBar()
return(menuBar);
}
/*************************************************************************/
/**
* Sets this frame's menu bar.
*
@ -352,8 +322,6 @@ setMenuBar(MenuBar menuBar)
this.menuBar = menuBar;
}
/*************************************************************************/
/**
* Tests whether or not this frame is resizable. This will be
* <code>true</code> by default.
@ -367,8 +335,6 @@ isResizable()
return(resizable);
}
/*************************************************************************/
/**
* Sets the resizability of this frame to the specified value.
*
@ -383,8 +349,6 @@ setResizable(boolean resizable)
((FramePeer) peer).setResizable(resizable);
}
/*************************************************************************/
/**
* Returns the cursor type of the cursor for this window. This will
* be one of the constants in this class.
@ -399,8 +363,6 @@ getCursorType()
return(getCursor().getType());
}
/*************************************************************************/
/**
* Sets the cursor for this window to the specified type. The specified
* type should be one of the constants in this class.
@ -415,8 +377,6 @@ setCursor(int type)
setCursor(new Cursor(type));
}
/*************************************************************************/
/**
* Removes the specified component from this frame's menu.
*
@ -428,8 +388,6 @@ remove(MenuComponent menu)
menuBar.remove(menu);
}
/*************************************************************************/
/**
* Notifies this frame that it should create its native peer.
*/
@ -450,17 +408,40 @@ public void removeNotify()
super.removeNotify();
}
/*************************************************************************/
/**
* Returns a debugging string describing this window.
*
* @return A debugging string describing this window.
*/
protected String
paramString()
protected String paramString ()
{
return(getClass().getName());
String title = getTitle ();
String resizable = "";
if (isResizable ())
resizable = ",resizable";
String state = "";
switch (getState ())
{
case NORMAL:
state = ",normal";
break;
case ICONIFIED:
state = ",iconified";
break;
case MAXIMIZED_BOTH:
state = ",maximized-both";
break;
case MAXIMIZED_HORIZ:
state = ",maximized-horiz";
break;
case MAXIMIZED_VERT:
state = ",maximized-vert";
break;
}
return super.paramString () + ",title=" + title + resizable + state;
}
public static Frame[]
@ -553,5 +534,19 @@ getFrames()
this.undecorated = undecorated;
}
} // class Frame
/**
* Generate a unique name for this frame.
*
* @return A unique name for this frame.
*/
String generateName ()
{
return "frame" + getUniqueLong ();
}
private static synchronized long getUniqueLong ()
{
return next_frame_number++;
}
}

View file

@ -340,7 +340,7 @@ public class GridBagLayout
if (components.length == 0)
return;
GridBagLayoutInfo info = getLayoutInfo (parent, MINSIZE);
GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
if (info.cols == 0 && info.rows == 0)
return;
layoutInfo = info;

View file

@ -246,7 +246,10 @@ public abstract class KeyboardFocusManager
*/
public Component getFocusOwner ()
{
return (Component) getObject (currentFocusOwners);
Component owner = (Component) getObject (currentFocusOwners);
if (owner == null)
owner = (Component) getObject (currentPermanentFocusOwners);
return owner;
}
/**

View file

@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt;
import java.awt.event.PaintEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@ -62,6 +63,19 @@ public class Panel extends Container implements Accessible
/** The cached accessible context. */
private transient AccessibleContext context;
/** Flag set when the first system-requested paint event is
dispatched. */
private transient boolean initialSystemUpdateDone;
/** Flag set when the first application-requested paint event is
consumed. */
private transient boolean initialUpdateConsumed;
/*
* The number used to generate the name returned by getName.
*/
private static transient long next_panel_number = 0;
/**
* Initializes a new instance of <code>Panel</code> that has a default
* layout manager of <code>FlowLayout</code>.
@ -83,6 +97,36 @@ public class Panel extends Container implements Accessible
setLayout(layoutManager);
}
/**
* Consume initial application-requested paint event if it has not
* already been consumed, and if the initial system-requested paint
* event has not already been handled. Otherwise, call
* super.dispatchEventImpl. These extra steps are required to
* prevent a Panel from being painted twice when it is initially
* shown.
*
* @param e the event to dispatch
*/
void dispatchEventImpl (AWTEvent e)
{
if (e instanceof PaintEvent)
{
if (e.id == PaintEvent.UPDATE)
{
if (!initialUpdateConsumed
&& !initialSystemUpdateDone)
{
e.consume ();
initialUpdateConsumed = true;
}
}
else if (e.id == PaintEvent.PAINT)
initialSystemUpdateDone = true;
}
else
super.dispatchEventImpl (e);
}
/**
* Notifies this object to create its native peer.
*
@ -141,5 +185,20 @@ public class Panel extends Container implements Accessible
{
return AccessibleRole.PANEL;
}
} // class AccessibleAWTPanel
} // class Panel
}
/**
* Generate a unique name for this panel.
*
* @return A unique name for this panel.
*/
String generateName ()
{
return "panel" + getUniqueLong ();
}
private static synchronized long getUniqueLong ()
{
return next_panel_number++;
}
}

View file

@ -157,6 +157,9 @@ ScrollPane(int scrollbarDisplayPolicy)
}
wheelScrollingEnabled = true;
// Default size.
setSize(100,100);
}
/*************************************************************************/
@ -400,6 +403,15 @@ addNotify()
setPeer((ComponentPeer)getToolkit().createScrollPane(this));
super.addNotify();
Component[] list = getComponents();
if (list != null && list.length > 0 && ! (list[0] instanceof Panel))
{
Panel panel = new Panel();
panel.setLayout(new BorderLayout());
panel.add(list[0], BorderLayout.CENTER);
add(panel);
}
}
/*************************************************************************/
@ -527,7 +539,19 @@ printComponents(Graphics graphics)
public String
paramString()
{
return(getClass().getName());
Insets insets = getInsets();
return getName() + ","
+ getX() + ","
+ getY() + ","
+ getWidth() + "x" + getHeight() + ","
+ "ScrollPosition=(" + scrollPosition.getX() + ","
+ scrollPosition.getY() + "),"
+ "Insets=(" + insets.top + ","
+ insets.left + ","
+ insets.bottom + ","
+ insets.right + "),"
+ "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + ","
+ "wheelScrollingEnabled=" + isWheelScrollingEnabled();
}
/**

View file

@ -39,6 +39,8 @@ exception statement from your version. */
package java.awt;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.awt.event.WindowListener;
@ -85,6 +87,8 @@ public class Window extends Container implements Accessible
private transient boolean shown;
private transient Component windowFocusOwner;
/**
* This (package access) constructor is used by subclasses that want
* to build windows that do not have parents. Eg. toplevel
@ -98,6 +102,33 @@ public class Window extends Container implements Accessible
// cycle roots.
focusCycleRoot = true;
setLayout(new BorderLayout());
addWindowFocusListener (new WindowAdapter ()
{
public void windowGainedFocus (WindowEvent event)
{
if (windowFocusOwner != null)
{
// FIXME: move this section and the other similar
// sections in Component into a separate method.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
synchronized (eq)
{
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
if (currentFocusOwner != null)
{
eq.postEvent (new FocusEvent (currentFocusOwner, FocusEvent.FOCUS_LOST,
false, windowFocusOwner));
eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED,
false, currentFocusOwner));
}
else
eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED, false));
}
}
}
});
}
Window(GraphicsConfiguration gc)
@ -658,8 +689,22 @@ public class Window extends Container implements Accessible
// The currently-focused Component belongs to the active Window.
if (activeWindow == this)
return manager.getFocusOwner ();
else
return windowFocusOwner;
}
return null;
/**
* Set the focus owner for this window. This method is used to
* remember which component was focused when this window lost
* top-level focus, so that when it regains top-level focus the same
* child component can be refocused.
*
* @param windowFocusOwner the component in this window that owns
* the focus.
*/
void setFocusOwner (Component windowFocusOwner)
{
this.windowFocusOwner = windowFocusOwner;
}
/**
@ -671,8 +716,7 @@ public class Window extends Container implements Accessible
*/
public boolean postEvent(Event e)
{
// FIXME
return false;
return handleEvent (e);
}
/**

View file

@ -47,6 +47,8 @@ import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.util.Hashtable;
import java.util.Vector;
import java.util.HashSet;
import java.util.Iterator;
import gnu.java.awt.ComponentDataBlitOp;
/**
@ -442,7 +444,57 @@ public class BufferedImage extends Image
public ImageProducer getSource()
{
throw new UnsupportedOperationException("not implemented");
return new ImageProducer() {
HashSet consumers = new HashSet();
public void addConsumer(ImageConsumer ic)
{
consumers.add(ic);
}
public boolean isConsumer(ImageConsumer ic)
{
return consumers.contains(ic);
}
public void removeConsumer(ImageConsumer ic)
{
consumers.remove(ic);
}
public void startProduction(ImageConsumer ic)
{
int x = 0;
int y = 0;
int width = getWidth();
int height = getHeight();
int stride = width;
int offset = 0;
int[] pixels = getRGB(x, y,
width, height,
(int[])null, offset, stride);
ColorModel model = getColorModel();
consumers.add(ic);
Iterator i = consumers.iterator();
while(i.hasNext())
{
ImageConsumer c = (ImageConsumer) i.next();
c.setHints(ImageConsumer.SINGLEPASS);
c.setDimensions(getWidth(), getHeight());
c.setPixels(x, y, width, height, model, pixels, offset, stride);
c.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
}
public void requestTopDownLeftRightResend(ImageConsumer ic)
{
startProduction(ic);
}
};
}
public Vector getSources()

View file

@ -0,0 +1,162 @@
/* ByteLookupTable.java -- Java class for a pixel translation table.
Copyright (C) 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 java.awt.image;
/**
* ByteLookupTable represents translation arrays for pixel values. It wraps
* one or more data arrays for each layer (or component) in an image, such as
* Alpha, R, G, and B. When doing translation, the offset is subtracted from
* the pixel values to allow a subset of an array to be used.
*
* @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
* @version 1.0
*/
public class ByteLookupTable extends LookupTable
{
// Array of translation tables.
private byte data[][];
/**
* Creates a new <code>ByteLookupTable</code> instance.
*
* Offset is subtracted from pixel values when looking up in the translation
* tables. If data.length is one, the same table is applied to all pixel
* components.
*
* @param offset Offset to be subtracted.
* @param data Array of lookup tables.
* @exception IllegalArgumentException if offset < 0 or data.length < 1.
*/
public ByteLookupTable(int offset, byte[][] data)
throws IllegalArgumentException
{
super(offset, data.length);
this.data = data;
}
/**
* Creates a new <code>ByteLookupTable</code> instance.
*
* Offset is subtracted from pixel values when looking up in the translation
* table. The same table is applied to all pixel components.
*
* @param offset Offset to be subtracted.
* @param data Lookup table for all components.
* @exception IllegalArgumentException if offset < 0.
*/
public ByteLookupTable(int offset, byte[] data)
throws IllegalArgumentException
{
super(offset, 1);
this.data = new byte[][] {data};
}
/** Return the lookup tables. */
public final byte[][] getTable()
{
return data;
}
/**
* Return translated values for a pixel.
*
* For each value in the pixel src, use the value minus offset as an index
* in the component array and copy the value there to the output for the
* component. If dest is null, the output is a new array, otherwise the
* translated values are written to dest. Dest can be the same array as
* src.
*
* For example, if the pixel src is [2, 4, 3], and offset is 1, the output
* is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
* translation arrays.
*
* @param src Component values of a pixel.
* @param dest Destination array for values, or null.
* @return Translated values for the pixel.
*/
public int[] lookupPixel(int[] src, int[] dst)
throws ArrayIndexOutOfBoundsException
{
if (dst == null)
dst = new int[numComponents];
if (data.length == 1)
for (int i=0; i < src.length; i++)
dst[i] = data[0][src[i] - offset];
else
for (int i=0; i < src.length; i++)
dst[i] = data[i][src[i] - offset];
return dst;
}
/**
* Return translated values for a pixel.
*
* For each value in the pixel src, use the value minus offset as an index
* in the component array and copy the value there to the output for the
* component. If dest is null, the output is a new array, otherwise the
* translated values are written to dest. Dest can be the same array as
* src.
*
* For example, if the pixel src is [2, 4, 3], and offset is 1, the output
* is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
* translation arrays.
*
* @param src Component values of a pixel.
* @param dest Destination array for values, or null.
* @return Translated values for the pixel.
*/
public byte[] lookupPixel(byte[] src, byte[] dst)
throws ArrayIndexOutOfBoundsException
{
if (dst == null)
dst = new byte[numComponents];
if (data.length == 1)
for (int i=0; i < src.length; i++)
dst[i] = data[0][((int)src[i]) - offset];
else
for (int i=0; i < src.length; i++)
dst[i] = data[i][((int)src[i]) - offset];
return dst;
}
}

View file

@ -37,6 +37,7 @@ exception statement from your version. */
package java.awt.image;
import java.util.Arrays;
import java.awt.Point;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
@ -551,8 +552,8 @@ public abstract class ColorModel implements Transparency
(transferType == o.transferType) &&
(transparency == o.transparency) &&
(hasAlpha == o.hasAlpha) &&
(isAlphaPremultiplied == isAlphaPremultiplied) &&
(bits.equals(o.bits)) &&
(isAlphaPremultiplied == o.isAlphaPremultiplied) &&
Arrays.equals(bits, o.bits) &&
(cspace.equals(o.cspace));
}

View file

@ -0,0 +1,136 @@
/* Kernel.java -- Java class for an image processing kernel
Copyright (C) 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 java.awt.image;
/**
* Kernel represents an image processing kernel. It gets used to hold
* convolution filters among other purposes. It stores an array of float
* values representing a 2-dimensional array in row-major order.
*
* @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
* @version 1.0
*/
public class Kernel implements Cloneable
{
private final int width;
private final int height;
private final float[] data;
/**
* Creates a new <code>Kernel</code> instance.
*
* @param width The 2D width of data.
* @param height The 2D height of data.
* @param data The source data array.
* @exception IllegalArgumentException if width * height < data.length.
*/
public Kernel(int width, int height, float[] data)
throws IllegalArgumentException
{
this.width = width;
this.height = height;
if (data.length < width * height || width < 0 || height < 0)
throw new IllegalArgumentException();
this.data = new float[width * height];
System.arraycopy(data, 0, this.data, 0, width * height);
}
/**
* Return the X origin: (width - 1) / 2
*/
public final int getXOrigin()
{
return (width - 1) / 2;
}
/**
* Return the Y origin: (height - 1) / 2
*/
public final int getYOrigin()
{
return (height - 1) / 2;
}
/**
* @return The kernel width.
*/
public final int getWidth()
{
return width;
}
/**
* @return The kernel height.
*/
public final int getHeight()
{
return height;
}
/**
* Return the kernel data.
*
* If data is null, allocates a new array and returns it. Otherwise, the
* kernel values are copied into data.
*
* @param data Array to copy values into, or null.
* @return The array with copied values.
* @exception IllegalArgumentException if data != null and too small.
*/
public final float[] getKernelData(float[] data)
throws IllegalArgumentException
{
if (data == null)
return (float[])this.data.clone();
if (data.length < this.data.length)
throw new IllegalArgumentException();
System.arraycopy(this.data, 0, data, 0, this.data.length);
return data;
}
/**
* @return a clone of this Kernel.
*/
public Object clone()
{
return new Kernel(width, height, data);
}
}

View file

@ -0,0 +1,109 @@
/* LookupTable.java -- Java class for a pixel translation table.
Copyright (C) 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 java.awt.image;
/**
* LookupTable represents translation arrays for pixel values. It wraps one
* or more data arrays for each layer (or component) in an image, such as
* Alpha, R, G, and B. When doing translation, the offset is subtracted from
* the pixel values to allow a subset of an array to be used.
*
* @see ByteLookupTable
* @see ShortLookupTable
*
* @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
* @version 1.0
*/
public abstract class LookupTable
{
// Not protected since that's part of the public API.
int offset;
int numComponents;
/**
* Creates a new <code>LookupTable</code> instance.
*
* If numComponents is 1, the same translation table is used for all pixel
* components.
*
* @param offset Offset to be subtracted.
* @param numComponents Number of image components.
* @exception IllegalArgumentException if offset < 0 or numComponents < 1.
*/
protected LookupTable(int offset, int numComponents)
throws IllegalArgumentException
{
if (offset < 0 || numComponents < 1)
throw new IllegalArgumentException();
this.offset = offset;
this.numComponents = numComponents;
}
/** Return the number of components. */
public int getNumComponents()
{
return numComponents;
}
/** Return the offset. */
public int getOffset()
{
return offset;
}
/**
* Return translated values for a pixel.
*
* For each value in the pixel src, use the value minus offset as an index
* in the component array and copy the value there to the output for the
* component. If dest is null, the output is a new array, otherwise the
* translated values are written to dest. Dest can be the same array as
* src.
*
* For example, if the pixel src is [2, 4, 3], and offset is 1, the output
* is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
* translation arrays.
*
* @param src Component values of a pixel.
* @param dest Destination array for values, or null.
* @return Translated values for the pixel.
*/
public abstract int[] lookupPixel(int[] src, int[] dest);
}

View file

@ -41,6 +41,7 @@ package java.awt.image;
import java.awt.Image;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class MemoryImageSource implements ImageProducer
{
@ -49,7 +50,8 @@ public class MemoryImageSource implements ImageProducer
private int pixeli[], width, height, offset, scansize;
private byte pixelb[];
private ColorModel cm;
private Hashtable props, consumers = new Hashtable();
private Hashtable props = new Hashtable();
private Vector consumers = new Vector();
/**
Constructs an ImageProducer from memory
@ -126,10 +128,10 @@ public class MemoryImageSource implements ImageProducer
* <code>ImageProducer</code>.
*/
public synchronized void addConsumer(ImageConsumer ic) {
if (consumers.containsKey(ic))
if (consumers.contains(ic))
return;
consumers.put(ic, ic);
consumers.addElement(ic);
}
/**
@ -137,7 +139,7 @@ public class MemoryImageSource implements ImageProducer
* already registered with this <code>ImageProducer</code>.
*/
public synchronized boolean isConsumer(ImageConsumer ic) {
if (consumers.containsKey(ic))
if (consumers.contains(ic))
return true;
return false;
}
@ -147,7 +149,7 @@ public class MemoryImageSource implements ImageProducer
* registered consumers for this <code>ImageProducer</code>.
*/
public synchronized void removeConsumer(ImageConsumer ic) {
consumers.remove(ic);
consumers.removeElement(ic);
}
/**
@ -157,16 +159,16 @@ public class MemoryImageSource implements ImageProducer
* registered consumers.
*/
public void startProduction(ImageConsumer ic) {
if (!(consumers.containsKey(ic))) {
consumers.put(ic, ic);
if (!(consumers.contains(ic))) {
consumers.addElement(ic);
}
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
sendPicture( ic );
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
Vector list = (Vector) consumers.clone();
for(int i = 0; i < list.size(); i++) {
ic = (ImageConsumer) list.elementAt(i);
sendPicture( ic );
ic.imageComplete( ImageConsumer.STATICIMAGEDONE );
}
}
/**
@ -210,9 +212,9 @@ public class MemoryImageSource implements ImageProducer
{
if( animated == true ) {
ImageConsumer ic;
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
Vector list = (Vector) consumers.clone();
for(int i = 0; i < list.size(); i++) {
ic = (ImageConsumer) list.elementAt(i);
sendPicture( ic );
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
@ -227,6 +229,7 @@ public class MemoryImageSource implements ImageProducer
ic.setProperties( props );
}
ic.setDimensions(width, height);
ic.setColorModel(cm);
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
} else {
@ -249,9 +252,9 @@ public class MemoryImageSource implements ImageProducer
newPixels();
} else {
ImageConsumer ic;
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
Vector list = (Vector) consumers.clone();
for(int i = 0; i < list.size(); i++) {
ic = (ImageConsumer) list.elementAt(i);
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );
@ -294,9 +297,9 @@ public class MemoryImageSource implements ImageProducer
newPixels();
} else {
ImageConsumer ic;
Enumeration e = consumers.elements();
for( ; e.hasMoreElements(); ) {
ic = (ImageConsumer)e.nextElement();
Vector list = (Vector) consumers.clone();
for(int i = 0; i < list.size(); i++) {
ic = (ImageConsumer) list.elementAt(i);
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );

View file

@ -79,6 +79,10 @@ public abstract class RGBImageFilter extends ImageFilter
if( ( model instanceof IndexColorModel) && canFilterIndexColorModel ) {
newmodel = filterIndexColorModel( (IndexColorModel) model );
consumer.setColorModel(newmodel);
}
else {
consumer.setColorModel(ColorModel.getRGBdefault());
}
}

View file

@ -0,0 +1,162 @@
/* ShortLookupTable.java -- Java class for a pixel translation table.
Copyright (C) 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 java.awt.image;
/**
* ShortLookupTable represents translation arrays for pixel values. It wraps
* one or more data arrays for each layer (or component) in an image, such as
* Alpha, R, G, and B. When doing translation, the offset is subtracted from
* the pixel values to allow a subset of an array to be used.
*
* @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
* @version 1.0
*/
public class ShortLookupTable extends LookupTable
{
// Array of translation tables.
private short data[][];
/**
* Creates a new <code>ShortLookupTable</code> instance.
*
* Offset is subtracted from pixel values when looking up in the translation
* tables. If data.length is one, the same table is applied to all pixel
* components.
*
* @param offset Offset to be subtracted.
* @param data Array of lookup tables.
* @exception IllegalArgumentException if offset < 0 or data.length < 1.
*/
public ShortLookupTable(int offset, short[][] data)
throws IllegalArgumentException
{
super(offset, data.length);
this.data = data;
}
/**
* Creates a new <code>ShortLookupTable</code> instance.
*
* Offset is subtracted from pixel values when looking up in the translation
* table. The same table is applied to all pixel components.
*
* @param offset Offset to be subtracted.
* @param data Lookup table for all components.
* @exception IllegalArgumentException if offset < 0.
*/
public ShortLookupTable(int offset, short[] data)
throws IllegalArgumentException
{
super(offset, 1);
this.data = new short[][] {data};
}
/** Return the lookup tables. */
public final short[][] getTable()
{
return data;
}
/**
* Return translated values for a pixel.
*
* For each value in the pixel src, use the value minus offset as an index
* in the component array and copy the value there to the output for the
* component. If dest is null, the output is a new array, otherwise the
* translated values are written to dest. Dest can be the same array as
* src.
*
* For example, if the pixel src is [2, 4, 3], and offset is 1, the output
* is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
* translation arrays.
*
* @param src Component values of a pixel.
* @param dest Destination array for values, or null.
* @return Translated values for the pixel.
*/
public int[] lookupPixel(int[] src, int[] dst)
throws ArrayIndexOutOfBoundsException
{
if (dst == null)
dst = new int[numComponents];
if (data.length == 1)
for (int i=0; i < src.length; i++)
dst[i] = data[0][src[i] - offset];
else
for (int i=0; i < src.length; i++)
dst[i] = data[i][src[i] - offset];
return dst;
}
/**
* Return translated values for a pixel.
*
* For each value in the pixel src, use the value minus offset as an index
* in the component array and copy the value there to the output for the
* component. If dest is null, the output is a new array, otherwise the
* translated values are written to dest. Dest can be the same array as
* src.
*
* For example, if the pixel src is [2, 4, 3], and offset is 1, the output
* is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
* translation arrays.
*
* @param src Component values of a pixel.
* @param dest Destination array for values, or null.
* @return Translated values for the pixel.
*/
public short[] lookupPixel(short[] src, short[] dst)
throws ArrayIndexOutOfBoundsException
{
if (dst == null)
dst = new short[numComponents];
if (data.length == 1)
for (int i=0; i < src.length; i++)
dst[i] = data[0][((int)src[i]) - offset];
else
for (int i=0; i < src.length; i++)
dst[i] = data[i][((int)src[i]) - offset];
return dst;
}
}

View file

@ -163,19 +163,19 @@ public abstract class AbstractButton extends JComponent
Icon pressed_icon;
/** The icon displayed when the button is disabled. */
Icon disabled_icon;
Icon disabeldIcon;
/** The icon displayed when the button is selected. */
Icon selected_icon;
Icon selectedIcon;
/** The icon displayed when the button is selected but disabled. */
Icon disabled_selected_icon;
Icon disabledSelectedIcon;
/** The icon displayed when the button is rolled over. */
Icon rollover_icon;
Icon rolloverIcon;
/** The icon displayed when the button is selected and rolled over. */
Icon rollover_selected_icon;
Icon rolloverSelectedIcon;
/** The icon currently displayed. */
Icon current_icon;
@ -183,26 +183,32 @@ public abstract class AbstractButton extends JComponent
/** The text displayed in the button. */
String text;
/** The gap between icon and text, if both icon and text are non-<code>null</code>. */
int iconTextGap;
/** The vertical alignment of the button's text and icon. */
int vert_align;
int verticalAlignment;
/** The horizontal alignment of the button's text and icon. */
int hori_align;
int horizontalAlignment;
/** The horizontal position of the button's text relative to its icon. */
int hori_text_pos;
int horizontalTextPosition;
/** The vertical position of the button's text relative to its icon. */
int vert_text_pos;
int verticalTextPosition;
/** Whether or not the button paints its border. */
boolean paint_border;
boolean borderPainted;
/** Whether or not the button paints its focus state. */
boolean paint_focus;
boolean focusPainted;
/** Whether or not the button fills its content area. */
boolean content_area_filled;
boolean contentAreaFilled;
/** Whether rollover is enabled. */
boolean rollOverEnabled;
/** The action taken when the button is clicked. */
Action action;
@ -230,6 +236,9 @@ public abstract class AbstractButton extends JComponent
Action. */
PropertyChangeListener actionPropertyChangeListener;
/** ChangeEvent that is fired to button's ChangeEventListeners */
private ChangeEvent changeEvent = new ChangeEvent(this);
/** Fired in a PropertyChangeEvent when the "borderPainted" property changes. */
public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted";
@ -533,17 +542,20 @@ public abstract class AbstractButton extends JComponent
model.addChangeListener(changeListener);
model.addItemListener(itemListener);
hori_align = CENTER;
hori_text_pos = TRAILING;
vert_align = CENTER;
vert_text_pos = CENTER;
paint_border = true;
content_area_filled = true;
horizontalAlignment = CENTER;
horizontalTextPosition = TRAILING;
verticalAlignment = CENTER;
verticalTextPosition = CENTER;
borderPainted = true;
contentAreaFilled = true;
iconTextGap = 4;
setAlignmentX(LEFT_ALIGNMENT);
setAlignmentY(CENTER_ALIGNMENT);
addFocusListener(new ButtonFocusListener());
setDisplayedMnemonicIndex(-1);
}
/**
@ -642,6 +654,7 @@ public abstract class AbstractButton extends JComponent
*/
public void fireItemStateChanged(ItemEvent e)
{
e.setSource(this);
EventListener[] ll = listenerList.getListeners(ItemListener.class);
for (int i = 0; i < ll.length; i++)
((ItemListener)ll[i]).itemStateChanged(e);
@ -655,6 +668,7 @@ public abstract class AbstractButton extends JComponent
*/
public void fireActionPerformed(ActionEvent e)
{
e.setSource(this);
EventListener[] ll = listenerList.getListeners(ActionListener.class);
for (int i = 0; i < ll.length; i++)
((ActionListener)ll[i]).actionPerformed(e);
@ -671,7 +685,7 @@ public abstract class AbstractButton extends JComponent
{
EventListener[] ll = listenerList.getListeners(ChangeListener.class);
for (int i = 0; i < ll.length; i++)
((ChangeListener)ll[i]).stateChanged(e);
((ChangeListener)ll[i]).stateChanged(changeEvent);
}
/**
@ -699,14 +713,7 @@ public abstract class AbstractButton extends JComponent
*/
public void setMnemonic(char mne)
{
int old = getModel().getMnemonic();
getModel().setMnemonic(mne);
if (old != getModel().getMnemonic())
{
firePropertyChange(MNEMONIC_CHANGED_PROPERTY, old, (int) mne);
revalidate();
repaint();
}
setMnemonic((int) mne);
}
/**
@ -720,10 +727,23 @@ public abstract class AbstractButton extends JComponent
*/
public void setMnemonic(int mne)
{
int old = mne;
getModel().setMnemonic(mne);
if (old != getModel().getMnemonic())
int old = getModel().getMnemonic();
if (old != mne)
{
getModel().setMnemonic(mne);
if (text != null && ! text.equals(""))
{
// Since lower case char = upper case char for
// mnemonic, we will convert both text and mnemonic
// to upper case before checking if mnemonic character occurs
// in the menu item text.
int upperCaseMne = Character.toUpperCase((char) mne);
String upperCaseText = text.toUpperCase();
setDisplayedMnemonicIndex(upperCaseText.indexOf(upperCaseMne));
}
firePropertyChange(MNEMONIC_CHANGED_PROPERTY, old, mne);
revalidate();
repaint();
@ -748,7 +768,7 @@ public abstract class AbstractButton extends JComponent
public void setDisplayedMnemonicIndex(int index)
{
if (index < -1 || index >= text.length())
if (index < -1 || (text != null && index >= text.length()))
throw new IllegalArgumentException();
else
mnemonicIndex = index;
@ -761,7 +781,7 @@ public abstract class AbstractButton extends JComponent
*
* @return An index into the button's "text" property
*/
public int getDisplayedMnemonicIndex(int index)
public int getDisplayedMnemonicIndex()
{
return mnemonicIndex;
}
@ -770,17 +790,16 @@ public abstract class AbstractButton extends JComponent
/**
* Set the "rolloverEnabled" property. When rollover is enabled, and the
* look and feel supports it, the button will change its icon to
* rollover_icon, when the mouse passes over it.
* rolloverIcon, when the mouse passes over it.
*
* @param r Whether or not to enable rollover icon changes
*/
public void setRolloverEnabled(boolean r)
{
boolean old = getModel().isRollover();
getModel().setRollover(r);
if (old != getModel().isRollover())
if (rollOverEnabled != r)
{
firePropertyChange(ROLLOVER_ENABLED_CHANGED_PROPERTY, old, r);
rollOverEnabled = r;
firePropertyChange(ROLLOVER_ENABLED_CHANGED_PROPERTY, !r, r);
revalidate();
repaint();
}
@ -794,7 +813,7 @@ public abstract class AbstractButton extends JComponent
*/
public boolean isRolloverEnabled()
{
return getModel().isRollover();
return rollOverEnabled;
}
/**
@ -842,7 +861,7 @@ public abstract class AbstractButton extends JComponent
*/
public int getHorizontalAlignment()
{
return hori_align;
return horizontalAlignment;
}
/**
@ -858,8 +877,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setHorizontalAlignment(int a)
{
int old = hori_align;
hori_align = a;
int old = horizontalAlignment;
horizontalAlignment = a;
if (old != a)
{
firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a);
@ -879,7 +898,7 @@ public abstract class AbstractButton extends JComponent
*/
public int getHorizontalTextPosition()
{
return hori_text_pos;
return horizontalTextPosition;
}
/**
@ -895,8 +914,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setHorizontalTextPosition(int t)
{
int old = hori_text_pos;
hori_text_pos = t;
int old = horizontalTextPosition;
horizontalTextPosition = t;
if (old != t)
{
firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, old, t);
@ -915,7 +934,7 @@ public abstract class AbstractButton extends JComponent
*/
public int getVerticalAlignment()
{
return vert_align;
return verticalAlignment;
}
/**
@ -930,8 +949,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setVerticalAlignment(int a)
{
int old = vert_align;
vert_align = a;
int old = verticalAlignment;
verticalAlignment = a;
if (old != a)
{
firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a);
@ -951,7 +970,7 @@ public abstract class AbstractButton extends JComponent
*/
public int getVerticalTextPosition()
{
return vert_text_pos;
return verticalTextPosition;
}
/**
@ -967,8 +986,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setVerticalTextPosition(int t)
{
int old = vert_text_pos;
vert_text_pos = t;
int old = verticalTextPosition;
verticalTextPosition = t;
if (old != t)
{
firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, old, t);
@ -986,7 +1005,7 @@ public abstract class AbstractButton extends JComponent
*/
public boolean isBorderPainted()
{
return paint_border;
return borderPainted;
}
/**
@ -998,8 +1017,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setBorderPainted(boolean b)
{
boolean old = paint_border;
paint_border = b;
boolean old = borderPainted;
borderPainted = b;
if (b != old)
{
firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, old, b);
@ -1139,6 +1158,33 @@ public abstract class AbstractButton extends JComponent
}
}
/**
* Set the value of the {@link #iconTextGap} property.
*
* @param i The new value of the property
*/
public void setIconTextGap(int i)
{
int old = iconTextGap;
iconTextGap = i;
if (old != i)
{
fireStateChanged(new ChangeEvent(this));
revalidate();
repaint();
}
}
/**
* Get the value of the {@link #iconTextGap} property.
*
* @return The current value of the property
*/
public int getIconTextGap()
{
return iconTextGap;
}
/**
* Return the button's "margin" property, which is an {@link Insets} object
* describing the distance between the button's border and its text and
@ -1214,11 +1260,11 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getDisabledIcon()
{
if (disabled_icon == null
if (disabeldIcon == null
&& default_icon instanceof ImageIcon)
disabled_icon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) default_icon).getImage()));
disabeldIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) default_icon).getImage()));
return disabled_icon;
return disabeldIcon;
}
/**
@ -1230,9 +1276,9 @@ public abstract class AbstractButton extends JComponent
*
* @param disabledIcon The new "disabledIcon" property
*/
public void setDisabledIcon(Icon disabledIcon)
public void setDisabledIcon(Icon d)
{
disabled_icon = disabledIcon;
disabeldIcon = d;
revalidate();
repaint();
}
@ -1248,7 +1294,7 @@ public abstract class AbstractButton extends JComponent
*/
public boolean isFocusPainted()
{
return paint_focus;
return focusPainted;
}
/**
@ -1260,14 +1306,14 @@ public abstract class AbstractButton extends JComponent
*
* @param b The new "paintFocus" property
*/
public void setFocusPainted(boolean b)
public void setFocusPainted(boolean p)
{
boolean old = paint_focus;
paint_focus = b;
boolean old = focusPainted;
focusPainted = p;
if (old != b)
if (old != focusPainted)
{
firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, old, b);
firePropertyChange(FOCUS_PAINTED_CHANGED_PROPERTY, old, p);
revalidate();
repaint();
}
@ -1391,7 +1437,13 @@ public abstract class AbstractButton extends JComponent
setToolTipText((String)(a.getValue(Action.SHORT_DESCRIPTION)));
if (a.getValue(Action.MNEMONIC_KEY) != null)
setMnemonic(((Integer)(a.getValue(Action.MNEMONIC_KEY))).intValue());
String actionCommand = (String)(a.getValue(Action.ACTION_COMMAND_KEY));
// Set actionCommand to button's text by default if it is not specified
if (actionCommand != null)
setActionCommand((String)(a.getValue(Action.ACTION_COMMAND_KEY)));
else
setActionCommand(getText());
}
}
@ -1416,7 +1468,6 @@ public abstract class AbstractButton extends JComponent
{
public void actionPerformed(ActionEvent e)
{
e.setSource(AbstractButton.this);
AbstractButton.this.fireActionPerformed(e);
}
};
@ -1489,7 +1540,6 @@ public abstract class AbstractButton extends JComponent
public void stateChanged(ChangeEvent e)
{
AbstractButton.this.fireStateChanged(e);
AbstractButton.this.revalidate();
AbstractButton.this.repaint();
}
};
@ -1569,7 +1619,7 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getDisabledSelectedIcon()
{
return disabled_selected_icon;
return disabledSelectedIcon;
}
/**
@ -1583,8 +1633,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
{
Icon old = disabled_selected_icon;
disabled_selected_icon = disabledSelectedIcon;
Icon old = disabledSelectedIcon;
disabledSelectedIcon = disabledSelectedIcon;
if (old != disabledSelectedIcon)
{
firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, old,
@ -1604,7 +1654,7 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getRolloverIcon()
{
return rollover_icon;
return rolloverIcon;
}
/**
@ -1614,10 +1664,10 @@ public abstract class AbstractButton extends JComponent
*
* @param rolloverIcon The new rollover icon
*/
public void setRolloverIcon(Icon rolloverIcon)
public void setRolloverIcon(Icon r)
{
Icon old = rollover_icon;
rollover_icon = rolloverIcon;
Icon old = rolloverIcon;
rolloverIcon = r;
if (old != rolloverIcon)
{
firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, old,
@ -1637,7 +1687,7 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getRolloverSelectedIcon()
{
return rollover_selected_icon;
return rolloverSelectedIcon;
}
/**
@ -1648,10 +1698,10 @@ public abstract class AbstractButton extends JComponent
*
* @param rolloverSelectedIcon The new rollover selected icon
*/
public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
public void setRolloverSelectedIcon(Icon r)
{
Icon old = rollover_selected_icon;
rollover_selected_icon = rolloverSelectedIcon;
Icon old = rolloverSelectedIcon;
rolloverSelectedIcon = r;
if (old != rolloverSelectedIcon)
{
firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, old,
@ -1673,7 +1723,7 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getSelectedIcon()
{
return selected_icon;
return selectedIcon;
}
/**
@ -1685,10 +1735,10 @@ public abstract class AbstractButton extends JComponent
*
* @param selectedIcon The new selected icon
*/
public void setSelectedIcon(Icon selectedIcon)
public void setSelectedIcon(Icon s)
{
Icon old = selected_icon;
selected_icon = selectedIcon;
Icon old = selectedIcon;
selectedIcon = s;
if (old != selectedIcon)
{
firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, old,
@ -1750,7 +1800,7 @@ public abstract class AbstractButton extends JComponent
*/
public boolean isContentAreaFilled()
{
return content_area_filled;
return contentAreaFilled;
}
/**
@ -1764,8 +1814,8 @@ public abstract class AbstractButton extends JComponent
*/
public void setContentAreaFilled(boolean b)
{
boolean old = content_area_filled;
content_area_filled = b;
boolean old = contentAreaFilled;
contentAreaFilled = b;
if (b != old)
{
firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b);

View file

@ -48,18 +48,15 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* ActionMap
* @author Andrew Selkirk
* @version 1.0
*/
public class ActionMap implements Serializable
{
static final long serialVersionUID = -6277518704513986346L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* @author Andrew Selkirk
* @author Michael Koch
*/
public class ActionMap
implements Serializable
{
private static final long serialVersionUID = -6277518704513986346L;
/**
* actionMap
@ -69,170 +66,146 @@ public class ActionMap implements Serializable
/**
* parent
*/
private ActionMap parent = null;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
private ActionMap parent;
/**
* Constructor ActionMap
* Creates a new <code>ActionMap</code> instance.
*/
public ActionMap() {
} // ActionMap()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
public ActionMap()
{
}
/**
* get
* @param key TODO
* @returns Action
* Returns an action associated with an object.
*
* @param key the key of the enty
*
* @return the action associated with key, may be null
*/
public Action get(Object key) {
public Action get(Object key)
{
Object result = actionMap.get(key);
// Variables
Object result;
// Check Local store
result = actionMap.get(key);
// Check Parent
if (result == null) {
if (result == null)
result = parent.get(key);
} // if
return (Action) result;
} // get()
}
/**
* put
* @param key TODO
* @param action TODO
* Puts a new <code>Action</code> into the <code>ActionMap</code>.
* If action is null an existing entry will be removed.
*
* @param key the key for the entry
* @param action the action.
*/
public void put(Object key, Action action) {
if (action == null) {
public void put(Object key, Action action)
{
if (action == null)
actionMap.remove(key);
} else {
else
actionMap.put(key, action);
} // if
} // put()
}
/**
* remove
* @param key TODO
* Remove an entry from the <code>ActionMap</code>.
*
* @param key the key of the entry to remove
*/
public void remove(Object key) {
public void remove(Object key)
{
actionMap.remove(key);
} // remove()
}
/**
* getParent
* @returns ActionMap
* Returns the parent of this <code>ActionMap</code>.
*
* @return the parent, may be null.
*/
public ActionMap getParent() {
public ActionMap getParent()
{
return parent;
} // getParent()
}
/**
* setParent
* @param parentMap TODO
* Sets a parent for this <code>ActionMap</code>.
*
* @param parentMap the new parent
*/
public void setParent(ActionMap parentMap) {
public void setParent(ActionMap parentMap)
{
parent = parentMap;
} // setParent()
}
/**
* size
* @returns int
* Returns the number of entries in this <code>ActionMap</code>.
*
* @return the number of entries
*/
public int size() {
public int size()
{
return actionMap.size();
} // size()
}
/**
* clear
* Clears the <code>ActionMap</code>.
*/
public void clear() {
public void clear()
{
actionMap.clear();
} // clear()
}
/**
* keys
* @returns Object[]
* Returns all keys of entries in this <code>ActionMap</code>.
*
* @return an array of keys
*/
public Object[] keys() {
return convertSet(actionMap.keySet());
} // keys()
public Object[] keys()
{
return actionMap.keySet().toArray();
}
/**
* allKeys
* @returns Object[]
* Returns all keys of entries in this <code>ActionMap</code>
* and all its parents.
*
* @return an array of keys
*/
public Object[] allKeys() {
public Object[] allKeys()
{
Set set = new HashSet();
// Variables
Set set;
// Initialize
set = new HashSet();
// Get Key Sets
if (parent != null) {
if (parent != null)
set.addAll(Arrays.asList(parent.allKeys()));
} // if
set.addAll(actionMap.keySet());
return convertSet(set);
} // allKeys()
private Object[] convertSet(Set set) {
// Variables
int index;
Iterator iterator;
Object[] keys;
// Create Final array
keys = new Object[set.size()];
iterator = set.iterator();
index = 0;
while (iterator.hasNext()) {
keys[index++] = iterator.next();
} // while
return keys;
} // convertSet()
//-------------------------------------------------------------
// Interface: Serializable ------------------------------------
//-------------------------------------------------------------
set.addAll(actionMap.keySet());
return set.toArray();
}
/**
* writeObject
* @param stream TODO
* @exception IOException TODO
*
* @param stream the stream to write to
*
* @exception IOException If an error occurs
*/
private void writeObject(ObjectOutputStream value0) throws IOException {
private void writeObject(ObjectOutputStream stream)
throws IOException
{
// TODO
} // writeObject()
}
/**
* readObject
* @param stream TODO
* @exception ClassNotFoundException TODO
* @exception IOException TODO
*
* @param stream the stream to read from
*
* @exception ClassNotFoundException If the serialized class cannot be found
* @exception IOException If an error occurs
*/
private void readObject(ObjectInputStream value0) throws ClassNotFoundException, IOException {
private void readObject(ObjectInputStream stream)
throws ClassNotFoundException, IOException
{
// TODO
} // readObject()
} // ActionMap
}
}

View file

@ -1,5 +1,5 @@
/* ComponentInputMap.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -37,79 +37,94 @@ exception statement from your version. */
package javax.swing;
/**
* ComponentInputMap
* @author Andrew Selkirk
* @version 1.0
* @author Michael Koch
*/
public class ComponentInputMap extends InputMap {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
public class ComponentInputMap extends InputMap
{
/**
* component
* The component to notify.
*/
private JComponent component;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor ComponentInputMap
* @param value0 TODO
*/
public ComponentInputMap(JComponent value0) {
// TODO
} // ComponentInputMap()
* Creates <code>ComponentInputMap</code> object that notifies the given
* component about changes to it.
*
* @param comp the component to notify
*
* @exception IllegalArgumentException if comp is null
*/
public ComponentInputMap(JComponent comp)
{
if (comp == null)
throw new IllegalArgumentException();
this.component = comp;
}
/**
* Puts a new entry into the <code>InputMap</code>.
* If actionMapKey is null an existing entry will be removed.
*
* @param keystroke the keystroke for the entry
* @param actionMapKey the action.
*/
public void put(KeyStroke keystroke, Object value)
{
super.put(keystroke, value);
// FIXME: Notify component.
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Clears the <code>InputMap</code>.
*/
public void clear()
{
super.clear();
// FIXME: Notify component.
}
/**
* put
* @param keystroke TODO
* @param value TODO
*/
public void put(KeyStroke keystroke, Object value) {
// TODO
} // put()
/**
* Remove an entry from the <code>InputMap</code>.
*
* @param key the key of the entry to remove
*/
public void remove(KeyStroke keystroke)
{
super.remove(keystroke);
// FIXME: Notify component.
}
/**
* clear
*/
public void clear() {
// TODO
} // clear()
/**
* Sets a parent for this <code>ComponentInputMap</code>.
*
* @param parentMap the new parent
*
* @exception IllegalArgument if parentMap is not a
* <code>ComponentInputMap</code> or not associated with the same component
*/
public void setParent(InputMap parentMap)
{
if (! (parentMap instanceof ComponentInputMap))
throw new IllegalArgumentException();
/**
* remove
* @param keystroke TODO
*/
public void remove(KeyStroke keystroke) {
// TODO
} // remove()
if (((ComponentInputMap) parentMap).getComponent() != component)
throw new IllegalArgumentException();
super.setParent(parentMap);
// FIXME: Notify component.
}
/**
* setParent
* @param parent TODO
*/
public void setParent(InputMap parent) {
// TODO
} // setParent()
/**
* getComponent
* @returns JComponent
*/
public JComponent getComponent() {
return null; // TODO
} // getComponent()
} // ComponentInputMap
/**
* Returns the component to notify about changes.
*
* @return a <code>JComponent</code> object
*/
public JComponent getComponent()
{
return component;
}
}

View file

@ -436,7 +436,6 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
int newWidth, int newHeight)
{
dragCache.setBounds(newX, newY, newWidth, newHeight);
dragCache = findMinimum(dragCache, component);
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
@ -628,27 +627,4 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
{
return frame.getWasIcon();
} // wasIcon()
/**
* This is a helper method that determines the minimum size a
* JInternalFrame can be resized to.
*
* @param r The desired size.
* @param c The JComponent to find a minimum size for.
*
* @return The minimum size a JInternalFrame can be resized to.
*/
private Rectangle findMinimum(Rectangle r, JComponent c)
{
if (r != null && c != null)
{
Dimension d = c.getPreferredSize();
if (d != null)
{
r.width = Math.max(d.width, r.width);
r.height = Math.max(d.height, r.height);
}
}
return r;
}
} // DefaultDesktopManager

View file

@ -41,6 +41,7 @@ import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.image.ImageObserver;
import java.io.Serializable;
import java.net.URL;
@ -50,42 +51,62 @@ public class ImageIcon
{
private static final long serialVersionUID = 532615968316031794L;
Image image;
String file;
String descr;
Component observer;
String description;
ImageObserver observer;
public ImageIcon(String s)
public ImageIcon()
{
// if description is not specified, then file name becomes
// desciption for this icon
this(s, s);
}
public ImageIcon(Image image)
public ImageIcon(String file)
{
this(file, file);
}
public ImageIcon(String file, String description)
{
this(Toolkit.getDefaultToolkit().getImage(file), description);
}
public ImageIcon(byte[] imageData)
{
this(imageData, null);
}
public ImageIcon(byte[] imageData, String description)
{
this(Toolkit.getDefaultToolkit().createImage(imageData), description);
}
public ImageIcon(URL url)
{
image = Toolkit.getDefaultToolkit().getImage(url);
this(url, null);
}
public ImageIcon(String file, String descr)
public ImageIcon(URL url, String description)
{
this.file = file;
this.descr = descr;
image = Toolkit.getDefaultToolkit().getImage(file);
if (image == null)
return;
//loadImage(image);
this(Toolkit.getDefaultToolkit().getImage(url), description);
}
// not in SUN's spec !!!
public void setParent(Component p)
public ImageIcon(Image image)
{
observer = p;
this(image, null);
}
public ImageIcon(Image image, String description)
{
this.image = Toolkit.getDefaultToolkit().createImage(image.getSource());
this.description = description;
}
public ImageObserver getImageObserver()
{
return observer;
}
public void setImageObserver(ImageObserver newObserver)
{
observer = newObserver;
}
public Image getImage()
@ -95,12 +116,12 @@ public class ImageIcon
public String getDescription()
{
return descr;
return description;
}
public void setDescription(String description)
{
this.descr = description;
this.description = description;
}
public int getIconHeight()
@ -115,6 +136,6 @@ public class ImageIcon
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.drawImage(image, x, y, observer);
g.drawImage(image, x, y, observer != null ? observer : c);
}
}

View file

@ -1,5 +1,5 @@
/* InputMap.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -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.io.IOException;
@ -43,24 +42,23 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Iterator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* InputMap
* @author Andrew Selkirk
* @version 1.0
*/
public class InputMap implements Serializable
{
static final long serialVersionUID = -5429059542008604257L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* @author Andrew Selkirk
* @author Michael Koch
*
* @since 1.3
*/
public class InputMap
implements Serializable
{
private static final long serialVersionUID = -5429059542008604257L;
/**
* inputMap
@ -70,171 +68,147 @@ public class InputMap implements Serializable
/**
* parent
*/
private InputMap parent = null;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
private InputMap parent;
/**
* Constructor InputMap
* Creates a new <code>InputMap</code> instance.
*/
public InputMap() {
public InputMap()
{
// TODO
} // InputMap()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
}
/**
* get
* @param value0 TODO
* @returns Object
* Returns the binding for keystroke.
*
* @param key the key of the enty
*
* @return the binding associated with keystroke may be null
*/
public Object get(KeyStroke keystroke) {
public Object get(KeyStroke keystroke)
{
Object result = inputMap.get(keystroke);
// Variables
Object result;
// Check Local store
result = inputMap.get(keystroke);
// Check Parent
if (result == null) {
if (result == null)
result = parent.get(keystroke);
} // if
return result;
} // get()
}
/**
* put
* @param keystroke TODO
* @param actionMapKey TODO
* Puts a new entry into the <code>InputMap</code>.
* If actionMapKey is null an existing entry will be removed.
*
* @param keystroke the keystroke for the entry
* @param actionMapKey the action.
*/
public void put(KeyStroke keystroke, Object actionMapKey) {
if (actionMapKey == null) {
public void put(KeyStroke keystroke, Object actionMapKey)
{
if (actionMapKey == null)
inputMap.remove(keystroke);
} else {
else
inputMap.put(keystroke, actionMapKey);
} // if
} // put()
}
/**
* remove
* @param keystroke TODO
* Remove an entry from the <code>InputMap</code>.
*
* @param key the key of the entry to remove
*/
public void remove(KeyStroke keystroke) {
public void remove(KeyStroke keystroke)
{
inputMap.remove(keystroke);
} // remove()
}
/**
* getParent
* @returns InputMap
* Returns the parent of this <code>InputMap</code>.
*
* @return the parent, may be null.
*/
public InputMap getParent() {
public InputMap getParent()
{
return parent;
} // getParent()
}
/**
* setParent
* @param parentMap TODO
* Sets a parent for this <code>InputMap</code>.
*
* @param parentMap the new parent
*/
public void setParent(InputMap parentMap) {
public void setParent(InputMap parentMap)
{
parent = parentMap;
} // setParent()
}
/**
* size
* @returns int
* Returns the number of entries in this <code>InputMap</code>.
*
* @return the number of entries
*/
public int size() {
public int size()
{
return inputMap.size();
} // size()
}
/**
* clear
* Clears the <code>InputMap</code>.
*/
public void clear() {
public void clear()
{
inputMap.clear();
} // clear()
}
/**
* keys
* @returns KeyStroke[]
* Returns all keys of entries in this <code>InputMap</code>.
*
* @return an array of keys
*/
public KeyStroke[] keys() {
return convertSet(inputMap.keySet());
} // keys()
public KeyStroke[] keys()
{
KeyStroke[] array = new KeyStroke[size()];
return (KeyStroke[]) inputMap.keySet().toArray(array);
}
/**
* allKeys
* @returns KeyStroke[]
* Returns all keys of entries in this <code>InputMap</code>
* and all its parents.
*
* @return an array of keys
*/
public KeyStroke[] allKeys() {
public KeyStroke[] allKeys()
{
Set set = new HashSet();
// Variables
Set set;
// Initialize
set = new HashSet();
// Get Key Sets
if (parent != null) {
if (parent != null)
set.addAll(Arrays.asList(parent.allKeys()));
} // if
set.addAll(inputMap.keySet());
return convertSet(set);
} // allKeys()
private KeyStroke[] convertSet(Set set) {
// Variables
int index;
Iterator iterator;
KeyStroke[] keys;
// Create Final array
keys = new KeyStroke[set.size()];
iterator = set.iterator();
index = 0;
while (iterator.hasNext()) {
keys[index++] = (KeyStroke) iterator.next();
} // while
return keys;
} // convertSet()
//-------------------------------------------------------------
// Interface: Serializable ------------------------------------
//-------------------------------------------------------------
set.addAll(inputMap.keySet());
KeyStroke[] array = new KeyStroke[size()];
return (KeyStroke[]) set.toArray(array);
}
/**
* writeObject
* @param stream TODO
* @exception IOException TODO
*
* @param stream the stream to write to
*
* @exception IOException If an error occurs
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
} // writeObject()
}
/**
* readObject
* @param stream TODO
* @exception ClassNotFoundException TODO
* @exception IOException TODO
*
* @param stream the stream to read from
*
* @exception ClassNotFoundException If the serialized class cannot be found
* @exception IOException If an error occurs
*/
private void readObject(ObjectInputStream stream) throws ClassNotFoundException, IOException {
private void readObject(ObjectInputStream stream)
throws ClassNotFoundException, IOException
{
// TODO
} // readObject()
} // InputMap
}
}

View file

@ -41,17 +41,18 @@ import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.plaf.ButtonUI;
/**
* An instance of JButton can be added to a panel, frame etc
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JButton extends AbstractButton implements Accessible
public class JButton extends AbstractButton
implements Accessible
{
private static final long serialVersionUID = -1907255238954382202L;
boolean def, is_def;
boolean def;
boolean is_def;
public JButton()
{
@ -98,8 +99,7 @@ public class JButton extends AbstractButton implements Accessible
public String getUIClassID()
{
//Returns a string that specifies the name of the Look and Feel
//class that renders this component.
//Returns a string that specifies the name of the L&F class that renders this component.
return "ButtonUI";
}
@ -120,17 +120,23 @@ public class JButton extends AbstractButton implements Accessible
return "JButton";
}
/**
* Overrides JComponent.removeNotify to check if this button is currently
* set as the default button on the RootPane, and if so, sets the RootPane's
* default button to null to ensure the RootPane doesn't hold onto an invalid
* button reference.
*/
public void removeNotify()
{
//Overrides JComponent.removeNotify to check if this button is currently set as the default button on the RootPane, and if so, sets the RootPane's default button to null to ensure the RootPane doesn't hold onto an invalid button reference.
}
public void setDefaultCapable(boolean defaultCapable)
{ def = defaultCapable; }
{
def = defaultCapable;
}
public void updateUI()
{
ButtonUI b = (ButtonUI)UIManager.getUI(this);
setUI(b);
setUI((ButtonUI) UIManager.getUI(this));
}
}

View file

@ -49,44 +49,76 @@ public class JCheckBox extends JToggleButton
{
private static final long serialVersionUID = -5246739313864538930L;
private boolean borderPaintedFlat;
private void init()
{
borderPainted = false;
contentAreaFilled = false;
}
public JCheckBox()
{
this(null, null);
super();
init();
}
public JCheckBox(Action a)
public JCheckBox(Action action)
{
this();
setAction(a);
super(action);
init();
}
public JCheckBox(Icon icon)
{
this(null, icon);
super(icon);
init();
}
public JCheckBox(Icon icon, boolean selected)
{
super(icon, selected);
init();
}
public JCheckBox(String text)
{
this(text, null);
super(text);
init();
}
public JCheckBox(String text, boolean selected)
{
super(text, selected);
init();
}
public JCheckBox(String text, Icon icon)
{
super(text, icon);
paint_border = false;
content_area_filled = false;
init();
}
public JCheckBox(String text, Icon icon, boolean selected)
{
super(text, icon, selected);
init();
}
/**
* Gets the AccessibleContext associated with this JCheckBox.
*/
public AccessibleContext getAccessibleContext()
{
//Gets the AccessibleContext associated with this JCheckBox.
return null;
}
/**
* Returns a string that specifies the name of the L&amp;F class
* that renders this component.
*/
public String getUIClassID()
{
//Returns a string that specifies the name of the Look and Feel
//class that renders this component.
return "CheckBoxUI";
}
@ -94,4 +126,15 @@ public class JCheckBox extends JToggleButton
{
return "JCheckBox";
}
public boolean isBorderPaintedFlat()
{
return borderPaintedFlat;
}
public void setBorderPaintedFlat(boolean newValue)
{
firePropertyChange("borderPaintedFlat", borderPaintedFlat, newValue);
borderPaintedFlat = newValue;
}
}

View file

@ -45,16 +45,28 @@ import javax.accessibility.AccessibleRole;
/**
* DOCUMENT ME!
* This class represents JCheckBoxMenuItem. Its behaviour is very similar
* to JCheckBoxButton. Just like the JCheckBoxButton, user can check and
* uncheck this menu item by clicking on it. Also setSelected()/setState()
* can be use used for the same purpose. JCheckBoxMenuItem uses
* ToggleButtonModel to keep track of its selection.
*/
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
Accessible
{
private static final long serialVersionUID = -6676402307973384715L;
/** name for the UI delegate for this menuItem. */
private static final String uiClassID = "CheckBoxMenuItemUI";
/** Indicates whether this menu item is checked. */
private boolean state;
private Object[] selectedObjects;
/**
* This array contains text of this menu item if this menu item is in
* checked state and null it is not.
*/
private Object[] selectedObjects = new Object[1];
/**
* Creates a new JCheckBoxMenuItem object.
@ -65,9 +77,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* Creates a new JCheckBoxMenuItem object.
* Creates a new JCheckBoxMenuItem with given icon
*
* @param icon DOCUMENT ME!
* @param icon Icon for this menu item
*/
public JCheckBoxMenuItem(Icon icon)
{
@ -75,9 +87,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* Creates a new JCheckBoxMenuItem object.
* Creates a new JCheckBoxMenuItem with given label
*
* @param text DOCUMENT ME!
* @param text Label for this menu item
*/
public JCheckBoxMenuItem(String text)
{
@ -85,9 +97,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* Creates a new JCheckBoxMenuItem object.
* Creates a new JCheckBoxMenuItem using given action
*
* @param action DOCUMENT ME!
* @param action Action for this menu item.
*/
public JCheckBoxMenuItem(Action action)
{
@ -96,10 +108,10 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* Creates a new JCheckBoxMenuItem object.
* Creates a new JCheckBoxMenuItem object with given label and icon
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param text Label for this menu item
* @param icon Icon for this menu item
*/
public JCheckBoxMenuItem(String text, Icon icon)
{
@ -107,10 +119,11 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* Creates a new JCheckBoxMenuItem object.
* Creates a new JCheckBoxMenuItem object using specified label and
* marked as checked if given 'state' is true
*
* @param text DOCUMENT ME!
* @param state DOCUMENT ME!
* @param text Label for this menu item
* @param state True if this item should be in checked state and false otherwise
*/
public JCheckBoxMenuItem(String text, boolean state)
{
@ -118,11 +131,12 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* Creates a new JCheckBoxMenuItem object.
* Creates a new JCheckBoxMenuItem object with given label, icon,
* and marked as checked if given 'state' is true
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param state DOCUMENT ME!
* @param text Label for this menu item
* @param icon icon for this menu item
* @param state True if this item should be in checked state and false otherwise
*/
public JCheckBoxMenuItem(String text, Icon icon, boolean state)
{
@ -131,22 +145,15 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
this.state = state;
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
}
/**
* DOCUMENT ME!
* This method returns a name to identify which look and feel class will be
* the UI delegate for the menuItem.
*
* @return $returnType$ DOCUMENT ME!
* @return The Look and Feel classID. "JCheckBoxMenuItemUI"
*/
public String getUIClassID()
{
@ -154,9 +161,10 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* DOCUMENT ME!
* Returns checked state for this check box menu item.
*
* @return $returnType$ DOCUMENT ME!
* @return Returns true if this menu item is in checked state
* and false otherwise.
*/
public boolean getState()
{
@ -164,9 +172,12 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* DOCUMENT ME!
* Sets state for this check box menu item. If
* given 'state' is true, then mark menu item as checked,
* and uncheck this menu item otherwise.
*
* @param state new state for this menu item
*
* @param state DOCUMENT ME!
*/
public synchronized void setState(boolean state)
{
@ -174,38 +185,43 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
}
/**
* DOCUMENT ME!
* This method returns array containing label of this
* menu item if it is selected and null otherwise.
*
* @return $returnType$ DOCUMENT ME!
* @return Array containing label of this
* menu item if this menu item is selected or null otherwise.
*/
public Object[] getSelectedObjects()
{
if (state == true)
selectedObjects[0] = this.getText();
else
selectedObjects[0] = null;
return selectedObjects;
}
/**
* DOCUMENT ME!
* This method overrides JComponent.requestFocus with an empty
* implementation, since JCheckBoxMenuItems should not
* receve focus in general.
*/
public void requestFocus()
{
// TODO
// Should do nothing here
}
/**
* DOCUMENT ME!
* A string that describes this JCheckBoxMenuItem. Normally only used
* for debugging.
*
* @return $returnType$ DOCUMENT ME!
* @return A string describing this JCheckBoxMenuItem
*/
protected String paramString()
{
return "JCheckBoxMenuItem";
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
@ -214,9 +230,6 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
return accessibleContext;
}
/**
* DOCUMENT ME!
*/
protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
{
private static final long serialVersionUID = 1079958073579370777L;
@ -228,11 +241,6 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
{
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.CHECK_BOX;

View file

@ -1625,6 +1625,7 @@ public abstract class JComponent extends Container implements Serializable
*/
public void revalidate()
{
invalidate();
RepaintManager.currentManager(this).addInvalidComponent(this);
}

View file

@ -39,15 +39,16 @@ package javax.swing;
import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import javax.accessibility.AccessibleContext;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.EditorKit;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainEditorKit;
public class JEditorPane extends JTextComponent
@ -82,12 +83,12 @@ public class JEditorPane extends JTextComponent
protected EditorKit createDefaultEditorKit()
{
return new PlainEditorKit();
return new DefaultEditorKit();
}
protected static EditorKit createEditorKitForContentType(String type)
public static EditorKit createEditorKitForContentType(String type)
{
return new PlainEditorKit();
return new DefaultEditorKit();
}
/**
@ -197,7 +198,8 @@ public class JEditorPane extends JTextComponent
}
/**
* Make sure that TAB and Shift-TAB events get consumed, so that awt doesn't attempt focus traversal.
* Make sure that TAB and Shift-TAB events get consumed,
* so that awt doesn't attempt focus traversal.
*/
protected void processKeyEvent(KeyEvent e)
{
@ -228,16 +230,18 @@ public class JEditorPane extends JTextComponent
}
/**
* Replaces the currently selected content with new content represented by the given string.
* Replaces the currently selected content with new content represented
* by the given string.
*/
public void replaceSelection(String content)
{
}
/**
* Scrolls the view to the given reference location (that is, the value returned by the UL.getRef method for the URL being displayed).
* Scrolls the view to the given reference location (that is, the value
* returned by the UL.getRef method for the URL being displayed).
*/
protected void scrollToReference(String reference)
public void scrollToReference(String reference)
{
}

View file

@ -131,6 +131,8 @@ public class JFormattedTextField extends JTextField
public static final int REVERT = 2;
public static final int PERSIST = 3;
private Object value;
public JFormattedTextField ()
{
throw new InternalError ("not implemented");
@ -158,7 +160,7 @@ public class JFormattedTextField extends JTextField
public JFormattedTextField (Object value)
{
throw new InternalError ("not implemented");
this.value = value;
}
public void commitEdit ()
@ -189,12 +191,12 @@ public class JFormattedTextField extends JTextField
public String getUIClassID ()
{
throw new InternalError ("not implemented");
return "FormattedTextFieldUI";
}
public Object getValue ()
{
throw new InternalError ("not implemented");
return value;
}
protected void invalidEdit ()
@ -212,9 +214,15 @@ public class JFormattedTextField extends JTextField
throw new InternalError ("not implemented");
}
public void setDocument (Document document)
public void setDocument(Document newdoc)
{
throw new InternalError ("not implemented");
Document document = getDocument();
if (document == newdoc)
return;
setDocument(newdoc);
firePropertyChange("document", document, newdoc);
}
public void setLostFocusBehavior (int behavior)
@ -232,8 +240,8 @@ public class JFormattedTextField extends JTextField
throw new InternalError ("not implemented");
}
public void setValue (Object value)
public void setValue (Object newValue)
{
throw new InternalError ("not implemented");
value = newValue;
}
}

View file

@ -994,7 +994,32 @@ public class JList extends JComponent implements Accessible, Scrollable
*/
public Dimension getPreferredScrollableViewportSize()
{
return getPreferredSize();
int vis = getVisibleRowCount();
int nrows = getModel() == null ? 0 : getModel().getSize();
// FIXME: this is a somewhat arbitrary default, but.. ?
Dimension single = new Dimension(10, 10);;
Rectangle bounds = null;
if (vis > nrows)
{
if (fixedCellWidth != -1 &&
fixedCellHeight != -1)
{
single = new Dimension(fixedCellWidth, fixedCellHeight);
}
else if (nrows != 0 && getUI() != null)
{
Rectangle tmp = getUI().getCellBounds(this, 0, 0);
if (tmp != null)
single = tmp.getSize();
}
}
else if (getUI() != null)
{
return getUI().getCellBounds(this, 0, vis - 1).getSize();
}
return new Dimension(single.width, single.height * vis);
}
/**

View file

@ -62,9 +62,19 @@ import javax.swing.plaf.MenuItemUI;
/**
* <p>
* This class represents a menu that can be added to a menu bar or
* to some other menu. When JMenu is selected it displays JPopupMenu
* containing its menu items.
* can be a submenu in some other menu. When JMenu is selected it
* displays JPopupMenu containing its menu items.
* </p>
*
* <p>
* JMenu's fires MenuEvents when this menu's selection changes. If this menu
* is selected, then fireMenuSelectedEvent() is invoked. In case when menu is
* deselected or cancelled, then fireMenuDeselectedEvent() or
* fireMenuCancelledEvent() is invoked, respectivelly.
* </p>
*
*/
public class JMenu extends JMenuItem implements Accessible, MenuElement
{
@ -76,10 +86,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
/** A Popup menu associated with this menu, which pops up when menu is selected */
private JPopupMenu popupMenu = new JPopupMenu();
/** MenuChangeListener that listens to change events occuring in menu's model */
private ChangeListener menuChangeListener;
/** MenuEvent */
/** Whenever menu is selected or deselected the MenuEvent is fired to
menu's registered listeners. */
private MenuEvent menuEvent = new MenuEvent(this);
/*Amount of time, in milliseconds, that should pass before popupMenu
@ -89,7 +97,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
/* PopupListener */
protected WinListener popupListener;
/** Location at which popup menu associated with this menu will be displayed*/
/** Location at which popup menu associated with this menu will be
displayed */
private Point menuLocation;
/**
@ -98,8 +107,6 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public JMenu()
{
super();
menuChangeListener = createMenuChangeListener();
getModel().addChangeListener(menuChangeListener);
}
/**
@ -110,8 +117,6 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public JMenu(String text)
{
super(text);
menuChangeListener = createMenuChangeListener();
getModel().addChangeListener(menuChangeListener);
}
/**
@ -123,8 +128,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
public JMenu(Action action)
{
super(action);
menuChangeListener = createMenuChangeListener();
getModel().addChangeListener(menuChangeListener);
createActionChangeListener(this);
}
/**
@ -335,14 +339,52 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
/**
* Changes this menu selected state if selected is true and false otherwise
* This method fires menuEvents to model's registered listeners.
* This method fires menuEvents to menu's registered listeners.
*
* @param selected true if the menu should be selected and false otherwise
*/
public void setSelected(boolean selected)
{
// if this menu selection is true, then activate this menu and
// display popup associated with this menu
if (selected)
{
super.setArmed(true);
super.setSelected(true);
// FIXME: The popup menu should be shown on the screen after certain
// number of seconds pass. The 'delay' property of this menu indicates
// this amount of seconds. 'delay' property is 0 by default.
if (this.isShowing())
{
fireMenuSelected();
int x = 0;
int y = 0;
if (menuLocation == null)
{
// Calculate correct position of the popup. Note that location of the popup
// passed to show() should be relative to the popup's invoker
if (isTopLevelMenu())
y = this.getHeight();
else
x = this.getWidth();
getPopupMenu().show(this, x, y);
}
else
getPopupMenu().show(this, menuLocation.x, menuLocation.y);
}
}
else
{
super.setSelected(false);
super.setArmed(false);
fireMenuDeselected();
popupMenu.setVisible(false);
}
}
/**
@ -640,17 +682,6 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
((MenuListener) ll[i]).menuCanceled(menuEvent);
}
/**
* Creates MenuChangeListener to listen to change events occuring
* in the model
*
* @return ChangeListener
*/
private ChangeListener createMenuChangeListener()
{
return new MenuChangeListener();
}
/**
* Creates WinListener that listens to the menu;s popup menu.
*
@ -675,34 +706,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
{
// if this menu selection is true, then activate this menu and
// display popup associated with this menu
if (changed)
{
setArmed(true);
fireMenuSelected();
int x = 0;
int y = 0;
if (menuLocation == null)
{
// Calculate correct position of the popup. Note that location of the popup
// passed to show() should be relative to the popup's invoker
if (isTopLevelMenu())
y = this.getHeight();
else
x = this.getWidth();
getPopupMenu().show(this, x, y);
}
else
getPopupMenu().show(this, menuLocation.x, menuLocation.y);
}
else
{
fireMenuDeselected();
popupMenu.setVisible(false);
setArmed(false);
}
setSelected(changed);
}
/**
@ -860,17 +864,6 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
}
}
/** This class listens to ChangeEvent fired by menu's model*/
protected class MenuChangeListener implements ChangeListener
{
/** This method is invoked when there is change in menu's model property */
public void stateChanged(ChangeEvent e)
{
revalidate();
repaint();
}
}
/**
* This class listens to PropertyChangeEvents occuring in menu's action
*/

View file

@ -66,7 +66,15 @@ import javax.swing.plaf.MenuItemUI;
/**
* JMenuBar
* <p>
* JMenuBar is a container for menu's. For a menu bar to be seen on the
* screen, at least one menu should be added to it. Just like adding
* components to container, one can use add() to add menu's to the menu bar.
* Menu's will be displayed in the menu bar in the order they were added.
* The JMenuBar uses selectionModel to keep track of selected menu index.
* JMenuBar's selectionModel will fire ChangeEvents to its registered
* listeners when the selected index changes.
* </p>
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement
{
@ -76,6 +84,8 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
/** Fired in a PropertyChangeEvent when the "model" changes. */
public static final String MODEL_CHANGED_PROPERTY = "model";
/** Fired in a PropertyChangeEvent when the "margin" changes. */
public static final String MARGIN_CHANGED_PROPERTY = "margin";
private static final long serialVersionUID = -8191026883931977036L;
/** JMenuBar's model. It keeps track of selected menu's index */
@ -112,7 +122,8 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* This method overrides addNotify() in the Container to register
* this menu bar with the current keyboard manager.
*/
public void addNotify()
{
@ -216,9 +227,9 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Returns number of menu's in this menu bar
*
* @return DOCUMENT ME!
* @return number of menu's in this menu bar
*/
public int getMenuCount()
{
@ -226,9 +237,12 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* Returns selection model for this menu bar.
* Returns selection model for this menu bar. SelectionModel
* keeps track of the selected menu in the menu bar. Whenever
* selected property of selectionModel changes, the ChangeEvent
* will be fired its ChangeListeners.
*
* @return selection mdoel for this menu bar.
* @return selection model for this menu bar.
*/
public SingleSelectionModel getSelectionModel()
{
@ -319,9 +333,10 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* A string that describes this JMenuBar. Normally only used
* for debugging.
*
* @return DOCUMENT ME!
* @return A string describing this JMenuBar
*/
protected String paramString()
{
@ -329,11 +344,13 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Process key events forwarded from MenuSelectionManager. This method
* doesn't do anything. It is here to conform to the MenuElement interface.
*
* @param event event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
* @param manager MenuSelectionManager for the current menu hierarchy
*
* @param e DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent e, MenuElement[] path,
MenuSelectionManager manager)
@ -342,11 +359,13 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Process mouse events forwarded from MenuSelectionManager. This method
* doesn't do anything. It is here to conform to the MenuElement interface.
*
* @param event event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
* @param manager MenuSelectionManager for the current menu hierarchy
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
@ -355,7 +374,8 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* This method overrides removeNotify() in the Container to
* unregister this menu bar from the current keyboard manager.
*/
public void removeNotify()
{
@ -364,9 +384,10 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Sets painting status of the border. If 'b' is true then menu bar's
* border will be painted, and it will not be painted otherwise.
*
* @param b DOCUMENT ME!
* @param b indicates if menu bar's border should be painted.
*/
public void setBorderPainted(boolean b)
{
@ -381,27 +402,38 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Sets help menu for this menu bar
*
* @param menu DOCUMENT ME!
* @param menu help menu
*/
public void setHelpMenu(JMenu menu)
{
}
/**
* DOCUMENT ME!
* Sets the menu bar's "margin" bound property, which represents
* distance between the menubar's border and its menus.
* icon. When marging property is modified, PropertyChangeEvent will
* be fired to menuBar's PropertyChangeListener's.
*
* @param m distance between the menubar's border and its menus.
*
* @param m DOCUMENT ME!
*/
public void setMargin(Insets m)
{
if (m.equals(this.margin))
{
Insets oldMargin = this.margin;
this.margin = m;
firePropertyChange(MARGIN_CHANGED_PROPERTY, oldMargin, margin);
}
this.margin = m;
}
/**
* Changes menu bar's selection to the specifies menu.
* This method updates selected index of menu bar's model,
* Changes menu bar's selection to the specified menu.
* This method updates selected index of menu bar's selection model,
* which results in a model firing change event.
*
* @param sel menu to select

View file

@ -150,26 +150,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
setMnemonic(mnemonic);
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
* @throws ClassNotFoundException DOCUMENT ME!
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException
{
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
}
@ -186,10 +171,14 @@ public class JMenuItem extends AbstractButton implements Accessible,
// Initializes properties for this menu item, that are different
// from Abstract button properties.
paint_border = false;
paint_focus = false;
hori_align = JButton.LEFT;
hori_text_pos = JButton.LEFT;
/* NOTE: According to java specifications paint_border should be set to false,
since menu item should not have a border. However running few java programs
it seems that menu items and menues can have a border. Commenting
out statement below for now. */
//borderPainted = false;
focusPainted = false;
horizontalAlignment = JButton.LEFT;
horizontalTextPosition = JButton.LEFT;
}
/**
@ -288,9 +277,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
super.configurePropertiesFromAction(action);
if (action == null)
setAccelerator(null);
else
if (! (this instanceof JMenu) && action != null)
setAccelerator((KeyStroke) (action.getValue(Action.ACCELERATOR_KEY)));
}
@ -325,70 +312,76 @@ public class JMenuItem extends AbstractButton implements Accessible,
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// Fire MenuDragMouseEvents if mouse is being dragged.
boolean dragged = (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0;
if (dragged)
processMenuDragMouseEvent(createMenuDragMouseEvent(event, path, manager));
switch (event.getID())
{
case MouseEvent.MOUSE_CLICKED:
break;
case MouseEvent.MOUSE_ENTERED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
if (isRolloverEnabled())
model.setRollover(true);
}
break;
case MouseEvent.MOUSE_EXITED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
if (isRolloverEnabled())
model.setRollover(false);
}
// for JMenu last element on the path is its popupMenu.
// JMenu shouldn't me disarmed.
if (! (path[path.length - 1] instanceof JPopupMenu) && ! dragged)
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:
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!
* Creates MenuDragMouseEvent.
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
* @param event MouseEvent that occured while mouse was pressed.
* @param path Path the the menu element where the dragging event was
* originated
* @param manager MenuSelectionManager for the current menu hierarchy.
*
* @return new MenuDragMouseEvent
*/
private MenuDragMouseEvent createMenuDragMouseEvent(MouseEvent event,
MenuElement[] path,
MenuSelectionManager manager)
{
return new MenuDragMouseEvent((Component) event.getSource(),
event.getID(), event.getWhen(),
event.getModifiers(), event.getX(),
event.getY(), event.getClickCount(),
event.isPopupTrigger(), path, manager);
}
/**
* Process key events forwarded from MenuSelectionManager.
*
* @param event event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
* @param manager MenuSelectionManager for the current menu hierarchy
*/
public void processKeyEvent(KeyEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// TODO
// Need to implement.
}
/**
@ -426,7 +419,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public void processMenuKeyEvent(MenuKeyEvent event)
{
// TODO
// Need to implement.
}
/**
@ -535,9 +528,19 @@ public class JMenuItem extends AbstractButton implements Accessible,
public void menuSelectionChanged(boolean changed)
{
if (changed)
{
model.setArmed(true);
if (this.getParent() instanceof JPopupMenu)
((JPopupMenu) this.getParent()).setSelected(this);
}
else
{
model.setArmed(false);
if (this.getParent() instanceof JPopupMenu)
((JPopupMenu) this.getParent()).getSelectionModel().clearSelection();
}
}
/**
@ -617,11 +620,6 @@ public class JMenuItem extends AbstractButton implements Accessible,
return "JMenuItem";
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)

View file

@ -39,11 +39,15 @@ package javax.swing;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Frame;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.Icon;
import javax.swing.JInternalFrame;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.plaf.OptionPaneUI;
@ -60,6 +64,7 @@ public class JOptionPane extends JComponent implements Accessible
*/
protected class AccessibleJOptionPane extends JComponent.AccessibleJComponent
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 686071432213084821L;
/**
@ -80,6 +85,7 @@ public class JOptionPane extends JComponent implements Accessible
}
}
/** DOCUMENT ME! */
private static final long serialVersionUID = 5231143276678566796L;
/** The value returned when cancel option is selected. */
@ -373,6 +379,8 @@ public class JOptionPane extends JComponent implements Accessible
dialog.getContentPane().add(this);
dialog.setModal(true);
dialog.setResizable(false);
dialog.invalidate();
dialog.repaint();
return dialog;
}
@ -394,8 +402,21 @@ public class JOptionPane extends JComponent implements Accessible
String title)
throws RuntimeException
{
// FIXME: implement.
return null;
JDesktopPane toUse = getDesktopPaneForComponent(parentComponent);
if (toUse == null)
throw new RuntimeException("parentComponent does not have a valid parent");
JInternalFrame frame = new JInternalFrame(title);
inputValue = UNINITIALIZED_VALUE;
value = UNINITIALIZED_VALUE;
frame.setClosable(true);
toUse.add(frame);
// FIXME: JLayeredPane broken? See bug # 16576
// frame.setLayer(JLayeredPane.MODAL_LAYER);
return frame;
}
/**
@ -421,7 +442,8 @@ public class JOptionPane extends JComponent implements Accessible
*/
public static JDesktopPane getDesktopPaneForComponent(Component parentComponent)
{
return (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class, parentComponent);
return (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class,
parentComponent);
}
/**
@ -434,7 +456,8 @@ public class JOptionPane extends JComponent implements Accessible
*/
public static Frame getFrameForComponent(Component parentComponent)
{
return (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parentComponent);
return (Frame) SwingUtilities.getAncestorOfClass(Frame.class,
parentComponent);
}
/**
@ -822,6 +845,7 @@ public class JOptionPane extends JComponent implements Accessible
{
JOptionPane pane = new JOptionPane(message);
JDialog dialog = pane.createDialog(parentComponent, "Select an Option");
dialog.pack();
dialog.show();
@ -1064,123 +1088,171 @@ public class JOptionPane extends JComponent implements Accessible
}
/**
* DOCUMENT ME!
* This method shows an internal confirmation dialog with the given message.
* The internal frame dialog will be placed in the first JDesktopPane
* ancestor of the given parentComponent. This method will return the value
* selected.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param parentComponent The parent to find a JDesktopPane in.
* @param message The message to display.
*
* @return DOCUMENT ME!
* @return The value selected.
*/
public static int showInternalConfirmDialog(Component parentComponent,
Object message)
{
// FIXME: implement
return 0;
JOptionPane pane = new JOptionPane(message);
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
startModal(frame, pane);
return ((Integer) pane.getValue()).intValue();
}
/**
* DOCUMENT ME!
* This method shows an internal confirmation dialog with the given message,
* optionType and title. The internal frame dialog will be placed in the
* first JDesktopPane ancestor of the given parentComponent. This method
* will return the selected value.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param optionType DOCUMENT ME!
* @param parentComponent The parent to find a JDesktopPane in.
* @param message The message to display.
* @param title The title to display.
* @param optionType The option type.
*
* @return DOCUMENT ME!
* @return The selected value.
*/
public static int showInternalConfirmDialog(Component parentComponent,
Object message, String title,
int optionType)
{
// FIXME: implement
return 0;
JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, optionType);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
return ((Integer) pane.getValue()).intValue();
}
/**
* DOCUMENT ME!
* This method shows an internal confirmation dialog with the given message,
* title, optionTypes and icon for the given message type. The internal
* confirmation dialog will be placed in the first instance of
* JDesktopPane ancestor of the given parentComponent.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param optionType DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param parentComponent The component to find a JDesktopPane in.
* @param message The message to display.
* @param title The title of the dialog.
* @param optionType The option type.
* @param messageType The message type.
*
* @return DOCUMENT ME!
* @return The selected value.
*/
public static int showInternalConfirmDialog(Component parentComponent,
Object message, String title,
int optionType, int messageType)
{
// FIXME: implement
return 0;
JOptionPane pane = new JOptionPane(message, messageType, optionType);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
return ((Integer) pane.getValue()).intValue();
}
/**
* DOCUMENT ME!
* This method shows an internal confirmation dialog with the given message,
* title, option type, message type, and icon. The internal frame dialog
* will be placed in the first JDesktopPane ancestor that is found in the
* given parentComponent. This method returns the selected value.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param optionType DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param parentComponent The parent to find a JDesktopPane in.
* @param message The message to display.
* @param title The title to display.
* @param optionType The option type.
* @param messageType The message type.
* @param icon The icon to display.
*
* @return DOCUMENT ME!
* @return The selected value.
*/
public static int showInternalConfirmDialog(Component parentComponent,
Object message, String title,
int optionType, int messageType,
Icon icon)
{
// FIXME: implement
return 0;
JOptionPane pane = new JOptionPane(message, messageType, optionType, icon);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
return ((Integer) pane.getValue()).intValue();
}
/**
* DOCUMENT ME!
* This method shows an internal input dialog with the given message. The
* internal frame dialog will be placed in the first JDesktopPane ancestor
* of the given parent component. This method returns the value input by
* the user.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param parentComponent The parent to find a JDesktopPane in.
* @param message The message to display.
*
* @return DOCUMENT ME!
* @return The user selected value.
*/
public static String showInternalInputDialog(Component parentComponent,
Object message)
{
// FIXME: implement
return null;
JOptionPane pane = new JOptionPane(message);
pane.setWantsInput(true);
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
startModal(frame, pane);
return (String) pane.getInputValue();
}
/**
* DOCUMENT ME!
* This method shows an internal input dialog with the given message, title
* and message type. The internal input dialog will be placed in the first
* JDesktopPane ancestor found in the given parent component. This method
* will return the input value given by the user.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param parentComponent The component to find a JDesktopPane in.
* @param message The message to display.
* @param title The title to display.
* @param messageType The message type.
*
* @return DOCUMENT ME!
* @return The user input value.
*/
public static String showInternalInputDialog(Component parentComponent,
Object message, String title,
int messageType)
{
// FIXME: implement
return null;
JOptionPane pane = new JOptionPane(message, messageType);
pane.setWantsInput(true);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
return (String) pane.getInputValue();
}
/**
* DOCUMENT ME!
* This method shows an internal input dialog with the given message, title
* message type, icon, selection value list and initial selection value.
* The internal frame dialog will be placed in the first JDesktopPane
* ancestor found in the given parent component. This method returns the
* input value from the user.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param selectionValues DOCUMENT ME!
* @param initialSelectionValue DOCUMENT ME!
* @param parentComponent The parent to find a JDesktopPane in.
* @param message The message to display.
* @param title The title to display.
* @param messageType The message type.
* @param icon The icon to display.
* @param selectionValues The selection value list.
* @param initialSelectionValue The initial selection value.
*
* @return DOCUMENT ME!
* @return The user input value.
*/
public static Object showInternalInputDialog(Component parentComponent,
Object message, String title,
@ -1188,66 +1260,94 @@ public class JOptionPane extends JComponent implements Accessible
Object[] selectionValues,
Object initialSelectionValue)
{
// FIXME: implement
return null;
JOptionPane pane = new JOptionPane(message, messageType);
pane.setWantsInput(true);
pane.setIcon(icon);
pane.setSelectionValues(selectionValues);
pane.setInitialSelectionValue(initialSelectionValue);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
return (String) pane.getInputValue();
}
/**
* DOCUMENT ME!
* This method shows an internal message dialog with the given message. The
* internal frame dialog will be placed in the first JDesktopPane ancestor
* found in the given parent component.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param parentComponent The component to find a JDesktopPane in.
* @param message The message to display.
*/
public static void showInternalMessageDialog(Component parentComponent,
Object message)
{
// FIXME: implement
JOptionPane pane = new JOptionPane(message);
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
startModal(frame, pane);
}
/**
* DOCUMENT ME!
* This method shows an internal message dialog with the given message,
* title and message type. The internal message dialog is placed in the
* first JDesktopPane ancestor found in the given parent component.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param parentComponent The parent component to find a JDesktopPane in.
* @param message The message to display.
* @param title The title to display.
* @param messageType The message type.
*/
public static void showInternalMessageDialog(Component parentComponent,
Object message, String title,
int messageType)
{
// FIXME: implement
JOptionPane pane = new JOptionPane(message, messageType);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
}
/**
* DOCUMENT ME!
* This method shows an internal message dialog with the given message,
* title, message type and icon. The internal message dialog is placed in
* the first JDesktopPane ancestor found in the given parent component.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param parentComponent The component to find a JDesktopPane in.
* @param message The message to display.
* @param title The title to display.
* @param messageType The message type.
* @param icon The icon to display.
*/
public static void showInternalMessageDialog(Component parentComponent,
Object message, String title,
int messageType, Icon icon)
{
// FIXME: implement
JOptionPane pane = new JOptionPane(message, messageType);
pane.setIcon(icon);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
}
/**
* DOCUMENT ME!
* This method displays an internal option dialog with the given message,
* title, option type, message type, icon, option list, and initial option
* value. The internal option dialog is placed in the first JDesktopPane
* ancestor found in the parent component. This method returns the option
* selected.
*
* @param parentComponent DOCUMENT ME!
* @param message DOCUMENT ME!
* @param title DOCUMENT ME!
* @param optionType DOCUMENT ME!
* @param messageType DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param options DOCUMENT ME!
* @param initialValue DOCUMENT ME!
* @param parentComponent The parent to find a JDesktopPane in.
* @param message The message displayed.
* @param title The title displayed.
* @param optionType The option type.
* @param messageType The message type.
* @param icon The icon to display.
* @param options The array of options.
* @param initialValue The initial value selected.
*
* @return DOCUMENT ME!
* @return The option that was selected.
*/
public static int showInternalOptionDialog(Component parentComponent,
Object message, String title,
@ -1255,8 +1355,14 @@ public class JOptionPane extends JComponent implements Accessible
Icon icon, Object[] options,
Object initialValue)
{
// FIXME: implement
return 0;
JOptionPane pane = new JOptionPane(message, messageType, optionType, icon,
options, initialValue);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
startModal(frame, pane);
return ((Integer) pane.getValue()).intValue();
}
/**
@ -1338,6 +1444,7 @@ public class JOptionPane extends JComponent implements Accessible
{
JOptionPane pane = new JOptionPane(message, messageType, optionType, icon,
options, initialValue);
JDialog dialog = pane.createDialog(parentComponent, title);
dialog.pack();
dialog.show();
@ -1394,4 +1501,49 @@ public class JOptionPane extends JComponent implements Accessible
}
return false;
}
/**
* This helper method makes the JInternalFrame wait until it is notified by
* an InternalFrameClosing event. This method also adds the given
* JOptionPane to the JInternalFrame and sizes it according to the
* JInternalFrame's preferred size.
*
* @param f The JInternalFrame to make modal.
* @param pane The JOptionPane to add to the JInternalFrame.
*/
private static void startModal(JInternalFrame f, JOptionPane pane)
{
f.getContentPane().add(pane);
f.pack();
f.show();
Dimension pref = f.getPreferredSize();
f.setBounds(0, 0, pref.width, pref.height);
synchronized (f)
{
final JInternalFrame tmp = f;
tmp.toFront();
f.addInternalFrameListener(new InternalFrameAdapter()
{
public void internalFrameClosed(InternalFrameEvent e)
{
synchronized (tmp)
{
tmp.removeInternalFrameListener(this);
tmp.notifyAll();
}
}
});
try
{
while (! f.isClosed())
f.wait();
}
catch (InterruptedException ignored)
{
}
}
}
}

View file

@ -68,7 +68,30 @@ import javax.swing.plaf.PopupMenuUI;
/**
* DOCUMENT ME!
* JPopupMenu is a container that is used to display popup menu's menu
* items. By default JPopupMenu is a lightweight container, however if it
* is the case that JPopupMenu's bounds are outside of main window, then
* heawyweight container will be used to display menu items. It is also
* possible to change JPopupMenu's default behavior and set JPopupMenu
* to always use heavyweight container.
*
* JPopupMenu can be displayed anywhere; it is a floating free popup menu.
* However before JPopupMenu is diplayed, its invoker property should be set.
* JPopupMenu's invoker is a component relative to which popup menu is
* displayed.
*
* JPopupMenu fires PopupMenuEvents to its registered listeners. Whenever
* JPopupMenu becomes visible on the screen then PopupMenuEvent indicating
* that popup menu became visible will be fired. In the case when
* JPopupMenu becomes invisible or cancelled without selection, then
* popupMenuBecomeInvisible() or popupMenuCancelled() methods of
* PopupMenuListeners will be invoked.
*
* JPopupMenu also fires PropertyChangeEvents when its bound properties
* change.In addittion to inheritted bound properties, JPopupMenu has
* 'visible' bound property. When JPopupMenu becomes visible/invisible on
* the screen it fires PropertyChangeEvents to its registered
* PropertyChangeListeners.
*/
public class JPopupMenu extends JComponent implements Accessible, MenuElement
{
@ -77,6 +100,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
/** name for the UI delegate for this menuItem. */
private static final String uiClassID = "PopupMenuUI";
/** Fire a PropertyChangeEvent when the "borderPainted" property changes. */
public static final String LABEL_CHANGED_PROPERTY = "label";
/* indicates if popup's menu border should be painted*/
private boolean borderPainted = true;
@ -98,7 +124,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
/* Component that invokes popup menu. */
transient Component invoker;
/* Label for this popup menu */
/* Label for this popup menu. It is not used in most of the look and feel themes. */
private String label;
/*Amount of space between menuItem's in JPopupMenu and JPopupMenu's border */
@ -130,7 +156,6 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
lightWeightPopupEnabled = DefaultLightWeightPopupEnabled;
selectionModel = new DefaultSingleSelectionModel();
super.setVisible(false);
}
@ -141,29 +166,14 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public JPopupMenu(String label)
{
this.label = label;
setLabel(label);
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
* @throws ClassNotFoundException DOCUMENT ME!
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException
{
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
}
@ -205,7 +215,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public JMenuItem add(Action action)
{
JMenuItem item = new JMenuItem(action);
JMenuItem item = createActionComponent(action);
if (action != null)
action.addPropertyChangeListener(createActionChangeListener(item));
@ -223,7 +233,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
super.remove(index);
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 100.0;
constraints.weighty = 100.0;
@ -258,7 +268,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
public void insert(Component component, int index)
{
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.fill = GridBagConstraints.BOTH;
constraints.weightx = 100.0;
constraints.weighty = 100.0;
@ -385,27 +395,28 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Creates new menu item associated with a given action.
*
* @param action DOCUMENT ME!
* @param action Action used to create new menu item
*
* @return DOCUMENT ME!
* @return new created menu item associated with a given action.
*/
protected JMenuItem createActionComponent(Action action)
{
return null;
return new JMenuItem(action);
}
/**
* DOCUMENT ME!
* Creates PropertyChangeListener that listens to PropertyChangeEvents
* occuring in the Action associated with given menu item in this popup menu.
*
* @param item DOCUMENT ME!
* @param item MenuItem
*
* @return DOCUMENT ME!
* @return The PropertyChangeListener
*/
protected PropertyChangeListener createActionChangeListener(JMenuItem item)
{
return null;
return new ActionChangeListener();
}
/**
@ -441,13 +452,20 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
}
/**
* Sets label for this popup menu
* Sets label for this popup menu. This method fires PropertyChangeEvent
* when the label property is changed. Please note that most
* of the Look & Feel will ignore this property.
*
* @param label label for this popup menu
*/
public void setLabel(String label)
{
if (label != this.label)
{
String oldLabel = this.label;
this.label = label;
firePropertyChange(LABEL_CHANGED_PROPERTY, oldLabel, label);
}
}
/**
@ -576,6 +594,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
size = this.getPreferredSize();
else
size = this.getSize();
if ((size.width > (rootContainer.getWidth() - popupLocation.x))
|| (size.height > (rootContainer.getHeight() - popupLocation.y)))
fit = false;
@ -602,27 +621,15 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
{
// Subtract insets of the top-level container if popup menu's
// top-left corner is inside it.
if (rootContainer.contains(popupLocation))
{
Insets insets = rootContainer.getInsets();
popup.show(popupLocation.x - insets.left,
popupLocation.y - insets.top, size.width,
size.height);
}
else
popup.show(popupLocation.x, popupLocation.y, size.width,
size.height);
}
}
else
{
// popup menu was cancelled without selection
if (! getSelectionModel().isSelected())
firePopupMenuCanceled();
firePopupMenuWillBecomeInvisible();
popup.hide();
}
}
@ -790,7 +797,8 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
}
/**
* Process mouse events forwarded from MenuSelectionManager.
* Process mouse events forwarded from MenuSelectionManager. This method
* doesn't do anything. It is here to conform to the MenuElement interface.
*
* @param event event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
@ -799,18 +807,24 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
public void processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// Empty Implementation. This method is needed for the implementation
// of MenuElement interface
}
/**
* DOCUMENT ME!
* Process key events forwarded from MenuSelectionManager. This method
* doesn't do anything. It is here to conform to the MenuElement interface.
*
* @param event event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
* @param manager MenuSelectionManager for the current menu hierarchy
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
public void processKeyEvent(KeyEvent event, MenuElement[] path,
MenuSelectionManager manager)
{
// Empty Implementation. This method is needed for the implementation
// of MenuElement interface
}
/**
@ -822,6 +836,8 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public void menuSelectionChanged(boolean changed)
{
if (! changed)
setVisible(false);
}
/**
@ -938,6 +954,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public void hide()
{
// FIXME: Right now the lightweight container is removed from JLayered
// pane. It is probably would be better in order to improve performance
// to make the container invisible instead of removing it everytime.
JLayeredPane layeredPane;
layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
int index = layeredPane.getIndexOf(c);
@ -982,6 +1001,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public void hide()
{
// FIXME: Right now the lightweight container is removed from JLayered
// pane. It is probably would be better in order to improve performance
// to make the container invisible instead of removing it everytime.
JLayeredPane layeredPane;
layeredPane = SwingUtilities.getRootPane(invoker).getLayeredPane();
int index = layeredPane.getIndexOf(this);
@ -1028,6 +1050,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
}
}
/**
* This is the separator that can be used in popup menu.
*/
public static class Separator extends JSeparator
{
public Separator()
@ -1053,4 +1078,15 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
return AccessibleRole.POPUP_MENU;
}
}
/* This class resizes popup menu and repaints popup menu appropriately if one
of item's action has changed */
protected class ActionChangeListener implements PropertyChangeListener
{
public void propertyChange(PropertyChangeEvent evt)
{
JPopupMenu.this.revalidate();
JPopupMenu.this.repaint();
}
}
}

View file

@ -67,8 +67,8 @@ public class JRadioButton extends JToggleButton
public JRadioButton(String text, Icon icon)
{
super(text, icon);
paint_border = false;
content_area_filled = false;
borderPainted = false;
contentAreaFilled = false;
}

View file

@ -42,15 +42,23 @@ import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
* DOCUMENT ME!
* This class represents JRadioButtonMenuItem. Its behaviour is very similar
* to JRadioButton. Just like JRadioButton, user can check and uncheck this
* menu item by clicking on it. JRadioButtonMenuItem uses ToggleButtonModel
* to keep track of its selection. If the JRadioButtonMenuItem is included in
* the button group, then only one JRadioButtonMenuItem can be selected at
* one time.
*/
public class JRadioButtonMenuItem extends JMenuItem implements Accessible
{
private static final long serialVersionUID = 8482658191548521743L;
/** name for the UI delegate for this radio button menu item. */
private static final String uiClassID = "RadioButtonMenuItemUI";
/**
@ -62,9 +70,9 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem with specified icon
*
* @param icon DOCUMENT ME!
* @param icon Icon to be used for this menu item
*/
public JRadioButtonMenuItem(Icon icon)
{
@ -72,9 +80,9 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem with specified label
*
* @param text DOCUMENT ME!
* @param text Label for this menu item
*/
public JRadioButtonMenuItem(String text)
{
@ -82,9 +90,9 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem using specified action
*
* @param action DOCUMENT ME!
* @param action Action for this menu item
*/
public JRadioButtonMenuItem(Action action)
{
@ -93,10 +101,10 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem with specified label and icon
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param text Label for this menu item
* @param icon Icon for this menu item
*/
public JRadioButtonMenuItem(String text, Icon icon)
{
@ -104,10 +112,11 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem with specified label
* and marked selected if 'selected' is true.
*
* @param text DOCUMENT ME!
* @param selected DOCUMENT ME!
* @param text Text for this menu item
* @param selected Selected state of this menu item
*/
public JRadioButtonMenuItem(String text, boolean selected)
{
@ -115,10 +124,11 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem with specified icon
* and given selected state
*
* @param icon DOCUMENT ME!
* @param selected DOCUMENT ME!
* @param icon Icon for this menu item
* @param selected Selected state for this menu item
*/
public JRadioButtonMenuItem(Icon icon, boolean selected)
{
@ -126,11 +136,12 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* Creates a new JRadioButtonMenuItem object.
* Creates a new JRadioButtonMenuItem with specified label,
* icon and selected state.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param selected DOCUMENT ME!
* @param text Label for this menu item
* @param icon Icon to be use for this menu item
* @param selected selected state of this menu item
*/
public JRadioButtonMenuItem(String text, Icon icon, boolean selected)
{
@ -139,22 +150,15 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
model.setSelected(selected);
}
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
}
/**
* DOCUMENT ME!
* This method returns a name to identify which look and feel class will be
* the UI delegate for the menuItem.
*
* @return $returnType$ DOCUMENT ME!
* @return The Look and Feel classID. "JRadioButtonMenuItemUI"
*/
public String getUIClassID()
{
@ -162,28 +166,26 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
}
/**
* DOCUMENT ME!
* This method overrides JComponent.requestFocus with an empty
* implementation, since JRadioButtonMenuItems should not
* receve focus in general.
*/
public void requestFocus()
{
// TODO
// Should do nothing here
}
/**
* DOCUMENT ME!
* A string that describes this JRadioButtonMenuItem. Normally only used
* for debugging.
*
* @return $returnType$ DOCUMENT ME!
* @return A string describing this JRadioButtonMenuItem
*/
protected String paramString()
{
return "JRadioButtonMenuItem";
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
@ -192,9 +194,6 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
return accessibleContext;
}
/**
* DOCUMENT ME!
*/
protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem
{
private static final long serialVersionUID = 4381471510145292179L;
@ -206,11 +205,6 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
{
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.RADIO_BUTTON;

View file

@ -48,15 +48,11 @@ import javax.accessibility.AccessibleRole;
import javax.swing.plaf.RootPaneUI;
/**
* This class is where JComponents are added to.
* Unlike awt where you could just say frame.add(),
* with swing you need to say frame.getRootPane()
* (which delivers an instance of this class)
* and add your components to that.
*
* It is implemented by several 'layers' (pane() should be read as plane())
* each on top of the others
* where you can add components to.
* This class is where JComponents are added to. Unlike awt where you could
* just say frame.add(), with swing you need to say frame.getRootPane()
* (which delivers an instance of this class) and add your components to
* that. It is implemented by several 'layers' (pane() should be read as
* plane()) each on top of the others where you can add components to.
* (getContentPane(), getGlassPane(), getLayeredPane())
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
@ -66,12 +62,21 @@ public class JRootPane extends JComponent
// The class used to obtain the accessible role for this object.
protected static class AccessibleJRootPane
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 1082432482784468088L;
/**
* Creates a new <code>AccessibleJRootPane</code> object.
*/
protected AccessibleJRootPane()
{
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.ROOT_PANE;
@ -82,34 +87,74 @@ public class JRootPane extends JComponent
// menuBar withing its layeredPane.
protected class RootLayout implements LayoutManager2, Serializable
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -4100116998559815027L;
/**
* Creates a new <code>RootLayout</code> object.
*/
protected RootLayout()
{
}
/**
* DOCUMENT ME!
*
* @param comp DOCUMENT ME!
* @param constraints DOCUMENT ME!
*/
public void addLayoutComponent(Component comp, Object constraints)
{
}
/**
* DOCUMENT ME!
*
* @param name DOCUMENT ME!
* @param comp DOCUMENT ME!
*/
public void addLayoutComponent(String name, Component comp)
{
}
/**
* DOCUMENT ME!
*
* @param target DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public float getLayoutAlignmentX(Container target)
{
return target.getAlignmentX();
}
/**
* DOCUMENT ME!
*
* @param target DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public float getLayoutAlignmentY(Container target)
{
return target.getAlignmentY();
}
/**
* DOCUMENT ME!
*
* @param target DOCUMENT ME!
*/
public void invalidateLayout(Container target)
{
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void layoutContainer(Container c)
{
Dimension menuBarSize;
@ -146,6 +191,8 @@ public class JRootPane extends JComponent
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
glassPane.setBounds(0, menuBarSize.height, maxWidth,
contentPaneSize.height);
contentPane.setBounds(0, menuBarSize.height, maxWidth,
contentPaneSize.height);
layeredPane.setSize(maxWidth,
@ -153,6 +200,8 @@ public class JRootPane extends JComponent
}
else
{
glassPane.setBounds(0, 0, contentPaneSize.width,
contentPaneSize.height);
contentPane.setBounds(0, 0, contentPaneSize.width,
contentPaneSize.height);
layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
@ -167,28 +216,55 @@ public class JRootPane extends JComponent
menuBarSize.height = containerSize.height;
menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
int remainingHeight = containerSize.height - menuBarSize.height;
glassPane.setBounds(0, menuBarSize.height, containerSize.width,
containerSize.height - menuBarSize.height);
contentPane.setBounds(0, menuBarSize.height,
containerSize.width,
(containerSize.height - menuBarSize.height));
}
else
{
glassPane.setBounds(0, 0, containerSize.width,
containerSize.height);
contentPane.setBounds(0, 0, containerSize.width,
containerSize.height);
}
layeredPane.setSize(containerSize.width, containerSize.height);
}
}
/**
* DOCUMENT ME!
*
* @param target DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension maximumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
/**
* DOCUMENT ME!
*
* @param target DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension minimumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Dimension preferredLayoutSize(Container c)
{
Dimension menuBarSize;
@ -204,9 +280,9 @@ public class JRootPane extends JComponent
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
prefSize =
new Dimension(maxWidth,
contentPaneSize.height + menuBarSize.height);
prefSize = new Dimension(maxWidth,
contentPaneSize.height
+ menuBarSize.height);
}
else
prefSize = contentPaneSize;
@ -217,32 +293,67 @@ public class JRootPane extends JComponent
return prefSize;
}
/**
* DOCUMENT ME!
*
* @param comp DOCUMENT ME!
*/
public void removeLayoutComponent(Component comp)
{
}
}
/** DOCUMENT ME! */
private static final long serialVersionUID = 8690748000348575668L;
/** DOCUMENT ME! */
protected Component glassPane;
/** DOCUMENT ME! */
protected JLayeredPane layeredPane;
/** DOCUMENT ME! */
protected JMenuBar menuBar;
/** DOCUMENT ME! */
protected Container contentPane;
/**
* DOCUMENT ME!
*
* @param m DOCUMENT ME!
*/
public void setJMenuBar(JMenuBar m)
{
menuBar = m;
getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JMenuBar getJMenuBar()
{
return menuBar;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isValidateRoot()
{
return true;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Container getContentPane()
{
if (contentPane == null)
@ -250,17 +361,34 @@ public class JRootPane extends JComponent
return contentPane;
}
/**
* DOCUMENT ME!
*
* @param p DOCUMENT ME!
*/
public void setContentPane(Container p)
{
contentPane = p;
getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
}
/**
* DOCUMENT ME!
*
* @param comp DOCUMENT ME!
* @param constraints DOCUMENT ME!
* @param index DOCUMENT ME!
*/
protected void addImpl(Component comp, Object constraints, int index)
{
super.addImpl(comp, constraints, index);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Component getGlassPane()
{
if (glassPane == null)
@ -268,6 +396,11 @@ public class JRootPane extends JComponent
return glassPane;
}
/**
* DOCUMENT ME!
*
* @param f DOCUMENT ME!
*/
public void setGlassPane(Component f)
{
if (glassPane != null)
@ -279,6 +412,11 @@ public class JRootPane extends JComponent
add(glassPane, 0);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public JLayeredPane getLayeredPane()
{
if (layeredPane == null)
@ -286,6 +424,11 @@ public class JRootPane extends JComponent
return layeredPane;
}
/**
* DOCUMENT ME!
*
* @param f DOCUMENT ME!
*/
public void setLayeredPane(JLayeredPane f)
{
if (layeredPane != null)
@ -295,6 +438,9 @@ public class JRootPane extends JComponent
add(f, -1);
}
/**
* Creates a new <code>JRootPane</code> object.
*/
public JRootPane()
{
setLayout(createRootLayout());
@ -305,11 +451,21 @@ public class JRootPane extends JComponent
updateUI();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected LayoutManager createRootLayout()
{
return new RootLayout();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected JComponent createContentPane()
{
JPanel p = new JPanel();
@ -318,15 +474,26 @@ public class JRootPane extends JComponent
return p;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected Component createGlassPane()
{
JPanel p = new JPanel();
p.setName(this.getName() + ".glassPane");
p.setLayout(new BorderLayout());
p.setVisible(false);
p.setOpaque(false);
return p;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected JLayeredPane createLayeredPane()
{
JLayeredPane l = new JLayeredPane();
@ -334,21 +501,39 @@ public class JRootPane extends JComponent
return l;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public RootPaneUI getUI()
{
return (RootPaneUI) ui;
}
/**
* DOCUMENT ME!
*
* @param ui DOCUMENT ME!
*/
public void setUI(RootPaneUI ui)
{
super.setUI(ui);
}
/**
* DOCUMENT ME!
*/
public void updateUI()
{
setUI((RootPaneUI) UIManager.getUI(this));
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getUIClassID()
{
return "RootPaneUI";

View file

@ -490,22 +490,15 @@ public class JScrollPane
{
// 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

View file

@ -312,9 +312,9 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void setComponent(Component c)
{
JTabbedPane.this.remove(component);
remove(component);
this.component = c;
JTabbedPane.this.add(c);
add(c);
}
/**

View file

@ -38,9 +38,11 @@ exception statement from your version. */
package javax.swing;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.Vector;
import java.util.Hashtable;
import javax.accessibility.Accessible;
import javax.swing.event.CellEditorListener;
@ -51,6 +53,11 @@ import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
@ -66,39 +73,115 @@ public class JTable extends JComponent
public static final int AUTO_RESIZE_OFF = 0;
public static final int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2;
protected boolean autoCreateColumnsFromModel;
protected int autoResizeMode;
protected TableCellEditor cellEditor;
protected boolean cellSelectionEnabled;
protected TableColumnModel columnModel;
protected TableModel dataModel;
protected Hashtable defaultEditorsByColumnClass;
protected Hashtable defaultRenderersByColumnClass;
protected int editingColumn;
protected int editingRow;
protected Color gridColor;
protected Dimension preferredViewportSize;
protected int rowHeight;
protected int rowMargin;
protected boolean rowSelectionAllowed;
protected Color selectionBackground;
protected Color selectionForeground;
protected ListSelectionModel selectionModel;
protected boolean showHorizontalLines;
protected boolean showVerticalLines;
protected JTableHeader tableHeader;
/**
* Creates a new <code>JTable</code> instance.
*/
public JTable ()
{
throw new Error ("Not implemented");
this(null, null, null);
}
/**
* Creates a new <code>JTable</code> instance.
*
* @param numRows an <code>int</code> value
* @param numColumns an <code>int</code> value
*/
public JTable (int numRows, int numColumns)
{
throw new Error ("Not implemented");
this(new DefaultTableModel(numRows, numColumns));
}
public JTable (Object[][] rowData, Object[] columnNames)
/**
* Creates a new <code>JTable</code> instance.
*
* @param data an <code>Object[][]</code> value
* @param columnNames an <code>Object[]</code> value
*/
public JTable(Object[][] data, Object[] columnNames)
{
throw new Error ("Not implemented");
this(new DefaultTableModel(data, columnNames));
}
/**
* Creates a new <code>JTable</code> instance.
*
* @param dm a <code>TableModel</code> value
*/
public JTable (TableModel dm)
{
throw new Error ("Not implemented");
this(dm, null, null);
}
/**
* Creates a new <code>JTable</code> instance.
*
* @param dm a <code>TableModel</code> value
* @param cm a <code>TableColumnModel</code> value
*/
public JTable (TableModel dm, TableColumnModel cm)
{
throw new Error ("Not implemented");
this(dm, cm, null);
}
/**
* Creates a new <code>JTable</code> instance.
*
* @param dm a <code>TableModel</code> value
* @param cm a <code>TableColumnModel</code> value
* @param sm a <code>ListSelectionModel</code> value
*/
public JTable (TableModel dm, TableColumnModel cm, ListSelectionModel sm)
{
throw new Error ("Not implemented");
this.dataModel = dm == null ? createDefaultDataModel() : dm;
this.columnModel = cm == null ? createDefaultColumnModel() : cm;
this.selectionModel = sm == null ? createDefaultListSelectionModel() : sm;
}
public JTable (Vector rowData, Vector columnNames)
/**
* Creates a new <code>JTable</code> instance.
*
* @param data a <code>Vector</code> value
* @param columnNames a <code>Vector</code> value
*/
public JTable(Vector data, Vector columnNames)
{
throw new Error ("Not implemented");
this(new DefaultTableModel(data, columnNames));
}
/**
* @deprecated 1.0.2, replaced by <code>new JScrollPane(JTable)</code>
*/
public static JScrollPane createScrollPaneForTable(JTable table)
{
return new JScrollPane(table);
}
public void clearSelection()
{
selectionModel.clearSelection();
}
public void columnAdded (TableColumnModelEvent event)
@ -126,6 +209,21 @@ public class JTable extends JComponent
throw new Error ("Not implemented");
}
protected TableColumnModel createDefaultColumnModel()
{
return new DefaultTableColumnModel();
}
protected TableModel createDefaultDataModel()
{
return new DefaultTableModel();
}
protected ListSelectionModel createDefaultListSelectionModel()
{
return new DefaultListSelectionModel();
}
public void editingCanceled (ChangeEvent event)
{
throw new Error ("Not implemented");
@ -138,7 +236,12 @@ public class JTable extends JComponent
public TableColumnModel getColumnModel ()
{
throw new Error ("Not implemented");
return columnModel;
}
public TableModel getModel()
{
return dataModel;
}
public Dimension getPreferredScrollableViewportSize ()
@ -168,12 +271,15 @@ public class JTable extends JComponent
public int getSelectedRow ()
{
throw new Error ("Not implemented");
return selectionModel.getMinSelectionIndex();
}
public ListSelectionModel getSelectionModel ()
{
throw new Error ("Not implemented");
if (! rowSelectionAllowed)
return null;
return selectionModel;
}
public void tableChanged (TableModelEvent event)
@ -183,7 +289,13 @@ public class JTable extends JComponent
public void setModel (TableModel model)
{
throw new Error ("Not implemented");
if (model == null)
throw new IllegalArgumentException();
// FIXME: Should we deregister from old model ?
dataModel = model;
dataModel.addTableModelListener(this);
}
public void setSelectionMode (int selectionMode)
@ -193,7 +305,13 @@ public class JTable extends JComponent
public void setSelectionModel (ListSelectionModel model)
{
throw new Error ("Not implemented");
if (model == null)
throw new IllegalArgumentException();
// FIXME: Should we deregister from old model ?
selectionModel = model;
selectionModel.addListSelectionListener(this);
}
public void setShowGrid (boolean showGrid)
@ -205,4 +323,71 @@ public class JTable extends JComponent
{
throw new Error ("Not implemented");
}
} // class JTable
public JTableHeader getTableHeader()
{
return tableHeader;
}
public void setTableHeader(JTableHeader newHeader)
{
tableHeader = newHeader;
}
public boolean getColumnSelectionAllowed()
{
return columnModel.getColumnSelectionAllowed();
}
public void setColumnSelectionAllowed(boolean flag)
{
columnModel.setColumnSelectionAllowed(flag);
}
public boolean getRowSelectionAllowed()
{
return rowSelectionAllowed;
}
public void setRowSelectionAllowed(boolean flag)
{
rowSelectionAllowed = flag;
}
public int getAutoResizeMode()
{
return autoResizeMode;
}
public void setAutoResizeMode(int mode)
{
autoResizeMode = mode;
}
public int getColumnCount()
{
return dataModel.getColumnCount();
}
public int getRowCount()
{
return dataModel.getRowCount();
}
public TableCellRenderer getCellRenderer(int row, int column)
{
TableCellRenderer renderer =
columnModel.getColumn(column).getCellRenderer();
if (renderer == null)
renderer = getDefaultRenderer(dataModel.getColumnClass(column));
return renderer;
}
public TableCellRenderer getDefaultRenderer(Class columnClass)
{
// FIXME:
return null;
}
}

View file

@ -49,6 +49,7 @@ public class JTextArea extends JTextComponent
private int rows;
private int columns;
private boolean wrapping;
private int tabSize = 8;
/**
* Creates a new <code>JTextArea</code> object.
@ -224,8 +225,28 @@ public class JTextArea extends JTextComponent
*
* @param wrapping true to enable line wrapping, false otherwise
*/
public void setLineWrap(boolean wrapping)
public void setLineWrap(boolean flag)
{
this.wrapping = wrapping;
if (wrapping == flag)
return;
boolean oldValue = wrapping;
wrapping = flag;
firePropertyChange("lineWrap", oldValue, wrapping);
}
public int getTabSize()
{
return tabSize;
}
public void setTabSize(int newSize)
{
if (tabSize == newSize)
return;
int oldValue = tabSize;
tabSize = newSize;
firePropertyChange("tabSize", oldValue, tabSize);
}
}

View file

@ -37,6 +37,9 @@ exception statement from your version. */
package javax.swing;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.accessibility.AccessibleStateSet;
@ -78,6 +81,8 @@ public class JTextField extends JTextComponent
private int columns;
private int align;
/**
* Creates a new instance of <code>JTextField</code>.
*/
@ -132,10 +137,7 @@ public class JTextField extends JTextComponent
*/
public JTextField(Document doc, String text, int columns)
{
if (doc == null)
doc = createDefaultModel();
setDocument(doc);
setDocument(doc == null ? createDefaultModel() : doc);
setText(text);
setColumns(columns);
}
@ -151,6 +153,16 @@ public class JTextField extends JTextComponent
return new PlainDocument();
}
/**
* Returns the class ID for the UI.
*
* @return "TextFieldUI";
*/
public String getUIClassID()
{
return "TextFieldUI";
}
/**
* Adds a new listener object to this text field.
*
@ -175,6 +187,8 @@ public class JTextField extends JTextComponent
* Returns all registered <code>ActionListener</code> objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public ActionListener[] getActionListeners()
{
@ -210,10 +224,46 @@ public class JTextField extends JTextComponent
throw new IllegalArgumentException();
this.columns = columns;
// FIXME: Invalidate layout.
invalidate();
repaint();
}
public void selectAll()
public int getHorizontalAlignment()
{
return align;
}
public void setHorizontalAlignment(int newAlign)
{
int oldAlign = align;
align = newAlign;
invalidate();
repaint();
firePropertyChange("horizontalAlignment", oldAlign, newAlign);
}
public void setFont(Font newFont)
{
super.setFont(newFont);
revalidate();
}
public Dimension getPreferredSize()
{
Dimension size;
FontMetrics fm = getFontMetrics(getFont());
int fontHeight = fm.getMaxAscent() + fm.getMaxDescent();
int columnWidth = fm.charWidth('m');
if (columns != 0)
{
size = new Dimension(columns * columnWidth + 4, fontHeight + 4);
}
else
{
size = new Dimension(10, 10);
}
return size;
}
}

View file

@ -81,6 +81,11 @@ public class JToggleButton extends AbstractButton implements Accessible
this(null, icon);
}
public JToggleButton (Icon icon, boolean selected)
{
this(null, icon, selected);
}
public JToggleButton(String text)
{
this(text, null);
@ -88,8 +93,7 @@ public class JToggleButton extends AbstractButton implements Accessible
public JToggleButton(String text, boolean selected)
{
this(text, null);
setSelected(selected);
this(text, null, selected);
}
public JToggleButton(String text, Icon icon)
@ -101,13 +105,15 @@ public class JToggleButton extends AbstractButton implements Accessible
{
super(text, icon);
hori_align = LEADING;
horizontalAlignment = LEADING;
setModel(new ToggleButtonModel());
model.setSelected(selected);
}
/**
* Gets the AccessibleContext associated with this JToggleButton.
* Gets the AccessibleContext associated with this <code>JToggleButton</code>.
*
* @return the associated context
*/
public AccessibleContext getAccessibleContext()
{

View file

@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
@ -46,26 +47,31 @@ import java.awt.LayoutManager;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
import javax.swing.plaf.ToolBarUI;
/**
* JToolBar
* @author Andrew Selkirk
* @version 1.0
* JToolBar is a component that provides a toolbar to Swing programs. Users
* can add buttons (or actions that will be represented by JButtons) as well
* as other components to the JToolBar. JToolBars can be dragged in and out
* of their parent components. If the JToolBar is dragged out of the parent,
* then it will be displayed in its own RootPaneContainer. For dragging to
* work properly, JToolBars need to be placed in a Container that has a
* BorderLayout. That parent Container cannot have components in the NORTH,
* EAST, SOUTH, or WEST components (that is not the JToolBar).
*/
public class JToolBar extends JComponent
implements SwingConstants, Accessible
public class JToolBar extends JComponent implements SwingConstants, Accessible
{
/**
* AccessibleJToolBar
*/
protected class AccessibleJToolBar extends AccessibleJComponent
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -5516888265903814215L;
/**
@ -77,6 +83,7 @@ public class JToolBar extends JComponent
/**
* getAccessibleStateSet
*
* @return AccessibleStateSet
*/
public AccessibleStateSet getAccessibleStateSet()
@ -86,6 +93,7 @@ public class JToolBar extends JComponent
/**
* getAccessibleRole
*
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
@ -95,409 +103,678 @@ public class JToolBar extends JComponent
}
/**
* Separator
* This is the private JToolBar layout manager.
*/
private class DefaultToolBarLayout implements LayoutManager
{
/**
* This method is called when a new component is added to the container.
*
* @param name The name of the component added.
* @param comp The component that was added.
*/
public static class Separator extends JSeparator {
public void addLayoutComponent(String name, Component comp)
{
// Do nothing.
}
private static final long serialVersionUID = -1656745644823105219L;
/**
* This method is called to lay out the given container to position and
* size the child components.
*
* @param c The container to lay out.
*
* @throws Error DOCUMENT ME!
*/
public void layoutContainer(Container c)
{
if (! (c instanceof JToolBar))
throw new Error("DefaultToolBarLayout can only be used on JToolBars.");
Insets insets = getInsets();
Insets margin = getMargin();
int middle;
if (margin != null)
{
insets.left += margin.left;
insets.top += margin.top;
insets.bottom += margin.bottom;
insets.right += margin.right;
}
Component[] components = c.getComponents();
Dimension tdims = c.getSize();
int start = 0;
Dimension pref;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
if (getOrientation() == SwingUtilities.HORIZONTAL)
{
start += insets.left;
for (int i = 0; i < components.length; i++)
{
if (components[i] != null && components[i].isVisible())
{
pref = components[i].getPreferredSize();
if (pref != null)
{
middle = (tdims.height - pref.height) / 2;
components[i].setBounds(start, middle, pref.width,
pref.height);
start += pref.width;
}
}
}
}
else
{
start += insets.top;
for (int i = 0; i < components.length; i++)
{
if (components[i] != null && components[i].isVisible())
{
pref = components[i].getPreferredSize();
if (pref != null)
{
middle = (tdims.width - pref.width) / 2;
components[i].setBounds(middle, start, pref.width,
pref.height);
start += pref.height;
}
}
}
}
}
/**
* This method returns the minimum size of the given container given the
* child components.
*
* @param parent The container to measure.
*
* @return The minimum size of the given container.
*/
public Dimension minimumLayoutSize(Container parent)
{
return preferredLayoutSize(parent);
}
/**
* separatorSize
* This method returns the preferred size of the given container given the
* child components.
*
* @param parent The container to measure.
*
* @return The preferred size of the given container.
*/
private Dimension size;
public Dimension preferredLayoutSize(Container parent)
{
int orientation = getOrientation();
Component[] components = getComponents();
int limit = 0;
int total = 0;
Dimension dims;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
int w = 0;
int h = 0;
if (orientation == SwingConstants.HORIZONTAL)
{
for (int i = 0; i < components.length; i++)
{
dims = components[i].getPreferredSize();
if (dims != null)
{
if (dims.height > limit)
limit = dims.height;
total += dims.width;
}
}
w = total;
h = limit;
}
else
{
for (int i = 0; i < components.length; i++)
{
dims = components[i].getPreferredSize();
if (dims != null)
{
if (dims.width > limit)
limit = dims.width;
total += dims.height;
}
}
w = limit;
h = total;
}
Insets insets = getInsets();
w += insets.left + insets.right;
h += insets.top + insets.bottom;
Insets margin = getMargin();
if (margin != null)
{
w += margin.left + margin.right;
h += margin.top + margin.bottom;
}
return new Dimension(w, h);
}
/**
* Constructor Separator
* This method is called when the given component is removed from the
* container.
*
* @param comp The component removed.
*/
public Separator() {
// TODO
} // Separator()
public void removeLayoutComponent(Component comp)
{
// Do nothing.
}
}
/**
* Constructor Separator
* @param size TODO
* This is an extension of JSeparator used in toolbars. Unlike JSeparator,
* nothing is painted for this Separator, it is only blank space that
* separates components.
*/
public Separator(Dimension size) {
// TODO
} // Separator()
public static class Separator extends JSeparator
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -1656745644823105219L;
/**
* Creates a new Separator object.
*/
public Separator()
{
super();
} // Separator()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Creates a new Separator object with the given size.
*
* @param size The size of the separator.
*/
public Separator(Dimension size)
{
setPreferredSize(size);
} // Separator()
/**
* getUIClassID
* @returns String
* This method returns the String ID of the UI class of Separator.
*
* @return The UI class' String ID.
*/
public String getUIClassID() {
return null; // TODO
public String getUIClassID()
{
return "ToolBarSeparatorUI";
} // getUIClassID()
/**
* getPreferredSize
* @returns Dimension
* This method returns the preferred size of the Separator.
*
* @return The preferred size of the Separator.
*/
public Dimension getPreferredSize() {
return null; // TODO
public Dimension getPreferredSize()
{
return super.getPreferredSize();
} // getPreferredSize()
/**
* getMaximumSize
* @returns Dimension
* This method returns the maximum size of the Separator.
*
* @return The maximum size of the Separator.
*/
public Dimension getMaximumSize() {
return null; // TODO
public Dimension getMaximumSize()
{
return super.getPreferredSize();
} // getMaximumSize()
/**
* getMinimumSize
* @returns Dimension
* This method returns the minimum size of the Separator.
*
* @return The minimum size of the Separator.
*/
public Dimension getMinimumSize() {
return null; // TODO
public Dimension getMinimumSize()
{
return super.getPreferredSize();
} // getMinimumSize()
/**
* getSeparatorSize
* @returns Dimension
* This method returns the size of the Separator.
*
* @return The size of the Separator.
*/
public Dimension getSeparatorSize() {
return null; // TODO
public Dimension getSeparatorSize()
{
return super.getPreferredSize();
} // getSeparatorSize()
/**
* setSeparatorSize
* @param size TODO
* This method sets the size of the Separator.
*
* @param size The new size of the Separator.
*/
public void setSeparatorSize(Dimension size) {
// TODO
public void setSeparatorSize(Dimension size)
{
setPreferredSize(size);
} // setSeparatorSize()
} // Separator
// /**
// * DefaultJToolBarLayout
// */
// private class DefaultJToolBarLayout {
//
// private void DefaultJToolBarLayout() {
// }
//
// private LayoutManager getLayout() {
// switch (JToolBar.this.getOrientation()) {
// case HORIZONTAL: setLayout(new GridLayout(1, 0, 4, 4));
// break;
// case VERTICAL: setLayout(new GridLayout(0, 1, 4, 4));
// break;
// }
// }
// } // DefaultJToolBarLayout
/** DOCUMENT ME! */
private static final long serialVersionUID = -1269915519555129643L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/** Whether the JToolBar paints its border. */
private transient boolean paintBorder = true;
/**
* uiClassID
*/
private static final String uiClassID = "ToolBarUI";
/** The extra insets around the JToolBar. */
private transient Insets margin;
/**
* paintBorder
*/
private boolean paintBorder;
/** Whether the JToolBar can float (and be dragged around). */
private transient boolean floatable = true;
/**
* margin
*/
private Insets margin;
/** Whether the buttons will have rollover borders. */
private transient boolean rollover;
/**
* floatable
*/
private boolean floatable;
/**
* orientation
*/
/** The orientation of the JToolBar. */
private int orientation = HORIZONTAL;
// protected transient DefaultJToolBarLayout toolbarLayout;
/** Fired in a PropertyChangeEvent when the "orientation" property changes.
*/
/** Fired in a PropertyChangeEvent when the orientation property changes. */
public static final String ORIENTATION_CHANGED_PROPERTY = "orientation";
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/** Fired in a PropertyChangeEvent when the floatable property changes. */
public static final String FLOATABLE_CHANGED_PROPERTY = "floatable";
/** Fired in a PropertyChangeEvent when the borderPainted property changes. */
public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted";
/** Fired in a PropertyChangeEvent when the margin property changes. */
public static final String MARGIN_CHANGED_PROPERTY = "margin";
/** Fired in a PropertyChangeEvent when the rollover property changes. */
public static final String ROLLOVER_CHANGED_PROPERTY = "rollover";
/**
* Constructor JToolBar
* This method creates a new JToolBar object with horizontal orientation
* and no name.
*/
public JToolBar() {
this(null);
public JToolBar()
{
this(null, HORIZONTAL);
} // JToolBar()
/**
* Constructor JToolBar
* This method creates a new JToolBar with the given orientation and no
* name.
*
* @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)
*/
public JToolBar(int orientation) {
public JToolBar(int orientation)
{
this(null, orientation);
} // JToolBar()
/**
* Constructor JToolBar
* This method creates a new JToolBar object with the given name and
* horizontal orientation.
*
* @param name Name assigned to undocked tool bar.
*/
public JToolBar(String name) {
public JToolBar(String name)
{
this(name, HORIZONTAL);
} // JToolBar()
/**
* Constructor JToolBar
* This method creates a new JToolBar object with the given name and
* orientation.
*
* @param name Name assigned to undocked tool bar.
* @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)
*/
public JToolBar(String name, int orientation) {
public JToolBar(String name, int orientation)
{
setName(name);
if (orientation != HORIZONTAL && orientation != VERTICAL)
throw new IllegalArgumentException(orientation + " is not a legal orientation");
this.orientation = orientation;
// toolbarLayout = new DefaultJToolBarLayout();
setOrientation(orientation);
setLayout(new DefaultToolBarLayout());
revalidate();
updateUI();
} // JToolBar()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* writeObject
* @param stream TODO
* @exception IOException TODO
* This method adds a new JButton that performs the given Action to the
* JToolBar.
*
* @param action The Action to add to the JToolBar.
*
* @return The JButton that wraps the Action.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
// TODO
} // writeObject()
/**
* add
* @param action TODO
* @returns JButton
*/
public JButton add(Action action) {
return null; // TODO
public JButton add(Action action)
{
JButton b = createActionComponent(action);
add(b);
return b;
} // add()
/**
* paintBorder
* @param graphics TODO
* This method paints the border if the borderPainted property is true.
*
* @param graphics The graphics object to paint with.
*/
protected void paintBorder(Graphics graphics) {
// TODO
protected void paintBorder(Graphics graphics)
{
if (paintBorder && isFloatable())
super.paintBorder(graphics);
} // paintBorder()
/**
* getUI
* @returns ToolBarUI
* This method returns the UI class used to paint this JToolBar.
*
* @return The UI class for this JToolBar.
*/
public ToolBarUI getUI() {
System.out.println("ui = " + ui);
public ToolBarUI getUI()
{
return (ToolBarUI) ui;
} // getUI()
/**
* setUI
* @param ui TODO
* This method sets the UI used with the JToolBar.
*
* @param ui The UI used with the JToolBar.
*/
public void setUI(ToolBarUI ui) {
public void setUI(ToolBarUI ui)
{
super.setUI(ui);
} // setUI()
/**
* updateUI
* This method resets the UI used to the Look and Feel defaults.
*/
public void updateUI() {
public void updateUI()
{
setUI((ToolBarUI)UIManager.getUI(this));
revalidate();
repaint();
} // updateUI()
/**
* getUIClassID
* @returns String
* This method returns the String identifier for the UI class to the used
* with the JToolBar.
*
* @return The String identifier for the UI class.
*/
public String getUIClassID() {
return uiClassID;
public String getUIClassID()
{
return "ToolBarUI";
} // getUIClassID()
/**
* getComponentIndex
* @param component TODO
* @returns int
* This method sets the rollover property for the JToolBar. In rollover
* mode, JButtons inside the JToolBar will only display their borders when
* the mouse is moving over them.
*
* @param b The new rollover property.
*/
public int getComponentIndex(Component component) {
return 0; // TODO
public void setRollover(boolean b)
{
if (b != rollover)
{
rollover = b;
firePropertyChange(ROLLOVER_CHANGED_PROPERTY, ! rollover, rollover);
revalidate();
repaint();
}
}
/**
* This method returns the rollover property.
*
* @return The rollover property.
*/
public boolean isRollover()
{
return rollover;
}
/**
* This method returns the index of the given component.
*
* @param component The component to find.
*
* @return The index of the given component.
*/
public int getComponentIndex(Component component)
{
Component[] components = getComponents();
if (components == null)
return -1;
for (int i = 0; i < components.length; i++)
if (components[i] == component)
return i;
return -1;
} // getComponentIndex()
/**
* getComponentAtIndex
* @param index TODO
* @returns Component
* This method returns the component at the given index.
*
* @param index The index of the component.
*
* @return The component at the given index.
*/
public Component getComponentAtIndex(int index) {
return null; // TODO
public Component getComponentAtIndex(int index)
{
return getComponent(index);
} // getComponentAtIndex()
/**
* getMargin
* @returns Insets
* This method returns the margin property.
*
* @return The margin property.
*/
public Insets getMargin() {
return null; // TODO
public Insets getMargin()
{
return margin;
} // getMargin()
/**
* setMargin
* @param margin TODO
* This method sets the margin property. The margin property determines the
* extra space between the children components of the JToolBar and the
* border.
*
* @param margin The margin property.
*/
public void setMargin(Insets margin) {
// TODO
public void setMargin(Insets margin)
{
if ((this.margin != null && margin == null)
|| (this.margin == null && margin != null)
|| (margin != null && this.margin != null
&& (margin.left != this.margin.left
|| margin.right != this.margin.right || margin.top != this.margin.top
|| margin.bottom != this.margin.bottom)))
{
Insets oldMargin = this.margin;
this.margin = margin;
firePropertyChange(MARGIN_CHANGED_PROPERTY, oldMargin, this.margin);
revalidate();
repaint();
}
} // setMargin()
/**
* isBorderPainted
* @returns boolean
* This method returns the borderPainted property.
*
* @return The borderPainted property.
*/
public boolean isBorderPainted() {
return false; // TODO
public boolean isBorderPainted()
{
return paintBorder;
} // isBorderPainted()
/**
* setBorderPainted
* @param painted TODO
* This method sets the borderPainted property. If set to false, the border
* will not be painted.
*
* @param painted Whether the border will be painted.
*/
public void setBorderPainted(boolean painted) {
// TODO
public void setBorderPainted(boolean painted)
{
if (painted != paintBorder)
{
paintBorder = painted;
firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, ! paintBorder,
paintBorder);
repaint();
}
} // setBorderPainted()
/**
* isFloatable
* @returns boolean
* This method returns the floatable property.
*
* @return The floatable property.
*/
public boolean isFloatable() {
return false; // TODO
public boolean isFloatable()
{
return floatable;
} // isFloatable()
/**
* setFloatable
* @param floatable TODO
* This method sets the floatable property. If set to false, the JToolBar
* cannot be dragged.
*
* @param floatable Whether the JToolBar can be dragged.
*/
public void setFloatable(boolean floatable) {
// TODO
public void setFloatable(boolean floatable)
{
if (floatable != this.floatable)
{
this.floatable = floatable;
firePropertyChange(FLOATABLE_CHANGED_PROPERTY, ! floatable, floatable);
}
} // setFloatable()
/**
* getOrientation
* @returns int
* This method returns the orientation of the JToolBar.
*
* @return The orientation of the JToolBar.
*/
public int getOrientation() {
return this.orientation;
public int getOrientation()
{
return orientation;
} // getOrientation()
/**
* setLayout
* @param mgr
* This method sets the layout manager to be used with the JToolBar.
*
* @param mgr The Layout Manager used with the JToolBar.
*/
public void setLayout(LayoutManager mgr) {
public void setLayout(LayoutManager mgr)
{
super.setLayout(mgr);
revalidate();
repaint();
} // setLayout()
/**
* setOrientation
* @param orientation
* This method sets the orientation property for JToolBar.
*
* @param orientation The new orientation for JToolBar.
*
* @throws IllegalArgumentException If the orientation is not HORIZONTAL or
* VERTICAL.
*/
public void setOrientation(int orientation) {
public void setOrientation(int orientation)
{
if (orientation != HORIZONTAL && orientation != VERTICAL)
throw new IllegalArgumentException(orientation + " is not a legal orientation");
throw new IllegalArgumentException(orientation
+ " is not a legal orientation");
if (orientation != this.orientation)
{
int oldOrientation = this.orientation;
this.orientation = orientation;
firePropertyChange(ORIENTATION_CHANGED_PROPERTY, oldOrientation,
this.orientation);
revalidate();
repaint();
}
} // setOrientation()
/**
* addSeparator
* This method adds a Separator of default size to the JToolBar.
*/
public void addSeparator() {
// TODO
public void addSeparator()
{
add(new Separator());
} // addSeparator()
/**
* addSeparator
* @param size TODO
* This method adds a Separator with the given size to the JToolBar.
*
* @param size The size of the Separator.
*/
public void addSeparator(Dimension size) {
// TODO
public void addSeparator(Dimension size)
{
add(new Separator(size));
} // addSeparator()
/**
* createActionComponent
* @param action TODO
* @returns JButton
* This method is used to create JButtons which can be added to the JToolBar
* for the given action.
*
* @param action The action to create a JButton for.
*
* @return The JButton created from the action.
*/
protected JButton createActionComponent(Action action) {
return null; // TODO
protected JButton createActionComponent(Action action)
{
return new JButton(action);
} // createActionComponent()
/**
* createActionChangeListener
* @param button TODO
* @returns PropertyChangeListener
* This method creates a pre-configured PropertyChangeListener which updates
* the control as changes are made to the Action. However, this is no
* longer the recommended way of adding Actions to Containers. As such,
* this method returns null.
*
* @param button The JButton to configure a PropertyChangeListener for.
*
* @return null.
*/
protected PropertyChangeListener createActionChangeListener(JButton button) {
return null; // TODO
protected PropertyChangeListener createActionChangeListener(JButton button)
{
// XXX: As specified, this returns null. But seems kind of strange, usually deprecated methods don't just return null, verify!
return null;
} // createActionChangeListener()
/**
* addImpl
* @param component TODO
* @param constraints TODO
* @param index TODO
*/
/*
protected void addImpl(Component component, Object constraints, int index) {
// TODO
} // addImpl()
* This method overrides Container's addImpl method. If a JButton is added,
* it is disabled.
*
* @param component The Component to add.
* @param constraints The Constraints placed on the component.
* @param index The index to place the Component at.
*/
protected void addImpl(Component component, Object constraints, int index)
{
// XXX: Sun says disable button but test cases show otherwise.
super.addImpl(component, constraints, index);
} // addImpl()
/**
* paramString
* @returns String
* This method returns a String description of the JToolBar.
*
* @return A String description of the JToolBar.
*/
protected String paramString() {
return null; // TODO
protected String paramString()
{
return "JToolBar";
} // paramString()
/**
* getAccessibleContext
*
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()

View file

@ -50,6 +50,7 @@ import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeWillExpandListener;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.ExpandVetoException;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
@ -60,6 +61,10 @@ public class JTree extends JComponent
{
private static final long serialVersionUID = 7559816092864483649L;
protected TreeCellRenderer cellRenderer;
protected boolean editable;
protected boolean rootVisible;
protected boolean showsRootHandles;
protected TreeModel treeModel;
/**
@ -142,31 +147,59 @@ public class JTree extends JComponent
return null;
}
/**
* Return the UI associated with this <code>JTree</code> object.
*
* @return the associated <code>TreeUI</code> object
*/
public TreeUI getUI()
{
return (TreeUI) ui;
}
/**
* Sets the UI associated with this <code>JTree</code> object.
*
* @param ui the <code>TreeUI</code> to associate
*/
public void setUI(TreeUI ui)
{
super.setUI(ui);
}
/**
* This method resets the UI used to the Look and Feel defaults..
*/
public void updateUI()
{
setUI((TreeUI) UIManager.getUI(this));
}
/**
* This method returns the String ID of the UI class of Separator.
*
* @return The UI class' String ID.
*/
public String getUIClassID()
{
return "TreeUI";
}
/**
* Gets the AccessibleContext associated with this <code>JToggleButton</code>.
*
* @return the associated context
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* Returns the preferred viewport size..
*
* @return the preferred size
*/
public Dimension getPreferredScrollableViewportSize()
{
return null;
@ -354,4 +387,87 @@ public class JTree extends JComponent
for (int index = 0; index < listeners.length; ++index)
listeners[index].treeWillExpand(event);
}
/**
* Returns the model of this <code>JTree</code> object.
*
* @return the associated <code>TreeModel</code>
*/
public TreeModel getModel()
{
return treeModel;
}
/**
* Sets the model to use in <code>JTree</object>.
*
* @param model the <code>TreeModel</code> to use
*/
public void setModel(TreeModel model)
{
treeModel = model;
}
/**
* Checks if this <code>JTree</code> object is editable.
*
* @return <code>true</code> if this tree object is editable,
* <code>false</code> otherwise
*/
public boolean isEditable()
{
return editable;
}
/**
* Sets the <code>editable</code> property.
*
* @param flag <code>true</code> to make this tree object editable,
* <code>false</code> otherwise
*/
public void setEditable(boolean flag)
{
if (editable == flag)
return;
boolean oldValue = editable;
editable = flag;
firePropertyChange("editable", oldValue, editable);
}
/**
* Checks if the root element is visible.
*
* @return <code>true</code> if the root element is visible,
* <code>false</code> otherwise
*/
public boolean isRootVisbile()
{
return rootVisible;
}
public void setRootVisible(boolean flag)
{
rootVisible = flag;
}
public boolean getShowsRootHandles()
{
return showsRootHandles;
}
public void setShowRootHandles(boolean flag)
{
showsRootHandles = flag;
}
public TreeCellRenderer getCellRenderer()
{
return cellRenderer;
}
public void setCellRenderer(TreeCellRenderer newRenderer)
{
cellRenderer = newRenderer;
}
}

View file

@ -327,11 +327,19 @@ public class JViewport extends JComponent
listenerList.remove(ChangeListener.class, listener);
}
/**
* This method returns the String ID of the UI class of Separator.
*
* @return The UI class' String ID.
*/
public String getUIClassID()
{
return "ViewportUI";
}
/**
* This method resets the UI used to the Look and Feel defaults..
*/
public void updateUI()
{
setUI((ViewportUI) UIManager.getUI(this));

View file

@ -82,7 +82,7 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
public JWindow()
{
super(null); // FIXME: This throws an exception.
super(SwingUtilities.getOwnerFrame());
}
// huuu ?

View file

@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Toolkit;
import javax.swing.text.JTextComponent;
@ -59,6 +61,20 @@ public abstract class LookAndFeel
public abstract String getName();
/**
* Returns true when the Look and Feel supports window decorations,
* false others. This method returns always false and needs to be overwritten
* when the derived Look and Feel supports this.
*
* @return false
*
* @since 1.4
*/
public boolean getSupportsWindowDecorations()
{
return false;
}
/**
* UIManager.setLookAndFeel calls this method before the first call
* (and typically the only call) to getDefaults().
@ -140,6 +156,18 @@ public abstract class LookAndFeel
return null;
}
/**
* Invoked when the user attempts an invalid operation. The default implement
* just beeps. Subclasses that wish to change this need to override this
* method.
*
* @param component the component the error occured in
*/
public void provideErrorFeedback(Component component)
{
Toolkit.getDefaultToolkit().beep();
}
/**
* Returns a string that displays and identifies this object's properties.
*

View file

@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
@ -124,24 +125,56 @@ public class MenuSelectionManager
for (int i = selectedPath.size() - 1; i >= 0; i--)
((MenuElement) selectedPath.get(i)).menuSelectionChanged(false);
// notify all listeners that the selected path was changed
fireStateChanged();
// clear selected path
selectedPath.clear();
// notify all listeners that the selected path was changed
fireStateChanged();
}
/**
* DOCUMENT ME!
* This method returns menu element on the selected path that contains
* given source point. If no menu element on the selected path contains this
* point, then null is returned.
*
* @param source DOCUMENT ME!
* @param sourcePoint DOCUMENT ME!
* @param source Component relative to which sourcePoint is given
* @param sourcePoint point for which we want to find menu element that contains it
*
* @return DOCUMENT ME!
* @return Returns menu element that contains given source point and belongs
* to the currently selected path. Null is return if no such menu element found.
*/
public Component componentForPoint(Component source, Point sourcePoint)
{
throw new UnsupportedOperationException("not implemented");
// Convert sourcePoint to screen coordinates.
Point sourcePointOnScreen = sourcePoint;
SwingUtilities.convertPointToScreen(sourcePointOnScreen, source);
Point compPointOnScreen;
Component resultComp = null;
// For each menu element on the selected path, express its location
// in terms of screen coordinates and check if there is any
// menu element on the selected path that contains given source point.
for (int i = 0; i < selectedPath.size(); i++)
{
Component comp = ((Component) selectedPath.get(i));
Dimension size = comp.getSize();
// convert location of this menu item to screen coordinates
compPointOnScreen = comp.getLocationOnScreen();
if (compPointOnScreen.x <= sourcePointOnScreen.x
&& sourcePointOnScreen.x < compPointOnScreen.x + size.width
&& compPointOnScreen.y <= sourcePointOnScreen.y
&& sourcePointOnScreen.y < compPointOnScreen.y + size.height)
{
Point p = sourcePointOnScreen;
SwingUtilities.convertPointFromScreen(p, comp);
resultComp = SwingUtilities.getDeepestComponentAt(comp, p.x, p.y);
break;
}
}
return resultComp;
}
/**
@ -176,7 +209,7 @@ public class MenuSelectionManager
* @param c Component for which to check
* @return True if specified component is part of current menu
*/
boolean isComponentPartOfCurrentMenu(Component c)
public boolean isComponentPartOfCurrentMenu(Component c)
{
MenuElement[] subElements;
for (int i = 0; i < selectedPath.size(); i++)
@ -209,19 +242,42 @@ public class MenuSelectionManager
*/
public void processMouseEvent(MouseEvent event)
{
Component c = ((Component) event.getSource());
Component source = ((Component) event.getSource());
MenuElement[] path = getPath(c);
((MenuElement) c).processMouseEvent(event, path, manager);
// In the case of drag event, event.getSource() returns component
// where drag event originated. However menu element processing this
// event should be the one over which mouse is currently located,
// which is not necessary the source of the drag event.
Component mouseOverMenuComp;
// forward events to subcomponents
MenuElement[] subComponents = ((MenuElement) c).getSubElements();
// find over which menu element the mouse is currently located
if (event.getID() == MouseEvent.MOUSE_DRAGGED
|| event.getID() == MouseEvent.MOUSE_RELEASED)
mouseOverMenuComp = componentForPoint(source, event.getPoint());
else
mouseOverMenuComp = source;
// Process this event only if mouse is located over some menu element
if (mouseOverMenuComp != null && (mouseOverMenuComp instanceof MenuElement))
{
MenuElement[] path = getPath(mouseOverMenuComp);
((MenuElement) mouseOverMenuComp).processMouseEvent(event, path,
manager);
// FIXME: Java specification says that mouse events should be
// forwarded to subcomponents. The code below does it, but
// menu's work fine without it. This code is commented for now.
/*
MenuElement[] subComponents = ((MenuElement) mouseOverMenuComp)
.getSubElements();
for (int i = 0; i < subComponents.length; i++)
{
if (subComponents[i] instanceof JMenuItem)
subComponents[i].processMouseEvent(event, path, manager);
}
*/
}
}
/**
@ -237,13 +293,13 @@ public class MenuSelectionManager
return;
}
fireStateChanged();
int i;
int minSize = path.length; // size of the smaller path.
if (path.length > selectedPath.size())
{
minSize = selectedPath.size();
// if new selected path contains more elements then current
// selection then first add all elements at
// the indexes > selectedPath.size
@ -252,8 +308,6 @@ public class MenuSelectionManager
selectedPath.add(path[i]);
path[i].menuSelectionChanged(true);
}
minSize = selectedPath.size();
}
else if (path.length < selectedPath.size())
@ -274,19 +328,21 @@ public class MenuSelectionManager
// same location and adjust selection until
// same menu elements will be encountered at the
// same index in both current and new selection path.
MenuElement oldSelectedPath;
MenuElement oldSelectedItem;
for (i = minSize - 1; i >= 0; i--)
{
oldSelectedPath = (MenuElement) selectedPath.get(i);
oldSelectedItem = (MenuElement) selectedPath.get(i);
if (path[i].equals(oldSelectedPath))
if (path[i].equals(oldSelectedItem))
break;
oldSelectedPath.menuSelectionChanged(false);
oldSelectedItem.menuSelectionChanged(false);
path[i].menuSelectionChanged(true);
selectedPath.setElementAt(path[i], i);
}
fireStateChanged();
}
/**
@ -298,7 +354,18 @@ public class MenuSelectionManager
*/
private MenuElement[] getPath(Component c)
{
// FIXME: There is the same method in BasicMenuItemUI. However I
// cannot use it here instead of this method, since I cannot assume that
// all the menu elements on the selected path are JMenuItem or JMenu.
// For now I've just duplicated it here. Please
// fix me or delete me if another better approach will be found, and
// this method will not be necessary.
ArrayList path = new ArrayList();
// if given component is JMenu, we also need to include
// it's popup menu in the path
if (c instanceof JMenu)
path.add(((JMenu) c).getPopupMenu());
while (c instanceof MenuElement)
{
path.add(0, (MenuElement) c);

View file

@ -252,16 +252,22 @@ public class RepaintManager
*/
public synchronized void addInvalidComponent(JComponent component)
{
while ((component.getParent() != null)
&& (component.getParent() instanceof JComponent)
&& (component.isValidateRoot()))
component = (JComponent) component.getParent();
Component ancestor = component.getParent();
while (ancestor != null
&& (! (ancestor instanceof JComponent)
|| ! ((JComponent) ancestor).isValidateRoot() ))
ancestor = ancestor.getParent();
if (ancestor != null
&& ancestor instanceof JComponent
&& ((JComponent) ancestor).isValidateRoot())
component = (JComponent) ancestor;
if (invalidComponents.contains(component))
return;
invalidComponents.add(component);
component.invalidate();
if (! repaintWorker.isLive())
{

View file

@ -44,6 +44,7 @@ import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.Point;
import java.io.Serializable;
import javax.swing.border.Border;
@ -197,9 +198,27 @@ public class ScrollPaneLayout
return null;
}
private static void maybeSetPreferredSize(JComponent src, Dimension dim)
{
Dimension tmp = null;
if (src != null)
tmp = src.getPreferredSize();
if (tmp != null)
dim.setSize(tmp);
}
private static void maybeSetMinimumSize(JComponent src, Dimension dim)
{
Dimension tmp = null;
if (src != null)
tmp = src.getMinimumSize();
if (tmp != null)
dim.setSize(tmp);
}
public Dimension preferredLayoutSize(Container parent)
{
if (parent instanceof JScrollPane)
if (parent != null && parent instanceof JScrollPane)
{
JScrollPane sc = (JScrollPane) parent;
synchronized (sc.getTreeLock ())
@ -217,36 +236,38 @@ public class ScrollPaneLayout
Insets viewportInsets = null;
if (viewportBorder != null)
{
viewportInsets = viewportBorder.getBorderInsets(parent);
if (viewportInsets != null)
viewportInsetsSize.setSize(viewportInsets.left + viewportInsets.right,
viewportInsets.top + viewportInsets.bottom);
}
if (insets != null)
insetsSize.setSize(insets.left + insets.right,
insets.top + insets.bottom);
if (viewport != null)
viewportSize.setSize(viewport.getPreferredSize());
if (colHead != null)
columnHeaderSize.setSize(colHead.getPreferredSize());
if (rowHead != null)
rowHeaderSize.setSize(rowHead.getPreferredSize());
if (vsb != null)
verticalScrollBarSize.setSize(vsb.getPreferredSize());
if (hsb != null)
horizontalScrollBarSize.setSize(hsb.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 + "]");
*/
{
Component view = null;
Scrollable scr = null;
Dimension pref = null;
view = viewport.getView();
if (view != null && view instanceof Scrollable)
scr = (Scrollable) view;
if (scr != null)
pref = scr.getPreferredScrollableViewportSize();
if (pref == null)
pref = viewport.getPreferredSize();
if (pref != null)
viewportSize.setSize(pref);
}
maybeSetPreferredSize(colHead, columnHeaderSize);
maybeSetPreferredSize(rowHead, rowHeaderSize);
maybeSetPreferredSize(vsb, verticalScrollBarSize);
maybeSetPreferredSize(hsb, horizontalScrollBarSize);
return new Dimension(insetsSize.width
+ viewportSize.width
@ -286,28 +307,26 @@ public class ScrollPaneLayout
Insets viewportInsets = null;
if (viewportBorder != null)
{
viewportInsets = viewportBorder.getBorderInsets(parent);
if (viewportInsets != null)
viewportInsetsSize.setSize(viewportInsets.left + viewportInsets.right,
viewportInsets.top + viewportInsets.bottom);
}
if (insets != null)
insetsSize.setSize(insets.left + insets.right,
insets.top + insets.bottom);
if (viewport != null)
viewportSize.setSize(viewport.getMinimumSize());
maybeSetMinimumSize(viewport, viewportSize);
maybeSetMinimumSize(colHead, columnHeaderSize);
maybeSetMinimumSize(rowHead, rowHeaderSize);
if (colHead != null)
columnHeaderSize.setSize(colHead.getMinimumSize());
if (rowHead != null)
rowHeaderSize.setSize(rowHead.getMinimumSize());
if (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)
maybeSetMinimumSize(vsb, verticalScrollBarSize);
if (vsb != null
&& vsbPolicy != VERTICAL_SCROLLBAR_NEVER)
verticalScrollBarSize.setSize(vsb.getMinimumSize());
if (hsb != null
&& hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER)
horizontalScrollBarSize.setSize(hsb.getMinimumSize());
if (hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER)
maybeSetMinimumSize(hsb, horizontalScrollBarSize);
return new Dimension(insetsSize.width
+ viewportSize.width
@ -355,14 +374,15 @@ public class ScrollPaneLayout
JScrollPane sc = (JScrollPane) parent;
synchronized (sc.getTreeLock ())
{
Rectangle scrollPaneBounds = sc.getBounds();
JViewport viewport = sc.getViewport();
Dimension viewportSize = viewport.getSize();
Dimension viewSize = viewport.getView().getSize();
Dimension viewSize = viewport.getViewSize();
Point viewPos = viewport.getViewPosition();
int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
int y1 = 0, y2 = 0, y3 = 0, y4 = 0;
Rectangle scrollPaneBounds = SwingUtilities.calculateInnerArea(sc, null);
x1 = scrollPaneBounds.x;
y1 = scrollPaneBounds.y;
x4 = scrollPaneBounds.x + scrollPaneBounds.width;
@ -381,26 +401,25 @@ public class ScrollPaneLayout
int vsbPolicy = sc.getVerticalScrollBarPolicy();
int hsbPolicy = sc.getHorizontalScrollBarPolicy();
x3 = x4 - vsb.getPreferredSize().width;
y3 = y4 - hsb.getPreferredSize().height;
boolean showVsb =
(vsb != null)
&& ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS)
|| (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
&& viewSize.height > viewportSize.height));
&& viewSize.height > (y3 - y2)));
boolean showHsb =
(hsb != null)
&& ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS)
|| (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
&& viewSize.width > viewportSize.width));
&& viewSize.width > (x3 - x2)));
if (showVsb)
x3 = x4 - vsb.getPreferredSize().width;
else
if (!showVsb)
x3 = x4;
if (showHsb)
y3 = y4 - hsb.getPreferredSize().height;
else
if (!showHsb)
y3 = y4;
// now set the layout
@ -415,10 +434,20 @@ public class ScrollPaneLayout
rowHead.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));
if (showVsb)
{
vsb.setVisible(true);
vsb.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
}
else if (vsb != null)
vsb.setVisible(false);
if (showHsb)
{
hsb.setVisible(true);
hsb.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));
}
else if (hsb != null)
hsb.setVisible(false);
if (upperLeft != null)
upperLeft.setBounds(new Rectangle(x1, y1, x2-x1, y2-y1));

View file

@ -0,0 +1,580 @@
/* Spring.java --
Copyright (C) 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;
/**
* Calculates the space between component edges, that are layed out by
* {@link SpringLayout}.
* <p>
* A Spring defines a minimum, preferred and maximum distance for each edge
* (north, east, south, west) of a component.
* </p>
* However, springs are not static, their actual values are computed at
* runtime. That means, if a Spring C is defined as the sum of Spring A and
* Spring B, then the values (min, pref and max) are not calculated at
* creation of Spring C, but instead always when {@link #getValue} is
* called. So, when Spring A or Spring B changes, this is reflected in
* Spring C.
*
* @author Roman Kennke (roman@ontographics.com)
*/
public abstract class Spring
{
/** Indicates a not-set value. **/
public static final int UNSET = -2147483648;
/**
* Creates a new Spring object. This constructor is used by the static
* methods which create Springs.
*/
protected Spring()
{
}
/**
* Creates a Spring which min, pref and max values are all the same.
* These kind of Springs are 'struts'.
*
* @param val the constant for min, pref and max values.
* @return a Spring object with constant values for min, pref and max.
*/
public static Spring constant(int val)
{
return new SimpleSpring(val, val, val);
}
/** Creates a Spring which min, pref and max values are constants.
* @param min the constant for the minimum value.
* @param pref the constant for the preferred value.
* @param max the constant for the maximum value.
* @return a Spring object with constant values for min, pref and max.
*/
public static Spring constant(int min, int pref, int max)
{
return new SimpleSpring(min, pref, max);
}
/**
* Returns the maximum value of the Spring.
*
* @return the maximum value.
*/
public abstract int getMaximumValue();
/**
* Returns the minimum value of this Spring.
*
* @return the minimum value.
*/
public abstract int getMinimumValue();
/**
* Return the preferred value of this Spring.
*
* @return the preferred value.
*/
public abstract int getPreferredValue();
/**
* Return the actual value of this Spring.
*
* @return the actual value of this Spring.
*/
public abstract int getValue();
/**
* Creates and returns a Spring, which always has the maximum values
* min = max(min_s1, min_s2), pref = max(pref_s1, pref_s2), max =
* max(max_s1, max_s2).
*
* @param s1 the first summand of the max Spring.
* @param s2 the second summand of the max Spring.
* @return a Spring which is max(s1, s2).
*/
public static Spring max(Spring s1, Spring s2)
{
return new MaxSpring(s1, s2);
}
/**
* Creates and returns a Spring, which is always the negation of s.
* min = -min_s, pref = -pref_s, max = -max_pref.
*
* @param s the Spring to be negated.
* @return the negative of <code>s</code>.
*/
public static Spring minus(Spring s)
{
return new MinusSpring(s);
}
/**
* Sets the actual value. If <code>value</code> is out of the (min, max)
* bounds, then the value is adjusted, so that is inside these bounds.
*
* @param value the value to be set.
*/
public abstract void setValue(int value);
/**
* Creates and returns a Spring, which is always the sum of s1 and s2.
* min_sum = min_s1 + min_s2, pref_sum = pref_s1 + pref_s2, max_sum =
* max_s1 + max_s2.
*
* @param s1 the 1st summand of the sum Spring.
* @param s2 the 2nd summand of the sum Spring.
* @return a sum which is <code>s1 + s2</code>.
*/
public static Spring sum(Spring s1, Spring s2)
{
return new AddSpring(s1, s2);
}
/**
* A simple Spring, that holds constant values for min, pref and max.
*
* @author Roman Kennke (roman@ontographics.com)
*/
private static final class SimpleSpring extends Spring
{
/** The constant value for min. */
private final int min;
/** The constant value for pref. */
private final int pref;
/** The constant value for max. */
private final int max;
/** The actual value of the spring. */
private int value;
/**
* Creates a new SimpleSpring object.
*
* @param min the constant minimum value.
* @param pref the constant preferred value.
* @param max the constant maximum value.
*/
public SimpleSpring(int newMin, int newPref, int newMax)
{
min = newMin;
pref = newPref;
max = newMax;
value = Spring.UNSET;
}
/**
* Returns the maximum value of this Spring.
*
* @return the maximum value.
*/
public int getMaximumValue()
{
return max;
}
/**
* Returns the minimum value of this Spring.
*
* @return the minimum value.
*/
public int getMinimumValue()
{
return min;
}
/**
* Returns the preferred value of this Spring.
*
* @return the preferred value.
*/
public int getPreferredValue()
{
return pref;
}
/**
* Return the actual current value of this Spring.
*
* @return the current value.
*/
public int getValue()
{
if (value == Spring.UNSET)
{
value = pref;
}
return value;
}
/**
* Sets the current value.
*
* @param val the value to be set.
*/
public void setValue(int val)
{
if (val > max)
{
value = max;
}
else if (val < min)
{
value = min;
}
else
{
value = val;
}
}
}
/**
* A Spring, that is the sum of two other Springs.
*
* @author Roman Kennke (roman@ontographics.com)
*/
private static final class AddSpring extends Spring
{
/** The springs, that are the 'operands' of this Spring. */
private final Spring s1;
private final Spring s2;
/** The current value for this Spring. */
private int value;
/**
* Creates a new AddSpring object.
*
* @param s1 the first operand.
* @param s2 the second operand.
*/
protected AddSpring(Spring s1, Spring s2)
{
super();
this.s1 = s1;
this.s2 = s2;
value = Spring.UNSET;
}
/**
* Returns the maximum value of this Spring.
*
* @return the maximum value.
*/
public int getMaximumValue()
{
int max1 = s1.getMaximumValue();
int max2 = s2.getMaximumValue();
return max1 + max2;
}
/**
* Return the minimum value of this Spring.
*
* @return the minimum value.
*/
public int getMinimumValue()
{
int min1 = s1.getMinimumValue();
int min2 = s2.getMinimumValue();
return min1 + min2;
}
/**
* Returns the preferred value of this Spring.
*
* @return the preferred value.
*/
public int getPreferredValue()
{
int pref1 = s1.getPreferredValue();
int pref2 = s2.getPreferredValue();
return pref1 + pref2;
}
/**
* Returns the actual current value of this Spring.
*
* @return the current value of this Spring.
*/
public int getValue()
{
if (value == Spring.UNSET)
{
int val1 = s1.getValue();
int val2 = s2.getValue();
value = val1 + val2;
}
return value;
}
/**
* Sets the current value.
*
* @param val the value to be set.
*/
public void setValue(int val)
{
if (val > getMaximumValue())
{
value = getMaximumValue();
}
else if (val < getMinimumValue())
{
value = getMinimumValue();
}
else
{
value = val;
}
}
}
/**
* A Spring that is calculated as the negation of another Spring.
*
* @author Roman Kennke (roman@ontographics.com)
*/
private static final class MinusSpring extends Spring
{
/** The Spring from which to calculate the negation. */
private final Spring s;
/** The current value of this Spring. */
private int value;
/**
* Creates a new MinusSpring object.
* @param s the Spring from which to calculate the negation.
*/
protected MinusSpring(Spring s)
{
super();
this.s = s;
value = Spring.UNSET;
}
/** Returns the maximum value of this Spring.
*
* @return the maximum value.
*/
public int getMaximumValue()
{
return -s.getMinimumValue();
}
/**
* Returns the minimum value of this Spring.
*
* @return the minimum value.
*/
public int getMinimumValue()
{
return -s.getMaximumValue();
}
/**
* Returns the preferred value of this Spring.
*
* @return the preferred value.
*/
public int getPreferredValue()
{
return -s.getPreferredValue();
}
/**
* Returns the current value of this Spring.
*
* @return the current value.
*/
public int getValue()
{
if (value == Spring.UNSET)
{
value = -s.getValue();
}
return value;
}
/**
* Sets the current value.
*
* @param val the value to be set.
*/
public void setValue(int val)
{
if (val > getMaximumValue())
{
value = getMaximumValue();
}
else if (val < getMinimumValue())
{
value = getMinimumValue();
}
else
{
value = val;
}
}
}
/**
* A Spring, that is calculated as the maximum of two Springs.
*
* @author Roman Kennke (roman@ontographics.com)
*/
private static final class MaxSpring extends Spring
{
/** The two other Springs from which to calculate the maximum. */
private final Spring s1;
private final Spring s2;
/** The current value of this Spring. */
private int value;
/**
* Creates a new MaxSpring object.
*
* @param s1 the 1st operand.
* @param s2 the 2nd operand.
*/
protected MaxSpring(Spring s1, Spring s2)
{
super();
this.s1 = s1;
this.s2 = s2;
value = Spring.UNSET;
}
/**
* Returns the maximum value of this Spring.
*
* @return the maximum value.
*/
public int getMaximumValue()
{
int max1 = s1.getMaximumValue();
int max2 = s2.getMaximumValue();
return Math.max(max1, max2);
}
/**
* Returns the minimum value of this Spring.
*
* @return the minimum value.
*/
public int getMinimumValue()
{
int min1 = s1.getMinimumValue();
int min2 = s2.getMinimumValue();
return Math.max(min1, min2);
}
/**
* Returns the preferred value of this Spring.
*
* @return the preferred value.
*/
public int getPreferredValue()
{
int pref1 = s1.getPreferredValue();
int pref2 = s2.getPreferredValue();
return Math.max(pref1, pref2);
}
/**
* Returns the actual value of this Spring.
*
* @return the current value.
*/
public int getValue()
{
if (value == Spring.UNSET)
{
int val1 = s1.getValue();
int val2 = s2.getValue();
value = Math.max(val1, val2);
}
return value;
}
/**
* Sets the current value.
*
* @param val the value to be set.
*/
public void setValue(int val)
{
if (val > getMaximumValue())
{
value = getMaximumValue();
}
else if (val < getMinimumValue())
{
value = getMinimumValue();
}
else
{
value = val;
}
}
}
}

View file

@ -0,0 +1,660 @@
/* SpringLayout.java --
Copyright (C) 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;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager2;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Spring;
/**
* A very flexible layout manager. Components are laid out by defining the
* relationships between them. The relationships are expressed as
* {@link Spring}s. You can attach a Spring for each edge of a component and
* link it to an edge of a different component. For example, you can say,
* the northern edge of component A should be attached to the southern edge
* of component B, and the space between them should be something between
* x and y pixels, and preferably z pixels.
* <p>While quite simple, this layout manager can be used to emulate most other
* layout managers, and can also be used to solve some layout problems, which
* would be hard to solve with other layout managers.</p>
*
* @author Roman Kennke (roman@ontographics.com)
*/
public class SpringLayout implements LayoutManager2
{
/** The right edge of a component. */
public static final String EAST = "East";
/** The top edge of a component. */
public static final String NORTH = "North";
/** The bottom edge of a component. */
public static final String SOUTH = "South";
/** The left edge of a component. */
public static final String WEST = "West";
/** maps components to their constraints. */
private Map constraintsMap;
/**
* The constraints that define the relationships between components.
* Each Constraints object can hold 4 Springs: one for each edge of the
* component. Additionally it can hold Springs for the components width
* and the components height. Since the height and width constraints are
* dependend on the other constraints, a component can be over-constraint.
* In this case (like when all of NORTH, SOUTH and HEIGHT are constraint),
* the values are adjusted, so that the mathematics still hold true.
*
* @author Roman Kennke (roman@ontographics.com)
*/
public final static class Constraints
{
// The constraints for each edge, and width and height.
/** The Spring for the left edge. */
private Spring x;
/** The Spring for the upper edge. */
private Spring y;
/** The Spring for the height. */
private Spring height;
/** The Spring for the width. */
private Spring width;
/** The Spring for the right edge. */
private Spring east;
/** The Spring for the bottom edge. */
private Spring south;
/**
* Creates a new Constraints object.
* There is no constraint set.
*/
public Constraints()
{
x = y = height = width = east = south = null;
}
/**
* Creates a new Constraints object.
*
* @param x the constraint for the left edge of the component.
* @param y the constraint for the upper edge of the component.
*/
public Constraints(Spring x, Spring y)
{
this.x = x;
this.y = y;
width = height = east = south = null;
}
/**
* Creates a new Constraints object.
*
* @param x the constraint for the left edge of the component.
* @param y the constraint for the upper edge of the component.
* @param width the constraint for the width of the component.
* @param height the constraint for the height of the component.
*/
public Constraints(Spring x, Spring y, Spring width, Spring height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
east = south = null;
}
/**
* Returns the constraint for the edge with the <code>edgeName</code>.
* This is expected to be one of
* {@link #EAST}, {@link #WEST}, {@link NORTH} or {@link SOUTH}.
*
* @param edgeName the name of the edge.
* @return the constraint for the specified edge.
*/
public Spring getConstraint(String edgeName)
{
Spring retVal = null;
if (edgeName.equals(SpringLayout.NORTH))
retVal = y;
else if (edgeName.equals(SpringLayout.WEST))
retVal = x;
else if (edgeName.equals(SpringLayout.SOUTH))
{
retVal = south;
if ((retVal == null) && (y != null) && (height != null))
retVal = Spring.sum(y, height);
}
else if (edgeName.equals(SpringLayout.EAST))
{
retVal = east;
if ((retVal == null) && (x != null) && (width != null))
retVal = Spring.sum(x, width);
}
return retVal;
}
/**
* Returns the constraint for the height of the component.
*
* @return the height constraint.
*/
public Spring getHeight()
{
Spring retVal = height;
if ((retVal == null) && (y != null) && (south != null))
{
retVal = Spring.sum(south, Spring.minus(y));
}
return retVal;
}
/**
* Returns the constraint for the width of the component.
*
* @return the width constraint.
*/
public Spring getWidth()
{
Spring retVal = width;
if ((retVal == null) && (x != null) && (east != null))
{
retVal = Spring.sum(east, Spring.minus(x));
}
return retVal;
}
/**
* Returns the constraint for the left edge of the component.
*
* @return the left-edge constraint (== WEST).
*/
public Spring getX()
{
Spring retVal = x;
if ((retVal == null) && (width != null) && (east != null))
{
retVal = Spring.sum(east, Spring.minus(width));
}
return retVal;
}
/**
* Returns the constraint for the upper edge of the component.
*
* @return the upper-edge constraint (== NORTH).
*/
public Spring getY()
{
Spring retVal = y;
if ((retVal == null) && (height != null) && (south != null))
{
retVal = Spring.sum(south, Spring.minus(height));
}
return retVal;
}
/**
* Sets a constraint for the specified edge. If this leads to an
* over-constrained situation, the constraints get adjusted, so that
* the mathematics still hold true.
*
* @param edgeName the name of the edge, one of {@link #EAST},
* {@link #WEST}, {@link NORTH} or {@link SOUTH}.
* @param s the constraint to be set.
*/
public void setConstraint(String edgeName, Spring s)
{
if (edgeName.equals(SpringLayout.WEST))
{
x = s;
if ((width != null) && (east != null))
width = Spring.sum(east, Spring.minus(x));
}
else if (edgeName.equals(SpringLayout.NORTH))
{
y = s;
if ((height != null) && (south != null))
height = Spring.sum(south, Spring.minus(y));
}
else if (edgeName.equals(SpringLayout.EAST))
{
east = s;
if ((x != null) && (width != null))
x = Spring.sum(east, Spring.minus(width));
}
else if (edgeName.equals(SpringLayout.SOUTH))
{
south = s;
if ((height != null) && (y != null))
y = Spring.sum(south, Spring.minus(height));
}
}
/**
* Sets the height-constraint.
*
* @param s the constraint to be set.
*/
public void setHeight(Spring s)
{
height = s;
if ((south != null) && (y != null))
south = Spring.sum(y, height);
}
/**
* Sets the width-constraint.
*
* @param s the constraint to be set.
*/
public void setWidth(Spring s)
{
width = s;
if ((east != null) && (x != null))
east = Spring.sum(x, width);
}
/**
* Sets the WEST-constraint.
*
* @param s the constraint to be set.
*/
public void setX(Spring s)
{
x = s;
if ((width != null) && (east != null))
width = Spring.sum(east, Spring.minus(x));
}
/**
* Sets the NORTH-constraint.
*
* @param s the constraint to be set.
*/
public void setY(Spring s)
{
y = s;
if ((height != null) && (south != null))
height = Spring.sum(south, Spring.minus(y));
}
}
/**
* Creates a new SpringLayout.
*/
public SpringLayout()
{
constraintsMap = new HashMap();
}
/**
* Adds a layout component and a constraint object to this layout.
* This method is usually only called by a {@java.awt.Container}s add
* Method.
*
* @param component the component to be added.
* @param constraint the constraint to be set.
*/
public void addLayoutComponent(Component component, Object constraint)
{
constraintsMap.put(component, constraint);
}
/**
* Adds a layout component and a constraint object to this layout.
* This method is usually only called by a {@java.awt.Container}s add
* Method. This method does nothing, since SpringLayout does not manage
* String-indexed components.
*
* @param component the component to be added.
* @param constraint the constraint to be set.
*/
public void addLayoutComponent(String name, Component c)
{
// do nothing here.
}
/**
* Returns the constraint of the edge named by <code>edgeName</code>.
*
* @param c the component from which to get the constraint.
* @param edgeName the name of the edge, one of {@link #EAST},
* {@link #WEST}, {@link NORTH} or {@link SOUTH}.
* @return the constraint of the edge <code>edgeName</code> of the
* component c.
*/
public Spring getConstraint(String edgeName, Component c)
{
Constraints constraints = getConstraints(c);
return constraints.getConstraint(edgeName);
}
/**
* Returns the {@link Constraints} object associated with the specified
* component.
*
* @param c the component for which to determine the constraint.
* @return the {@link Constraints} object associated with the specified
* component.
*/
public SpringLayout.Constraints getConstraints(Component c)
{
Constraints constraints = (Constraints) constraintsMap.get(c);
if (constraints == null)
{
Container parent = c.getParent();
constraints = new Constraints();
if (parent != null)
{
constraints.setX
(Spring.constant(parent.getInsets().left));
constraints.setY
(Spring.constant(parent.getInsets().top));
}
else
{
constraints.setX
(Spring.constant(0));
constraints.setY
(Spring.constant(0));
}
constraints.setWidth
(Spring.constant(c.getMinimumSize().width,
c.getPreferredSize().width,
c.getMaximumSize().width));
constraints.setHeight
(Spring.constant(c.getMinimumSize().height,
c.getPreferredSize().height,
c.getMaximumSize().height));
constraintsMap.put(c, constraints);
}
return constraints;
}
/**
* Returns the X alignment of the Container <code>p</code>.
*
* @param p the {@link java.awt.Container} for which to determine the X
* alignment.
* @return always 0.0
*/
public float getLayoutAlignmentX(Container p)
{
return 0.0F;
}
/**
* Returns the Y alignment of the Container <code>p</code>.
*
* @param p the {@link java.awt.Container} for which to determine the Y
* alignment.
* @return always 0.0
*/
public float getLayoutAlignmentY(Container p)
{
return 0.0F;
}
/**
* Recalculate a possibly cached layout.
*/
public void invalidateLayout(Container p)
{
// nothing to do here yet
}
/**
* Lays out the container <code>p</code>.
*
* @param p the container to be laid out.
*/
public void layoutContainer(Container p)
{
addLayoutComponent(p, new Constraints(Spring.constant(0),
Spring.constant(0)));
int offsetX = p.getInsets().left;
int offsetY = p.getInsets().right;
Component[] components = p.getComponents();
for (int index = 0; index < components.length; index++)
{
Component c = components[index];
Constraints constraints = getConstraints(c);
int x = constraints.getX().getValue();
int y = constraints.getY().getValue();
int width = constraints.getWidth().getValue();
int height = constraints.getHeight().getValue();
c.setLocation(x + offsetX, y + offsetY);
c.setSize(width, height);
}
}
/**
* Calculates the maximum size of the layed out container. This
* respects the maximum sizes of all contained components.
*
* @param p the container to be laid out.
* @return the maximum size of the container.
*/
public Dimension maximumLayoutSize(Container p)
{
int maxX = 0;
int maxY = 0;
int offsetX = p.getInsets().left;
int offsetY = p.getInsets().right;
Component[] components = p.getComponents();
for (int index = 0; index < components.length; index++)
{
Component c = components[index];
Constraints constraints = getConstraints(c);
int x = constraints.getX().getMaximumValue();
int y = constraints.getY().getMaximumValue();
int width = constraints.getWidth().getMaximumValue();
int height = constraints.getHeight().getMaximumValue();
int rightEdge = offsetX + x + width;
if (rightEdge > maxX)
maxX = rightEdge;
int bottomEdge = offsetY + y + height;
if (bottomEdge > maxY)
maxY = bottomEdge;
}
return new Dimension(maxX, maxY);
}
/**
* Calculates the minimum size of the layed out container. This
* respects the minimum sizes of all contained components.
*
* @param p the container to be laid out.
* @return the minimum size of the container.
*/
public Dimension minimumLayoutSize(Container p)
{
int maxX = 0;
int maxY = 0;
int offsetX = p.getInsets().left;
int offsetY = p.getInsets().right;
Component[] components = p.getComponents();
for (int index = 0; index < components.length; index++)
{
Component c = components[index];
Constraints constraints = getConstraints(c);
int x = constraints.getX().getMinimumValue();
int y = constraints.getY().getMinimumValue();
int width = constraints.getWidth().getMinimumValue();
int height = constraints.getHeight().getMinimumValue();
int rightEdge = offsetX + x + width;
if (rightEdge > maxX)
maxX = rightEdge;
int bottomEdge = offsetY + y + height;
if (bottomEdge > maxY)
maxY = bottomEdge;
}
return new Dimension(maxX, maxY);
}
/**
* Calculates the preferred size of the layed out container. This
* respects the preferred sizes of all contained components.
*
* @param p the container to be laid out.
* @return the preferred size of the container.
*/
public Dimension preferredLayoutSize(Container p)
{
int maxX = 0;
int maxY = 0;
int offsetX = p.getInsets().left;
int offsetY = p.getInsets().right;
Component[] components = p.getComponents();
for (int index = 0; index < components.length; index++)
{
Component c = components[index];
Constraints constraints = getConstraints(c);
int x = constraints.getX().getPreferredValue();
int y = constraints.getY().getPreferredValue();
int width = constraints.getWidth().getPreferredValue();
int height = constraints.getHeight().getPreferredValue();
int rightEdge = offsetX + x + width;
if (rightEdge > maxX)
maxX = rightEdge;
int bottomEdge = offsetY + y + height;
if (bottomEdge > maxY)
maxY = bottomEdge;
}
return new Dimension(maxX, maxY);
}
/**
* Attaches the edge <code>e1</code> of component <code>c1</code> to
* the edge <code>e2</code> of component <code>c2</code> width the
* fixed strut <code>pad</code>.
*
* @param e1 the edge of component 1.
* @param c1 the component 1.
* @param pad the space between the components in pixels.
* @param e2 the edge of component 2.
* @param c2 the component 2.
*/
public void putConstraint(String e1, Component c1, int pad, String e2,
Component c2)
{
Constraints constraints1 = getConstraints(c1);
Constraints constraints2 = getConstraints(c2);
Spring strut = Spring.constant(pad);
Spring otherEdge = constraints2.getConstraint(e2);
constraints1.setConstraint(e1, Spring.sum(strut, otherEdge));
}
/**
* Attaches the edge <code>e1</code> of component <code>c1</code> to
* the edge <code>e2</code> of component <code>c2</code> width the
* {@link Spring} <code>s</code>.
*
* @param e1 the edge of component 1.
* @param c1 the component 1.
* @param s the space between the components as a {@link Spring} object.
* @param e2 the edge of component 2.
* @param c2 the component 2.
*/
public void putConstraint(String e1, Component c1, Spring s, String e2,
Component c2)
{
Constraints constraints1 = getConstraints(c1);
Constraints constraints2 = getConstraints(c2);
Spring otherEdge = constraints2.getConstraint(e2);
constraints1.setConstraint(e1, Spring.sum(s, otherEdge));
}
/**
* Removes a layout component.
* @param c the layout component to remove.
*/
public void removeLayoutComponent(Component c)
{
// do nothing here
}
}

View file

@ -65,8 +65,11 @@ import java.lang.reflect.InvocationTargetException;
*/
public class SwingUtilities implements SwingConstants
{
private static Frame ownerFrame;
/**
* This frame should be used as parent for JWindow or JDialog
* that doesn't an owner
*/
private static OwnerFrame ownerFrame;
/**
* Calculates the portion of the base rectangle which is inside the
@ -197,8 +200,6 @@ public class SwingUtilities implements SwingConstants
*
* @see #getAncestorOfClass
* @see #windowForComponent
* @see
*
*/
public static Container getAncestorOfClass(Class c, Component comp)
{
@ -711,11 +712,14 @@ public class SwingUtilities implements SwingConstants
{
case TOP:
textR.y = 0;
iconR.y = textR.height + textIconGap;
iconR.y = (horizontalTextPosition == CENTER
? textR.height + textIconGap : 0);
break;
case BOTTOM:
iconR.y = 0;
textR.y = iconR.height + textIconGap;
textR.y = (horizontalTextPosition == CENTER
? iconR.height + textIconGap
: iconR.height - textR.height);
break;
case CENTER:
int centerLine = Math.max(textR.height, iconR.height) / 2;
@ -838,15 +842,15 @@ public class SwingUtilities implements SwingConstants
}
/**
* This method returns the common Frame owner used in JDialogs
* when no owner is provided.
* This method returns the common Frame owner used in JDialogs or
* JWindow when no owner is provided.
*
* @return The common Frame
*/
static Frame getOwnerFrame()
{
if (ownerFrame == null)
ownerFrame = new Frame();
ownerFrame = new OwnerFrame();
return ownerFrame;
}
@ -888,4 +892,23 @@ public class SwingUtilities implements SwingConstants
return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK)
== InputEvent.BUTTON3_DOWN_MASK);
}
/**
* This frame should be used when constructing a Window/JDialog without
* a parent. In this case, we are forced to use this frame as a window's
* parent, because we simply cannot pass null instead of parent to Window
* constructor, since doing it will result in NullPointerException.
*/
private static class OwnerFrame extends Frame
{
public void setVisible(boolean b)
{
// Do nothing here.
}
public boolean isShowing()
{
return true;
}
}
}

View file

@ -114,6 +114,7 @@ public class Timer implements Serializable
while (running)
{
sleep(delay);
queueEvent();
if (logTimers)
System.out.println("javax.swing.Timer -> clocktick");

View file

@ -43,135 +43,86 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
/**
* ToolTipManager
*
* @author Andrew Selkirk
* @version 1.0
*/
public class ToolTipManager extends MouseAdapter implements MouseMotionListener {
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
public class ToolTipManager extends MouseAdapter
implements MouseMotionListener
{
/**
* stillInsideTimerAction
*/
protected class stillInsideTimerAction implements ActionListener {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
protected class stillInsideTimerAction
implements ActionListener
{
/**
* Constructor stillInsideTimerAction
* @param manager TODO
*/
protected stillInsideTimerAction(ToolTipManager manager) {
protected stillInsideTimerAction()
{
// TODO
} // stillInsideTimerAction()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
}
/**
* actionPerformed
* @param event TODO
*/
public void actionPerformed(ActionEvent event) {
public void actionPerformed(ActionEvent event)
{
// TODO
} // actionPerformed()
} // stillInsideTimerAction
}
}
/**
* outsideTimerAction
*/
protected class outsideTimerAction implements ActionListener {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
protected class outsideTimerAction
implements ActionListener
{
/**
* Constructor outsideTimerAction
* @param manager TODO
*/
protected outsideTimerAction(ToolTipManager manager) {
protected outsideTimerAction()
{
// TODO
} // outsideTimerAction()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
}
/**
* actionPerformed
* @param value0 TODO
*/
public void actionPerformed(ActionEvent event) {
public void actionPerformed(ActionEvent event)
{
// TODO
} // actionPerformed()
} // outsideTimerAction
}
}
/**
* insideTimerAction
*/
protected class insideTimerAction implements ActionListener {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
protected class insideTimerAction
implements ActionListener
{
/**
* Constructor insideTimerAction
* @param manager TODO
*/
protected insideTimerAction(ToolTipManager manager) {
protected insideTimerAction()
{
// TODO
} // insideTimerAction()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
}
/**
* actionPerformed
* @param event TODO
*/
public void actionPerformed(ActionEvent event) {
public void actionPerformed(ActionEvent event)
{
// TODO
} // actionPerformed()
} // insideTimerAction
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
}
}
/**
* enterTimer
@ -228,166 +179,173 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
*/
protected boolean heavyWeightPopupEnabled;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor ToolTipManager
*/
ToolTipManager() {
ToolTipManager()
{
// TODO
} // ToolTipManager()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
}
/**
* sharedInstance
* @returns ToolTipManager
* @return ToolTipManager
*/
public static ToolTipManager sharedInstance() {
public static ToolTipManager sharedInstance()
{
return null; // TODO
} // sharedInstance()
}
/**
* setEnabled
* @param enabled TODO
*/
public void setEnabled(boolean enabled) {
public void setEnabled(boolean enabled)
{
// TODO
} // setEnabled()
}
/**
* isEnabled
* @returns boolean
* @return boolean
*/
public boolean isEnabled() {
public boolean isEnabled()
{
return false; // TODO
} // isEnabled()
}
/**
* isLightWeightPopupEnabled
* @returns boolean
* @return boolean
*/
public boolean isLightWeightPopupEnabled() {
public boolean isLightWeightPopupEnabled()
{
return false; // TODO
} // isLightWeightPopupEnabled()
}
/**
* setLightWeightPopupEnabled
* @param enabled TODO
*/
public void setLightWeightPopupEnabled(boolean enabled) {
public void setLightWeightPopupEnabled(boolean enabled)
{
// TODO
} // setLightWeightPopupEnabled()
}
/**
* getInitialDelay
* @returns int
* @return int
*/
public int getInitialDelay() {
public int getInitialDelay()
{
return 0; // TODO
} // getInitialDelay()
}
/**
* setInitialDelay
* @param delay TODO
*/
public void setInitialDelay(int delay) {
public void setInitialDelay(int delay)
{
// TODO
} // setInitialDelay()
}
/**
* getDismissDelay
* @returns int
* @return int
*/
public int getDismissDelay() {
public int getDismissDelay()
{
return 0; // TODO
} // getDismissDelay()
}
/**
* setDismissDelay
* @param delay TODO
*/
public void setDismissDelay(int delay) {
public void setDismissDelay(int delay)
{
// TODO
} // setDismissDelay()
}
/**
* getReshowDelay
* @returns int
* @return int
*/
public int getReshowDelay() {
public int getReshowDelay()
{
return 0; // TODO
} // getReshowDelay()
}
/**
* setReshowDelay
* @param delay TODO
*/
public void setReshowDelay(int delay) {
public void setReshowDelay(int delay)
{
// TODO
} // setReshowDelay()
}
/**
* registerComponent
* @param component TODO
*/
public void registerComponent(JComponent component) {
public void registerComponent(JComponent component)
{
// TODO
} // registerComponent()
}
/**
* unregisterComponent
* @param component TODO
*/
public void unregisterComponent(JComponent component) {
public void unregisterComponent(JComponent component)
{
// TODO
} // unregisterComponent()
}
/**
* mouseEntered
* @param event TODO
*/
public void mouseEntered(MouseEvent event) {
public void mouseEntered(MouseEvent event)
{
// TODO
} // mouseEntered()
}
/**
* mouseExited
* @param event TODO
*/
public void mouseExited(MouseEvent event) {
public void mouseExited(MouseEvent event)
{
// TODO
} // mouseExited()
}
/**
* mousePressed
* @param event TODO
*/
public void mousePressed(MouseEvent event) {
public void mousePressed(MouseEvent event)
{
// TODO
} // mousePressed()
}
/**
* mouseDragged
* @param event TODO
*/
public void mouseDragged(MouseEvent event) {
public void mouseDragged(MouseEvent event)
{
// TODO
} // mouseDragged()
}
/**
* mouseMoved
* @param event TODO
*/
public void mouseMoved(MouseEvent event) {
public void mouseMoved(MouseEvent event)
{
// TODO
} // mouseMoved()
} // ToolTipManager
}
}

View file

@ -43,10 +43,9 @@ import java.awt.Font;
import java.awt.Insets;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Locale;
@ -66,15 +65,14 @@ import javax.swing.plaf.ComponentUI;
*/
public class UIDefaults extends Hashtable
{
private LinkedList bundles;
private Locale defaultLocale;
private PropertyChangeSupport propertyChangeSupport;
LinkedList bundles;
Set listeners;
Locale defaultLocale;
interface ActiveValue
public interface ActiveValue
{
Object createValue(UIDefaults table);
} // interface ActiveValue
}
public static class LazyInputMap implements LazyValue
{
@ -93,12 +91,12 @@ public class UIDefaults extends Hashtable
}
return im;
}
} // class LazyInputMap
}
interface LazyValue
public interface LazyValue
{
Object createValue(UIDefaults table);
} // interface LazyValue
}
public static class ProxyLazyValue implements LazyValue
{
@ -209,28 +207,24 @@ public class UIDefaults extends Hashtable
{
return inner.createValue (table);
}
} // class ProxyLazyValue
}
private static final long serialVersionUID = 7341222528856548117L;
public UIDefaults()
{
bundles = new LinkedList ();
listeners = new HashSet ();
defaultLocale = Locale.getDefault ();
propertyChangeSupport = new PropertyChangeSupport(this);
}
public UIDefaults(Object[] entries)
{
bundles = new LinkedList ();
listeners = new HashSet ();
defaultLocale = Locale.getDefault ();
this();
for (int i = 0; (2*i+1) < entries.length; ++i)
{
put (entries[2*i], entries[2*i+1]);
}
}
public Object get(Object key)
{
@ -472,7 +466,6 @@ public class UIDefaults extends Hashtable
getUIError ("InvocationTargetException ("+ ite.getTargetException()
+") calling createUI(...) on " + cls.toString ());
return null;
}
catch (Exception e)
{
@ -481,43 +474,38 @@ public class UIDefaults extends Hashtable
}
}
void addPropertyChangeListener(PropertyChangeListener listener)
public void addPropertyChangeListener(PropertyChangeListener listener)
{
listeners.add (listener);
propertyChangeSupport.addPropertyChangeListener(listener);
}
void removePropertyChangeListener(PropertyChangeListener listener)
{
listeners.remove (listener);
propertyChangeSupport.removePropertyChangeListener(listener);
}
public PropertyChangeListener[] getPropertyChangeListeners()
{
return (PropertyChangeListener[]) listeners.toArray ();
return propertyChangeSupport.getPropertyChangeListeners();
}
protected void firePropertyChange(String property, Object o, Object n)
protected void firePropertyChange(String property,
Object oldValue, Object newValue)
{
Iterator i = listeners.iterator ();
PropertyChangeEvent pce = new PropertyChangeEvent (this, property, o, n);
while (i.hasNext ())
{
PropertyChangeListener pcl = (PropertyChangeListener) i.next ();
pcl.propertyChange (pce);
}
propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
}
void addResourceBundle(String name)
public void addResourceBundle(String name)
{
bundles.addFirst (name);
}
void removeResourceBundle(String name)
public void removeResourceBundle(String name)
{
bundles.remove (name);
}
void setDefaultLocale(Locale loc)
public void setDefaultLocale(Locale loc)
{
defaultLocale = loc;
}
@ -526,4 +514,4 @@ public class UIDefaults extends Hashtable
{
return defaultLocale;
}
} // class UIDefaults
}

View file

@ -87,18 +87,31 @@ public class UIManager implements Serializable
// Do nothing here.
}
/**
* Add a <code>PropertyChangeListener</code> to the listener list.
*
* @param listener the listener to add
*/
public static void addPropertyChangeListener (PropertyChangeListener listener)
{
// FIXME
}
/**
* Remove a <code>PropertyChangeListener</code> from the listener list.
*
* @param listener the listener to remove
*/
public static void removePropertyChangeListener (PropertyChangeListener listener)
// Remove a PropertyChangeListener from the listener list.
{
// FIXME
}
/**
* Returns an array of all added <code>PropertyChangeListener</code> objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public static PropertyChangeListener[] getPropertyChangeListeners ()
@ -107,9 +120,11 @@ public class UIManager implements Serializable
throw new Error ("Not implemented");
}
/**
* Add a LookAndFeel to the list of auxiliary look and feels.
*/
public static void addAuxiliaryLookAndFeel (LookAndFeel l)
{
// Add a LookAndFeel to the list of auxiliary look and feels.
if (aux_installed == null)
{
aux_installed = new LookAndFeel[1];
@ -201,14 +216,18 @@ public class UIManager implements Serializable
return (Font) getLookAndFeel().getDefaults().get(key);
}
/**
* Returns an Icon from the defaults table.
*/
public static Icon getIcon(Object key)
// Returns an Icon from the defaults table.
{
return (Icon) getLookAndFeel().getDefaults().get(key);
}
/**
* Returns an Insets object from the defaults table.
*/
public static Insets getInsets(Object key)
// Returns an Insets object from the defaults table.
{
return (Insets) getLookAndFeel().getDefaults().getInsets(key);
}
@ -240,49 +259,71 @@ public class UIManager implements Serializable
return getLookAndFeel().getDefaults();
}
/**
* Returns a string from the defaults table.
*/
public static String getString(Object key)
// Returns a string from the defaults table.
{
return (String) getLookAndFeel().getDefaults().get(key);
}
/**
* Returns the name of the LookAndFeel class that implements the
* native systems look and feel if there is one, otherwise the name
* of the default cross platform LookAndFeel class.
*/
public static String getSystemLookAndFeelClassName()
// Returns the name of the LookAndFeel class that implements the native systems look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.
{
return getCrossPlatformLookAndFeelClassName();
}
/**
* Returns the L&amp;F object that renders the target component.
*/
public static ComponentUI getUI(JComponent target)
// Returns the Look and Feel object that renders the target component.
{
ComponentUI ui = getDefaults().getUI(target);
//System.out.println("GET-UI-> " + ui + ", for " + target);
return ui;
return getDefaults().getUI(target);
}
/**
* Creates a new look and feel and adds it to the current array.
*/
public static void installLookAndFeel(String name, String className)
// Creates a new look and feel and adds it to the current array.
{
}
/**
* Adds the specified look and feel to the current array and then calls
* setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).
*/
public static void installLookAndFeel(LookAndFeelInfo info)
// Adds the specified look and feel to the current array and then calls setInstalledLookAndFeels(javax.swing.UIManager.LookAndFeelInfo[]).
{
}
/**
* Stores an object in the defaults table.
*/
public static Object put(Object key, Object value)
// Stores an object in the defaults table.
{
return getLookAndFeel().getDefaults().put(key,value);
}
/**
* Replaces the current array of installed LookAndFeelInfos.
*/
public static void setInstalledLookAndFeels(UIManager.LookAndFeelInfo[] infos)
// Replaces the current array of installed LookAndFeelInfos.
{
}
/**
* Set the current default look.
*/
public static void setLookAndFeel(LookAndFeel newLookAndFeel)
throws UnsupportedLookAndFeelException
{
if (! newLookAndFeel.isSupportedLookAndFeel())
throw new UnsupportedLookAndFeelException(newLookAndFeel.getName());
if (look_and_feel != null)
look_and_feel.uninitialize();
@ -294,11 +335,13 @@ public class UIManager implements Serializable
//repaint();
}
/**
* Set the current default look and feel using a class name.
*/
public static void setLookAndFeel (String className)
throws ClassNotFoundException, InstantiationException, IllegalAccessException,
UnsupportedLookAndFeelException
{
// Set the current default look and feel using a class name.
Class c = Class.forName(className);
LookAndFeel a = (LookAndFeel) c.newInstance(); // throws class-cast-exception
setLookAndFeel(a);

View file

@ -67,13 +67,6 @@ public class ViewportLayout implements LayoutManager, Serializable
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
if (view instanceof Scrollable)
{
Scrollable sc = (Scrollable) view;
Dimension d = sc.getPreferredScrollableViewportSize();
return d;
}
else
return view.getPreferredSize();
}
public Dimension minimumLayoutSize(Container parent)
@ -126,7 +119,7 @@ public class ViewportLayout implements LayoutManager, Serializable
// the viewport require inputs in view space.
Rectangle portBounds = port.getViewRect();
Dimension viewSize = port.getViewSize();
Dimension viewPref = view.getPreferredSize();
Dimension viewMinimum = view.getMinimumSize();
Point portLowerRight = new Point(portBounds.x + portBounds.width,
portBounds.y + portBounds.height);
@ -135,12 +128,12 @@ public class ViewportLayout implements LayoutManager, Serializable
if (portBounds.height >= viewMinimum.height)
{
portBounds.y = 0;
viewSize.height = portBounds.height;
viewPref.height = portBounds.height;
}
else
{
viewSize.height = viewMinimum.height;
int overextension = portLowerRight.y - viewSize.height;
viewPref.height = viewMinimum.height;
int overextension = portLowerRight.y - viewPref.height;
if (overextension > 0)
portBounds.y -= overextension;
}
@ -149,17 +142,17 @@ public class ViewportLayout implements LayoutManager, Serializable
if (portBounds.width >= viewMinimum.width)
{
portBounds.x = 0;
viewSize.width = portBounds.width;
viewPref.width = portBounds.width;
}
else
{
viewSize.width = viewMinimum.width;
int overextension = portLowerRight.x - viewSize.width;
viewPref.width = viewMinimum.width;
int overextension = portLowerRight.x - viewPref.width;
if (overextension > 0)
portBounds.x -= overextension;
}
port.setViewPosition(portBounds.getLocation());
port.setViewSize(viewSize);
port.setViewSize(viewPref);
}
}

View file

@ -40,9 +40,11 @@ package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Graphics;
import java.awt.Polygon;
import java.awt.Rectangle;
import javax.swing.border.Border;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.SwingConstants;
@ -170,6 +172,47 @@ public class BasicArrowButton extends JButton implements SwingConstants
/** The top and left edges of the button. */
private transient Color highlight = Color.BLACK;
/** The border around the ArrowButton. */
private transient Border tmpBorder = new Border()
{
public Insets getBorderInsets(Component c)
{
return new Insets(0, 0, 0, 0);
}
public boolean isBorderOpaque()
{
return false;
}
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h)
{
Rectangle bounds = getBounds();
Color saved = g.getColor();
g.setColor(highlight);
g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height);
g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);
g.setColor(shadow);
g.drawLine(bounds.x + 1, bounds.y + bounds.height - 1,
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
g.drawLine(bounds.x + bounds.width - 1, bounds.y + 1,
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
g.setColor(darkShadow);
g.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width,
bounds.y + bounds.height);
g.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width,
bounds.y + bounds.height);
g.setColor(saved);
}
};
/**
* Creates a new BasicArrowButton object.
*
@ -179,6 +222,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
{
super();
setDirection(direction);
setBorder(tmpBorder);
}
/**
@ -234,29 +278,6 @@ public class BasicArrowButton extends JButton implements SwingConstants
public void paint(Graphics g)
{
super.paint(g);
Rectangle bounds = getBounds();
Color saved = g.getColor();
g.setColor(highlight);
g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height);
g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);
g.setColor(shadow);
g.drawLine(bounds.x + 1, bounds.y + bounds.height - 1,
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
g.drawLine(bounds.x + bounds.width - 1, bounds.y + 1,
bounds.x + bounds.width - 1, bounds.y + bounds.height - 1);
g.setColor(darkShadow);
g.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width,
bounds.y + bounds.height);
g.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width,
bounds.y + bounds.height);
g.setColor(saved);
}
/**

View file

@ -61,7 +61,7 @@ public class BasicButtonUI extends ButtonUI
{
/** A constant used to pad out elements in the button's layout and
preferred size calculations. */
int defaultTextIconGap = 3;
int defaultTextIconGap = 4;
/** A constant added to the defaultTextIconGap to adjust the text
within this particular button. */
@ -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.setIconTextGap(defaults.getInt("Button.textIconGap"));
b.setOpaque(true);
}
@ -100,6 +101,7 @@ public class BasicButtonUI extends ButtonUI
b.setForeground(null);
b.setBackground(null);
b.setBorder(null);
b.setIconTextGap(defaultTextIconGap);
b.setMargin(null);
}
@ -234,19 +236,19 @@ public class BasicButtonUI extends ButtonUI
b.getVerticalTextPosition(),
b.getHorizontalTextPosition(),
vr, ir, tr,
defaultTextIconGap
b.getIconTextGap()
+ defaultTextShiftOffset);
if ((b.getModel().isArmed() && b.getModel().isPressed())
|| b.isSelected())
paintButtonPressed(g, br, c);
paintButtonPressed(g, b);
else
paintButtonNormal(g, br, c);
paintIcon(g, c, ir);
if (text != null)
paintText(g, c, tr, b.getText());
paintFocus(g, c, vr, tr, ir);
paintText(g, b, tr, text);
paintFocus(g, b, vr, tr, ir);
}
/**
@ -256,7 +258,7 @@ public class BasicButtonUI extends ButtonUI
* "focusPainted" property is <code>true</code>.
*
* @param g Graphics context to paint with
* @param c Component to paint the focus of
* @param b Button to paint the focus of
* @param vr Visible rectangle, the area in which to paint
* @param tr Text rectangle, contained in visible rectangle
* @param ir Icon rectangle, contained in visible rectangle
@ -264,10 +266,9 @@ public class BasicButtonUI extends ButtonUI
* @see AbstractButton.isFocusPainted()
* @see JComponent.hasFocus()
*/
protected void paintFocus(Graphics g, JComponent c, Rectangle vr,
protected void paintFocus(Graphics g, AbstractButton b, Rectangle vr,
Rectangle tr, Rectangle ir)
{
AbstractButton b = (AbstractButton) c;
if (b.hasFocus() && b.isFocusPainted())
{
Graphics2D g2 = (Graphics2D) g;
@ -313,13 +314,14 @@ public class BasicButtonUI extends ButtonUI
* pressedBackgroundColor}.
*
* @param g The graphics context to paint with
* @param area The area in which to paint
* @param b The component to paint the state of
* @param b The button to paint the state of
*/
protected void paintButtonPressed(Graphics g, Rectangle area, JComponent b)
protected void paintButtonPressed(Graphics g, AbstractButton b)
{
if (((AbstractButton)b).isContentAreaFilled())
if (b.isContentAreaFilled())
{
Rectangle area = new Rectangle();
SwingUtilities.calculateInnerArea(b, area);
g.setColor(b.getBackground().darker());
g.fillRect(area.x, area.y, area.width, area.height);
}
@ -334,7 +336,7 @@ public class BasicButtonUI extends ButtonUI
* @param area The area in which to paint
* @param b The component to paint the state of
*/
protected void paintButtonNormal(Graphics g, Rectangle area, JComponent b)
private void paintButtonNormal(Graphics g, Rectangle area, JComponent b)
{
if (((AbstractButton)b).isContentAreaFilled() && b.isOpaque())
{
@ -355,20 +357,37 @@ public class BasicButtonUI extends ButtonUI
protected void paintText(Graphics g, JComponent c, Rectangle textRect,
String text)
{
Font f = c.getFont();
paintText(g, (AbstractButton) c, textRect, text);
}
/**
* Paints the "text" property of an {@link AbstractButton}, using the
* {@link textColor} color.
*
* @param g The graphics context to paint with
* @param b The button to paint the state of
* @param textRect The area in which to paint the text
* @param text The text to paint
*
* @since 1.4
*/
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect,
String text)
{
Font f = b.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
if (c.isEnabled())
if (b.isEnabled())
{
g.setColor(c.getForeground());
g.setColor(b.getForeground());
g.drawString(text, textRect.x, textRect.y + fm.getAscent());
}
else
{
g.setColor(c.getBackground().brighter());
g.setColor(b.getBackground().brighter());
g.drawString(text, textRect.x, textRect.y + fm.getAscent());
g.setColor(c.getBackground().darker());
g.setColor(b.getBackground().darker());
g.drawString(text, textRect.x + 1, textRect.y + fm.getAscent() + 1);
}
}

View file

@ -53,11 +53,12 @@ import javax.swing.plaf.ComponentUI;
public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
{
/**
* DOCUMENT ME!
* Factory method to create a BasicCheckBoxMenuItemUI for the given {@link
* JComponent}, which should be a JCheckBoxMenuItem
*
* @param c DOCUMENT ME!
* @param c The {@link JComponent} a UI is being created for.
*
* @return $returnType$ DOCUMENT ME!
* @return A BasicCheckBoxMenuItemUI for the {@link JComponent}.
*/
public static ComponentUI createUI(final JComponent c)
{
@ -71,11 +72,12 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
*/
protected String getPropertyPrefix()
{
return null; // TODO
return null;
}
/**
* DOCUMENT ME!
* This method installs the defaults that are defined in the Basic look and
* feel for this JRadioButtonMenuItem
*/
protected void installDefaults()
{
@ -93,7 +95,8 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement[] path,
public void processMouseEvent(JMenuItem item, MouseEvent e,
MenuElement[] path,
MenuSelectionManager manager)
{
}

View file

@ -37,6 +37,7 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.AWTEvent;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@ -179,6 +180,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
/** The direction that the resize is occuring in. */
private transient int direction = -1;
/** Cache rectangle that can be reused. */
private transient Rectangle cacheRect = new Rectangle();
/**
* This method is called when the mouse is clicked.
*
@ -204,6 +208,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
return;
DesktopManager dm = getDesktopManager();
Rectangle b = frame.getBounds();
Dimension min = frame.getMinimumSize();
if (min == null)
min = new Dimension(0, 0);
Insets insets = frame.getInsets();
int x = e.getX();
int y = e.getY();
@ -212,31 +219,43 @@ public class BasicInternalFrameUI extends InternalFrameUI
switch (direction)
{
case NORTH:
dm.resizeFrame(frame, b.x, b.y + y, b.width, b.height - y);
cacheRect.setBounds(b.x,
Math.min(b.y + y, b.y + b.height
- min.height), b.width, b.height
- y);
break;
case NORTH_EAST:
dm.resizeFrame(frame, b.x, b.y + y, x, b.height - y);
cacheRect.setBounds(b.x,
Math.min(b.y + y, b.y + b.height
- min.height), x, b.height - y);
break;
case EAST:
dm.resizeFrame(frame, b.x, b.y, x, b.height);
cacheRect.setBounds(b.x, b.y, x, b.height);
break;
case SOUTH_EAST:
dm.resizeFrame(frame, b.x, b.y, x, y);
cacheRect.setBounds(b.x, b.y, x, y);
break;
case SOUTH:
dm.resizeFrame(frame, b.x, b.y, b.width, y);
cacheRect.setBounds(b.x, b.y, b.width, y);
break;
case SOUTH_WEST:
dm.resizeFrame(frame, b.x + x, b.y, b.width - x, y);
cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
b.y, b.width - x, y);
break;
case WEST:
dm.resizeFrame(frame, b.x + x, b.y, b.width - x, b.height);
cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
b.y, b.width - x, b.height);
break;
case NORTH_WEST:
dm.resizeFrame(frame, b.x + x, b.y + y, b.width - x, b.height
- y);
cacheRect.setBounds(Math.min(b.x + x, b.x + b.width - min.width),
Math.min(b.y + y, b.y + b.height
- min.height), b.width - x,
b.height - y);
break;
}
dm.resizeFrame(frame, cacheRect.x, cacheRect.y,
Math.max(min.width, cacheRect.width),
Math.max(min.height, cacheRect.height));
}
else if (e.getSource() == titlePane)
{
@ -498,7 +517,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public Dimension minimumLayoutSize(Container c)
{
return preferredLayoutSize(c);
return getSize(c, true);
}
/**
@ -521,10 +540,25 @@ public class BasicInternalFrameUI extends InternalFrameUI
* @return The preferred dimensions for the JInternalFrame.
*/
public Dimension preferredLayoutSize(Container c)
{
return getSize(c, false);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
* @param min DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private Dimension getSize(Container c, boolean min)
{
Insets insets = frame.getInsets();
Dimension contentDims = frame.getContentPane().getPreferredSize();
if (min)
contentDims.width = contentDims.height = 0;
int nWidth = 0;
int nHeight = 0;
int sWidth = 0;
@ -578,8 +612,8 @@ public class BasicInternalFrameUI extends InternalFrameUI
int width = Math.max(sWidth, nWidth);
width = Math.max(width, contentDims.width + eWidth + wWidth);
int height = Math.max(contentDims.height, eHeight);
height = Math.max(height, wHeight);
int height = Math.max(eHeight, wHeight);
height = Math.max(height, contentDims.height);
height += nHeight + sHeight;
width += insets.left + insets.right;
@ -606,6 +640,18 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
protected class GlassPaneDispatcher implements MouseInputListener
{
/** The MouseEvent target. */
private transient Component mouseEventTarget;
/** The component pressed. */
private transient Component pressedComponent;
/** The last component entered. */
private transient Component lastComponentEntered;
/** The number of presses. */
private transient int pressCount;
/**
* This method is called when the mouse enters the glass pane.
*
@ -613,7 +659,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mouseEntered(MouseEvent e)
{
dispatchFor(e);
handleEvent(e);
}
/**
@ -623,7 +669,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mouseClicked(MouseEvent e)
{
dispatchFor(e);
handleEvent(e);
}
/**
@ -633,7 +679,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mouseDragged(MouseEvent e)
{
dispatchFor(e);
handleEvent(e);
}
/**
@ -643,7 +689,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mouseExited(MouseEvent e)
{
dispatchFor(e);
handleEvent(e);
}
/**
@ -653,7 +699,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mouseMoved(MouseEvent e)
{
dispatchFor(e);
handleEvent(e);
}
/**
@ -664,7 +710,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
public void mousePressed(MouseEvent e)
{
activateFrame(frame);
dispatchFor(e);
handleEvent(e);
}
/**
@ -674,27 +720,149 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public void mouseReleased(MouseEvent e)
{
dispatchFor(e);
handleEvent(e);
}
/**
* This helper method redispatches the MouseEvent to the proper sub
* component.
* This method acquires a candidate component to dispatch the MouseEvent
* to.
*
* @param e The MouseEvent.
* @param me The MouseEvent to acquire a component for.
*/
private void dispatchFor(MouseEvent e)
private void acquireComponentForMouseEvent(MouseEvent me)
{
Component candidate = SwingUtilities.getDeepestComponentAt(frame.getRootPane()
.getContentPane(),
e.getX(),
e.getY());
if (candidate == null || candidate == frame.getRootPane().getGlassPane())
int x = me.getX();
int y = me.getY();
// Find the candidate which should receive this event.
Component parent = frame.getContentPane();
if (parent == null)
return;
MouseEvent newevt = SwingUtilities.convertMouseEvent(frame.getRootPane()
Component candidate = null;
Point p = me.getPoint();
while (candidate == null && parent != null)
{
candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
if (candidate == null)
{
p = SwingUtilities.convertPoint(parent, p.x, p.y,
parent.getParent());
parent = parent.getParent();
}
}
// If the only candidate we found was the native container itself,
// don't dispatch any event at all. We only care about the lightweight
// children here.
if (candidate == frame.getContentPane())
candidate = null;
// If our candidate is new, inform the old target we're leaving.
if (lastComponentEntered != null && lastComponentEntered.isShowing()
&& lastComponentEntered != candidate)
{
Point tp = SwingUtilities.convertPoint(frame.getContentPane(), x, y,
lastComponentEntered);
MouseEvent exited = new MouseEvent(lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen(), me.getModifiers(),
tp.x, tp.y, me.getClickCount(),
me.isPopupTrigger(),
me.getButton());
lastComponentEntered.dispatchEvent(exited);
lastComponentEntered = null;
}
// If we have a candidate, maybe enter it.
if (candidate != null)
{
mouseEventTarget = candidate;
if (candidate.isLightweight() && candidate.isShowing()
&& candidate != frame.getContentPane()
&& candidate != lastComponentEntered)
{
lastComponentEntered = mouseEventTarget;
Point cp = SwingUtilities.convertPoint(frame.getContentPane(),
x, y, lastComponentEntered);
MouseEvent entered = new MouseEvent(lastComponentEntered,
MouseEvent.MOUSE_ENTERED,
me.getWhen(),
me.getModifiers(), cp.x,
cp.y, me.getClickCount(),
me.isPopupTrigger(),
me.getButton());
lastComponentEntered.dispatchEvent(entered);
}
}
if (me.getID() == MouseEvent.MOUSE_RELEASED
|| me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
|| me.getID() == MouseEvent.MOUSE_DRAGGED)
// If any of the following events occur while a button is held down,
// they should be dispatched to the same component to which the
// original MOUSE_PRESSED event was dispatched:
// - MOUSE_RELEASED
// - MOUSE_PRESSED: another button pressed while the first is held down
// - MOUSE_DRAGGED
mouseEventTarget = pressedComponent;
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
{
// Don't dispatch CLICKED events whose target is not the same as the
// target for the original PRESSED event.
if (candidate != pressedComponent)
mouseEventTarget = null;
else if (pressCount == 0)
pressedComponent = null;
}
}
/**
* This is a helper method that dispatches the GlassPane MouseEvents to
* the proper component.
*
* @param e The AWTEvent to be dispatched. Usually an instance of
* MouseEvent.
*/
private void handleEvent(AWTEvent e)
{
if (e instanceof MouseEvent)
{
MouseEvent me = SwingUtilities.convertMouseEvent(frame.getRootPane()
.getGlassPane(),
e, candidate);
candidate.dispatchEvent(newevt);
(MouseEvent) e,
frame.getRootPane()
.getGlassPane());
acquireComponentForMouseEvent(me);
// Avoid dispatching ENTERED and EXITED events twice.
if (mouseEventTarget != null && mouseEventTarget.isShowing()
&& e.getID() != MouseEvent.MOUSE_ENTERED
&& e.getID() != MouseEvent.MOUSE_EXITED)
{
MouseEvent newEvt = SwingUtilities.convertMouseEvent(frame
.getContentPane(),
me,
mouseEventTarget);
mouseEventTarget.dispatchEvent(newEvt);
switch (e.getID())
{
case MouseEvent.MOUSE_PRESSED:
if (pressCount++ == 0)
pressedComponent = mouseEventTarget;
break;
case MouseEvent.MOUSE_RELEASED:
// Clear our memory of the original PRESSED event, only if
// we're not expecting a CLICKED event after this. If
// there is a CLICKED event after this, it will do clean up.
if (--pressCount == 0
&& mouseEventTarget != pressedComponent)
pressedComponent = null;
break;
}
}
}
}
}
@ -1108,7 +1276,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
public Dimension getMinimumSize(JComponent x)
{
return getPreferredSize(x);
return internalFrameLayout.minimumLayoutSize(x);
}
/**

View file

@ -121,7 +121,6 @@ public class BasicListUI extends ListUI
*/
public void contentsChanged(ListDataEvent e)
{
// System.err.println(this + ".contentsChanged(" + e + ")");
BasicListUI.this.damageLayout();
}
@ -132,7 +131,6 @@ public class BasicListUI extends ListUI
*/
public void intervalAdded(ListDataEvent e)
{
// System.err.println(this + ".intervalAdded(" + e + ")");
BasicListUI.this.damageLayout();
}
@ -143,7 +141,6 @@ public class BasicListUI extends ListUI
*/
public void intervalRemoved(ListDataEvent e)
{
// System.err.println(this + ".intervalRemoved(" + e + ")");
BasicListUI.this.damageLayout();
}
}
@ -161,7 +158,6 @@ public class BasicListUI extends ListUI
*/
public void valueChanged(ListSelectionEvent e)
{
// System.err.println(this + ".valueChanged(" + e + ")");
}
}
@ -189,12 +185,10 @@ public class BasicListUI extends ListUI
*/
public void mousePressed(MouseEvent event)
{
// System.err.println("got mouse click event " + event);
int row = BasicListUI.this.convertYToRow(event.getY());
if (row == -1)
return;
// System.err.println("clicked on row " + row);
BasicListUI.this.list.setSelectedIndex(row);
}
@ -262,7 +256,6 @@ public class BasicListUI extends ListUI
*/
public void propertyChange(PropertyChangeEvent e)
{
// System.err.println(this + ".propertyChange(" + e + ")");
if (e.getSource() == BasicListUI.this.list)
{
if (e.getOldValue() != null && e.getOldValue() instanceof ListModel)
@ -357,6 +350,8 @@ public class BasicListUI extends ListUI
*/
public Rectangle getCellBounds(JList l, int index1, int index2)
{
maybeUpdateLayoutState();
if (l != list || cellWidth == -1)
return null;
@ -366,6 +361,7 @@ public class BasicListUI extends ListUI
getRowHeight(lo));
Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth,
getRowHeight(hi));
return lobounds.union(hibounds);
}
@ -408,7 +404,6 @@ public class BasicListUI extends ListUI
{
int h = getRowHeight(row);
// System.err.println("convertYToRow(" + y0 + ") vs. " + h);
if (y0 < h)
return row;
y0 -= h;
@ -468,7 +463,6 @@ public class BasicListUI extends ListUI
*/
void maybeUpdateLayoutState()
{
// System.err.println(this + ".maybeUpdateLayoutState()");
if (updateLayoutStateNeeded != 0)
{
updateLayoutState();
@ -576,7 +570,6 @@ public class BasicListUI extends ListUI
installDefaults();
installListeners();
installKeyboardActions();
// System.err.println(this + ".installUI()");
maybeUpdateLayoutState();
}
@ -618,11 +611,9 @@ public class BasicListUI extends ListUI
*/
public Dimension getPreferredSize(JComponent c)
{
maybeUpdateLayoutState();
if (list.getModel().getSize() == 0)
return new Dimension(0, 0);
int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize());
Rectangle bounds = getCellBounds(list, 0, nrows - 1);
Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1);
return bounds.getSize();
}
@ -678,7 +669,7 @@ public class BasicListUI extends ListUI
*/
public void paint(Graphics g, JComponent c)
{
int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize());
int nrows = list.getModel().getSize();
if (nrows == 0)
return;
@ -687,11 +678,13 @@ public class BasicListUI extends ListUI
ListModel model = list.getModel();
ListSelectionModel sel = list.getSelectionModel();
int lead = sel.getLeadSelectionIndex();
Rectangle clip = g.getClipBounds();
paintBackground(g, list);
for (int row = 0; row < nrows; ++row)
{
Rectangle bounds = getCellBounds(list, row, row);
if (bounds.intersects(clip))
paintCell(g, row, bounds, render, model, sel, lead);
}
}

View file

@ -250,7 +250,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, 2, 2, 2),
"Button.margin", new InsetsUIResource(2, 14, 2, 14),
"Button.shadow", new ColorUIResource(Color.gray),
"Button.textIconGap", new Integer(4),
"Button.textShiftOffset", new Integer(0),
@ -493,7 +493,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ENTER", "return",
"SPACE", "return"
},
"Menutext.selectionBackground", new ColorUIResource(lightPurple),
"Menu.selectionBackground", new ColorUIResource(lightPurple),
"Menu.selectionForeground", new ColorUIResource(Color.black),
"MenuBar.background", new ColorUIResource(Color.lightGray),
"MenuBar.border", new BasicBorders.MenuBarBorder(null, null),
@ -875,12 +875,12 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ToolBar.background", new ColorUIResource(Color.lightGray),
"ToolBar.border", new BorderUIResource.EtchedBorderUIResource(),
"ToolBar.dockingBackground", new ColorUIResource(Color.lightGray),
"ToolBar.dockingForeground", new ColorUIResource(Color.red),
"ToolBar.dockingForeground", new ColorUIResource(11, 30, 143),
"ToolBar.floatingBackground", new ColorUIResource(Color.lightGray),
"ToolBar.floatingForeground", new ColorUIResource(Color.darkGray),
"ToolBar.floatingForeground", new ColorUIResource(113, 171, 212),
"ToolBar.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"ToolBar.foreground", new ColorUIResource(Color.black),
"ToolBar.separatorSize", new DimensionUIResource(10, 10),
"ToolBar.separatorSize", new DimensionUIResource(20, 20),
"ToolTip.background", new ColorUIResource(Color.white),
"ToolTip.border", new BorderUIResource.LineBorderUIResource(Color.lightGray),
"ToolTip.font", new FontUIResource("SansSerif", Font.PLAIN, 12),

View file

@ -101,9 +101,9 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Creates ChangeListener
*
* @return DOCUMENT ME!
* @return The ChangeListener
*/
protected ChangeListener createChangeListener()
{
@ -112,7 +112,7 @@ public class BasicMenuBarUI extends MenuBarUI
/**
* Creates ContainerListener() to listen for ContainerEvents
* fired by JMenuBar
* fired by JMenuBar.
*
* @return The ContainerListener
*/
@ -242,7 +242,7 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Unregisters all the listeners that this UI delegate was using.
*/
protected void uninstallListeners()
{
@ -273,7 +273,8 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* This class handles ContainerEvents fired by JMenuBar
* This class handles ContainerEvents fired by JMenuBar. It revalidates
* and repaints menu bar whenever menu is added or removed from it.
*/
protected class ContainerHandler implements ContainerListener
{
@ -284,17 +285,19 @@ public class BasicMenuBarUI extends MenuBarUI
*/
public void componentAdded(ContainerEvent e)
{
System.out.println("BasicMenuBar...componentAdded.. listener");
menuBar.revalidate();
menuBar.repaint();
}
/**
* This method is called whenever menu is removed from the menu bar
* This method is called whenever menu is removed from the menu bar.
*
* @param e The ContainerEvent.
*/
public void componentRemoved(ContainerEvent e)
{
System.out.println("BasicMenuBar...componentRemoved.. listener");
menuBar.revalidate();
menuBar.repaint();
}
}
@ -313,6 +316,8 @@ public class BasicMenuBarUI extends MenuBarUI
{
if (e.getPropertyName().equals(JMenuBar.BORDER_PAINTED_CHANGED_PROPERTY))
menuBar.repaint();
if (e.getPropertyName().equals(JMenuBar.MARGIN_CHANGED_PROPERTY))
menuBar.repaint();
}
}
}

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.plaf.basic;
import java.awt.Color;
@ -152,7 +151,7 @@ public class BasicMenuItemUI extends MenuItemUI
protected Color selectionBackground;
/**
* Color of the background that is used when menu item is selected.
* Color of the text that is used when menu item is selected.
*/
protected Color selectionForeground;
@ -276,6 +275,11 @@ public class BasicMenuItemUI extends MenuItemUI
public MenuElement[] getPath()
{
ArrayList path = new ArrayList();
// Path to menu should also include its popup menu.
if (menuItem instanceof JMenu)
path.add(((JMenu) menuItem).getPopupMenu());
Component c = menuItem;
while (c instanceof MenuElement)
{
@ -305,19 +309,6 @@ public class BasicMenuItemUI extends MenuItemUI
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,
Icon arrowIcon,
int defaultTextIconGap)
{
// FIXME: Need to implement.
return null;
}
/**
* Returns preferred size of the given component
*
* @param c component for which to return preferred size
*
* @return $Dimension$ preferred size for the given component
*/
public Dimension getPreferredSize(JComponent c)
{
JMenuItem m = (JMenuItem) c;
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m,
@ -361,10 +352,17 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Returns preferred size of the given component
*
* @return $returnType$ DOCUMENT ME!
* @param c component for which to return preferred size
*
* @return $Dimension$ preferred size for the given component
*/
public Dimension getPreferredSize(JComponent c)
{
return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap);
}
protected String getPropertyPrefix()
{
return null;
@ -416,6 +414,7 @@ public class BasicMenuItemUI extends MenuItemUI
protected void installListeners()
{
menuItem.addMouseListener(mouseInputListener);
menuItem.addMouseMotionListener(mouseInputListener);
menuItem.addMenuDragMouseListener(menuDragMouseListener);
menuItem.addMenuKeyListener(menuKeyListener);
menuItem.addPropertyChangeListener(propertyChangeListener);
@ -433,6 +432,7 @@ public class BasicMenuItemUI extends MenuItemUI
super.installUI(c);
menuItem = (JMenuItem) c;
installDefaults();
installComponents(menuItem);
installListeners();
}
@ -516,7 +516,7 @@ public class BasicMenuItemUI extends MenuItemUI
{
if (m.isContentAreaFilled())
{
g.setColor(m.getBackground().darker());
g.setColor(selectionBackground);
g.fillRect(br.x, br.y, br.width, br.height);
}
}
@ -529,6 +529,7 @@ public class BasicMenuItemUI extends MenuItemUI
}
}
// If this menu item is a JCheckBoxMenuItem then paint check icon
if (checkIcon != null)
{
SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,
@ -543,6 +544,7 @@ public class BasicMenuItemUI extends MenuItemUI
vr.x = cr.x + cr.width + defaultTextIconGap;
}
// if this is a submenu, then paint arrow icon to indicate it.
if (arrowIcon != null && (c instanceof JMenu))
{
if (! ((JMenu) c).isTopLevelMenu())
@ -555,6 +557,18 @@ public class BasicMenuItemUI extends MenuItemUI
}
}
// paint icon
// FIXME: should paint different icon at different button state's.
// i.e disabled icon when button is disabled.. etc.
Icon i = m.getIcon();
if (i != null)
{
i.paintIcon(c, g, vr.x, vr.y);
// Adjust view rectangle, s.t text would be drawn after menu item's icon.
vr.x += i.getIconWidth() + defaultTextIconGap;
}
// paint text and user menu icon if it exists
SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),
vertAlign, horAlign, vertTextPos,
@ -563,20 +577,6 @@ public class BasicMenuItemUI extends MenuItemUI
paintText(g, m, tr, m.getText());
// paint icon
// FIXME: should paint different icon at different button state's.
// i.e disabled icon when button is disabled.. etc.
/*
Icon i = m.getIcon();
if (i != null)
{
int x = ir.x;
int y = ir.y;
i.paintIcon(c, g, x, y);
}
*/
// paint accelerator
String acceleratorText = "";
@ -612,11 +612,28 @@ public class BasicMenuItemUI extends MenuItemUI
Font f = menuItem.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
g.setColor(menuItem.getForeground());
if (text != null && ! text.equals(""))
{
if (menuItem.isEnabled())
g.setColor(menuItem.getForeground());
else
// FIXME: should fix this to use 'disabledForeground', but its
// default value in BasicLookAndFeel is null.
g.setColor(Color.gray);
int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
if (mnemonicIndex != -1)
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex,
textRect.x,
textRect.y
+ fm.getAscent());
else
BasicGraphicsUtils.drawString(g, text, 0, textRect.x,
textRect.y + fm.getAscent());
}
}
/**
* This method uninstalls the components for this {@link JMenuItem}.
@ -682,6 +699,7 @@ public class BasicMenuItemUI extends MenuItemUI
{
uninstallListeners();
uninstallDefaults();
uninstallComponents(menuItem);
menuItem = null;
}
@ -751,7 +769,14 @@ public class BasicMenuItemUI extends MenuItemUI
{
g.setFont(acceleratorFont);
FontMetrics fm = g.getFontMetrics(acceleratorFont);
if (menuItem.isEnabled())
g.setColor(acceleratorForeground);
else
// FIXME: should fix this to use 'disabledForeground', but its
// default value in BasicLookAndFeel is null.
g.setColor(Color.gray);
BasicGraphicsUtils.drawString(g, acceleratorText, 0, acceleratorRect.x,
acceleratorRect.y + fm.getAscent());
}
@ -859,14 +884,17 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void mouseReleased(MouseEvent e)
{
Rectangle size = menuItem.getBounds(); //this.getParent().getSize();
Rectangle size = menuItem.getBounds();
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0
&& e.getY() < size.height)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
menuItem.doClick(0);
menuItem.doClick();
}
else
manager.processMouseEvent(e);
}
}
@ -882,6 +910,8 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(e.getPath());
}
/**
@ -892,6 +922,8 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(e.getPath());
}
/**
@ -912,6 +944,13 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
MenuElement[] path = e.getPath();
if (path[path.length - 1] instanceof JMenuItem)
((JMenuItem) path[path.length - 1]).doClick();
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
}
}
@ -963,6 +1002,8 @@ public class BasicMenuItemUI extends MenuItemUI
*/
public void propertyChange(PropertyChangeEvent evt)
{
menuItem.revalidate();
menuItem.repaint();
}
}
}

View file

@ -213,8 +213,11 @@ public class BasicMenuUI extends BasicMenuItemUI
acceleratorFont = defaults.getFont("Menu.acceleratorFont");
acceleratorForeground = defaults.getColor("Menu.acceleratorForeground");
acceleratorSelectionForeground = defaults.getColor("Menu.acceleratorSelectionForeground");
selectionBackground = defaults.getColor("Menu.selectionBackground");
selectionForeground = defaults.getColor("Menu.selectionForeground");
arrowIcon = defaults.getIcon("Menu.arrowIcon");
oldBorderPainted = defaults.getBoolean("Menu.borderPainted");
menuItem.setOpaque(true);
}
/**
@ -233,7 +236,9 @@ public class BasicMenuUI extends BasicMenuItemUI
protected void installListeners()
{
((JMenu) menuItem).addMouseListener(mouseInputListener);
((JMenu) menuItem).addMouseMotionListener(mouseInputListener);
((JMenu) menuItem).addMenuListener(menuListener);
((JMenu) menuItem).addMenuDragMouseListener(menuDragMouseListener);
}
protected void setupPostTimer(JMenu menu)
@ -254,6 +259,8 @@ public class BasicMenuUI extends BasicMenuItemUI
acceleratorFont = null;
acceleratorForeground = null;
acceleratorSelectionForeground = null;
selectionBackground = null;
selectionForeground = null;
arrowIcon = null;
}
@ -304,11 +311,10 @@ public class BasicMenuUI extends BasicMenuItemUI
selected. (If nothing was selected, menu should be pressed before
it will be selected)
*/
JMenu menu = (JMenu) menuItem;
if (! menu.isTopLevelMenu()
|| (menu.isTopLevelMenu()
&& (((JMenuBar) menu.getParent()).isSelected())))
&& (((JMenuBar) menu.getParent()).isSelected() && ! menu.isArmed())))
{
// set new selection and forward this event to MenuSelectionManager
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
@ -329,7 +335,6 @@ public class BasicMenuUI extends BasicMenuItemUI
public void mousePressed(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
JMenu menu = (JMenu) menuItem;
manager.processMouseEvent(e);
@ -339,11 +344,9 @@ public class BasicMenuUI extends BasicMenuItemUI
if (menu.isTopLevelMenu())
{
if (menu.getPopupMenu().isVisible())
{
// If menu is visible and menu button was pressed..
// then need to cancel the menu
manager.clearSelectedPath();
}
else
{
// Display the menu
@ -374,30 +377,44 @@ public class BasicMenuUI extends BasicMenuItemUI
{
/**
* This method is called when menu is cancelled. The menu is cancelled
* when its popup menu is closed without selection.
* when its popup menu is closed without selection. It clears selected index
* in the selectionModel of the menu parent.
*
* @param e The MenuEvent.
*/
public void menuCanceled(MenuEvent e)
{
menuDeselected(e);
}
/**
* This method is called when menu is deselected.
* This method is called when menu is deselected. It clears selected index
* in the selectionModel of the menu parent.
*
* @param e The MenuEvent.
*/
public void menuDeselected(MenuEvent e)
{
JMenu menu = (JMenu) menuItem;
if (menu.isTopLevelMenu())
((JMenuBar) menu.getParent()).getSelectionModel().clearSelection();
else
((JPopupMenu) menu.getParent()).getSelectionModel().clearSelection();
}
/**
* This method is called when menu is selected.
* This method is called when menu is selected. It sets selected index
* in the selectionModel of the menu parent.
*
* @param e The MenuEvent.
*/
public void menuSelected(MenuEvent e)
{
JMenu menu = (JMenu) menuItem;
if (menu.isTopLevelMenu())
((JMenuBar) menu.getParent()).setSelected(menu);
else
((JPopupMenu) menu.getParent()).setSelected(menu);
}
}
@ -426,31 +443,35 @@ public class BasicMenuUI extends BasicMenuItemUI
}
/**
* This class handles mouse dragged events.
* This class handles mouse dragged events occuring in the menu.
*/
protected class MenuDragMouseHandler implements MenuDragMouseListener
{
/**
* Tbis method is invoked when mouse is dragged over the menu item.
* This method is invoked when mouse is dragged over the menu item.
*
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(e.getPath());
}
/**
* Tbis method is invoked when mouse enters the menu item while it is
* This method is invoked when mouse enters the menu item while it is
* being dragged.
*
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(e.getPath());
}
/**
* Tbis method is invoked when mouse exits the menu item while
* This method is invoked when mouse exits the menu item while
* it is being dragged
*
* @param e The MenuDragMouseEvent
@ -460,7 +481,7 @@ public class BasicMenuUI extends BasicMenuItemUI
}
/**
* Tbis method is invoked when mouse was dragged and released
* This method is invoked when mouse was dragged and released
* inside the menu item.
*
* @param e The MenuDragMouseEvent

View file

@ -56,6 +56,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
@ -63,6 +64,7 @@ import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
@ -111,7 +113,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
Object value = new Integer(JOptionPane.CLOSED_OPTION);
Object[] options = optionPane.getOptions();
if (options != null)
value = options[buttonIndex];
value = new Integer(buttonIndex);
else
{
String text = ((JButton) e.getSource()).getText();
@ -131,6 +133,20 @@ public class BasicOptionPaneUI extends OptionPaneUI
if (owner instanceof JDialog)
((JDialog) owner).dispose();
//else we probably have some kind of internal frame.
JInternalFrame inf = (JInternalFrame) SwingUtilities.getAncestorOfClass(JInternalFrame.class,
optionPane);
if (inf != null)
{
try
{
inf.setClosed(true);
}
catch (PropertyVetoException pve)
{
}
}
}
}
@ -642,10 +658,10 @@ public class BasicOptionPaneUI extends OptionPaneUI
toAdd = new JButton((Icon) buttons[i]);
else
toAdd = new JButton(buttons[i].toString());
((JButton) toAdd).addActionListener(createButtonActionListener(i));
hasCustomComponents = true;
}
if (toAdd instanceof JButton)
((JButton) toAdd).addActionListener(createButtonActionListener(i));
if (i == initialIndex)
initialFocusComponent = toAdd;
container.add(toAdd);
@ -837,8 +853,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
{
public Dimension getPreferredSize()
{
int w = Math.max(optionPane.getSize().width,
minimumWidth);
int w = Math.max(optionPane.getSize().width, minimumWidth);
Insets i = optionPane.getInsets();
Dimension orig = super.getPreferredSize();
Dimension value = new Dimension(w - i.left - i.right - iconSize,
@ -856,10 +871,13 @@ public class BasicOptionPaneUI extends OptionPaneUI
{
Object[] selection = optionPane.getSelectionValues();
// if (selection == null)
// inputComponent = new JTextField();
// else if (selection.length < 20)
// inputComponent = new JComboBox(selection);
// FIXME: Uncomment when the widgets are done.
if (selection == null)
inputComponent = new JTextField();
else if (selection.length < 20)
inputComponent = new JComboBox(selection);
inputComponent = null;
else
inputComponent = new JList(selection);
if (inputComponent != null)
@ -972,7 +990,9 @@ public class BasicOptionPaneUI extends OptionPaneUI
tmp = questionIcon;
break;
}
return new IconUIResource(tmp);
return tmp;
// FIXME: Don't cast till the default icons are in.
// return new IconUIResource(tmp);
}
/**

View file

@ -40,15 +40,20 @@ package javax.swing.plaf.basic;
import java.awt.AWTKeyStroke;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
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.GridLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
@ -88,14 +93,22 @@ import javax.swing.plaf.PopupMenuUI;
/**
* DOCUMENT ME!
* UI Delegate for JPopupMenu
*/
public class BasicPopupMenuUI extends PopupMenuUI
{
/* popupMenu for which this UI delegate is for*/
protected JPopupMenu popupMenu;
/* MouseInputListener listens to mouse events */
private static transient MouseInputListener mouseInputListener;
/* PopupMenuListener listens to popup menu events fired by JPopupMenu*/
private transient PopupMenuListener popupMenuListener;
/* ComponentListener listening to popupMenu's invoker. */
private TopWindowListener topWindowListener;
/**
* Creates a new BasicPopupMenuUI object.
*/
@ -103,14 +116,16 @@ public class BasicPopupMenuUI extends PopupMenuUI
{
popupMenuListener = new PopupMenuHandler();
mouseInputListener = new MouseInputHandler();
topWindowListener = new TopWindowListener();
}
/**
* DOCUMENT ME!
* Factory method to create a BasicPopupMenuUI for the given {@link
* JComponent}, which should be a {@link JMenuItem}.
*
* @param x DOCUMENT ME!
* @param x The {@link JComponent} a UI is being created for.
*
* @return DOCUMENT ME!
* @return A BasicPopupMenuUI for the {@link JComponent}.
*/
public static ComponentUI createUI(JComponent x)
{
@ -118,9 +133,11 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* Installs and initializes all fields for this UI delegate. Any properties
* of the UI that need to be initialized and/or set to defaults will be
* done now. It will also install any listeners necessary.
*
* @param c DOCUMENT ME!
* @param c The {@link JComponent} that is having this UI installed.
*/
public void installUI(JComponent c)
{
@ -128,14 +145,15 @@ public class BasicPopupMenuUI extends PopupMenuUI
popupMenu = (JPopupMenu) c;
popupMenu.setLayout(new GridBagLayout());
popupMenu.setBorderPainted(true);
popupMenu.setDefaultLightWeightPopupEnabled(true);
JPopupMenu.setDefaultLightWeightPopupEnabled(true);
installDefaults();
installListeners();
}
/**
* DOCUMENT ME!
* This method installs the defaults that are defined in the Basic look and
* feel for this {@link JPopupMenu}.
*/
public void installDefaults()
{
@ -148,7 +166,7 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* This method installs the listeners for the {@link JMenuItem}.
*/
protected void installListeners()
{
@ -158,16 +176,19 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* This method installs the keyboard actions for this {@link JPopupMenu}.
*/
protected void installKeyboardActions()
{
// FIXME: Need to implement
}
/**
* DOCUMENT ME!
* Performs the opposite of installUI. Any properties or resources that need
* to be cleaned up will be done now. It will also uninstall any listeners
* it has. In addition, any properties of this UI will be nulled.
*
* @param c DOCUMENT ME!
* @param c The {@link JComponent} that is having this UI uninstalled.
*/
public void uninstallUI(JComponent c)
{
@ -177,7 +198,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* This method uninstalls the defaults and sets any objects created during
* install to null
*/
protected void uninstallDefaults()
{
@ -188,25 +210,29 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* Unregisters all the listeners that this UI delegate was using.
*/
protected void uninstallListeners()
{
popupMenu.removeMouseListener(mouseInputListener);
popupMenu.removeMouseMotionListener(mouseInputListener);
popupMenu.removePopupMenuListener(popupMenuListener);
}
/**
* DOCUMENT ME!
* Uninstalls any keyboard actions.
*/
protected void uninstallKeyboardActions()
{
// FIXME: Need to implement
}
/**
* DOCUMENT ME!
* This method returns the minimum size of the JPopupMenu.
*
* @param c DOCUMENT ME!
* @param c The JComponent to find a size for.
*
* @return DOCUMENT ME!
* @return The minimum size.
*/
public Dimension getMinimumSize(JComponent c)
{
@ -214,11 +240,11 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* This method returns the preferred size of the JPopupMenu.
*
* @param c DOCUMENT ME!
* @param c The JComponent to find a size for.
*
* @return DOCUMENT ME!
* @return The preferred size.
*/
public Dimension getPreferredSize(JComponent c)
{
@ -226,11 +252,11 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* This method returns the minimum size of the JPopupMenu.
*
* @param c DOCUMENT ME!
* @param c The JComponent to find a size for.
*
* @return DOCUMENT ME!
* @return The minimum size.
*/
public Dimension getMaximumSize(JComponent c)
{
@ -238,11 +264,13 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* Return true if given mouse event is a platform popup trigger,
* and false otherwise
*
* @param e DOCUMENT ME!
* @param e MouseEvent that is to be checked for popup trigger event
*
* @return DOCUMENT ME!
* @return true if given mouse event is a platform popup trigger,
* and false otherwise
*/
public boolean isPopupTrigger(MouseEvent e)
{
@ -250,102 +278,153 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* DOCUMENT ME!
* This listener handles PopupMenuEvents fired by JPopupMenu
*/
protected class PopupMenuHandler implements PopupMenuListener
private class PopupMenuHandler implements PopupMenuListener
{
/**
* DOCUMENT ME!
* This method is invoked when JPopupMenu is cancelled.
*
* @param event DOCUMENT ME!
* @param event the PopupMenuEvent
*/
public void popupMenuCanceled(PopupMenuEvent event)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
}
/**
* DOCUMENT ME!
* This method is invoked when JPopupMenu becomes invisible
*
* @param event DOCUMENT ME!
* @param event the PopupMenuEvent
*/
public void popupMenuWillBecomeInvisible(PopupMenuEvent event)
{
// remove listener that listens to component events fired
// by the top - level window that this popup belongs to.
Component invoker = popupMenu.getInvoker();
Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
rootContainer.removeComponentListener(topWindowListener);
}
/**
* DOCUMENT ME!
* This method is invoked when JPopupMenu becomes visible
*
* @param event DOCUMENT ME!
* @param event the PopupMenuEvent
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent event)
{
// Adds topWindowListener to top-level window to listener to
// ComponentEvents fired by it. We need to cancel this popup menu
// if topWindow to which this popup belongs was resized or moved.
Component invoker = popupMenu.getInvoker();
Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
rootContainer.addComponentListener(topWindowListener);
// if this popup menu is a free floating popup menu,
// then by default its first element should be always selected when
// this popup menu becomes visible.
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
if (manager.getSelectedPath().length == 0)
{
// Set selected path to point to the first item in the popup menu
MenuElement[] path = new MenuElement[2];
path[0] = popupMenu;
Component[] comps = popupMenu.getComponents();
if (comps.length != 0 && comps[0] instanceof MenuElement)
path[1] = (MenuElement) comps[0];
manager.setSelectedPath(path);
}
}
}
/**
* DOCUMENT ME!
* ComponentListener that listens to Component Events fired by the
* top - level window to which popup menu belongs. If top-level
* window was resized, moved or hidded then popup menu will
* be hidded and selected path of current menu hierarchy will be set
* to null.
*
*/
protected class MouseInputHandler implements MouseInputListener
private class TopWindowListener implements ComponentListener
{
/**
* DOCUMENT ME!
* This method is invoked when top-level window is resized.
* This method closes current menu hierarchy.
*
* @param e DOCUMENT ME!
* @param e The ComponentEvent
*/
public void componentResized(ComponentEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
}
/**
* This method is invoked when top-level window is moved.
* This method closes current menu hierarchy.
*
* @param e The ComponentEvent
*/
public void componentMoved(ComponentEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
}
/**
* This method is invoked when top-level window is shown
* This method does nothing by default.
*
* @param e The ComponentEvent
*/
public void componentShown(ComponentEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
}
/**
* This method is invoked when top-level window is hidden
* This method closes current menu hierarchy.
*
* @param e The ComponentEvent
*/
public void componentHidden(ComponentEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
}
}
private class MouseInputHandler implements MouseInputListener
{
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

@ -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;
@ -49,7 +48,7 @@ import javax.swing.plaf.ComponentUI;
/**
* DOCUMENT ME!
* UI Delegator for JRadioButtonMenuItem
*/
public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
{
@ -64,11 +63,12 @@ public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
}
/**
* DOCUMENT ME!
* Factory method to create a BasicRadioButtonMenuItemUI for the given {@link
* JComponent}, which should be a JRadioButtonMenuItem.
*
* @param b DOCUMENT ME!
* @param b The {@link JComponent} a UI is being created for.
*
* @return $returnType$ DOCUMENT ME!
* @return A BasicRadioButtonMenuItemUI for the {@link JComponent}.
*/
public static ComponentUI createUI(JComponent b)
{
@ -83,7 +83,6 @@ public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
protected String getPropertyPrefix()
{
return null;
// TODO
}
/**
@ -94,7 +93,8 @@ public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
*/
void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement[] path,
public void processMouseEvent(JMenuItem item, MouseEvent e,
MenuElement[] path,
MenuSelectionManager manager)
{
}

View file

@ -38,12 +38,16 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.RootPaneUI;
public class BasicRootPaneUI extends RootPaneUI
implements PropertyChangeListener
{
public static ComponentUI createUI(JComponent x)
{
@ -53,7 +57,11 @@ public class BasicRootPaneUI extends RootPaneUI
public void installUI(JComponent c)
{
c.setOpaque(true);
c.setBackground(javax.swing.UIManager.getColor("control"));
c.setBackground(UIManager.getColor("control"));
super.installUI(c);
}
public void propertyChange(PropertyChangeEvent event)
{
}
}

View file

@ -548,14 +548,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
3));
/** The Icon that points right. */
private static Icon rightIcon = new arrowIcon(new Polygon(new int[]
{
3, 7, 3
},
new int[]
{
2, 5, 8
}, 3));
private static Icon rightIcon = new arrowIcon(new Polygon(new int[] { 3, 7, 3},
new int[] { 2, 5, 8},
3));
/**
* This method adds a component to the layout.
@ -606,7 +601,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected JButton createIncreaseButton(int orientation)
{
if (incrButton == null)
{
incrButton = new JButton();
incrButton.setMargin(new Insets(0,0,0,0));
incrButton.setHorizontalAlignment(SwingConstants.CENTER);
incrButton.setHorizontalTextPosition(SwingConstants.CENTER);
incrButton.setVerticalAlignment(SwingConstants.CENTER);
incrButton.setVerticalTextPosition(SwingConstants.CENTER);
}
if (orientation == SwingConstants.HORIZONTAL)
incrButton.setIcon(rightIcon);
else
@ -626,7 +629,15 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
protected JButton createDecreaseButton(int orientation)
{
if (decrButton == null)
{
decrButton = new JButton();
decrButton.setMargin(new Insets(0,0,0,0));
decrButton.setHorizontalAlignment(SwingConstants.CENTER);
decrButton.setHorizontalTextPosition(SwingConstants.CENTER);
decrButton.setVerticalAlignment(SwingConstants.CENTER);
decrButton.setVerticalTextPosition(SwingConstants.CENTER);
}
if (orientation == SwingConstants.HORIZONTAL)
decrButton.setIcon(leftIcon);
else

View file

@ -43,11 +43,15 @@ import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.ScrollPaneLayout;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ScrollPaneUI;
public class BasicScrollPaneUI extends ScrollPaneUI
implements ScrollPaneConstants
{
public static ComponentUI createUI(final JComponent c)
@ -55,12 +59,37 @@ public class BasicScrollPaneUI extends ScrollPaneUI
return new BasicScrollPaneUI();
}
protected void installDefaults(JScrollPane p)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
p.setForeground(defaults.getColor("ScrollPane.foreground"));
p.setBackground(defaults.getColor("ScrollPane.background"));
p.setFont(defaults.getFont("ScrollPane.font"));
p.setBorder(defaults.getBorder("ScrollPane.border"));
p.setOpaque(true);
}
protected void uninstallDefaults(JScrollPane p)
{
p.setForeground(null);
p.setBackground(null);
p.setFont(null);
p.setBorder(null);
}
public void installUI(final JComponent c)
{
super.installUI(c);
this.installDefaults((JScrollPane)c);
}
public void uninstallUI(final JComponent c)
{
super.uninstallUI(c);
this.uninstallDefaults((JScrollPane)c);
}
public Dimension getMinimumSize(JComponent c)
{
JScrollPane p = (JScrollPane ) c;

View file

@ -58,7 +58,6 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Dictionary;
import java.util.Enumeration;
import javax.swing.BoundedRangeModel;
import javax.swing.JComponent;
import javax.swing.JLabel;
@ -152,7 +151,6 @@ public class BasicSliderUI extends SliderUI
{
// Maximum, minimum, and extent values will be taken
// care of automatically when the slider is repainted.
// Only thing that needs recalculation is the thumb.
calculateThumbLocation();
slider.repaint();
@ -232,12 +230,12 @@ public class BasicSliderUI extends SliderUI
slider.getModel().addChangeListener(changeListener);
calculateThumbLocation();
}
// elif the componentOrientation changes (this is a bound property,
// just undocumented) we change leftToRightCache. In Sun's
// implementation, the LTR cache changes on a repaint. This is strange
// since there is no need to do so. We could events here and
// update the cache.
// elif the border/insets change, we recalculateInsets.
slider.repaint();
}
@ -330,8 +328,9 @@ public class BasicSliderUI extends SliderUI
/** The current Y position of the mouse. */
protected int currentMouseY;
/** The offset between the current slider value
and the cursor's position. */
/**
* The offset between the current slider value and the cursor's position.
*/
protected int offset;
/**
@ -390,9 +389,6 @@ public class BasicSliderUI extends SliderUI
if (slider.getSnapToTicks())
value = findClosestTick(value);
if (value == slider.getValue())
return;
// If the thumb is hit, then we don't need to set the timers to move it.
if (!thumbRect.contains(e.getPoint()))
{
@ -857,8 +853,8 @@ public class BasicSliderUI extends SliderUI
*/
/**
* This method returns the preferred size when the slider is
* horizontally oriented.
* This method returns the preferred size when the slider is horizontally
* oriented.
*
* @return The dimensions of the preferred horizontal size.
*/
@ -868,8 +864,9 @@ public class BasicSliderUI extends SliderUI
// The width should cover all the labels (which are usually the
// deciding factor of the width)
int width = getWidthOfWidestLabel() * (slider.getLabelTable() == null ?
0 : slider.getLabelTable().size());
int width = getWidthOfWidestLabel() * (slider.getLabelTable() == null ? 0
: slider.getLabelTable()
.size());
// If there are not enough labels.
// This number is pretty much arbitrary, but it looks nice.
@ -878,28 +875,27 @@ public class BasicSliderUI extends SliderUI
// We can only draw inside of the focusRectangle, so we have to
// pad it with insets.
width += insets.left + insets.right + focusInsets.left +
focusInsets.right;
width += insets.left + insets.right + focusInsets.left + focusInsets.right;
// Height is determined by the thumb, the ticks and the labels.
int height = thumbHeight;
if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0 ||
slider.getMinorTickSpacing() > 0)
if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
|| slider.getMinorTickSpacing() > 0)
height += tickHeight;
if (slider.getPaintLabels())
height += getHeightOfTallestLabel();
height += insets.top + insets.bottom + focusInsets.top +
focusInsets.bottom;
height += insets.top + insets.bottom + focusInsets.top
+ focusInsets.bottom;
return new Dimension(width, height);
}
/**
* This method returns the preferred size when the slider is
* vertically oriented.
* This method returns the preferred size when the slider is vertically
* oriented.
*
* @return The dimensions of the preferred vertical size.
*/
@ -907,33 +903,33 @@ public class BasicSliderUI extends SliderUI
{
Insets insets = slider.getInsets();
int height = getHeightOfTallestLabel() * (slider.getLabelTable() == null ?
0 : slider.getLabelTable().size());
int height = getHeightOfTallestLabel() * (slider.getLabelTable() == null
? 0 : slider.getLabelTable()
.size());
if (height < 200)
height = 200;
height += insets.top + insets.bottom + focusInsets.top +
focusInsets.bottom;
height += insets.top + insets.bottom + focusInsets.top
+ focusInsets.bottom;
int width = thumbHeight;
if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0 ||
slider.getMinorTickSpacing() > 0)
if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
|| slider.getMinorTickSpacing() > 0)
width += tickHeight;
if (slider.getPaintLabels())
width += getWidthOfWidestLabel();
width += insets.left + insets.right + focusInsets.left +
focusInsets.right;
width += insets.left + insets.right + focusInsets.left + focusInsets.right;
return new Dimension(width, height);
}
/**
* This method returns the minimum size when the slider is
* horizontally oriented.
* This method returns the minimum size when the slider is horizontally
* oriented.
*
* @return The dimensions of the minimum horizontal size.
*/
@ -943,8 +939,8 @@ public class BasicSliderUI extends SliderUI
}
/**
* This method returns the minimum size of the slider when it
* is vertically oriented.
* This method returns the minimum size of the slider when it is vertically
* oriented.
*
* @return The dimensions of the minimum vertical size.
*/
@ -1005,8 +1001,8 @@ public class BasicSliderUI extends SliderUI
}
/**
* This method calculates all the sizes of the rectangles by delegating
* to the helper methods calculateXXXRect.
* This method calculates all the sizes of the rectangles by delegating to
* the helper methods calculateXXXRect.
*/
protected void calculateGeometry()
{
@ -1539,18 +1535,17 @@ public class BasicSliderUI extends SliderUI
c.translate((trackRect.width / 2) + (width / 2), trackRect.height);
d.translate((trackRect.width / 2) + (width / 2), 0);
}
high = new Polygon(new int[] { b.x, c.x, d.x },
new int[] { b.y, c.y, d.y }, 3);
shadow = new Polygon(new int[] { b.x, a.x, d.x },
new int[] { b.y, a.y, d.y }, 3);
g.setColor(Color.GRAY);
g.fillRect(a.x, a.y, width, height);
g.setColor(getHighlightColor());
g.drawPolygon(high);
g.setColor(getShadowColor());
g.drawPolygon(shadow);
g.drawLine(b.x, b.y, c.x, c.y);
g.drawLine(c.x, c.y, d.x, d.y);
g.setColor(getShadowColor());
g.drawLine(b.x, b.y, a.x, a.y);
g.drawLine(a.x, a.y, d.x, d.y);
g.setColor(Color.GRAY);
g.fillRect(a.x + 1, a.y + 1, width - 2, height - 2);
g.setColor(saved_color);
}
@ -1662,8 +1657,11 @@ public class BasicSliderUI extends SliderUI
Rectangle tickBounds, int x)
{
int y = tickRect.y + tickRect.height / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.drawLine(x, y, x, y + tickRect.height / 4);
g.setColor(saved);
}
/**
@ -1678,8 +1676,11 @@ public class BasicSliderUI extends SliderUI
Rectangle tickBounds, int x)
{
int y = tickRect.y + tickRect.height / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.drawLine(x, y, x, y + tickRect.height / 2);
g.setColor(saved);
}
/**
@ -1694,8 +1695,11 @@ public class BasicSliderUI extends SliderUI
int y)
{
int x = tickRect.x + tickRect.width / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.drawLine(x, y, x + tickRect.width / 4, y);
g.setColor(saved);
}
/**
@ -1710,8 +1714,11 @@ public class BasicSliderUI extends SliderUI
int y)
{
int x = tickRect.x + tickRect.width / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.drawLine(x, y, x + tickRect.width / 2, y);
g.setColor(saved);
}
/**
@ -1786,7 +1793,6 @@ public class BasicSliderUI extends SliderUI
// the labels may not fit inside the slider's bounds. Rather than mucking
// with font sizes and possible icon sizes, we'll set the bounds for
// the label and let it get clipped.
Dimension dim = label.getPreferredSize();
int w = (int) dim.getWidth();
int h = (int) dim.getHeight();
@ -1804,8 +1810,6 @@ public class BasicSliderUI extends SliderUI
// | |
// | |
// The label must move w/2 to the right to fit directly under the value.
int xpos = xPositionForValue(value) - w / 2;
int ypos = labelRect.y;

View file

@ -157,6 +157,29 @@ public class BasicSplitPaneDivider extends Container
* buttons. */
private transient int currentDividerLocation = 1;
private transient Border tmpBorder = new Border()
{
public Insets getBorderInsets(Component c)
{
return new Insets(2, 2, 2, 2);
}
public boolean isBorderOpaque()
{
return false;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
{
Color saved = g.getColor();
g.setColor(Color.BLACK);
g.drawRect(x + 2, y + 2, width - 4, height - 4);
g.setColor(saved);
}
};
/**
* Constructs a new divider.
*
@ -167,6 +190,7 @@ public class BasicSplitPaneDivider extends Container
setLayout(new DividerLayout());
setBasicSplitPaneUI(ui);
setDividerSize(splitPane.getDividerSize());
setBorder(tmpBorder);
}
/**

View file

@ -133,7 +133,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
throw new IllegalArgumentException("Illegal placement in JSplitPane");
components[i] = component;
resetSizeAt(i);
layoutContainer(splitPane);
splitPane.revalidate();
splitPane.repaint();
}
@ -1265,15 +1265,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),
splitPane.getInsets())
- tmpSizes[0] - tmpSizes[1];
Point p = divider.getLocation();
// if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
// setLastDragLocation(p.x);
// else
// setLastDragLocation(p.y);
layoutManager.setSizes(tmpSizes);
layoutManager.layoutContainer(splitPane);
splitPane.revalidate();
splitPane.repaint();
}
@ -1414,7 +1408,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
getSplitPane().setLayout(layoutManager);
// invalidating by itself does not invalidate the layout.
getSplitPane().invalidate();
getSplitPane().revalidate();
}
/**
@ -1437,7 +1431,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
nonContinuousLayoutDivider.setVisible(true);
nonContinuousLayoutDivider.setBounds(divider.getBounds());
}
splitPane.invalidate();
splitPane.revalidate();
splitPane.repaint();
}

View file

@ -1108,7 +1108,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
selectedRun = getRunForTab(tabPane.getTabCount(),
tabPane.getSelectedIndex());
tabPane.layout();
tabPane.revalidate();
tabPane.repaint();
}
}

View file

@ -0,0 +1,82 @@
/* BasicTextFieldUI.java
Copyright (C) 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.beans.PropertyChangeEvent;
import javax.swing.JComponent;
import javax.swing.JTextField;
import javax.swing.plaf.ComponentUI;
import javax.swing.text.Element;
import javax.swing.text.FieldView;
import javax.swing.text.PlainDocument;
import javax.swing.text.View;
public class BasicTextFieldUI extends BasicTextUI
{
public BasicTextFieldUI()
{
super();
}
public View create(Element elem)
{
return new FieldView(elem);
}
public static ComponentUI createUI(JComponent c)
{
return new BasicTextFieldUI();
}
protected String getPropertyPrefix()
{
return "TextField";
}
public void installUI(JComponent c)
{
super.installUI(c);
}
protected void propertyChange(PropertyChangeEvent event)
{
// Does nothing by default.
}
}

View file

@ -1,5 +1,5 @@
/* BasicTextUI.java
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,85 +35,186 @@ 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.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TextUI;
import javax.swing.plaf.UIResource;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.DefaultCaret;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
import javax.swing.text.Element;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
public class BasicTextUI extends TextUI
public abstract class BasicTextUI extends TextUI
implements ViewFactory
{
int gap = 3;
View view = null; // was: new RootView();
Color textColor;
Color disabledTextColor;
Color normalBackgroundColor;
EditorKit kit = new DefaultEditorKit();
/* *****************************************************************
* This View is way too incomplete to be of any use. To avoid errors
* when compiling with the Sun JDK, it has been commented out.
* -- Sascha Brawer (brawer@dandelis.ch)
*
* (begin of commented out section)
class RootView extends View
public static class BasicCaret extends DefaultCaret
implements UIResource
{
RootView()
public BasicCaret()
{
}
}
public static class BasicHighlighter extends DefaultHighlighter
implements UIResource
{
public BasicHighlighter()
{
}
}
private class RootView extends View
{
private JTextComponent textComponent;
private View view;
public RootView(JTextComponent parent)
{
super(null);
textComponent = parent;
}
public void paint(Graphics g, Shape s)
public void setView(View v)
{
if (view != null)
{
Rectangle r = s.getBounds();
view.setParent(null);
if (v != null)
v.setParent(null);
view.setSize((int)r.getWidth(),
(int)r.getHeight());
view.paint(g, s);
view = v;
}
public Container getContainer()
{
return textComponent;
}
public float getPreferredSpan(int axis)
{
if (view != null)
return view.getPreferredSpan(axis);
return Integer.MAX_VALUE;
}
public void paint(Graphics g, Shape s)
{
System.out.println("Michael: BasicTextUI.RootView.paint");
if (view != null)
view.paint(g, s);
}
}
* (end of commented out section)
*************************************************************** */
RootView rootView;
JTextComponent textComponent;
int gap = 3;
EditorKit kit = new DefaultEditorKit();
public BasicTextUI()
{
}
public static ComponentUI createUI(final JComponent c)
protected Caret createCaret()
{
return new BasicTextUI();
return new BasicCaret();
}
protected Highlighter createHighlighter()
{
return new BasicHighlighter();
}
protected final JTextComponent getComponent()
{
return textComponent;
}
public void installUI(final JComponent c)
{
super.installUI(c);
c.setOpaque(true);
textColor = new Color(0, 0, 0);
disabledTextColor = new Color(130, 130, 130);
normalBackgroundColor = new Color(192, 192, 192);
textComponent = (JTextComponent) c;
Document doc = textComponent.getDocument();
if (doc == null)
{
doc = new PlainDocument();
textComponent.setDocument(doc);
}
rootView = new RootView(textComponent);
setView(create(doc.getDefaultRootElement()));
installDefaults();
installListeners();
installKeyboardActions();
}
protected void installDefaults()
{
}
protected void installListeners()
{
}
protected void installKeyboardActions()
{
}
public void uninstallUI(final JComponent c)
{
super.uninstallUI(c);
rootView = null;
uninstallDefaults();
uninstallListeners();
uninstallKeyboardActions();
}
protected void uninstallDefaults()
{
}
protected void uninstallListeners()
{
}
protected void uninstallKeyboardActions()
{
}
protected abstract String getPropertyPrefix();
public Dimension getPreferredSize(JComponent c)
{
JTextComponent b = (JTextComponent) c;
View v = getRootView(b);
View v = getRootView(textComponent);
float w = v.getPreferredSpan(View.X_AXIS);
float h = v.getPreferredSpan(View.Y_AXIS);
@ -121,9 +222,32 @@ public class BasicTextUI extends TextUI
return new Dimension((int) w, (int) h);
}
public void paint(Graphics g, JComponent c)
public final void paint(Graphics g, JComponent c)
{
// view.paint(
paintSafely(g);
}
protected void paintSafely(Graphics g)
{
Caret caret = textComponent.getCaret();
Highlighter highlighter = textComponent.getHighlighter();
if (textComponent.isOpaque())
paintBackground(g);
rootView.paint(g, getVisibleEditorRect());
if (highlighter != null)
highlighter.paint(g);
if (caret != null)
caret.paint(g);
}
protected void paintBackground(Graphics g)
{
g.setColor(Color.WHITE); // FIXME: set background color
g.fillRect(0, 0, textComponent.getWidth(), textComponent.getHeight());
}
public void damageRange(JTextComponent t, int p0, int p1)
@ -151,7 +275,7 @@ public class BasicTextUI extends TextUI
public View getRootView(JTextComponent t)
{
return view;
return rootView;
}
public Rectangle modelToView(JTextComponent t, int pos)
@ -181,4 +305,30 @@ public class BasicTextUI extends TextUI
// subclasses have to implement this to get this functionality
return null;
}
public View create(Element elem, int p0, int p1)
{
// subclasses have to implement this to get this functionality
return null;
}
protected Rectangle getVisibleEditorRect()
{
int width = textComponent.getWidth();
int height = textComponent.getHeight();
if (width <= 0 || height <= 0)
return null;
Insets insets = textComponent.getInsets();
return new Rectangle(insets.left, insets.top,
width - insets.left + insets.right,
height - insets.top + insets.bottom);
}
protected final void setView(View view)
{
rootView.setView(view);
view.setParent(rootView);
}
}

View file

@ -0,0 +1,132 @@
/* BasicToolBarSeparatorUI.java
Copyright (C) 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.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.JComponent;
import javax.swing.JToolBar.Separator;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.SeparatorUI;
/**
* The Basic Look and Feel UI delegate for Separator.
*/
public class BasicToolBarSeparatorUI extends BasicSeparatorUI
{
private transient Dimension size;
/**
* Creates a new UI delegate for the given JComponent.
*
* @param c The JComponent to create a delegate for.
*
* @return A new BasicToolBarSeparatorUI.
*/
public static ComponentUI createUI(JComponent c)
{
return new BasicToolBarSeparatorUI();
}
/**
* This method installs the defaults that are given by the Basic L&F.
*
* @param s The Separator that is being installed.
*/
protected void installDefaults(JSeparator s)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
size = defaults.getDimension("ToolBar.separatorSize");
}
/**
* This method does nothing as a Separator is just blank space.
*
* @param g The Graphics object to paint with
* @param c The JComponent to paint.
*/
public void paint(Graphics g, JComponent c)
{
// Do nothing.
}
/**
* This method returns the preferred size of the JComponent.
*
* @param c The JComponent to measure.
*
* @return The preferred size.
*/
public Dimension getPreferredSize(JComponent c)
{
return size;
}
/**
* This method returns the minimum size of the JComponent.
*
* @param c The JComponent to measure.
*
* @return The minimum size.
*/
public Dimension getMinimumSize(JComponent c)
{
return size;
}
/**
* This method returns the maximum size of the JComponent.
*
* @param c The JComponent to measure.
*
* @return The maximum size.
*/
public Dimension getMaximumSize(JComponent c)
{
return size;
}
}

File diff suppressed because it is too large Load diff

View file

@ -173,6 +173,7 @@ public class BasicViewportUI extends ViewportUI
g.clearRect(0, 0, portBounds.width, portBounds.height);
}
g2.setClip(g.getClipBounds());
g2.translate(-pos.x, -pos.y);
try
{

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.table;
import java.beans.PropertyChangeEvent;
@ -52,21 +51,18 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
/**
* DefaultTableColumnModel
* @author Andrew Selkirk
* @version 1.0
*/
public class DefaultTableColumnModel
implements TableColumnModel, PropertyChangeListener,
ListSelectionListener, Serializable
implements TableColumnModel, PropertyChangeListener, ListSelectionListener,
Serializable
{
static final long serialVersionUID = 6580012493508960512L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* tableColumns
*/
@ -102,265 +98,283 @@ public class DefaultTableColumnModel
*/
protected int totalColumnWidth;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor DefaultTableColumnModel
*/
public DefaultTableColumnModel() {
public DefaultTableColumnModel()
{
// TODO
} // DefaultTableColumnModel()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
}
/**
* addColumn
* @param value0 TODO
*/
public void addColumn(TableColumn value0) {
public void addColumn(TableColumn value0)
{
// TODO
} // addColumn()
}
/**
* removeColumn
* @param value0 TODO
*/
public void removeColumn(TableColumn value0) {
public void removeColumn(TableColumn value0)
{
// TODO
} // removeColumn()
}
/**
* moveColumn
* @param value0 TODO
* @param value1 TODO
*/
public void moveColumn(int value0, int value1) {
public void moveColumn(int value0, int value1)
{
// TODO
} // moveColumn()
}
/**
* setColumnMargin
* @param value0 TODO
*/
public void setColumnMargin(int value0) {
public void setColumnMargin(int value0)
{
// TODO
} // setColumnMargin()
}
/**
* getColumnCount
* @returns int
* @return int
*/
public int getColumnCount() {
public int getColumnCount()
{
return 0; // TODO
} // getColumnCount()
}
/**
* getColumns
* @returns Enumeration
* @return Enumeration
*/
public Enumeration getColumns() {
public Enumeration getColumns()
{
return null; // TODO
} // getColumns()
}
/**
* getColumnIndex
* @param value0 TODO
* @returns int
* @return int
*/
public int getColumnIndex(Object value0) {
public int getColumnIndex(Object value0)
{
return 0; // TODO
} // getColumnIndex()
}
/**
* getColumn
* @param value0 TODO
* @returns TableColumn
* @return TableColumn
*/
public TableColumn getColumn(int value0) {
public TableColumn getColumn(int value0)
{
return null; // TODO
} // getColumn()
}
/**
* getColumnMargin
* @returns int
* @return int
*/
public int getColumnMargin() {
public int getColumnMargin()
{
return 0; // TODO
} // getColumnMargin()
}
/**
* getColumnIndexAtX
* @param value0 TODO
* @returns int
* @return int
*/
public int getColumnIndexAtX(int value0) {
public int getColumnIndexAtX(int value0)
{
return 0; // TODO
} // getColumnIndexAtX()
}
/**
* getTotalColumnWidth
* @returns int
* @return int
*/
public int getTotalColumnWidth() {
public int getTotalColumnWidth()
{
return 0; // TODO
} // getTotalColumnWidth()
}
/**
* setSelectionModel
* @param value0 TODO
*/
public void setSelectionModel(ListSelectionModel value0) {
public void setSelectionModel(ListSelectionModel value0)
{
// TODO
} // setSelectionModel()
}
/**
* getSelectionModel
* @returns ListSelectionModel
* @return ListSelectionModel
*/
public ListSelectionModel getSelectionModel() {
public ListSelectionModel getSelectionModel()
{
return null; // TODO
} // getSelectionModel()
}
/**
* setColumnSelectionAllowed
* @param value0 TODO
*/
public void setColumnSelectionAllowed(boolean value0) {
public void setColumnSelectionAllowed(boolean value0)
{
// TODO
} // setColumnSelectionAllowed()
}
/**
* getColumnSelectionAllowed
* @returns boolean
* @return boolean
*/
public boolean getColumnSelectionAllowed() {
public boolean getColumnSelectionAllowed()
{
return false; // TODO
} // getColumnSelectionAllowed()
}
/**
* getSelectedColumns
* @returns int[]
* @return int[]
*/
public int[] getSelectedColumns() {
public int[] getSelectedColumns()
{
return null; // TODO
} // getSelectedColumns()
}
/**
* getSelectedColumnCount
* @returns int
* @return int
*/
public int getSelectedColumnCount() {
public int getSelectedColumnCount()
{
return 0; // TODO
} // getSelectedColumnCount()
}
/**
* addColumnModelListener
* @param value0 TODO
*/
public void addColumnModelListener(TableColumnModelListener value0) {
public void addColumnModelListener(TableColumnModelListener value0)
{
// TODO
} // addColumnModelListener()
}
/**
* removeColumnModelListener
* @param value0 TODO
*/
public void removeColumnModelListener(TableColumnModelListener value0) {
public void removeColumnModelListener(TableColumnModelListener value0)
{
// TODO
} // removeColumnModelListener()
}
/**
* fireColumnAdded
* @param value0 TODO
*/
protected void fireColumnAdded(TableColumnModelEvent value0) {
protected void fireColumnAdded(TableColumnModelEvent value0)
{
// TODO
} // fireColumnAdded()
}
/**
* fireColumnRemoved
* @param value0 TODO
*/
protected void fireColumnRemoved(TableColumnModelEvent value0) {
protected void fireColumnRemoved(TableColumnModelEvent value0)
{
// TODO
} // fireColumnRemoved()
}
/**
* fireColumnMoved
* @param value0 TODO
*/
protected void fireColumnMoved(TableColumnModelEvent value0) {
protected void fireColumnMoved(TableColumnModelEvent value0)
{
// TODO
} // fireColumnMoved()
}
/**
* fireColumnSelectionChanged
* @param value0 TODO
*/
protected void fireColumnSelectionChanged(ListSelectionEvent value0) {
protected void fireColumnSelectionChanged(ListSelectionEvent value0)
{
// TODO
} // fireColumnSelectionChanged()
}
/**
* fireColumnMarginChanged
*/
protected void fireColumnMarginChanged() {
protected void fireColumnMarginChanged()
{
// TODO
} // fireColumnMarginChanged()
}
/**
* getListeners
* @param value0 TODO
* @returns EventListener[]
* @return EventListener[]
*/
public EventListener[] getListeners(Class value0) {
public EventListener[] getListeners(Class value0)
{
return null; // TODO
} // getListeners()
}
/**
* propertyChange
* @param value0 TODO
*/
public void propertyChange(PropertyChangeEvent value0) {
public void propertyChange(PropertyChangeEvent value0)
{
// TODO
} // propertyChange()
}
/**
* valueChanged
* @param value0 TODO
*/
public void valueChanged(ListSelectionEvent value0) {
public void valueChanged(ListSelectionEvent value0)
{
// TODO
} // valueChanged()
}
/**
* createSelectionModel
* @returns ListSelectionModel
* @return ListSelectionModel
*/
protected ListSelectionModel createSelectionModel() {
protected ListSelectionModel createSelectionModel()
{
return null; // TODO
} // createSelectionModel()
}
/**
* recalcWidthCache
*/
protected void recalcWidthCache() {
protected void recalcWidthCache()
{
// TODO
} // recalcWidthCache()
}
/**
* invalidateWidthCache
*/
private void invalidateWidthCache() {
private void invalidateWidthCache()
{
// TODO
} // invalidateWidthCache()
} // DefaultTableColumnModel
}
}

Some files were not shown because too many files have changed in this diff Show more