[multiple changes]

2004-06-17  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JToolBar.java
	(name): Removed.
	(JToolBar): Use Component.setName(String) instead of doing it all
	alone.
	* javax/swing/Timer.java
	(queueEvent): Added missing modifier.

2004-06-17  Olga Rodimina  <rodimina@redhat.coom>

	* Makefile.am: Added new file.
	* Makefile.in: Re-generate.
	* javax/swing/JMenu.java:
	(insertSeparator): Implemented.
	* javax/swing/JPopupMenu.java:
	(JPopupMenu.Separator): Implemented.
	* javax/swing/MenuSelectionManager.java:
	(processMouseEvent): Use java.awt.Component
	for event source instead of javax.swing.JComponent.
	* javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java:
	New File. Implemented.

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

	* java/awt/GridBagLayout.java
	(GetLayoutInfo): Adjust cell sizes iff parent size is not zero.
	Make sure pos_x and pos_y are never negative.

2004-04-16  Andrew Overholt  <overholt@redhat.com>

	* Makefile.am: Add new file.
	* Makefile.in: Re-generate.
	* javax/swing/JToolBar.java
	Partially implemented.
	* javax/swing/plaf/basic/BasicToolBarUI.java
	New file. Partially implemented.

2004-06-16  Graydon Hoare  <graydon@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(setComposite): Accept AlphaComposite arguments.
	* gnu/java/awt/peer/gtk/GdkPixbufDecoder.java
	(createBufferedImage): Add new overloads.
	* gnu/java/awt/peer/gtk/GtkToolkit.java
	(createImage): Use GdkPixbufDecoder.createBufferedImage
	when useGraphics2D() is true.
	(getImage): Delegate to createImage.
	* javax/swing/JList.java
	(isSelectionEmpty):
	(getFirstVisibleIndex):
	(getLastVisibleIndex):
	(setSelectedValue):
	(ensureIndexIsVisible): New methods.
	* javax/swing/Timer.java: Reimplement.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AbstractDocument.java
	(AbstracElement): Made public, implements java.io.Serializable.
	(AttributeContext): Made public.
	(BranchElement): Likewise.
	(Content): Likewise.
	(DefaultDocumentEvent): Made public, extends
	javax.swing.undo.CompoundEdit.
	(ElementEdit): Made public, extends
	javax.swing.undo.AbstractUndoableEdit.
	(LeafElement): Made public.
	(LeafElement.LeafElement): Made public.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/JTextComponent.java: Totally reworked. Removed many
	methods (that were obviously never be intended to get included hi this
	class. Added some methods too.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/PlainDocument.java
	(serialVersionUID): New constant.
	(lineLimitAttribute): Likewise.
	(tabSizeAttribute): Likewise.
	(tabSize): New field.
	(PlainDocument): Made public.
	(PlainDocument): New constructor.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AbstractDocument.java
	(insertString): Throws BadLocationException.
	* javax/swing/text/Document.java
	(insertString): Likewise.
	* javax/swing/text/JTextComponent.java:
	Javadocs and comments cleaned up.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/event/UndoableEditListener.java: Reformatted.
	* javax/swing/text/AbstractDocument.java
	(AbstractDocument): Implements java.io.Serializable.
	(doc_list): Removed.
	(undo_list): Removed.
	(AbstractElement.serialVerionUID): New field.
	(BranchElement.serialVerionUID): Likewise.
	(DefaultDocumentEvent.serialVerionUID): Likewise.
	(ElementEdit.serialVerionUID): Likewise.
	(LeafElement.serialVerionUID): Likewise.
	(serialVerionUID): Likewise.
	(BAD_LOCATION): New constant.
	(BidiElementName): Likewise.
	(ContentElementName): Likewise.
	(ParagraphElementName): Likewise.
	(SectionElementName): Likewise.
	(ElementNameAttribute): Likewise.
	(AbstractDocument): Made protected.
	(AbstractDocument): New construtor.
	(listenerList): New field.
	(fireChangedUpdate): Implemented.
	(fireInsertUpdate): Likewise.
	(fireRemoveUpdate): Likewise.
	(fireUndoableEditUpdate): Likewise.
	(getListeners): Likewise.
	(addDocumentListener): Likewise.
	(removeDocumentListener): Likewise.
	(addUndoableEditListener): Likewise.
	(removeUndoableEditListener): Likewise.
	(getDocumentListeners): New method.
	(getUndoableEditListeners): Likewise.
	(getAsynchronousLoadPriority): Made public.
	(getBidiRootElement): Likewise.
	(setAsynchronousLoadPriority): Likewise.
	(setDocumentProperties): Likewise.
	* javax/swing/text/BadLocationException.java
	(serialVerionUID): New field.
	* javax/swing/text/DefaultCaret.java
	(changeEvent): New field.
	(listenerList): Likewise.
	(changes): Removed.
	(addChangeListener): Reimplemented.
	(removeChangeListener): Likewise.
	(getListeners): New method.
	(getChangeListeners): Likwise.
	(getComponent): Likewise.
	* javax/swing/text/GapContent.java
	(GapContent): Implements java.io.Serializable.
	(serialVerionUID): New field.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JTree.java
	(treeModel): New field.
	(JTree): New constructors, one existing one made public.
	(createTreeModel): New method.
	(addTreeExpansionListener): Likewise.
	(removeTreeExpansionListener): Likewise.
	(getTreeExpansionListeners): Likewise.
	(fireTreeCollapsed): Likewise.
	(fireTreeExpanded): Likewise.
	(addTreeSelectionListener): Likewise.
	(removeTreeSelectionListener): Likewise.
	(getTreeSelectionListeners): Likewise.
	(fireValueChanged): Likewise.
	(addTreeWillExpandListener): Likewise.
	(removeTreeWillExpandListener): Likewise.
	(getTreeWillExpandListeners): Likewise.
	(fireTreeWillCollapse): Likewise.
	(fireTreeWillExpand): Likewise.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JTree.java: Reformatted.

2004-06-16  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JTextArea.java: New file.
	* javax/swing/JTextField.java
	(actions): Removed.
	(notifyAction): New constant.
	(columns): New field.
	(JTextField): New constructors.
	(createDefaultModel): New method.
	(addActionListener): Reimplmemented.
	(removeActionListener): Reimplemented.
	(getActionListeners): New method.
	(fireActionPerformed): New method.
	(getColumns): New method.
	(setColumne): New method.
	* javax/swing/text/JTextComponent.java
	(AccessibleJTextComponent.serialVersionUID): New field.
	(serialVersionUID): Likewise.
	(DEFAULT_KEYMAP): Likewise.
	(FOCUS_ACCELERATOR_KEY): Likewise.
	(doc): Made private.
	(icon_gap): Likewise.
	(icon): Likewise.
	(align): Likewise.
	(JTextComponent): Some constructors removed.
	(getScrollableTracksViewportHeight): New method.
	(getScrollableTracksViewportWidth): Likewise.
	* Makefile.am: Added javax/swing/JTextArea.java.
	* Makefile.in: Regenerated.

2004-06-15  Graydon Hoare  <graydon@redhat.com>

	* javax/swing/ImageIcon.java (ImageIcon): New constructor.
	* javax/swing/JFrame.java (defaultLookAndFeelDecorated): New property.
	* javax/swing/JViewport.java
	(getExtentSize): Return size rather than preferred size.
	(toViewCoordinates): New methods.
	(getViewSize): Return size rather than preferred size.
	(setViewSize): Note view size as set.
	* javax/swing/ViewportLayout.java (layoutContainer): Reimplement.
	* javax/swing/plaf/basic/BasicScrollBarUI.java
	(getPreferredSize): Don't redo layout.
	* javax/swing/plaf/basic/BasicViewportUI.java
	(paint): Translate image properly and eat exceptions.

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

	* javax/swing/JTabbedPane.java
	(setComponent): Remove old component and
	add new component.
	(setSelectedIndex): Don't operate on the
	components if they're null. Don't set index
	on the model if the index is the same.
	(insertTab): Don't add or hide the component
	if it's null. Repaint the container.
	* javax/swing/plaf/basic/BasicLookAndFeel.java
	Change colors for TabbedPane.
	* javax/swing/plaf/basic/BasicTabbedPaneUI.java
	(mousePressed): Re-layout and paint the component.
	(layoutContainer): Don't set location on the view.
	(ScrollingViewport::paint): Remove.

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

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(gtkWidgetDispatchKeyEvent): Change warning message to comment.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (drawString):
	Wrap baseline y value in PANGO_PIXELS macro, rather than simply
	dividing by PANGO_SCALE.  Call gdk_flush before leaving GDK
	critical region.
	(drawLine): Call gdk_flush before leaving GDK critical region.
	(fillRect): Likewise.
	(drawRect): Likewise.
	(copyArea): Likewise.
	(copyPixmap): Likewise.
	(clearRect): Likewise.
	(drawArc): Likewise.
	(drawPolyline): Likewise.
	(drawPolygon): Likewise.
	(fillPolygon): Likewise.
	(fillArc): Likewise.
	(drawOval): Likewise.
	(fillOval): Likewise.

	* gnu/java/awt/peer/gtk/GdkFontMetrics.java (initState): Add
	style parameter.
	(GdkFontMetrics): Add style argument to initState call.
	(stringWidth(String,int,int,String)): Add style parameter.
	(stringWidth(String)): Add style argument to stringWidth call.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c
	(initState): Set pango font style and weight based on AWT style
	parameter.  Pass default GTK language to
	pango_context_get_metrics.  Use PANGO_PIXELS macro rather than
	simply dividing by PANGO_SCALE.
	(stringWidth): Set pango font style and weight based on AWT style
	parameter.

	* java/awt/Button.java (next_button_number): New field.
	(paramString): Change output.
	(generateName): New method.
	(getUniqueLong): New method.

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

	* javax/swing/JTabbedPane.java:
	(setComponentAt): Set the component, not
	the enabled status.
	* javax/swing/plaf/basic/BasicDesktopIconUI.java
	(actionPerformed): Let deiconize catch exception.

2004-06-14  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JPopupMenu.java:
	(setVisible): Corrected location of a
	heavyweight popup menu.

2004-06-14  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/MenuSelectionManager.java:
	Ran through jalopy to fix formatting style.

2004-06-14  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JLayeredPane.java:
	(remove): Revalidate and repaint layered pane after
	the component was removed.
	javax/swing/JMenu.java:
	(setVisible): Display popup menu at the user location,
	if one was set by the user.
	(setMenuLocation): Reimplemented. Fixed javadoc.
	* javax/swing/JMenuBar.java: Added javadoc.
	(BORDER_PAINTED_CHANGED_PROPERTY): New Property.
	(MODEL_CHANGED_PROPERTY): New Property.
	(isSelected): Implemented.
	(setBorderPainted): Fire PropertyChangeEvent
	if paintBorder property changes.
	(setSelected): Implemented.
	(setSelectionModel): Implemented.
	* javax/swing/JPopupMenu.java: Added Javadoc
	(pack): Implemented.
	(setVisible): Reimplemented.
	(show): Fixed location.
	(JPopupMenu.LigthWeightPopup): Reimplemented to use
	Container instead of JPanel.
	* javax/swing/MenuSelectionManager.java: Added Javadocs.
	(clearSelectedPath): Reimplemented to clear selectedPath
	in reverse order.
	(processMouseEvent): Reimplemented.
	(setSelectedPath): Fire stateChange event indicating that
	selected menu path has changed.
	(getPath): Change to use ArrayList instead of Vector.
	* javax/swing/plaf/basic/BasicMenuBarUI.java:
	(installUI): call installKeyboardActions().
	(uninstallUI): call uninstallKeyboardActions().

2004-06-13  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/DefaultCaret.java,
	javax/swing/text/BadLocationException.java:
	Reformatted.

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

	* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java (DEFAULT_ROWS,
	DEFAULT_COLS): New variables.
	(create): Don't allow 0 rows or 0 columns.  Instead, set the
	values to DEFAULT_ROWS or DEFAULT_COLS.
	(getMinimumSize): Likewise.
	(getPreferredSize): Likewise.
	(minimumSize): Likewise.
	(preferredSize): Likewise.
	(create): Set peer's editable state.
	* java/awt/TextArea.java (TextArea()): Set rows and columns to
	zero.  Update javadocs.
	(TextArea(String)): Likewise.
	(TextArea(int,int)): Fix javadocs.
	(TextArea(String,int,int,int)): Only throw exception if one of
	rows or columns is zero.  Fix javadocs.

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

	* java/awt/AWTEvent.java (toString): Handle MenuComponents in
	addition to Components.

	* java/awt/MenuItem.java (dispatchEventImpl): If the event
	wasn't consumed by normal processing, send it to the parent
	menu.

	* gnu/java/awt/peer/gtk/GtkImagePainter.java
	(setPixels(int,int,int,int,ColorModel,int[],int,int)): Remove
	translation.

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

	* java/awt/MediaTracker.java
	(addImage(Image,int)): Call imageUpdate() to udpate image status.
	(addImage(Image,int,int,int)): Likewise.

2004-06-11  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/AbstractDocument.java,
	javax/swing/text/Document.java,
	javax/swing/text/GapContent.java,
	javax/swing/text/JTextComponent.java,
	javax/swing/text/PlainDocument.java:
	Reformatted.

2004-06-11  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JRootPane.java
	(AccessibleJRootPane.serialVersionUID): New field.
	(AccessibleJRootPane.AccessibleJRootPane): New constructor.
	(AccessibleJRootPane.getAccessibleRole): New method.
	(RootLayout): Implements Serializable.
	(RootLayout.serialVersionUID): New field.
	(RootLayout.RootLayout): New constructor.
	(setJMenuBar): Made public.
	(getJMenuBar): Likewise.
	(JRootPane): Likewise.
	(createContentPane): Likewise.
	(createGlassPane): Likewise.
	(createLayeredPane): Likewise.

2004-06-11  Michael Koch  <konqueror@gmx.de>

	* javax/swing/SwingUtilities.java
	(isLeftMouseButton): Fixed javadoc.
	(isMiddleMouseButton): Likewise.
	(isRightMouseButton): Likewise.

2004-06-11  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JScrollPane.java
	(serialVersionUID): New field.
	(columnHeader): Made protected.
	(rowHeader): Likewise.
	(lowerLeft): Likewise.
	(lowerRight): Likewise.
	(upperLeft): Likewise.
	(upperRight): Likewise.
	(horizontalScrollBar): Likewise.
	(horizontalScrollBarPolicy): Likewise.
	(verticalScrollBar): Likewise.
	(verticalScrollBarPolicy): Likewise.
	(viewport): Likewise.

2004-06-11  Michael Koch  <konqueror@gmx.de>

	* javax/swing/LookAndFeel.java: Fixed javadocs.

2004-06-11  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JEditorPane.java: Fixed javadocs.
	(JEditorPane): Removed redundant call to to this().
	(fireHyperlinkUpdate): Implemented.

2004-06-10  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JMenu.java: Fixed file name
	in the file comment.

2004-06-10  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JMenu.java: Added javadoc.
	(JMenu): Added MenuChangeListener to listen to
	ChangeEvents occuring in menu's model.
	(insert): Throw IllegalArgumentException if
	index is less than 0
	(setSelected): Reimplement.
	(setPopupMenuVisible): Call menu's model isEnabled()
	(setDelay): Throw IllegalArgumentException if
	given amount of delay is less than 0.
	(createActionComponent): Implemented.
	(createActionChangeListener): Implemented.
	(addSeparator): Implemented.
	(getItem): Throw IllegalArgumentException if index is
	less than 0.
	(getItemCount): Implemented.
	(fireMenuSelected): Changed to use menuEvent.
	(fireMenuDeselected): Likewise.
	(fireMenuCanceled): Likewise.
	(setAccelerator): Changed to throw an error if this
	method is used.
	(doClick): Implemented.
	(JMenu.ActionChangedListener): New inner class to handle
	PropertyChangeEvents occuring in the actions associated with menu.
	* javax/swing/plaf/basic/BasicMenuUI.java: Added javadoc.
	(BasicMenuUI): Added PropertyChangeListener to the menu.
	(createChangeListener): Implemented.
	(createMenuDragMouseListener): Likewise.
	(createMenuKeyListener): Likewise.
	(createPropertyChangeListener): Likewise.
	(uninstallListeners): Likewise.
	(BasicMenuUI.MouseInputHandler): Reimplemented.
	(BasicMenuUI.PropertyChangeHandler): New class. Not implemented yet.
	(BasicMenuUI.ChangeHandler): Likewise.
	(BasicMenuUI.MenuDragMouseHandler): Likewise.
	(BasicMenuUI.MenuKeyHandler): Likewise.

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

	* java/awt/MediaTracker.java
	(imageUpdate): Only do notifyAll() if the image is complete.

2004-06-10  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JApplet.java:
	(getJMenuBar): Made public.
	(setJMenuBar): Likewise.
	* javax/swing/JFrame.java:
	(getJMenuBar): Made public.
	(setJMenuBar): Likewise.
	* javax/swing/JWindow.java:
	(getJMenuBar): Removed.
	(setJMenuBar): Removed.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JEditorPane.java
	(createEditorKitForContentType): Fixed visibility.
	(fireHyperlinkUpdate): Likewise.
	(getContentType): Likewise.
	(getEditorKit): Likewise.
	(getEditorKitForContentType): Likewise.
	(getPage): Likewise.
	(read): Likewise.
	(registerEditorKitForContentTyoe): Likewise.
	(replaceSelection): Likewise.
	(setContentType): Likewise.
	(setEditorKit): Likewise.
	(setPage): Likewise.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/Timer.java
	(Timer): New constructor.
	* javax/swing/plaf/basic/BasicProgressBarUI.java
	(animationTimer): Don't initialize at construction.
	(startAnimationTimer): Added since tag.
	(stopAnimationTimer): Likewise.
	(installUI): Use new Timer constructor.
	* javax/swing/plaf/basic/BasicScrollBarUI.java
	(installUI): Likewise.
	* javax/swing/plaf/basic/BasicSliderUI.java
	(installUI): Likewise.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ButtonGroup.java
	(serialVersionUID): Made private.
	(buttons): Renamed from v, added javadoc.
	(sel): Added javadoc.
	(ButtonGroup): Likewise.
	(add): Likewise.
	(remove): Likewise.
	(getElements): Likewise.
	(getSelection): Likewise.
	(setSelected): Likewise.
	(isSelected): Likewise.
	(getButtonCount): Likewise.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ButtonGroup.java,
	javax/swing/ImageIcon.java,
	javax/swing/JEditorPane.java,
	javax/swing/JRootPane.java,
	javax/swing/JTextField.java,
	javax/swing/LookAndFeel.java,
	javax/swing/plaf/basic/BasicTextUI.java:
	Reindented.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/text/Style.java: Added javadocs.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JComponent.java
	(fireVetoableChange): Removed redundant cast.
	* javax/swing/JLabel.java
	(getDisabledIcon): Save icon for next call.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/KeyStroke.java
	(getKeyStroke(char,boolean)): Marked deprecated.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/DefaultCellEditor.java,
	javax/swing/GrayFilter.java,
	javax/swing/event/DocumentEvent.java,
	javax/swing/text/JTextComponent.java,
	javax/swing/text/MutableAttributeSet.java:
	Reindented.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/BorderUIResource.java:
	Added serialVersionUID all over.

2004-06-10  Sascha Brawer  <brawer@dandelis.ch>

	* javax/swing/undo/UndoManager.java: Re-written from scratch.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/table/DefaultTableCellRenderer.java
	(noFocusBorder): Initialize directly.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicArrowButton.java
	(setDirection): Use method argument.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/BorderUIResource.java,
	javax/swing/plaf/ComponentUI.java,
	javax/swing/undo/CompoundEdit.java,
	javax/swing/undo/StateEdit.java:
	Fixed javadocs all over.

2004-06-10  Michael Koch  <konqueror@gmx.de>

	* javax/swing/DefaultButtonModel.java
	(ARMED): Made public final, fixed value.
	(ENABLED): Likewise.
	(PRESSED): Likewise.
	(ROLLOVER): Likewise.
	(SELECTED): Likewise.
	(stateMask): Initialize directly.
	(listenerList): Likewise.
	(mnemonic): Likewise.
	(fireStateChanged): Removed argument, use changeEvent as event.
	All places where this method is called are fixed too.
	(getActionCommant): Fixed javadoc.
	(setGroup): Fixed javadoc.
	(getGroup): New method.

2004-06-09  Olga Rodimina <rodimina@redhat.com>

	* javax/swing/AbstractButton.java
	(AbstractButton): Use init() to initialize the button.
	(init): New Method. Initializes AbstractButton.
	* javax/swing/JMenuItem.java: Documented.
	(JMenuItem): Reimplemented.
	(init): Implemented.
	(setEnabled): Changed to call super.setEnabled()
	(processMouseEvent): Reimplemented.
	(fireMenuKeyPressed): Implemented.
	(fireMenuKeyReleased): Implemented.
	(fireMenuKeyTyped): Implemented.
	(menuSelectionChanged): disarm the model if the menu item was
	deselected.
	* javax/swing/plaf/basic/BasicMenuItemUI.java:Documented.
	(getPath): Change to use ArrayList instead of Vector.
	(getPreferredSize): Renamed variable.
	(paintMenuItem): Paint margin area of menu item.
	(MouseInputHandler.mouseEntered): Set selection in MenuSelectionManager.
	(MouseInputHandler.mouseReleased): Check if mouse was pressed inside
	menu item's bounds before clearing the selection.

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

	* gnu/java/awt/peer/gtk/GtkTextComponentPeer.java
	(GtkTextComponentPeer): Set caret position to 0.
	* java/awt/TextComponent.java
	(setText): Set caret position to 0.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilter):
	Handle GtkScrolledWindow separately. Fix signal handler blocking.
	(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeFilter):
	Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_create): Make cursor
	visible.

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

	* Makefile.am: New files
	* Makefile.in: Regenerated
	* java/awt/Container.java
	(getComponentAt): Removed.
	* javax/swing/AbstractAction.java
	(ENABLED_PROPERTY): New property.
	(putValue): Fire PropertyChangeEvents.
	(setEnabled): ditto.
	(firePropertyChange): Javadoc and implement
	convenience method.
	* javax/swing/AbstractButton.java
	(setAction): Don't create PropertyChangeListener
	if new Action is null.
	(setIcon): Don't set icon till after comparing
	it.
	(configurePropertiesFromAction): Check mnemonic
	key before calling intValue().
	(createActionPropertyChangeListener): Check
	properties rather than bulk change.
	* javax/swing/DefaultDesktopManager.java:
	Implement.
	* javax/swing/DesktopManager.java:
	Jalopy and javadoc.
	* javax/swing/JComponent.java
	(fireVetoableChange): Implement.
	(paintImmediately): Use root component.
	* javax/swing/JDesktopPane.java: Implement
	* javax/swing/JInternalFrame.java: Implement
	* javax/swing/JLabel.java
	(getDisabledIcon): Return grayscaled icon if
	no disabled icon specified.
	* javax/swing/JMenuBar.java
	(getComponentAtIndex): Use getComponent
	* javax/swing/JOptionPane.java
	(getDesktopPaneForComponent): Use SwingUtilities'
	getAncestorOfClass
	(getFrameForComponent): ditto.
	* javax/swing/JSplitPane.java
	(remove): Use getComponent.
	* javax/swing/SwingUtilities.java
	(convertPoint): Implement.
	* javax/swing/plaf/basic/BasicButtonUI.java
	(paintButtonNormal): Check opaqueness before
	filling background.
	* javax/swing/plaf/basic/BasicDesktopIconUI.java:
	Implement
	* javax/swing/plaf/basic/BasicDesktopPaneUI.java:
	Implement.
	* javax/swing/plaf/basic/BasicInternalFrameTitlePane.java:
	Implement.
	* javax/swing/plaf/basic/BasicInternalFrameUI.java:
	Implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Change InternalFrame and Desktop colors.

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

	* java/awt/Container.java
	(remove): Do not set component to invisible.

2004-06-09  Michael Koch  <konqueror@gmx.de>

	* javax/swing/tree/DefaultMutableTreeNode.java
	(getLeafCount): Renamed enum to e.

2004-06-09  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicSplitPaneDivider.java
	(positionForMouseEvent): Removed redundant semicolon.
	(continueDrag): Use method arguments.

2004-06-09  Michael Koch  <konqueror@gmx.de>

	* javax/swing/border/TitledBorder.java,
	javax/swing/filechooser/FileSystemView.java,
	javax/swing/plaf/basic/BasicButtonListener.java,
	javax/swing/plaf/basic/BasicGraphicsUtils.java,
	javax/swing/plaf/basic/BasicLabelUI.java,
	javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java,
	javax/swing/plaf/basic/BasicScrollBarUI.java,
	javax/swing/plaf/basic/BasicScrollPaneUI.java,
	javax/swing/plaf/basic/BasicSliderUI.java,
	javax/swing/plaf/basic/BasicTabbedPaneUI.java,
	javax/swing/plaf/basic/BasicToggleButtonUI.java,
	javax/swing/table/JTableHeader.java,
	javax/swing/text/AbstractDocument.java,
	javax/swing/text/DefaultCaret.java,
	javax/swing/text/StyledEditorKit.java,
	javax/swing/tree/DefaultTreeCellEditor.java:
	Reworked import statements.

2004-06-08  Graydon Hoare  <graydon@redhat.com>

	* javax/swing/Box.java: Temporarily comment out code
	broken due to visibility bug.

2004-06-09  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ImageIcon.java
	(ImageIcon): Added missing constructor.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JToggleButton.java
	(JToggleButton): New constructor.
	(getAccessibleContext): Moved documentation into javadoc.
	(getUIClassID): Likewise.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/AbstractButton.java
	(getDisabledIcon): Create disabled icon if none exists yet.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicLookAndFeel.java
	(initClassDefaults): Added FormattedTextFieldUI.
	(loadResourceBundle): Renamed enum to e.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/plaf/basic/BasicButtonUI.java
	(paintIcon): Simplified.
	(paintText): Paint disabled button correctly.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JComponent.java
	(createToolTip): Use official JToolTip API.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/JToolTip.java
	(JToolTip): No arguments in API.
	(setTipText): New method.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/SwingUtilities.java
	(isLeftMouseButton): New method.
	(isMiddleMouseButton): New method.
	(isRightMouseButton): New method.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/AbstractButton.java,
	javax/swing/CellRendererPane.java,
	javax/swing/JCheckBoxMenuItem.java,
	javax/swing/JColorChooser.java,
	javax/swing/JComboBox.java,
	javax/swing/JComponent.java,
	javax/swing/JDesktopPane.java,
	javax/swing/JFileChooser.java,
	javax/swing/JMenu.java,
	javax/swing/JMenuItem.java,
	javax/swing/JOptionPane.java,
	javax/swing/JPasswordField.java,
	javax/swing/JPopupMenu.java,
	javax/swing/JProgressBar.java,
	javax/swing/JRadioButtonMenuItem.java,
	javax/swing/JScrollBar.java,
	javax/swing/JSeparator.java,
	javax/swing/JSlider.java,
	javax/swing/JSplitPane.java,
	javax/swing/JTabbedPane.java,
	javax/swing/JTextField.java,
	javax/swing/JToolBar.java,
	javax/swing/text/JTextComponent.java:
	Fixed all constructors of accessibility classes.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/ScrollPaneLayout.java: Renamed all memeber variables all
	over.

2004-06-08  Michael Koch  <konqueror@gmx.de>

	* javax/swing/Box.java
	(AccessibleBoxFiller): Extends AccessibleAWTComponent.
	(AccessibleBoxFiller.serialVersionUID): New member variable.
	* javax/swing/DefaultButtonModel.java
	(stateMask): Made protected.
	(listenerList): Likewise.
	(changeEvent): Likewise.
	(group): Likewise.
	(mnemonic): Likewise.
	(actionCommand): Likewise.
	(getListeners): New method.
	(getActionListeners): New method.
	(getItemListeners): New method.
	(getChangeListeners): New method.
	(fireItemStateChanged): Simplified.
	(fireActionPerformed): Simplified.
	(fireStateChanged): Simplified.
	* javax/swing/JFrame.java
	(JFrame): Implements WindowContants.
	(HIDE_ON_CLOSE): Removed.
	(EXIT_ON_CLOSE): Removed.
	(DISPOSE_ON_CLOSE): Removed.
	(DO_NOTHING_ON_CLOSE): Removed.
	(processWindowEvent): Exit with code 0.
	(setDefaultCloseOperation): Do security check before setting value.
	* javax/swing/JOptionPane.java
	(message): Initialize only in constructor.
	* javax/swing/JToolTip.java: Removed unused imports.
	* javax/swing/JViewport.java
	(serialVersionUID): New member variable.
	(SIMPLE_SCROLL_MODE): Made final, fixed value.
	(BLIT_SCROLL_MODE): Likewise.
	(BACKINGSTORE_SCROLL_MODE): Likewise.
	(scrollUnderway): Made protected.
	(isViewSizeSet): Likewise.
	* javax/swing/ListModel.java: Fixed javadoc.
	* javax/swing/Popup.java: Likewise.
	* javax/swing/RepaintManager.java
	(paintDirtyRegions): Don't use internal classes of
	java.util.AbstractMap.
	* javax/swing/ScrollPaneConstants.java: Reindented.
	* javax/swing/ScrollPaneLayout.java
	(viewport): Made protected.
	(verticalScrollBar): Made protected, renamed to vsb.
	(horizontalScrollBar): Made protected, renamed to hsb.
	(rowHeader): Made protected, renamed to rowHead.
	(columnHeader): Made protected, renamed to colHead.
	(lowerLeft): Made protected.
	(lowerRight): Made protected.
	(upperLeft): Made protected.
	(upperRight): Made protected.
	(verticalScrollBarPolicy): Made protected, renamed to vsbPolicy.
	(horizontalScrollBarPolicy): Made protected, renamed to hsbPolicy.

2004-06-07  Bernd Schmidt  <bernds@btinternet.com>

	* java/awt/MediaTracker.java (imageUpdate): Only set status to
	LOADING if flags has SOMEBITS set.

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

	* javax/swing/AbstractButton.java: Reorganized imports.
	* javax/swing/ActionMap.java: Likewise.
	* javax/swing/DefaultButtonModel.java: Likewise.
	* javax/swing/DefaultListModel.java: Likewise.
	* javax/swing/ImageIcon.java: Likewise.
	(serialVersionUID): New member variable.
	* javax/swing/JComboBox.java: Reorganized imports.
	* javax/swing/JComponent.java: Likewise.
	(ui): Made protected.
	(listenerList): Made protected.
	(TOOL_TIP_TEXT_KEY): New constant.
	(scrollRectToVisible): Removed redundant null check.
	* javax/swing/JFrame.java: Reorganized imports.
	* javax/swing/JInternalFrame.java: Reorganized imports.
	* javax/swing/JProgressBar.java: Likewise.
	* javax/swing/JRootPane.java: Likewise.
	* javax/swing/JScrollBar.java: Likewise.
	* javax/swing/JSeparator.java: Likewise.
	* javax/swing/JSlider.java: Likewise.
	* javax/swing/JTabbedPane.java: Likewise.
	* javax/swing/JTextField.java: Likewise.
	* javax/swing/JToolBar.java: Likewise.
	* javax/swing/JTree.java: Likewise.
	* javax/swing/JViewport.java: Likewise.
	* javax/swing/JWindow.java: Likewise.
	* javax/swing/KeyStroke.java: Likewise.
	* javax/swing/LookAndFeel.java: Likewise.
	* javax/swing/MenuSelectionManager.java: Likewise.
	* javax/swing/SwingUtilities.java: Likewise.
	* javax/swing/Timer.java: Likewise.
	* javax/swing/DefaultBoundedRangeModel.java: Fixed javadoc.
	* javax/swing/JList.java
	(HORIZONTAL_WRAP): Made final, fixed value.
	(VERTICAL): Likewise.
	(VERTICAL_WRAP): Likewise.

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

	* javax/swing/AbstractButton.java
	(serialVersionUID): New member variable.
	(AccessibleAbstractButton.serialVersionUID): Likewise.
	(AbstractButton): Made public.
	* javax/swing/Box.java
	(AccessibleBox.serialVersionUID): New member variable.
	(Filler.serialVersionUID): Likewise.
	* javax/swing/DefaultListSelectionModel.java
	(serialVersionUID): Likewise.
	* javax/swing/JApplet.java
	(serialVersionUID): Likewise.
	* javax/swing/JCheckBox.java
	(serialVersionUID): Likewise.
	* javax/swing/JCheckBoxMenuItem.java
	(serialVersionUID): Likewise.
	(AccessibleJCheckBoxMenuItem.serialVersionUID): Likewise.
	* javax/swing/JColorChooser.java
	(serialVersionUID): Likewise.
	(AccessibleJColorChooser.serialVersionUID): Likewise.
	* javax/swing/JComponent.java
	(serialVersionUID): Made private.
	(AccessibleJComponent.serialVersionUID): New member variable.
	* javax/swing/JDesktopPane.java
	(serialVersionUID): Likewise.
	* javax/swing/JDialog.java
	(serialVersionUID): Likewise.
	* javax/swing/JFormattedTextField.java
	(serialVersionUID): Fixed value.
	* javax/swing/JFrame.java
	(serialVersionUID): New member variable.
	(getDefaultCloseOpertation): Made public.
	* javax/swing/JLayeredPane.java
	(serialVersionUID): Likewise.
	(LAYER_PROPERTY): Made final, fixed value.
	(JLayeredPane): Made public.
	* javax/swing/JMenu.java
	(AccessibleJMenu.serialVersionUID): New member variable.
	(WinListener.serialVersionUID): Likewise.
	* javax/swing/JMenuBar.java
	(serialVersionUID): Likewise.
	(getComponentAtIndex): Added @deprecated tag.
	* javax/swing/JMenuItem.java
	(serialVersionUID): New member variable.
	(AccessibleJMenuItem.serialVersionUID): Likewise.
	* javax/swing/JOptionPane.java
	(serialVersionUID): Likewise.
	(AccessibleJOptionPane.serialVersionUID): Likewise.
	* javax/swing/JPopupMenu.java
	(serialVersionUID): Likewise.
	(AccessibleJPopupMenu.serialVersionUID): Likewise.
	(getPopupMenuListeners): New method.
	(getComponentAtIndex): Added @deprecated tag.
	* javax/swing/JProgressBar.java
	(serialVersionUID): New member variable.
	(AccessibleJProgressBar.serialVersionUID): Likewise.
	* javax/swing/JRadioButton.java
	(serialVersionUID): Likewise.
	* javax/swing/JRadioButtonMenuItem.java
	(serialVersionUID): Likewise.
	(AccessibleJRadioButtonMenuItem.serialVersionUID): Likewise.
	* javax/swing/JScrollBar.java
	(serialVersionUID): Likewise.
	(AccessibleJScrollBar.serialVersionUID): Likewise.
	* javax/swing/JSeparator.java
	(serialVersionUID): Likewise.
	(AccessibleJSeparator.serialVersionUID): Likewise.
	* javax/swing/JSlider.java: Fixed javadocs.
	(AccessibleJSlider.serialVersionUID): New member variable.
	* javax/swing/JSplitPane.java: Added copyright statement.
	(serialVersionUID): New member variable.
	(AccessibleJSplitPane.serialVersionUID): Likewise.
	* javax/swing/JTabbedPane.java
	(serialVersionUID): Likewise.
	(AccessibleJTabbedPane.serialVersionUID): Likewise.
	(ModelListener.serialVersionUID): Likewise.
	(ModelListener.ModelListener): New constructor.
	(SCROLL_TAB_LAYOUT): Made public final, fixed value.
	(WRAP_TAB_LAYOUT): Likewise.
	* javax/swing/JTable.java
	(serialVersionUID): New member variable.
	* javax/swing/JToggleButton.java
	(serialVersionUID): Likewise.
	(ToggleButtonModel): Made static.
	(ToggleButtonModel.serialVersionUID): New member variable.
	* javax/swing/JToolTip.java
	(serialVersionUID): Likewise.
	* javax/swing/JTree.java
	(serialVersionUID): Likewise.
	* javax/swing/JWindow.java
	(serialVersionUID): Likewise.
	* javax/swing/Timer.java
	(serialVersionUID): Likewise.

2004-06-06  Michael Koch  <konqueror@gmx.de>

	* javax/swing/SwingConstants.java
	(NEXT): New constant.
	(PREVIOUS): Likewise.
	* javax/swing/UIManager.java
	(LookAndFeel): Made public.
	(LookAndFeel.getClassName): Likewise.
	(LookAndFeel.getName): Likewise.

2004-06-02  Olga Rodimina  <rodimina@redhat.com>

	* javax/swing/JCheckBoxMenuItem.java:
	Removed CVS tags.
	* javax/swing/JMenu.java: Likewise.
	* javax/swing/JMenuBar.java: Likewise.
	* javax/swing/JMenuItem.java: Likewise.
	* javax/swing/JPopupMenu.java: Likewise.
	* javax/swing/JRadioButtonMenuItem.java: Likewise.
	* javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java:Likewise.
	* javax/swing/plaf/basic/BasicMenuBarUI.java: Likewise.
	* javax/swing/plaf/basic/BasicMenuItemUI.java: Likewise.
	* javax/swing/plaf/basic/BasicMenuUI.java: Likewise.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java: Likewise.
	* javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java: Likewise.

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

	* javax/swing/plaf/basic/BasicMenuUI.java:
	(MouseEntered): Do not call getPath() from MenuSelectionManager.
	Call getPath() from super class instead.

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

	* java/awt/Container.java
	(remove): Set component visibility to false after removing it.

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

	* java/awt/Component.java (getForeground): Return SystemColor if
	parent is null.
	(getBackground): Likewise.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c
	(item_highlighted): New function.
	(connectSignals): Set item_highlighted as list's select
	function.

	* java/applet/Applet.java: Revert changes from 2004-04-29,
	2004-03-15 and 2004-03-14.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (drawString):
	Divide baseline y coordinate by PANGO_SCALE, not DPI conversion
	factor.

	* gnu/java/awt/peer/gtk/GtkTextAreaPeer.java (create): Set
	"Dialog" as the default font.
	* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java (create):
	Likewise.
	* java/awt/Component.java (getFont): Return "Dialog" font by
	default.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeer.c:
	Multiply size argument to pango_font_description_set_size by the
	DPI conversion factor rather than by PANGO_SCALE.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkFontMetrics.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkListPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextAreaPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c (drawString):
	Divide baseline y coordinate by DPI conversion factor rather
	than by PANGO_SCALE.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c
	(area_prepared): Fix typo.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLabelPeer.c
	(gtkSetFont): Move gtk_bin_get_child inside GDK critical region.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
	(dpi_conversion_factor): New global variable.
	(init_dpi_conversion_factor): New function to calculate and
	track DPI conversion factor.
	(dpi_changed_cb): New callback.
	* jni/gtk-peer/gtkpeer.h (dpi_conversion_factor): Declare.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(getGraphics): Return a new GdkGraphics instance.
	* gnu/java/awt/peer/gtk/GtkContainerPeer.java
	(getGraphics): Call super.getGraphics().

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

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(setNativeBounds): Clamp width and height values to >= 0.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(find_fg_color_widget): Handle GtkOptionMenu specially.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c
	(pre_event_handler): Only post configure events to visible
	top-level windows.

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

	* java/awt/BorderLayout.java
	(layoutContainer): Fix size calculations.

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

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(window_wm_protocols_filter): Remove function.
	(create): Remove filter that removes WM_TAKE_FOCUS client
	messages.

From-SVN: r83324
This commit is contained in:
Graydon Hoare 2004-06-17 23:43:16 +00:00
parent 398ce3dd7c
commit 4dfcdad172
130 changed files with 14127 additions and 4565 deletions

File diff suppressed because it is too large Load diff

View file

@ -1322,7 +1322,11 @@ javax/swing/plaf/basic/BasicArrowButton.java \
javax/swing/plaf/basic/BasicButtonListener.java \
javax/swing/plaf/basic/BasicButtonUI.java \
javax/swing/plaf/basic/BasicCheckBoxUI.java \
javax/swing/plaf/basic/BasicDesktopIconUI.java \
javax/swing/plaf/basic/BasicDesktopPaneUI.java \
javax/swing/plaf/basic/BasicGraphicsUtils.java \
javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \
javax/swing/plaf/basic/BasicInternalFrameUI.java \
javax/swing/plaf/basic/BasicLabelUI.java \
javax/swing/plaf/basic/BasicListUI.java \
javax/swing/plaf/basic/BasicMenuUI.java \
@ -1331,6 +1335,7 @@ javax/swing/plaf/basic/BasicMenuItemUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicPopupMenuUI.java \
javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
javax/swing/plaf/basic/BasicRootPaneUI.java \
javax/swing/plaf/basic/BasicRadioButtonUI.java \
@ -1345,6 +1350,7 @@ javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
javax/swing/plaf/basic/BasicTextUI.java \
javax/swing/plaf/basic/BasicToggleButtonUI.java \
javax/swing/plaf/basic/BasicToolBarUI.java \
javax/swing/plaf/basic/BasicTreeUI.java \
javax/swing/plaf/basic/BasicViewportUI.java \
javax/swing/plaf/basic/BasicLookAndFeel.java \
@ -1444,6 +1450,7 @@ javax/swing/JRootPane.java \
javax/swing/JScrollBar.java \
javax/swing/JScrollPane.java \
javax/swing/JTabbedPane.java \
javax/swing/JTextArea.java \
javax/swing/JTextField.java \
javax/swing/JToggleButton.java \
javax/swing/JToolTip.java \

View file

@ -1001,7 +1001,11 @@ javax/swing/plaf/basic/BasicArrowButton.java \
javax/swing/plaf/basic/BasicButtonListener.java \
javax/swing/plaf/basic/BasicButtonUI.java \
javax/swing/plaf/basic/BasicCheckBoxUI.java \
javax/swing/plaf/basic/BasicDesktopIconUI.java \
javax/swing/plaf/basic/BasicDesktopPaneUI.java \
javax/swing/plaf/basic/BasicGraphicsUtils.java \
javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \
javax/swing/plaf/basic/BasicInternalFrameUI.java \
javax/swing/plaf/basic/BasicLabelUI.java \
javax/swing/plaf/basic/BasicListUI.java \
javax/swing/plaf/basic/BasicMenuUI.java \
@ -1010,6 +1014,7 @@ javax/swing/plaf/basic/BasicMenuItemUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicPopupMenuUI.java \
javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
javax/swing/plaf/basic/BasicRootPaneUI.java \
javax/swing/plaf/basic/BasicRadioButtonUI.java \
@ -1024,6 +1029,7 @@ javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
javax/swing/plaf/basic/BasicTextUI.java \
javax/swing/plaf/basic/BasicToggleButtonUI.java \
javax/swing/plaf/basic/BasicToolBarUI.java \
javax/swing/plaf/basic/BasicTreeUI.java \
javax/swing/plaf/basic/BasicViewportUI.java \
javax/swing/plaf/basic/BasicLookAndFeel.java \
@ -1123,6 +1129,7 @@ javax/swing/JRootPane.java \
javax/swing/JScrollBar.java \
javax/swing/JScrollPane.java \
javax/swing/JTabbedPane.java \
javax/swing/JTextArea.java \
javax/swing/JTextField.java \
javax/swing/JToggleButton.java \
javax/swing/JToolTip.java \
@ -4545,14 +4552,14 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/JScrollBar.P .deps/javax/swing/JScrollPane.P \
.deps/javax/swing/JSeparator.P .deps/javax/swing/JSlider.P \
.deps/javax/swing/JSplitPane.P .deps/javax/swing/JTabbedPane.P \
.deps/javax/swing/JTable.P .deps/javax/swing/JTextField.P \
.deps/javax/swing/JTextPane.P .deps/javax/swing/JToggleButton.P \
.deps/javax/swing/JToolBar.P .deps/javax/swing/JToolTip.P \
.deps/javax/swing/JTree.P .deps/javax/swing/JViewport.P \
.deps/javax/swing/JWindow.P .deps/javax/swing/KeyStroke.P \
.deps/javax/swing/ListCellRenderer.P .deps/javax/swing/ListModel.P \
.deps/javax/swing/ListSelectionModel.P .deps/javax/swing/LookAndFeel.P \
.deps/javax/swing/MenuElement.P \
.deps/javax/swing/JTable.P .deps/javax/swing/JTextArea.P \
.deps/javax/swing/JTextField.P .deps/javax/swing/JTextPane.P \
.deps/javax/swing/JToggleButton.P .deps/javax/swing/JToolBar.P \
.deps/javax/swing/JToolTip.P .deps/javax/swing/JTree.P \
.deps/javax/swing/JViewport.P .deps/javax/swing/JWindow.P \
.deps/javax/swing/KeyStroke.P .deps/javax/swing/ListCellRenderer.P \
.deps/javax/swing/ListModel.P .deps/javax/swing/ListSelectionModel.P \
.deps/javax/swing/LookAndFeel.P .deps/javax/swing/MenuElement.P \
.deps/javax/swing/MenuSelectionManager.P \
.deps/javax/swing/MutableComboBoxModel.P \
.deps/javax/swing/OverlayLayout.P .deps/javax/swing/Popup.P \
@ -4667,8 +4674,12 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/plaf/basic/BasicButtonUI.P \
.deps/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.P \
.deps/javax/swing/plaf/basic/BasicCheckBoxUI.P \
.deps/javax/swing/plaf/basic/BasicDesktopIconUI.P \
.deps/javax/swing/plaf/basic/BasicDesktopPaneUI.P \
.deps/javax/swing/plaf/basic/BasicGraphicsUtils.P \
.deps/javax/swing/plaf/basic/BasicIconFactory.P \
.deps/javax/swing/plaf/basic/BasicInternalFrameTitlePane.P \
.deps/javax/swing/plaf/basic/BasicInternalFrameUI.P \
.deps/javax/swing/plaf/basic/BasicLabelUI.P \
.deps/javax/swing/plaf/basic/BasicListUI.P \
.deps/javax/swing/plaf/basic/BasicLookAndFeel.P \
@ -4677,6 +4688,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/plaf/basic/BasicMenuUI.P \
.deps/javax/swing/plaf/basic/BasicOptionPaneUI.P \
.deps/javax/swing/plaf/basic/BasicPanelUI.P \
.deps/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.P \
.deps/javax/swing/plaf/basic/BasicPopupMenuUI.P \
.deps/javax/swing/plaf/basic/BasicProgressBarUI.P \
.deps/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.P \
@ -4691,6 +4703,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/javax/swing/plaf/basic/BasicTabbedPaneUI.P \
.deps/javax/swing/plaf/basic/BasicTextUI.P \
.deps/javax/swing/plaf/basic/BasicToggleButtonUI.P \
.deps/javax/swing/plaf/basic/BasicToolBarUI.P \
.deps/javax/swing/plaf/basic/BasicTreeUI.P \
.deps/javax/swing/plaf/basic/BasicViewportUI.P \
.deps/javax/swing/plaf/metal/MetalLookAndFeel.P \

View file

@ -50,19 +50,21 @@ public class GdkFontMetrics extends FontMetrics
MAX_ADVANCE = 4;
private int[] metrics;
private native int[] initState (String fname, int size);
private native int[] initState (String fname, int style, int size);
public GdkFontMetrics (Font font)
{
super (font);
metrics = initState (font.getName (), font.getSize ());
metrics = initState (font.getName (), font.getStyle (), font.getSize ());
}
native public int stringWidth (String fname, int size, String str);
native public int stringWidth (String fname, int style, int size,
String str);
public int stringWidth (String str)
{
return stringWidth (font.getName (), font.getSize (), str);
return stringWidth (font.getName (), font.getStyle (), font.getSize (),
str);
}
public int charWidth (char ch)

View file

@ -1260,7 +1260,18 @@ public class GdkGraphics2D extends Graphics2D
public void setComposite(Composite comp)
{
throw new java.lang.UnsupportedOperationException ();
if (comp instanceof AlphaComposite)
{
AlphaComposite a = (AlphaComposite) comp;
cairoSetOperator(a.getRule());
Color c = getColor();
setColor(new Color(c.getRed(),
c.getGreen(),
c.getBlue(),
(int) (a.getAlpha() * ((float) c.getAlpha()))));
}
else
throw new java.lang.UnsupportedOperationException ();
}
public void setRenderingHint(RenderingHints.Key hintKey,

View file

@ -220,4 +220,31 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
dec.startProduction (bb);
return bb.getBufferedImage ();
}
public static BufferedImage createBufferedImage (URL u)
{
BufferedImageBuilder bb = new BufferedImageBuilder ();
GdkPixbufDecoder dec = new GdkPixbufDecoder (u);
dec.startProduction (bb);
return bb.getBufferedImage ();
}
public static BufferedImage createBufferedImage (byte[] imagedata, int imageoffset,
int imagelength)
{
BufferedImageBuilder bb = new BufferedImageBuilder ();
GdkPixbufDecoder dec = new GdkPixbufDecoder (imagedata, imageoffset, imagelength);
dec.startProduction (bb);
return bb.getBufferedImage ();
}
public static BufferedImage createBufferedImage (ImageProducer producer)
{
BufferedImageBuilder bb = new BufferedImageBuilder ();
producer.startProduction(bb);
return bb.getBufferedImage ();
}
}

View file

@ -199,7 +199,10 @@ public class GtkComponentPeer extends GtkGenericPeer
public Graphics getGraphics ()
{
return null;
if (GtkToolkit.useGraphics2D ())
return new GdkGraphics2D (this);
else
return new GdkGraphics (this);
}
public Point getLocationOnScreen ()

View file

@ -107,10 +107,7 @@ public class GtkContainerPeer extends GtkComponentPeer
public Graphics getGraphics ()
{
if (GtkToolkit.useGraphics2D ())
return new GdkGraphics2D (this);
else
return new GdkGraphics (this);
return super.getGraphics();
}
public void beginLayout () { }

View file

@ -104,7 +104,7 @@ public class GtkImagePainter implements Runnable, ImageConsumer
s_width = Math.abs (sx2 - sx1);
s_height = Math.abs (sy2 - sy1);
clip = new Rectangle (sx1, sy1, s_width, s_height);
new Thread (this).start ();
}
@ -170,8 +170,6 @@ public class GtkImagePainter implements Runnable, ImageConsumer
offset += r.y * scansize + r.x;
r.translate (-Math.abs (clip.x - startX), -Math.abs (clip.y - startY));
width = r.width;
height = r.height;
x = r.x;

View file

@ -47,6 +47,9 @@ import java.awt.peer.TextAreaPeer;
public class GtkTextAreaPeer extends GtkTextComponentPeer
implements TextAreaPeer
{
private static transient int DEFAULT_ROWS = 10;
private static transient int DEFAULT_COLS = 80;
native void create (int width, int height, int scrollbarVisibility);
native void gtkSetFont (String name, int style, int size);
@ -61,7 +64,7 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
// GtkComponent.create.
if (f == null)
{
f = new Font ("Fixed", Font.PLAIN, 12);
f = new Font ("Dialog", Font.PLAIN, 12);
awtComponent.setFont (f);
}
@ -72,13 +75,17 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
fm = new GdkFontMetrics (f);
TextArea ta = ((TextArea) awtComponent);
int rows = ta.getRows ();
int cols = ta.getColumns ();
int sizeRows = ta.getRows ();
int sizeCols = ta.getColumns ();
int width = cols * fm.getMaxAdvance ();
int height = rows * (fm.getMaxDescent () + fm.getMaxAscent ());
sizeRows = sizeRows == 0 ? DEFAULT_ROWS : sizeRows;
sizeCols = sizeCols == 0 ? DEFAULT_COLS : sizeCols;
int width = sizeCols * fm.getMaxAdvance ();
int height = sizeRows * (fm.getMaxDescent () + fm.getMaxAscent ());
create (width, height, ta.getScrollbarVisibility ());
setEditable (ta.isEditable ());
}
public GtkTextAreaPeer (TextArea ta)
@ -91,12 +98,14 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
public Dimension getMinimumSize (int rows, int cols)
{
return minimumSize (rows, cols);
return minimumSize (rows == 0 ? DEFAULT_ROWS : rows,
cols == 0 ? DEFAULT_COLS : cols);
}
public Dimension getPreferredSize (int rows, int cols)
{
return preferredSize (rows, cols);
return preferredSize (rows == 0 ? DEFAULT_ROWS : rows,
cols == 0 ? DEFAULT_COLS : cols);
}
native int getHScrollbarHeight ();
@ -127,8 +136,11 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
else
fm = new GdkFontMetrics (f);
width += cols * fm.getMaxAdvance ();
height += rows * (fm.getMaxDescent () + fm.getMaxAscent ());
int sizeRows = rows == 0 ? DEFAULT_ROWS : rows;
int sizeCols = cols == 0 ? DEFAULT_COLS : cols;
width += sizeCols * fm.getMaxAdvance ();
height += sizeRows * (fm.getMaxDescent () + fm.getMaxAscent ());
return new Dimension (width, height);
}
@ -157,8 +169,11 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
else
fm = new GdkFontMetrics (f);
width += cols * fm.getMaxAdvance ();
height += rows * (fm.getMaxDescent () + fm.getMaxAscent ());
int sizeRows = rows == 0 ? DEFAULT_ROWS : rows;
int sizeCols = cols == 0 ? DEFAULT_COLS : cols;
width += sizeCols * fm.getMaxAdvance ();
height += sizeRows * (fm.getMaxDescent () + fm.getMaxAscent ());
return new Dimension (width, height);
}

View file

@ -54,6 +54,7 @@ public class GtkTextComponentPeer extends GtkComponentPeer
super (tc);
setText (tc.getText ());
setCaretPosition(0);
}
public native void connectSignals ();

View file

@ -60,7 +60,7 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
// GtkComponent.create.
if (f == null)
{
f = new Font ("Fixed", Font.PLAIN, 12);
f = new Font ("Dialog", Font.PLAIN, 12);
awtComponent.setFont (f);
}

View file

@ -129,26 +129,58 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public Image createImage (String filename)
{
return new GtkImage (new GdkPixbufDecoder (filename), null);
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (filename);
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (filename);
GtkImage image = new GtkImage (d, null);
d.startProduction (image);
return image;
}
}
public Image createImage (URL url)
{
return new GtkImage (new GdkPixbufDecoder (url), null);
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (url);
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (url);
GtkImage image = new GtkImage (d, null);
d.startProduction (image);
return image;
}
}
public Image createImage (ImageProducer producer)
{
return new GtkImage (producer, null);
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (producer);
else
{
GtkImage image = new GtkImage (producer, null);
producer.startProduction (image);
return image;
}
}
public Image createImage (byte[] imagedata, int imageoffset,
int imagelength)
{
return new GtkImage (new GdkPixbufDecoder (imagedata,
imageoffset,
imagelength),
null);
if (useGraphics2D())
return GdkPixbufDecoder.createBufferedImage (imagedata,
imageoffset,
imagelength);
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (imagedata,
imageoffset,
imagelength);
GtkImage image = new GtkImage (d, null);
d.startProduction (image);
return image;
}
}
public ColorModel getColorModel ()
@ -175,18 +207,12 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public Image getImage (String filename)
{
GdkPixbufDecoder d = new GdkPixbufDecoder (filename);
GtkImage image = new GtkImage (d, null);
d.startProduction (image);
return image;
return createImage (filename);
}
public Image getImage (URL url)
{
GdkPixbufDecoder d = new GdkPixbufDecoder (url);
GtkImage image = new GtkImage (d, null);
d.startProduction (image);
return image;
return createImage (url);
}
public PrintJob getPrintJob (Frame frame, String jobtitle, Properties props)

View file

@ -77,11 +77,6 @@ public class Applet extends Panel
/** The applet stub for this applet. */
private transient AppletStub stub;
/**
* The dimensions passed to this applet through its HTML tag.
*/
private transient Dimension dimensions;
/**
* The accessibility context for this applet.
*
@ -462,41 +457,6 @@ public class Applet extends Panel
s.defaultReadObject();
}
private Dimension getDimensions ()
{
if (dimensions == null)
{
int width = Integer.parseInt(stub.getParameter("width"));
int height = Integer.parseInt(stub.getParameter("height"));
dimensions = new Dimension(width, height);
}
return dimensions;
}
/**
* Returns an instance of {@link Dimension} representing the
* applet's width and height parameters.
*
* @return the applet's preferred size
*/
public Dimension preferredSize()
{
return stub == null ? super.preferredSize () : getDimensions ();
}
/**
* Returns an instance of {@link Dimension} representing the
* applet's width and height parameters.
*
* @return the applet's minimum size
*/
public Dimension minimumSize()
{
return stub == null ? super.minimumSize () : getDimensions ();
}
/**
* This class provides accessibility support for Applets, and is the
* runtime type returned by {@link #getAccessibleContext()}.

View file

@ -238,8 +238,16 @@ public abstract class AWTEvent extends EventObject
*/
public String toString ()
{
return getClass ().getName () + "[" + paramString () + "] on "
+ ((Component) source).getName ();
String string = null;
if (source instanceof Component)
string = getClass ().getName () + "[" + paramString () + "] on "
+ ((Component) source).getName ();
else if (source instanceof MenuComponent)
string = getClass ().getName () + "[" + paramString () + "] on "
+ ((MenuComponent) source).getName ();
return string;
}
/**

View file

@ -592,13 +592,21 @@ layoutContainer(Container target)
int x1 = i.left;
int x2 = x1 + w.width + hgap;
int x3 = Math.max(x2 + w.width + hgap, t.width - i.right - e.width);
int x3;
if (t.width <= i.right + e.width)
x3 = x2 + w.width + hgap;
else
x3 = t.width - i.right - e.width;
int ww = t.width - i.right - i.left;
int y1 = i.top;
int y2 = y1 + n.height + vgap;
int midh = Math.max(e.height, Math.max(w.height, c.height));
int y3 = Math.max(y2 + midh + vgap, t.height - i.bottom - s.height);
int y3;
if (t.height <= i.bottom + s.height)
y3 = y2 + midh + vgap;
else
y3 = t.height - i.bottom - s.height;
int hh = y3-y2-vgap;
setBounds(center, x2, y2, x3-x2-hgap, hh);

View file

@ -81,6 +81,11 @@ private String label;
// List of ActionListeners for this class.
private transient ActionListener action_listeners;
/*
* The number used to generate the name returned by getName.
*/
private static transient long next_button_number = 0;
/*************************************************************************/
/*
@ -305,9 +310,24 @@ dispatchEventImpl(AWTEvent e)
protected String
paramString()
{
return ("label=" + getLabel() + ",actionCommand=" + getActionCommand()
+ "," + super.paramString());
return getName () + "," + getX () + "," + getY () + ","
+ getWidth () + "x" + getHeight () + ",label=" + getLabel ();
}
/**
* Generate a unique name for this button.
*
* @return A unique name for this button.
*/
String generateName ()
{
return "button" + getUniqueLong ();
}
private static synchronized long getUniqueLong ()
{
return next_button_number++;
}
} // class Button

View file

@ -941,7 +941,7 @@ public abstract class Component
{
if (foreground != null)
return foreground;
return parent == null ? null : parent.getForeground();
return parent == null ? SystemColor.windowText : parent.getForeground();
}
/**
@ -982,7 +982,7 @@ public abstract class Component
{
if (background != null)
return background;
return parent == null ? null : parent.getBackground();
return parent == null ? SystemColor.window : parent.getBackground();
}
/**
@ -1031,7 +1031,7 @@ public abstract class Component
if (parent != null)
return parent.getFont ();
else
return new Font ("Fixed", Font.PLAIN, 12);
return new Font ("Dialog", Font.PLAIN, 12);
}
/**

View file

@ -876,11 +876,6 @@ public class Container extends Component
{
return locate (x, y);
}
public Component getComponentAt(int index)
{
return component[index];
}
/**
* Returns the component located at the specified point. This is done

View file

@ -790,13 +790,26 @@ public class GridBagLayout
info.rowWeights);
} // end of STEP 4
calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
// Adjust cell sizes iff parent size not zero.
if (parentDim.width > 0 && parentDim.height > 0)
{
calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
}
int totalWidth = sumIntArray(info.colWidths);
int totalHeight = sumIntArray(info.rowHeights);
info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
// Make sure pos_x and pos_y are never negative.
if (totalWidth >= parentDim.width)
info.pos_x = parentInsets.left;
else
info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
if (totalHeight >= parentDim.height)
info.pos_y = parentInsets.top;
else
info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
// DEBUG
//dumpLayoutInfo (info);

View file

@ -81,12 +81,17 @@ public class MediaTracker implements java.io.Serializable
status = ERRORED | COMPLETE;
else if ((flags & ALLBITS) != 0)
status = COMPLETE;
else
else if ((flags & SOMEBITS) != 0)
status = LOADING;
synchronized (MediaTracker.this)
else
status = 0;
if ((status & COMPLETE) == COMPLETE)
{
MediaTracker.this.notifyAll();
synchronized (MediaTracker.this)
{
MediaTracker.this.notifyAll();
}
}
// If status is not COMPLETE then we need more updates.
return (status & COMPLETE) == 0;
@ -106,7 +111,8 @@ public class MediaTracker implements java.io.Serializable
e.next = head;
head = e;
// Start tracking image status.
target.checkImage(image, e);
int flags = target.checkImage(image, e);
e.imageUpdate(image, flags, -1, -1, -1, -1);
}
public void addImage(Image image, int id, int width, int height)
@ -119,7 +125,8 @@ public class MediaTracker implements java.io.Serializable
e.height = height;
head = e;
// Start tracking image status.
target.checkImage(image, width, height, e);
int flags = target.checkImage(image, width, height, e);
e.imageUpdate(image, flags, -1, -1, width, height);
}
public boolean checkAll()

View file

@ -424,6 +424,11 @@ dispatchEventImpl(AWTEvent e)
&& (action_listeners != null
|| (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
processEvent(e);
// Send the event to the parent menu if it has not yet been
// consumed.
if (!e.isConsumed ())
((Menu) getParent ()).processEvent (e);
}
/**

View file

@ -103,29 +103,33 @@ public class TextArea extends TextComponent implements java.io.Serializable
private static transient long next_text_number = 0;
/**
* Initialize a new instance of <code>TextArea</code> that is empty
* and is one row by one column. Both horizontal and vertical
* Initialize a new instance of <code>TextArea</code> that is empty.
* Conceptually the <code>TextArea</code> has 0 rows and 0 columns
* but its initial bounds are defined by its peer or by the
* container in which it is packed. Both horizontal and vertical
* scrollbars will be displayed.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea ()
{
this ("", 1, 1, SCROLLBARS_BOTH);
this ("", 0, 0, SCROLLBARS_BOTH);
}
/**
* Initialize a new instance of <code>TextArea</code> that initially
* contains the specified text. Both horizontal and veritcal
* scrollbars will be displayed.
* Initialize a new instance of <code>TextArea</code> that contains
* the specified text. Conceptually the <code>TextArea</code> has 0
* rows and 0 columns but its initial bounds are defined by its peer
* or by the container in which it is packed. Both horizontal and
* veritcal scrollbars will be displayed.
*
* @param text The text to display in this text area.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (String text)
{
this (text, 1, text.length (), SCROLLBARS_BOTH);
this (text, 0, 0, SCROLLBARS_BOTH);
}
/**
@ -137,7 +141,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (int rows, int columns)
{
@ -154,7 +158,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (String text, int rows, int columns)
{
@ -175,7 +179,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
* SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY,
* SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless () is true,
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
public TextArea (String text, int rows, int columns, int scrollbarVisibility)
{
@ -184,7 +188,7 @@ public class TextArea extends TextComponent implements java.io.Serializable
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
if (rows < 1 || columns < 0)
if (rows < 0 || columns < 0)
throw new IllegalArgumentException ("Bad row or column value");
if (scrollbarVisibility != SCROLLBARS_BOTH

View file

@ -141,6 +141,7 @@ setText(String text)
TextComponentPeer tcp = (TextComponentPeer)getPeer();
if (tcp != null)
tcp.setText(text);
setCaretPosition(0);
}
/*************************************************************************/

View file

@ -60,6 +60,8 @@ public abstract class AbstractAction
* enabled
*/
protected boolean enabled = true;
public static final String ENABLED_PROPERTY = "enabled";
/**
* changeSupport
@ -162,7 +164,12 @@ public abstract class AbstractAction
*/
public void putValue(String key, Object value)
{
store.put(key, value);
Object old = getValue(key);
if (old != value)
{
store.put(key, value);
firePropertyChange(key, old, value);
}
}
/**
@ -182,7 +189,11 @@ public abstract class AbstractAction
*/
public void setEnabled(boolean enabled)
{
this.enabled = enabled;
if (enabled != this.enabled)
{
this.enabled = enabled;
firePropertyChange(ENABLED_PROPERTY, !this.enabled, this.enabled);
}
}
/**
@ -195,17 +206,31 @@ public abstract class AbstractAction
}
/**
* firePropertyChange
* This method fires a PropertyChangeEvent given the propertyName
* and the old and new values.
*
* @param propertyName TODO
* @param oldValue TODO
* @param newValue TODO
* @param propertyName The property that changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
*/
protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue)
{
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
* This convenience method fires a PropertyChangeEvent given
* the propertyName and the old and new values.
*
* @param propertyName The property that changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
*/
private void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
{
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
* addPropertyChangeListener

View file

@ -154,6 +154,8 @@ import javax.swing.text.AttributeSet;
public abstract class AbstractButton extends JComponent
implements ItemSelectable, SwingConstants
{
private static final long serialVersionUID = -937921345538462020L;
/** The icon displayed by default. */
Icon default_icon;
@ -292,9 +294,10 @@ public abstract class AbstractButton extends JComponent
extends AccessibleJComponent implements AccessibleAction, AccessibleValue,
AccessibleText
{
protected AccessibleAbstractButton(JComponent c)
private static final long serialVersionUID = -5673062525319836790L;
protected AccessibleAbstractButton()
{
super(c);
}
public AccessibleStateSet getAccessibleStateSet()
@ -459,7 +462,7 @@ public abstract class AbstractButton extends JComponent
/**
* Creates a new AbstractButton object.
*/
AbstractButton()
public AbstractButton()
{
this("",null);
}
@ -472,28 +475,7 @@ public abstract class AbstractButton extends JComponent
*/
AbstractButton(String txt, Icon icon)
{
text = txt;
default_icon = icon;
model = new DefaultButtonModel();
actionListener = createActionListener();
changeListener = createChangeListener();
itemListener = createItemListener();
model.addActionListener(actionListener);
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;
setAlignmentX(LEFT_ALIGNMENT);
setAlignmentY(CENTER_ALIGNMENT);
addFocusListener(new ButtonFocusListener());
init (txt, icon);
updateUI();
}
@ -538,6 +520,32 @@ public abstract class AbstractButton extends JComponent
repaint();
}
protected void init(String text, Icon icon)
{
this.text = text;
default_icon = icon;
model = new DefaultButtonModel();
actionListener = createActionListener();
changeListener = createChangeListener();
itemListener = createItemListener();
model.addActionListener(actionListener);
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;
setAlignmentX(LEFT_ALIGNMENT);
setAlignmentY(CENTER_ALIGNMENT);
addFocusListener(new ButtonFocusListener());
}
/**
* Get the action command string for this button's model.
*
@ -1036,15 +1044,17 @@ public abstract class AbstractButton extends JComponent
action.removePropertyChangeListener(actionPropertyChangeListener);
actionPropertyChangeListener = null;
}
actionPropertyChangeListener = createActionPropertyChangeListener(a);
}
Action old = action;
action = a;
configurePropertiesFromAction(action);
if (action != null)
{
actionPropertyChangeListener = createActionPropertyChangeListener(a);
action.addPropertyChangeListener(actionPropertyChangeListener);
addActionListener(action);
}
@ -1067,15 +1077,15 @@ public abstract class AbstractButton extends JComponent
* @param i The new default icon
*/
public void setIcon(Icon i)
{
if (default_icon != i)
{
Icon old = default_icon;
default_icon = i;
if (old != i)
{
firePropertyChange(ICON_CHANGED_PROPERTY, old, i);
Icon old = default_icon;
default_icon = i;
firePropertyChange(ICON_CHANGED_PROPERTY, old, i);
revalidate();
repaint();
}
}
}
/**
@ -1204,6 +1214,10 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getDisabledIcon()
{
if (disabled_icon == null
&& default_icon instanceof ImageIcon)
disabled_icon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) default_icon).getImage()));
return disabled_icon;
}
@ -1375,7 +1389,8 @@ public abstract class AbstractButton extends JComponent
setIcon((Icon)(a.getValue(Action.SMALL_ICON)));
setEnabled(a.isEnabled());
setToolTipText((String)(a.getValue(Action.SHORT_DESCRIPTION)));
setMnemonic(((Integer)(a.getValue(Action.MNEMONIC_KEY))).intValue());
if (a.getValue(Action.MNEMONIC_KEY) != null)
setMnemonic(((Integer)(a.getValue(Action.MNEMONIC_KEY))).intValue());
setActionCommand((String)(a.getValue(Action.ACTION_COMMAND_KEY)));
}
}
@ -1433,9 +1448,21 @@ public abstract class AbstractButton extends JComponent
{
public void propertyChange(PropertyChangeEvent e)
{
Action act = (Action)(e.getSource());
AbstractButton.this.configurePropertiesFromAction(act);
}
Action act = (Action) (e.getSource());
if (e.getPropertyName().equals(AbstractAction.ENABLED_PROPERTY))
setEnabled(act.isEnabled());
else if (e.getPropertyName().equals(Action.NAME))
setText((String)(act.getValue(Action.NAME)));
else if (e.getPropertyName().equals(Action.SMALL_ICON))
setIcon((Icon)(act.getValue(Action.SMALL_ICON)));
else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION))
setToolTipText((String)(act.getValue(Action.SHORT_DESCRIPTION)));
else if (e.getPropertyName().equals(Action.MNEMONIC_KEY))
if (act.getValue(Action.MNEMONIC_KEY) != null)
setMnemonic(((Integer)(act.getValue(Action.MNEMONIC_KEY))).intValue());
else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY))
setActionCommand((String)(act.getValue(Action.ACTION_COMMAND_KEY)));
}
};
}

View file

@ -1,5 +1,5 @@
/* Box.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -55,8 +55,12 @@ public class Box extends JComponent implements Accessible
{
private static final long serialVersionUID = 1525417495883046342L;
protected class AccessibleBox extends AccessibleAWTContainer
protected class AccessibleBox
// FIXME: disable to make libjava compile; visibility rules are broken
// extends Container.AccessibleAWTContainer
{
private static final long serialVersionUID = -7775079816389931944L;
protected AccessibleBox()
{
}
@ -69,8 +73,14 @@ public class Box extends JComponent implements Accessible
public static class Filler extends JComponent implements Accessible
{
protected class AccessibleBoxFiller// extends AccessibleAWTComponent
private static final long serialVersionUID = -1204263191910183998L;
protected class AccessibleBoxFiller
// FIXME: disable to make libjava compile; visibility rules are broken
// extends Component.AccessibleAWTComponent
{
private static final long serialVersionUID = 164963348357479321L;
protected AccessibleBoxFiller()
{
}
@ -99,8 +109,9 @@ public class Box extends JComponent implements Accessible
public AccessibleContext getAccessibleContext()
{
// if (accessibleContext == null)
// accessibleContext = new AccessibleBoxFiller();
// FIXME: disable to make libjava compile; visibility rules are broken
// if (accessibleContext == null)
// accessibleContext = new AccessibleBoxFiller();
return accessibleContext;
}
@ -172,8 +183,8 @@ public class Box extends JComponent implements Accessible
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleBox();
// if (accessibleContext == null)
// accessibleContext = new AccessibleBox();
return accessibleContext;
}

View file

@ -1,4 +1,4 @@
/* ButtonGroup.java --
/* ButtonGroup.java --
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,97 +35,145 @@ 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.Serializable;
import java.util.Enumeration;
import java.util.Vector;
public class ButtonGroup implements Serializable
public class ButtonGroup
implements Serializable
{
static final long serialVersionUID = 4259076101881721375L;
private static final long serialVersionUID = 4259076101881721375L;
Vector v = new Vector();
ButtonModel sel;
public ButtonGroup() {}
public void add(AbstractButton b)
{
b.getModel().setGroup(this);
v.addElement(b);
}
public void remove(AbstractButton b)
{
b.getModel().setGroup(null);
v.removeElement(b);
}
/**
* The buttons added to this button group.
*/
protected Vector buttons = new Vector();
/**
* The currently selected button model.
*/
ButtonModel sel;
public Enumeration getElements() {
return v.elements();
}
/**
* Creates a new button group.
*/
public ButtonGroup()
{
}
public ButtonModel getSelection() {
return sel;
}
/**
* Adds a button to this group.
*
* @param b the button to add
*/
public void add(AbstractButton b)
{
b.getModel().setGroup(this);
buttons.addElement(b);
}
AbstractButton FindButton(ButtonModel m)
{
for (int i=0;i<v.size();i++)
{
AbstractButton a = (AbstractButton) v.get(i);
if (a.getModel()== m)
{
return a;
}
}
return null;
}
/**
* Removed a given button from this group.
*
* @param b the button to remove
*/
public void remove(AbstractButton b)
{
b.getModel().setGroup(null);
buttons.removeElement(b);
}
public void setSelected(ButtonModel m, boolean b)
{
if ((m == sel) &&
(b == true))
{
// clicked on sam item twice.
System.out.println("PRESSED TWICE:" + m + ", sel="+sel);
return;
}
if (sel != null)
{
/**
* Returns the currently added buttons.
*
* @return <code>Enumeration</code> over all added buttons
*/
public Enumeration getElements()
{
return buttons.elements();
}
System.out.println("DESELECTING: " + sel);
sel.setSelected(!b);
/**
* Returns the currently selected button model.
*
* @return the currently selected button model,
* null if none was selected yet
*/
public ButtonModel getSelection()
{
return sel;
}
AbstractButton but = FindButton(sel);
if (but != null)
{
System.out.println("REPAINT-REQUIST: " + but.text);
//but.revalidate();
but.repaint();
}
}
else
{
System.out.println("NO SELECTION YET");
}
sel = m;
}
public boolean isSelected(ButtonModel m)
{
return (m == sel);
}
AbstractButton FindButton(ButtonModel m)
{
for (int i = 0;i < buttons.size(); i++)
{
AbstractButton a = (AbstractButton) buttons.get(i);
if (a.getModel() == m)
return a;
}
return null;
}
public int getButtonCount()
{
return v.size();
}
/**
* Sets the currently selected button model. Only one button of a group
* can be selected at a time.
*
* @param m the model to select
* @param b true if this button is to be selected, false otherwise
*/
public void setSelected(ButtonModel m, boolean b)
{
if ((m == sel) && (b == true))
{
// clicked on same item twice.
System.out.println("PRESSED TWICE:" + m + ", sel=" + sel);
return;
}
if (sel != null)
{
System.out.println("DESELECTING: " + sel);
sel.setSelected(! b);
AbstractButton but = FindButton(sel);
if (but != null)
{
System.out.println("REPAINT-REQUEST: " + but.text);
//but.revalidate();
but.repaint();
}
}
else
System.out.println("NO SELECTION YET");
sel = m;
}
/**
* Checks if the given <code>ButtonModel</code> is selected
* in this button group.
*
* @return true of given <code>ButtonModel</code> is selected,
* false otherwise
*/
public boolean isSelected(ButtonModel m)
{
return m == sel;
}
/**
* Return the number of buttons in this button group.
*
* @return the number of buttons
*
* @since 1.3
*/
public int getButtonCount()
{
return buttons.size();
}
}

View file

@ -56,50 +56,30 @@ public class CellRendererPane extends Container implements Accessible
{
private static final long serialVersionUID = -7642183829532984273L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* AccessibleCellRendererPane
*/
protected class AccessibleCellRendererPane extends AccessibleAWTContainer
{
private static final long serialVersionUID = -8981090083147391074L;
/**
* AccessibleCellRendererPane
*/
protected class AccessibleCellRendererPane extends AccessibleAWTContainer {
/**
* Constructor AccessibleCellRendererPane
* @param component TODO
*/
protected AccessibleCellRendererPane()
{
}
private static final long serialVersionUID = 7300340301783504481L;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleCellRendererPane
* @param component TODO
*/
protected AccessibleCellRendererPane(CellRendererPane component) {
super();
// TODO
} // AccessibleCellRendererPane()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PANEL;
} // getAccessibleRole()
} // AccessibleCellRendererPane
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.PANEL;
}
}
/**
* accessibleContext
@ -209,16 +189,15 @@ public class CellRendererPane extends Container implements Accessible
// TODO
} // paintComponent()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleCellRendererPane(this);
} // if
return accessibleContext;
} // getAccessibleContext()
/**
* getAccessibleContext
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleCellRendererPane();
} // CellRendererPane
return accessibleContext;
}
}

View file

@ -41,6 +41,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.io.Serializable;
import java.util.EventListener;
@ -80,56 +81,52 @@ public class DefaultButtonModel implements ButtonModel, Serializable
/** Indicates that the button is <em>partially</em> committed to being
pressed, but not entirely. This usually happens when a user has pressed
but not yet released the mouse button. */
static int ARMED = 1;
public static final int ARMED = 1;
/** State constant indicating that the button is enabled. Buttons cannot
be pressed or selected unless they are enabled. */
static int ENABLED = 2;
public static final int ENABLED = 8;
/** State constant indicating that the user is holding down the button.
When this transitions from true to false, an ActionEvent may be fired,
depending on the value of the "armed" property.*/
static int PRESSED = 4;
public static final int PRESSED = 4;
/** State constant indicating that the mouse is currently positioned over
the button. */
static int ROLLOVER = 8;
public static final int ROLLOVER = 16;
/** State constant indicating that the button is selected. This constant
is only meaningful for toggle-type buttons (radio buttons,
checkboxes). */
static int SELECTED = 16;
public static final int SELECTED = 2;
/** Represents the "state properties" (armed, enabled, pressed, rollover
and selected) by a bitwise combination of integer constants. */
int stateMask;
protected int stateMask = ENABLED;
/** List of ItemListeners, ChangeListeners, and ActionListeners
registered on this model. */
EventListenerList listenerList;
protected EventListenerList listenerList = new EventListenerList();;
/** The single ChangeEvent this model (re)uses to call its
ChangeListeners. */
ChangeEvent changeEvent;
protected ChangeEvent changeEvent = new ChangeEvent(this);
/** The group this model belongs to. Only one button in a group may be
selected at any given time. */
ButtonGroup group;
protected ButtonGroup group;
/** The key code (one of {@link java.awt.event.KeyEvent} VK_*) used to
press this button via a keyboard interface. */
int mnemonic;
protected int mnemonic = KeyEvent.VK_UNDEFINED;
/** The string used as the "command" property of any ActionEvent this
model sends. */
String actionCommand;
protected String actionCommand;
public DefaultButtonModel()
{
stateMask = ENABLED;
mnemonic = java.awt.event.KeyEvent.VK_UNDEFINED;
listenerList = new EventListenerList();
changeEvent = new ChangeEvent(this);
}
/**
@ -143,6 +140,18 @@ public class DefaultButtonModel implements ButtonModel, Serializable
return null;
}
/**
* Returns a specified class of listeners.
*
* @param listenerType the type of listener to return
*
* @return array of listeners
*/
public EventListener[] getListeners(Class listenerType)
{
return listenerList.getListeners(listenerType);
}
/**
* Add an ActionListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
@ -165,6 +174,16 @@ public class DefaultButtonModel implements ButtonModel, Serializable
listenerList.remove(ActionListener.class, l);
}
/**
* Returns all registered <code>ActionListener</code> objects.
*
* @return array of <code>ActionListener</code> objects
*/
public ActionListener[] getActionListeners()
{
return (ActionListener[]) listenerList.getListeners(ActionListener.class);
}
/**
* Add an ItemListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
@ -187,6 +206,16 @@ public class DefaultButtonModel implements ButtonModel, Serializable
listenerList.remove(ItemListener.class, l);
}
/**
* Returns all registered <code>ItemListener</code> objects.
*
* @return array of <code>ItemListener</code> objects
*/
public ItemListener[] getItemListeners()
{
return (ItemListener[]) listenerList.getListeners(ItemListener.class);
}
/**
* Add a ChangeListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
@ -209,6 +238,16 @@ public class DefaultButtonModel implements ButtonModel, Serializable
listenerList.remove(ChangeListener.class, l);
}
/**
* Returns all registered <code>ChangeListener</code> objects.
*
* @return array of <code>ChangeListener</code> objects
*/
public ChangeListener[] getChangeListeners()
{
return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
}
/**
* Inform each ItemListener in the {@link listenerList} that an ItemEvent
* has occurred. This happens in response to any change to the {@link
@ -218,9 +257,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void fireItemStateChanged(ItemEvent e)
{
EventListener[] ll = listenerList.getListeners(ItemListener.class);
ItemListener[] ll = getItemListeners();
for (int i = 0; i < ll.length; i++)
((ItemListener)ll[i]).itemStateChanged(e);
ll[i].itemStateChanged(e);
}
/**
@ -233,9 +273,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void fireActionPerformed(ActionEvent e)
{
EventListener[] ll = listenerList.getListeners(ActionListener.class);
ActionListener[] ll = getActionListeners();
for (int i = 0; i < ll.length; i++)
((ActionListener)ll[i]).actionPerformed(e);
ll[i].actionPerformed(e);
}
/**
@ -245,11 +286,12 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*
* @param event The ChangeEvent to fire
*/
public void fireStateChanged(ChangeEvent e)
public void fireStateChanged()
{
EventListener[] ll = listenerList.getListeners(ChangeListener.class);
ChangeListener[] ll = getChangeListeners();
for (int i = 0; i < ll.length; i++)
((ChangeListener)ll[i]).stateChanged(e);
ll[i].stateChanged(changeEvent);
}
/**
@ -276,7 +318,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
stateMask = newstate;
fireStateChanged(changeEvent);
fireStateChanged();
if ((oldstate & SELECTED) == 0
&& (newstate & SELECTED) == SELECTED)
@ -418,7 +460,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
if (mnemonic != key)
{
mnemonic = key;
fireStateChanged(changeEvent);
fireStateChanged();
}
}
@ -434,14 +476,12 @@ public class DefaultButtonModel implements ButtonModel, Serializable
if (actionCommand != s)
{
actionCommand = s;
fireStateChanged(changeEvent);
fireStateChanged();
}
}
/**
* Set the value of the model's "actionCommand" property. This property
* is used as the "command" property of the {@link ActionEvent} fired
* from the model.
* Returns the current value of the model's "actionCommand" property.
*
* @return The current "actionCommand" property
*/
@ -453,7 +493,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
/**
* Set the value of the model's "group" property. The model is said to be
* a member of the {@link ButtonGroup} held in its "group" property, and
* only one models in a given group can have their "selected" property be
* only one model in a given group can have their "selected" property be
* <code>true</code> at a time.
*
* @param g The new "group" property
@ -463,7 +503,17 @@ public class DefaultButtonModel implements ButtonModel, Serializable
if (group != g)
{
group = g;
fireStateChanged(changeEvent);
fireStateChanged();
}
}
/**
* Returns the current value of the model's "group" property.
*
* @return The value of the "group" property
*/
public ButtonGroup getGroup()
{
return group;
}
}

View file

@ -58,50 +58,34 @@ public class DefaultCellEditor
{
static final long serialVersionUID = 3564035141373880027L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* EditorDelegate
*/
protected class EditorDelegate
implements ActionListener, ItemListener, Serializable
{
private static final long serialVersionUID = -1420007406015481933L;
/**
* EditorDelegate
*/
protected class EditorDelegate implements ActionListener,
ItemListener, Serializable {
/**
* value
*/
protected Object value;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* Constructor EditorDelegate
* @param value0 TODO
*/
protected EditorDelegate()
{
}
/**
* value
*/
protected Object value;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor EditorDelegate
* @param value0 TODO
*/
protected EditorDelegate(DefaultCellEditor editor) {
// TODO
} // EditorDelegate()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* setValue
* @param event TODO
*/
public void setValue(Object event) {
// TODO
} // setValue()
/**
* setValue
* @param event TODO
*/
public void setValue(Object event)
{
}
/**
* getCellEditorValue
@ -172,11 +156,6 @@ public class DefaultCellEditor
} // EditorDelegate
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* editorComponent
*/
@ -192,11 +171,6 @@ public class DefaultCellEditor
*/
protected int clickCountToStart;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor DefaultCellEditor
* @param textfield TODO
@ -221,11 +195,6 @@ public class DefaultCellEditor
// TODO
} // DefaultCellEditor()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getComponent
* @returns Component
@ -320,6 +289,4 @@ public class DefaultCellEditor
Object value, boolean isSelected, int row, int column) {
return null; // TODO
} // getTableCellEditorComponent()
} // DefaultCellEditor
}

View file

@ -37,249 +37,618 @@ exception statement from your version. */
package javax.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.beans.PropertyVetoException;
import java.io.Serializable;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JInternalFrame.JDesktopIcon;
/**
* DefaultDesktopManager
* @author Andrew Selkirk
* @version 1.0
* DefaultDesktopManager is the default implementation of DesktopManager for
* swing. It implements the basic beaviours for JInternalFrames in arbitrary
* parents. The methods provided by the class are not meant to be called by
* the user, instead, the JInternalFrame methods will call these methods.
*/
public class DefaultDesktopManager implements DesktopManager, Serializable
{
/** DOCUMENT ME! */
static final long serialVersionUID = 4657624909838017887L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/** The property change event fired when the wasIcon property changes. */
static final String WAS_ICON_ONCE_PROPERTY = "wasIconOnce";
/**
* HAS_BEEN_ICONIFIED_PROPERTY
*/
static final String HAS_BEEN_ICONIFIED_PROPERTY = ""; // TODO
/**
* The method of dragging used by the JDesktopPane that parents the
* JInternalFrame that is being dragged.
*/
private int currentDragMode = 0;
/**
* DEFAULT_DRAG_MODE
*/
static final int DEFAULT_DRAG_MODE = 0; // TODO
/**
* The cache of the bounds used to draw the outline rectangle when
* OUTLINE_DRAG_MODE is used.
*/
private transient Rectangle dragCache = new Rectangle();
/**
* OUTLINE_DRAG_MODE
*/
static final int OUTLINE_DRAG_MODE = 0; // TODO
/**
* A cached JDesktopPane that is stored when the JInternalFrame is initially
* dragged.
*/
private transient Container pane;
/**
* FASTER_DRAG_MODE
*/
static final int FASTER_DRAG_MODE = 0; // TODO
/**
* An array of Rectangles that holds the bounds of the JDesktopIcons in the
* JDesktopPane when looking for where to place a new icon.
*/
private transient Rectangle[] iconRects;
/**
* dragMode
*/
int dragMode;
/**
* This creates a new DefaultDesktopManager object.
*/
public DefaultDesktopManager()
{
} // DefaultDesktopManager()
/**
* This method is not normally called since the user will typically add the
* JInternalFrame to a Container. If this is called, it will try to
* determine the parent of the JInternalFrame and remove any icon that
* represents this JInternalFrame and add this JInternalFrame.
*
* @param frame The JInternalFrame to open.
*/
public void openFrame(JInternalFrame frame)
{
Container c = frame.getParent();
if (c == null)
c = frame.getDesktopIcon().getParent();
if (c == null)
return;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
c.remove(frame.getDesktopIcon());
c.add(frame);
frame.setVisible(true);
} // openFrame()
/**
* Constructor DefaultDesktopManager
*/
public DefaultDesktopManager() {
// TODO
} // DefaultDesktopManager()
/**
* This method removes the JInternalFrame and JDesktopIcon (if one is
* present) from their parents.
*
* @param frame The JInternalFrame to close.
*/
public void closeFrame(JInternalFrame frame)
{
Container c = frame.getParent();
frame.doDefaultCloseAction();
if (c != null)
{
if (frame.isIcon())
c.remove(frame.getDesktopIcon());
else
c.remove(frame);
c.repaint();
}
} // closeFrame()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* This method resizes the JInternalFrame to match its parent's bounds.
*
* @param frame The JInternalFrame to maximize.
*/
public void maximizeFrame(JInternalFrame frame)
{
// Can't maximize from iconified state.
// It can only return to maximized state, but that would fall under
// deiconify.
if (frame.isIcon())
return;
frame.setNormalBounds(frame.getBounds());
/**
* openFrame
* @param frame TODO
*/
public void openFrame(JInternalFrame frame) {
// TODO
} // openFrame()
Container p = frame.getParent();
if (p != null)
{
Rectangle pBounds = p.getBounds();
Insets insets = p.getInsets();
pBounds.width -= insets.left + insets.right;
pBounds.height -= insets.top + insets.bottom;
/**
* closeFrame
* @param frame TODO
*/
public void closeFrame(JInternalFrame frame) {
// TODO
} // closeFrame()
setBoundsForFrame(frame, 0, 0, pBounds.width, pBounds.height);
}
if (p instanceof JDesktopPane)
((JDesktopPane) p).setSelectedFrame(frame);
else
{
try
{
frame.setSelected(true);
}
catch (PropertyVetoException e)
{
// Do nothing.
}
}
} // maximizeFrame()
/**
* maximizeFrame
* @param frame TODO
*/
public void maximizeFrame(JInternalFrame frame) {
// TODO
} // maximizeFrame()
/**
* This method restores the JInternalFrame's bounds to what they were
* previous to the setMaximize call.
*
* @param frame The JInternalFrame to minimize.
*/
public void minimizeFrame(JInternalFrame frame)
{
Rectangle normalBounds = frame.getNormalBounds();
/**
* minimizeFrame
* @param frame TODO
*/
public void minimizeFrame(JInternalFrame frame) {
// TODO
} // minimizeFrame()
JDesktopPane p = frame.getDesktopPane();
if (p != null)
p.setSelectedFrame(frame);
else
{
try
{
frame.setSelected(true);
}
catch (PropertyVetoException e)
{
// Do nothing.
}
}
/**
* iconifyFrame
* @param frame TODO
*/
public void iconifyFrame(JInternalFrame frame) {
// TODO
} // iconifyFrame()
setBoundsForFrame(frame, normalBounds.x, normalBounds.y,
normalBounds.width, normalBounds.height);
} // minimizeFrame()
/**
* deiconifyFrame
* @param frame TODO
*/
public void deiconifyFrame(JInternalFrame frame) {
// TODO
} // deiconifyFrame()
/**
* This method removes the JInternalFrame from its parent and adds its
* JDesktopIcon representation.
*
* @param frame The JInternalFrame to iconify.
*/
public void iconifyFrame(JInternalFrame frame)
{
JDesktopPane p = frame.getDesktopPane();
JDesktopIcon icon = frame.getDesktopIcon();
if (p != null && p.getSelectedFrame() == frame)
p.setSelectedFrame(null);
else
{
try
{
frame.setSelected(false);
}
catch (PropertyVetoException e)
{
}
}
/**
* activateFrame
* @param frame TODO
*/
public void activateFrame(JInternalFrame frame) {
// TODO
} // activateFrame()
Container c = frame.getParent();
/**
* deactivateFrame
* @param frame TODO
*/
public void deactivateFrame(JInternalFrame frame) {
// TODO
} // deactivateFrame()
if (! wasIcon(frame))
{
Rectangle r = getBoundsForIconOf(frame);
icon.setBounds(r);
setWasIcon(frame, true);
}
/**
* beginDraggingFrame
* @param component TODO
*/
public void beginDraggingFrame(JComponent component) {
// TODO
} // beginDraggingFrame()
if (c != null)
{
if (icon != null)
{
c.add(icon);
icon.setVisible(true);
}
c.remove(frame);
}
} // iconifyFrame()
/**
* dragFrame
* @param component TODO
* @param newX TODO
* @param newY TODO
*/
public void dragFrame(JComponent component, int newX, int newY) {
// TODO
} // dragFrame()
/**
* This method removes the JInternalFrame's JDesktopIcon representation and
* adds the JInternalFrame back to its parent.
*
* @param frame The JInternalFrame to deiconify.
*/
public void deiconifyFrame(JInternalFrame frame)
{
JDesktopIcon icon = frame.getDesktopIcon();
Container c = icon.getParent();
/**
* endDraggingFrame
* @param component TODO
*/
public void endDraggingFrame(JComponent component) {
// TODO
} // endDraggingFrame()
removeIconFor(frame);
c.add(frame);
frame.setVisible(true);
/**
* beginResizingFrame
* @param component TODO
* @param direction TODO
*/
public void beginResizingFrame(JComponent component, int direction) {
// TODO
} // beginResizingFrame()
if (! frame.isSelected())
{
JDesktopPane p = frame.getDesktopPane();
if (p != null)
p.setSelectedFrame(frame);
else
{
try
{
frame.setSelected(true);
}
catch (PropertyVetoException e)
{
// Do nothing.
}
}
}
/**
* resizeFrame
* @param component TODO
* @param newX TODO
* @param newY TODO
* @param newWidth TODO
* @param newHeight TODO
*/
public void resizeFrame(JComponent component, int newX, int newY,
int newWidth, int newHeight) {
// TODO
} // resizeFrame()
c.invalidate();
} // deiconifyFrame()
/**
* endResizingFrame
* @param component TODO
*/
public void endResizingFrame(JComponent component) {
// TODO
} // endResizingFrame()
/**
* This method activates the JInternalFrame by moving it to the front and
* selecting it.
*
* @param frame The JInternalFrame to activate.
*/
public void activateFrame(JInternalFrame frame)
{
JDesktopPane p = frame.getDesktopPane();
/**
* setBoundsForFrame
* @param component TODO
* @param newX TODO
* @param newY TODO
* @param newWidth TODO
* @param newHeight TODO
*/
public void setBoundsForFrame(JComponent component, int newX,
int newY, int newWidth, int newHeight) {
// TODO
} // setBoundsForFrame()
if (p != null)
p.setSelectedFrame(frame);
else
{
try
{
frame.setSelected(true);
}
catch (PropertyVetoException e)
{
}
}
/**
* removeIconFor
* @param frame TODO
*/
protected void removeIconFor(JInternalFrame frame) {
// TODO
} // removeIconFor()
frame.toFront();
} // activateFrame()
/**
* getBoundsForIconOf
* @param frame TODO
* @returns Rectangle
*/
protected Rectangle getBoundsForIconOf(JInternalFrame frame) {
return null; // TODO
} // getBoundsForIconOf()
/**
* This method is called when the JInternalFrame loses focus.
*
* @param frame The JInternalFram to deactivate.
*/
public void deactivateFrame(JInternalFrame frame)
{
JDesktopPane p = frame.getDesktopPane();
if (p != null)
{
if (p.getSelectedFrame() == frame)
p.setSelectedFrame(null);
}
else
{
try
{
frame.setSelected(false);
}
catch (PropertyVetoException e)
{
}
}
} // deactivateFrame()
/**
* setPreviousBounds
* @param frame TODO
* @param rect TODO
*/
protected void setPreviousBounds(JInternalFrame frame, Rectangle rect) {
// TODO
} // setPreviousBounds()
/**
* This method is called to indicate that the DesktopManager should prepare
* to drag the JInternalFrame. Any state information needed to drag the
* frame will be prepared now.
*
* @param component The JComponent to drag, usually a JInternalFrame.
*/
public void beginDraggingFrame(JComponent component)
{
if (component instanceof JDesktopIcon)
pane = ((JDesktopIcon) component).getInternalFrame().getDesktopPane();
else
pane = ((JInternalFrame) component).getDesktopPane();
if (pane == null)
return;
/**
* getPreviousBounds
* @param frame TODO
* @returns Rectangle
*/
protected Rectangle getPreviousBounds(JInternalFrame frame) {
return null; // TODO
} // getPreviousBounds()
dragCache = component.getBounds();
/**
* setWasIcon
* @param frame TODO
* @param value TODO
*/
protected void setWasIcon(JInternalFrame frame, Boolean value) {
// TODO
} // setWasIcon()
if (! (pane instanceof JDesktopPane))
currentDragMode = JDesktopPane.LIVE_DRAG_MODE;
else
currentDragMode = ((JDesktopPane) pane).getDragMode();
} // beginDraggingFrame()
/**
* wasIcon
* @param frame TODO
* @returns boolean
*/
protected boolean wasIcon(JInternalFrame frame) {
return false; // TODO
} // wasIcon()
/**
* This method is called to drag the JInternalFrame to a new location.
*
* @param component The JComponent to drag, usually a JInternalFrame.
* @param newX The new x coordinate.
* @param newY The new y coordinate.
*/
public void dragFrame(JComponent component, int newX, int newY)
{
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
// FIXME: Do outline drag mode painting.
}
else
{
Rectangle b = component.getBounds();
if (component instanceof JDesktopIcon)
component.setBounds(newX, newY, b.width, b.height);
else
setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
b.height);
}
} // dragFrame()
/**
* This method indicates that the dragging is done. Any state information
* stored by the DesktopManager can be cleared.
*
* @param component The JComponent that has finished dragging.
*/
public void endDraggingFrame(JComponent component)
{
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
setBoundsForFrame((JInternalFrame) component, dragCache.x,
dragCache.y, dragCache.width, dragCache.height);
pane = null;
dragCache = null;
}
component.repaint();
} // endDraggingFrame()
/**
* This method is called to indicate that the given JComponent will be
* resized. Any state information necessary to resize the JComponent will
* be prepared now.
*
* @param component The JComponent to resize, usually a JInternalFrame.
* @param direction The direction to drag in (a SwingConstant).
*/
public void beginResizingFrame(JComponent component, int direction)
{
pane = ((JInternalFrame) component).getDesktopPane();
if (pane == null)
return;
dragCache = component.getBounds();
if (! (pane instanceof JDesktopPane))
currentDragMode = JDesktopPane.LIVE_DRAG_MODE;
else
currentDragMode = ((JDesktopPane) pane).getDragMode();
} // beginResizingFrame()
/**
* This method resizes the give JComponent.
*
* @param component The JComponent to resize.
* @param newX The new x coordinate.
* @param newY The new y coordinate.
* @param newWidth The new width.
* @param newHeight The new height.
*/
public void resizeFrame(JComponent component, int newX, int newY,
int newWidth, int newHeight)
{
dragCache.setBounds(newX, newY, newWidth, newHeight);
dragCache = findMinimum(dragCache, component);
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
// FIXME: Do outline drag painting.
}
else
setBoundsForFrame(component, dragCache.x, dragCache.y, dragCache.width,
dragCache.height);
} // resizeFrame()
/**
* This method is called to indicate that the given JComponent has finished
* dragging. Any state information stored by the DesktopManager can be
* cleared.
*
* @param component The JComponent that finished resizing.
*/
public void endResizingFrame(JComponent component)
{
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
setBoundsForFrame((JInternalFrame) component, dragCache.x,
dragCache.y, dragCache.width, dragCache.height);
pane = null;
dragCache = null;
}
component.repaint();
} // endResizingFrame()
/**
* This method calls setBounds with the given parameters and repaints the
* JComponent.
*
* @param component The JComponent to set bounds for.
* @param newX The new x coordinate.
* @param newY The new y coordinate.
* @param newWidth The new width.
* @param newHeight The new height.
*/
public void setBoundsForFrame(JComponent component, int newX, int newY,
int newWidth, int newHeight)
{
component.setBounds(newX, newY, newWidth, newHeight);
component.revalidate();
// If not null, I'd rather repaint the parent
if (component.getParent() != null)
component.getParent().repaint();
else
component.repaint();
} // setBoundsForFrame()
/**
* This is a helper method that removes the JDesktopIcon of the given
* JInternalFrame from the parent.
*
* @param frame The JInternalFrame to remove an icon for.
*/
protected void removeIconFor(JInternalFrame frame)
{
JDesktopIcon icon = frame.getDesktopIcon();
Container c = icon.getParent();
if (c != null && icon != null)
c.remove(icon);
} // removeIconFor()
/**
* This method is called by iconifyFrame to determine the bounds of the
* JDesktopIcon for the given JInternalFrame.
*
* @param frame The JInternalFrame to find the bounds of its JDesktopIcon
* for.
*
* @return The bounds of the JDesktopIcon.
*/
protected Rectangle getBoundsForIconOf(JInternalFrame frame)
{
// IconRects has no order to it.
// The icon _must_ be placed in the first free slot (working from
// the bottom left corner)
// The icon also must not be placed where another icon is placed
// (regardless whether that frame is an icon currently or not)
JDesktopPane desktopPane = frame.getDesktopPane();
Rectangle paneBounds = desktopPane.getBounds();
Insets insets = desktopPane.getInsets();
Dimension pref = frame.getDesktopIcon().getPreferredSize();
if (desktopPane == null)
return frame.getDesktopIcon().getBounds();
Component[] frames = desktopPane.getComponents();
int count = 0;
for (int i = 0, j = 0; i < frames.length; i++)
if (frames[i] instanceof JDesktopIcon
|| frames[i] instanceof JInternalFrame
&& ((JInternalFrame) frames[i]).getWasIcon() && frames[i] != frame)
count++;
iconRects = new Rectangle[count];
for (int i = 0, j = 0; i < frames.length; i++)
if (frames[i] instanceof JDesktopIcon)
iconRects[--count] = frames[i].getBounds();
else if (frames[i] instanceof JInternalFrame
&& ((JInternalFrame) frames[i]).getWasIcon()
&& frames[i] != frame)
iconRects[--count] = ((JInternalFrame) frames[i]).getDesktopIcon()
.getBounds();
int startingX = insets.left;
int startingY = paneBounds.height - insets.bottom - pref.height;
Rectangle ideal = new Rectangle(startingX, startingY, pref.width,
pref.height);
boolean clear = true;
while (iconRects.length > 0)
{
clear = true;
for (int i = 0; i < iconRects.length; i++)
{
if (iconRects[i] != null && iconRects[i].intersects(ideal))
{
clear = false;
break;
}
}
if (clear)
return ideal;
startingX += pref.width;
if (startingX + pref.width > paneBounds.width - insets.right)
{
startingX = insets.left;
startingY -= pref.height;
}
ideal.setBounds(startingX, startingY, pref.width, pref.height);
}
return ideal;
} // getBoundsForIconOf()
/**
* This method sets the bounds of the JInternalFrame right before the
* maximizeFrame call.
*
* @param frame The JInternalFrame being maximized.
* @param rect The normal bounds.
*/
protected void setPreviousBounds(JInternalFrame frame, Rectangle rect)
{
frame.setNormalBounds(rect);
} // setPreviousBounds()
/**
* This method returns the normal bounds of the JInternalFrame from before
* the maximize call.
*
* @param frame The JInternalFrame that is being restored.
*
* @return The previous bounds of the JInternalFrame.
*/
protected Rectangle getPreviousBounds(JInternalFrame frame)
{
return frame.getNormalBounds();
} // getPreviousBounds()
/**
* This method sets the value to true if the given JInternalFrame has been
* iconized and the bounds of its DesktopIcon are valid.
*
* @param frame The JInternalFrame for the JDesktopIcon.
* @param value True if the JInternalFrame has been iconized and the bounds
* of the JDesktopIcon are valid.
*/
protected void setWasIcon(JInternalFrame frame, boolean value)
{
frame.setWasIcon(value, WAS_ICON_ONCE_PROPERTY);
} // setWasIcon()
/**
* This method returns true if the given JInternalFrame has been iconized
* and the bounds of its DesktopIcon are valid.
*
* @param frame The JInternalFrame for the JDesktopIcon.
*
* @return True if the given JInternalFrame has been iconized and the bounds
* of its DesktopIcon are valid.
*/
protected boolean wasIcon(JInternalFrame frame)
{
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

@ -62,6 +62,7 @@ public class DefaultListSelectionModel implements Cloneable,
ListSelectionModel,
Serializable
{
private static final long serialVersionUID = -5718799865110415860L;
/** The list of ListSelectionListeners subscribed to this selection model. */
protected EventListenerList listenerList = new EventListenerList();

View file

@ -1,5 +1,5 @@
/* DesktopManager.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,118 +38,140 @@ exception statement from your version. */
package javax.swing;
/**
* DesktopManager
* @author Andrew Selkirk
* @version 1.0
* DesktopManagers are responsible for implementing the behaviours for the
* JInternalFrames that belong to JDesktopPanes. Actions such as maximizing,
* minimizing, iconifying, etc will be delegated to the DesktopManager.
*/
public interface DesktopManager {
public interface DesktopManager
{
/**
* This method will cause the JInternalFrame to be displayed in the set
* location. This usually is not needed since the user will add the
* JInternalFrame to a Container separately.
*
* @param frame The JInternalFrame to open.
*/
void openFrame(JInternalFrame frame);
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* This method should remove the JInternalFrame from its parent.
*
* @param frame The JInternalFrame to close.
*/
void closeFrame(JInternalFrame frame);
/**
* openFrame
* @param frame TODO
*/
void openFrame(JInternalFrame frame);
/**
* This method should maximize the JInternalFrame to match its parent's
* bounds.
*
* @param frame The JInternalFrame to maximize.
*/
void maximizeFrame(JInternalFrame frame);
/**
* closeFrame
* @param frame TODO
*/
void closeFrame(JInternalFrame frame);
/**
* This method should restore the JInternalFrame to its normal bounds.
*
* @param frame The JInternalFrame to minimize.
*/
void minimizeFrame(JInternalFrame frame);
/**
* maximizeFrame
* @param frame TODO
*/
void maximizeFrame(JInternalFrame frame);
/**
* This method should remove the JInternalFrame from its parent and replace
* it with a JDesktopIcon.
*
* @param frame The JInternalFrame to iconify.
*/
void iconifyFrame(JInternalFrame frame);
/**
* minimizeFrame
* @param frame TODO
*/
void minimizeFrame(JInternalFrame frame);
/**
* This method should remove the JDesktopIcon from its parent and replace it
* with the JInternalFrame that the JDesktopIcon represents.
*
* @param frame The JInternalFrame to deiconify.
*/
void deiconifyFrame(JInternalFrame frame);
/**
* iconifyFrame
* @param frame TODO
*/
void iconifyFrame(JInternalFrame frame);
/**
* This method should give focus to the JInternalFrame and its default focus
* owner.
*
* @param frame The JInternalFrame to activate.
*/
void activateFrame(JInternalFrame vframe);
/**
* deiconifyFrame
* @param frame TODO
*/
void deiconifyFrame(JInternalFrame frame);
/**
* This method should be called when the JInternalFrame gets deselected and
* subsequently loses focus.
*
* @param frame The JInternalFrame to deactivate.
*/
void deactivateFrame(JInternalFrame frame);
/**
* activateFrame
* @param frame TODO
*/
void activateFrame(JInternalFrame vframe);
/**
* This method should be called in preparation for dragging. This needs to
* be called prior to dragFrame calls so that the DesktopManager can
* prepare any state information.
*
* @param frame The JInternalFrame to prepare for dragging.
*/
void beginDraggingFrame(JComponent frame);
/**
* deactivateFrame
* @param frame TODO
*/
void deactivateFrame(JInternalFrame frame);
/**
* This method drags the given JInternalFrame to the given x and y
* coordinates.
*
* @param frame The JInternalFrame to drag.
* @param x The new x coordinate.
* @param y The new y coordinate.
*/
void dragFrame(JComponent frame, int x, int y);
/**
* beginDraggingFrame
* @param frame TODO
*/
void beginDraggingFrame(JComponent frame);
/**
* This method should be called after dragFrame calls. Any information used
* by the DesktopManager for dragging the JInternalFrame can be cleared.
*
* @param frame The JInternalFrame that finished dragging.
*/
void endDraggingFrame(JComponent frame);
/**
* dragFrame
* @param frame TODO
* @param x TODO
* @param y TODO
*/
void dragFrame(JComponent frame, int x, int y);
/**
* This method should be called prior to any resizeFrame calls. Any state
* information needed by the DesktopManager to resize the JInternalFrame
* will be prepared here.
*
* @param frame The JInternalFrame to resize.
* @param direction One of eight directions specified by SwingConstants.
*/
void beginResizingFrame(JComponent frame, int direction);
/**
* endDraggingFrame
* @param frame TODO
*/
void endDraggingFrame(JComponent frame);
/**
* beginResizingFrame
* @param frame TODO
* @param direction TODO
*/
void beginResizingFrame(JComponent frame, int direction);
/**
* resizeFrame
* @param frame TODO
* @param x TODO
* @param y TODO
* @param width TODO
* @param height TODO
*/
void resizeFrame(JComponent frame, int x, int y,
int width, int height);
/**
* endResizingFrame
* @param frame TODO
*/
void endResizingFrame(JComponent frame);
/**
* setBoundsForFrame
* @param frame TODO
* @param x TODO
* @param y TODO
* @param width TODO
* @param height TODO
*/
void setBoundsForFrame(JComponent frame, int x, int y,
int width, int height);
/**
* This method is called to resize the given JInternalFrame to the given
* bounds.
*
* @param frame The JInternalFrame to resize.
* @param x The new x coordinate.
* @param y The new y coordinate.
* @param width The new width.
* @param height The new height.
*/
void resizeFrame(JComponent frame, int x, int y, int width, int height);
/**
* This method is called to signify that the resize is finished. Any
* information used to resize the JInternalFrame can now be cleared.
*
* @param frame The JInternalFrame that just finished dragging.
*/
void endResizingFrame(JComponent frame);
/**
* This method does the actual work for reshaping the JInternalFrame.
*
* @param frame The JInternalFrame to resize.
* @param x The new x coordinate.
* @param y The new y coordinate.
* @param width The new width.
* @param height The new height.
*/
void setBoundsForFrame(JComponent frame, int x, int y, int width, int height);
} // DesktopManager

View file

@ -45,41 +45,41 @@ import java.awt.Toolkit;
public class GrayFilter extends RGBImageFilter
{
private boolean b;
private int p;
private boolean b;
private int p;
/**
Create a GrayFilter. If b is true then brighten. Also, indicate how much gray.
@param b if brighten
@param p percent of gray, 0 - 100
*/
public GrayFilter(boolean b, int p)
{
this.b = b; //FIXME - HANDLE THIS
this.p = p;
}
/**
* Create a GrayFilter. If b is true then brighten. Also, indicate how much gray.
*
* @param b if brighten
* @param p percent of gray, 0 - 100
*/
public GrayFilter(boolean b, int p)
{
this.b = b; //FIXME - HANDLE THIS
this.p = p;
}
/**
Create grayed image
@param i image to gray
@return a grayed image
*/
public static Image createDisabledImage(Image src)
{
return Toolkit.getDefaultToolkit().createImage( new FilteredImageSource(src.getSource(),
new GrayFilter(false, 100)));
}
/**
Filter RGB to gray
*/
public int filterRGB(int x,
int y,
int rgb)
{
return (int) ( ( p * ( 0.299 * ( (0xff0000 & rgb) >> 16) + 0.587 * ( (0xff00 & rgb) >> 8 ) + 0.114 * (0xff & rgb ) ) ));
}
/**
* Create grayed image
*
* @param src image to gray
*
* @return a grayed image
*/
public static Image createDisabledImage(Image src)
{
return (Toolkit.getDefaultToolkit().
createImage(new FilteredImageSource(src.getSource(),
new GrayFilter(false, 100))));
}
/**
* Filter RGB to gray
*/
public int filterRGB(int x, int y, int rgb)
{
return (int) (p * (0.299 * ((0xff0000 & rgb) >> 16)
+ 0.587 * ((0xff00 & rgb) >> 8) + 0.114 * (0xff & rgb)));
}
}

View file

@ -35,65 +35,86 @@ 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.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.Serializable;
import java.net.URL;
public class ImageIcon implements Icon
public class ImageIcon
implements Icon, Serializable
{
Image image;
String file, descr;
Component observer;
private static final long serialVersionUID = 532615968316031794L;
Image image;
String file;
String descr;
Component observer;
public ImageIcon(String s)
{
// if description is not specified, then file name becomes
// desciption for this icon
this(s, s);
}
{
// if description is not specified, then file name becomes
// desciption for this icon
this(s, s);
}
public ImageIcon(String file,
String descr)
{
this.file = file;
this.descr = descr;
public ImageIcon(Image image)
{
}
image = Toolkit.getDefaultToolkit().getImage(file);
if (image == null) {
return;
}
//loadImage(image);
}
public ImageIcon(URL url)
{
image = Toolkit.getDefaultToolkit().getImage(url);
}
// not in SUN's spec !!!
public void setParent(Component p)
{
observer = p;
}
public ImageIcon(String file, String descr)
{
this.file = file;
this.descr = descr;
public Image getImage()
{ return image; }
image = Toolkit.getDefaultToolkit().getImage(file);
if (image == null)
return;
public String getDescription()
{ return descr; }
public void setDescription(String description)
{ this.descr = description; }
//loadImage(image);
}
public int getIconHeight()
{ return image.getHeight(observer); }
public int getIconWidth()
{ return image.getWidth(observer); }
// not in SUN's spec !!!
public void setParent(Component p)
{
observer = p;
}
public void paintIcon(Component c,
Graphics g,
int x,
int y)
{
g.drawImage(image, x, y, observer);
}
public Image getImage()
{
return image;
}
public String getDescription()
{
return descr;
}
public void setDescription(String description)
{
this.descr = description;
}
public int getIconHeight()
{
return image.getHeight(observer);
}
public int getIconWidth()
{
return image.getWidth(observer);
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.drawImage(image, x, y, observer);
}
}

View file

@ -1,5 +1,5 @@
/* JApplet.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -51,6 +51,7 @@ import javax.accessibility.AccessibleContext;
public class JApplet extends Applet implements RootPaneContainer
{
private static final long serialVersionUID = 7269359214497372587L;
public final static int HIDE_ON_CLOSE = 0;
public final static int EXIT_ON_CLOSE = 1;
@ -136,10 +137,10 @@ public class JApplet extends Applet implements RootPaneContainer
{ return close_action; }
JMenuBar getJMenuBar()
public JMenuBar getJMenuBar()
{ return getRootPane().getJMenuBar(); }
void setJMenuBar(JMenuBar menubar)
public void setJMenuBar(JMenuBar menubar)
{ getRootPane().setJMenuBar(menubar); }

View file

@ -87,6 +87,7 @@ public class JButton extends AbstractButton implements Accessible
protected void configurePropertiesFromAction(Action a)
{
//Factory method which sets the AbstractButton's properties according to values from the Action instance.
super.configurePropertiesFromAction(a);
}
public AccessibleContext getAccessibleContext()

View file

@ -1,5 +1,5 @@
/* JCheckBox.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -47,6 +47,8 @@ import javax.accessibility.AccessibleContext;
*/
public class JCheckBox extends JToggleButton
{
private static final long serialVersionUID = -5246739313864538930L;
public JCheckBox()
{
this(null, null);

View file

@ -50,6 +50,8 @@ import javax.accessibility.AccessibleRole;
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
Accessible
{
private static final long serialVersionUID = -6676402307973384715L;
private static final String uiClassID = "CheckBoxMenuItemUI";
private boolean state;
private Object[] selectedObjects;
@ -207,7 +209,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJCheckBoxMenuItem(this);
accessibleContext = new AccessibleJCheckBoxMenuItem();
return accessibleContext;
}
@ -217,16 +219,13 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
*/
protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
{
private static final long serialVersionUID = 1079958073579370777L;
/**
* Creates a new AccessibleJCheckBoxMenuItem object.
*
* @param component DOCUMENT ME!
*/
protected AccessibleJCheckBoxMenuItem(JCheckBoxMenuItem component)
protected AccessibleJCheckBoxMenuItem()
{
super(component);
// TODO
}
/**

View file

@ -1,5 +1,5 @@
/* JColorChooser.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -57,6 +57,8 @@ import javax.swing.plaf.ColorChooserUI;
*/
public class JColorChooser extends JComponent implements Accessible {
private static final long serialVersionUID = 9168066781620640889L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
@ -66,6 +68,8 @@ public class JColorChooser extends JComponent implements Accessible {
*/
protected class AccessibleJColorChooser extends JComponent.AccessibleJComponent {
private static final long serialVersionUID = -2038297864782299082L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
@ -79,15 +83,9 @@ public class JColorChooser extends JComponent implements Accessible {
* Constructor AccessibleJColorChooser
* @param component TODO
*/
protected AccessibleJColorChooser(JColorChooser component) {
super(component);
// TODO
} // AccessibleJColorChooser()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
protected AccessibleJColorChooser()
{
}
/**
* getAccessibleRole
@ -355,16 +353,15 @@ public class JColorChooser extends JComponent implements Accessible {
return null; // TODO
} // paramString()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJColorChooser(this);
} // if
return accessibleContext;
} // getAccessibleContext()
/**
* getAccessibleContext
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJColorChooser();
} // JColorChooser
return accessibleContext;
}
}

View file

@ -69,39 +69,21 @@ public class JComboBox extends JComponent
{
private static final long serialVersionUID = 5654585963292734470L;
/**
* AccessibleJComboBox
*/
protected class AccessibleJComboBox extends AccessibleJComponent
implements AccessibleAction, AccessibleSelection
{
private static final long serialVersionUID = 8217828307256675666L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* AccessibleJComboBox
*/
protected class AccessibleJComboBox extends AccessibleJComponent
implements AccessibleAction, AccessibleSelection {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJComboBox
* @param component TODO
*/
protected AccessibleJComboBox(JComboBox component) {
super(component);
// TODO
} // AccessibleJComboBox()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJComboBox
* @param component TODO
*/
protected AccessibleJComboBox()
{
}
/**
* getAccessibleChildrenCount
@ -804,16 +786,18 @@ public class JComboBox extends JComponent
return null; // TODO
} // paramString()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJComboBox(this);
} // if
return accessibleContext;
} // getAccessibleContext()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJComboBox();
return accessibleContext;
}
/**
* addActionListener
* @param listener TODO

View file

@ -57,6 +57,7 @@ import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.awt.image.ImageObserver;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
@ -87,7 +88,7 @@ import javax.swing.plaf.ComponentUI;
*/
public abstract class JComponent extends Container implements Serializable
{
static final long serialVersionUID = -5242478962609715464L;
private static final long serialVersionUID = -7908749299918704233L;
/**
* Accessibility support is currently missing.
@ -101,7 +102,7 @@ public abstract class JComponent extends Container implements Serializable
protected class AccessibleFocusHandler
implements FocusListener
{
protected AccessibleFocusHandler(AccessibleJComponent component){}
protected AccessibleFocusHandler(){}
public void focusGained(FocusEvent event){}
public void focusLost(FocusEvent valevent){}
}
@ -109,15 +110,17 @@ public abstract class JComponent extends Container implements Serializable
protected class AccessibleContainerHandler
implements ContainerListener
{
protected AccessibleContainerHandler(AccessibleJComponent component) {}
protected AccessibleContainerHandler() {}
public void componentAdded(ContainerEvent event) {}
public void componentRemoved(ContainerEvent valevent) {}
}
private static final long serialVersionUID = -7047089700479897799L;
protected ContainerListener accessibleContainerHandler;
protected FocusListener accessibleFocusHandler;
protected AccessibleJComponent(JComponent component) {}
protected AccessibleJComponent() {}
public void addPropertyChangeListener(PropertyChangeListener listener) {}
public void removePropertyChangeListener(PropertyChangeListener listener) {}
public int getAccessibleChildrenCount() { return 0; }
@ -273,7 +276,7 @@ public abstract class JComponent extends Container implements Serializable
* @see #getUI
* @see #updateUI
*/
ComponentUI ui;
protected ComponentUI ui;
/**
* A hint to the focus system that this component should or should not
@ -343,6 +346,7 @@ public abstract class JComponent extends Container implements Serializable
*/
private static Locale defaultLocale;
public static final String TOOL_TIP_TEXT_KEY = "ToolTipText";
/**
* Constant used to indicate that no condition has been assigned to a
@ -735,7 +739,12 @@ public abstract class JComponent extends Container implements Serializable
Object newValue)
throws PropertyVetoException
{
// Support for reporting constrained property changes.
VetoableChangeListener[] listeners = getVetoableChangeListeners();
PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, oldValue, newValue);
for (int i = 0; i < listeners.length; i++)
listeners[i].vetoableChange(evt);
}
/**
@ -1105,7 +1114,11 @@ public abstract class JComponent extends Container implements Serializable
public JToolTip createToolTip()
{
if (toolTip == null)
toolTip = new JToolTip(toolTipText);
{
toolTip = new JToolTip();
toolTip.setTipText(toolTipText);
}
return toolTip;
}
@ -1378,7 +1391,7 @@ public abstract class JComponent extends Container implements Serializable
g2 = doubleBuffer.getGraphics();
g2.setClip(g.getClipBounds());
}
g2 = getComponentGraphics(g2);
paintComponent(g2);
paintBorder(g2);
@ -1470,7 +1483,7 @@ public abstract class JComponent extends Container implements Serializable
*/
public void paintImmediately(Rectangle r)
{
Component root = this.getRootPane();
Component root = SwingUtilities.getRoot(this);
if (root == null || ! root.isShowing())
return;
Graphics g = root.getGraphics();
@ -1624,7 +1637,7 @@ public abstract class JComponent extends Container implements Serializable
public void scrollRectToVisible(Rectangle r)
{
Component p = getParent();
if (p != null && p instanceof JComponent)
if (p instanceof JComponent)
((JComponent) p).scrollRectToVisible(r);
}

View file

@ -37,6 +37,8 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
@ -44,244 +46,281 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.plaf.DesktopPaneUI;
/**
* JDesktopPane
* @author Andrew Selkirk
* @version 1.0
* JDesktopPane is a container (usually for JInternalFrames) that simulates a
* desktop. Typically, the user will create JInternalFrames and place thme in
* a JDesktopPane. The user can then interact with JInternalFrames like they
* usually would with JFrames. The actions (minimize, maximize, close, etc)
* are done by using a DesktopManager that is associated with the
* JDesktopPane.
*/
public class JDesktopPane extends JLayeredPane implements Accessible
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 766333777224038726L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* This specifies that when dragged, a JInternalFrame should be completely
* visible.
*/
public static int LIVE_DRAG_MODE = 0;
/**
* AccessibleJDesktopPane
*/
protected class AccessibleJDesktopPane extends AccessibleJComponent {
/**
* This specifies that when dragged, a JInternalFrame should only be visible
* as an outline.
*/
public static int OUTLINE_DRAG_MODE = 1;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/** The selected frame in the JDesktopPane. */
private transient JInternalFrame selectedFrame;
/**
* Constructor AccessibleJDesktopPane
* @param component TODO
*/
protected AccessibleJDesktopPane(JDesktopPane component) {
super(component);
// TODO
} // AccessibleJDesktopPane()
/** The JDesktopManager to use for acting on JInternalFrames. */
transient DesktopManager desktopManager;
/** The drag mode used by the JDesktopPane. */
private transient int dragMode = LIVE_DRAG_MODE;
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* AccessibleJDesktopPane
*/
protected class AccessibleJDesktopPane extends AccessibleJComponent
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 6079388927946077570L;
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.DESKTOP_PANE;
} // getAccessibleRole()
/**
* Constructor AccessibleJDesktopPane
*/
protected AccessibleJDesktopPane()
{
}
/**
* getAccessibleRole
*
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.DESKTOP_PANE;
}
}
} // AccessibleJDesktopPane
/**
* Creates a new JDesktopPane object.
*/
public JDesktopPane()
{
setLayout(null);
updateUI();
}
/**
* This method returns the UI used with the JDesktopPane.
*
* @return The UI used with the JDesktopPane.
*/
public DesktopPaneUI getUI()
{
return (DesktopPaneUI) ui;
}
//-------------------------------------------------------------
// Constants --------------------------------------------------
//-------------------------------------------------------------
/**
* LIVE_DRAG_MODE
*/
public static int LIVE_DRAG_MODE = 0;
/**
* This method sets the UI used with the JDesktopPane.
*
* @param ui The UI to use with the JDesktopPane.
*/
public void setUI(DesktopPaneUI ui)
{
super.setUI(ui);
}
/**
* OUTLINE_DRAG_MODE
*/
public static int OUTLINE_DRAG_MODE = 1;
/**
* This method sets the drag mode to use with the JDesktopPane.
*
* @param mode The drag mode to use.
*
* @throws IllegalArgumentException If the drag mode given is not
* LIVE_DRAG_MODE or OUTLINE_DRAG_MODE.
*/
public void setDragMode(int mode)
{
if ((mode != LIVE_DRAG_MODE) && (mode != OUTLINE_DRAG_MODE))
throw new IllegalArgumentException("Drag mode not valid.");
/**
* uiClassID
*/
private static final String uiClassID = "DesktopPaneUI";
// FIXME: Unsupported mode.
if (mode == OUTLINE_DRAG_MODE)
throw new IllegalArgumentException("Outline drag modes are unsupported.");
dragMode = mode;
}
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* This method returns the drag mode used with the JDesktopPane.
*
* @return The drag mode used with the JDesktopPane.
*/
public int getDragMode()
{
return dragMode;
}
/**
* selectedFrame
*/
private transient JInternalFrame selectedFrame;
/**
* This method returns the DesktopManager used with the JDesktopPane.
*
* @return The DesktopManager to use with the JDesktopPane.
*/
public DesktopManager getDesktopManager()
{
return desktopManager;
}
/**
* desktopManager
*/
private transient DesktopManager desktopManager;
/**
* This method sets the DesktopManager to use with the JDesktopPane.
*
* @param manager The DesktopManager to use with the JDesktopPane.
*/
public void setDesktopManager(DesktopManager manager)
{
desktopManager = manager;
}
/**
* This method restores the UI used with the JDesktopPane to the default.
*/
public void updateUI()
{
setUI((DesktopPaneUI) UIManager.getUI(this));
invalidate();
}
/**
* dragMode
*/
private int dragMode;
/**
* This method returns a String identifier that allows the UIManager to know
* which class will act as JDesktopPane's UI.
*
* @return A String identifier for the UI class to use.
*/
public String getUIClassID()
{
return "DesktopPaneUI";
}
/**
* This method returns all JInternalFrames that are in the JDesktopPane.
*
* @return All JInternalFrames that are in the JDesktopPane.
*/
public JInternalFrame[] getAllFrames()
{
return getFramesFromComponents(getComponents());
}
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* This method returns the currently selected frame in the JDesktopPane.
*
* @return The currently selected frame in the JDesktopPane.
*/
public JInternalFrame getSelectedFrame()
{
return selectedFrame;
}
/**
* Constructor JDesktopPane
*/
public JDesktopPane() {
// TODO
} // JDesktopPane()
/**
* This method sets the selected frame in the JDesktopPane.
*
* @param frame The selected frame in the JDesktopPane.
*/
public void setSelectedFrame(JInternalFrame frame)
{
if (selectedFrame != null)
{
try
{
selectedFrame.setSelected(false);
}
catch (PropertyVetoException e)
{
}
}
selectedFrame = null;
try
{
if (frame != null)
frame.setSelected(true);
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
selectedFrame = frame;
}
catch (PropertyVetoException e)
{
}
}
/**
* writeObject
* @param stream TODO
* @exception IOException TODO
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
// TODO
} // writeObject()
/**
* This method returns all the JInternalFrames in the given layer.
*
* @param layer The layer to grab frames in.
*
* @return All JInternalFrames in the given layer.
*/
public JInternalFrame[] getAllFramesInLayer(int layer)
{
return getFramesFromComponents(getComponentsInLayer(layer));
}
/**
* getUI
* @returns DesktopPaneUI
*/
public DesktopPaneUI getUI() {
return (DesktopPaneUI) ui;
} // getUI()
/**
* This method always returns true to indicate that it is not transparent.
*
* @return true.
*/
public boolean isOpaque()
{
return true;
}
/**
* setUI
* @param ui TODO
*/
public void setUI(DesktopPaneUI ui) {
super.setUI(ui);
} // setUI()
/**
* This method returns a String that describes the JDesktopPane.
*
* @return A String that describes the JDesktopPane.
*/
protected String paramString()
{
return "JDesktopPane";
}
/**
* setDragMode
* @param mode TODO
*/
public void setDragMode(int mode) {
this.dragMode = mode;
// TODO
} // setDragMode()
/**
* This method returns all the JInternalFrames in the given Component array.
*
* @param components An array to search for JInternalFrames in.
*
* @return An array of JInternalFrames found in the Component array.
*/
private static JInternalFrame[] getFramesFromComponents(Component[] components)
{
int count = 0;
/**
* getDragMode
* @returns int
*/
public int getDragMode() {
return dragMode;
} // getDragMode()
for (int i = 0; i < components.length; i++)
if (components[i] instanceof JInternalFrame)
count++;
JInternalFrame[] value = new JInternalFrame[count];
for (int i = 0, j = 0; i < components.length && j != count; i++)
if (components[i] instanceof JInternalFrame)
value[j++] = (JInternalFrame) components[i];
return value;
}
/**
* getDesktopManager
* @returns DesktopManager
*/
public DesktopManager getDesktopManager() {
return desktopManager;
} // getDesktopManager()
/**
* getAccessibleContext
*
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJDesktopPane();
/**
* setDesktopManager
* @param manager TODO
*/
public void setDesktopManager(DesktopManager manager) {
this.desktopManager = manager;
// TODO
} // setDesktopManager()
/**
* updateUI
*/
public void updateUI() {
setUI((DesktopPaneUI) UIManager.get(this));
invalidate();
} // updateUI()
/**
* getUIClassID
* @returns String
*/
public String getUIClassID() {
return uiClassID;
} // getUIClassID()
/**
* getAllFrames
* @returns JInternalFrame[]
*/
public JInternalFrame[] getAllFrames() {
return null; // TODO
} // getAllFrames()
/**
* getSelectedFrame
* @returns JInternalFrame
*/
public JInternalFrame getSelectedFrame() {
return null; // TODO
} // getSelectedFrame()
/**
* setSelectedFrame
* @param frame TODO
*/
public void setSelectedFrame(JInternalFrame frame) {
// TODO
} // setSelectedFrame()
/**
* getAllFramesInLayer
* @param layer TODO
* @returns JInternalFrame[]
*/
public JInternalFrame[] getAllFramesInLayer(int layer) {
return null; // TODO
} // getAllFramesInLayer()
/**
* isOpaque
* @returns boolean
*/
public boolean isOpaque() {
return true;
} // isOpaque()
/**
* paramString
* @returns String
*/
protected String paramString() {
return null; // TODO
} // paramString()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJDesktopPane(this);
} // if
return accessibleContext;
} // getAccessibleContext()
} // JDesktopPane
return accessibleContext;
}
}

View file

@ -62,6 +62,7 @@ import javax.accessibility.AccessibleContext;
public class JDialog extends Dialog implements Accessible, WindowConstants,
RootPaneContainer
{
private static final long serialVersionUID = -864070866424508218L;
/** DOCUMENT ME! */
protected AccessibleContext accessibleContext;

View file

@ -1,4 +1,4 @@
/* JEditorPane.java --
/* JEditorPane.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,207 +35,280 @@ 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.Dimension;
import java.awt.event.KeyEvent;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.accessibility.AccessibleContext;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.EditorKit;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainEditorKit;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
public class JEditorPane extends JTextComponent
{
private static final long serialVersionUID = 3140472492599046285L;
URL page_url;
EditorKit kit;
String ctype = "text/plain";
boolean focus_root;
boolean manages_focus;
URL page_url;
EditorKit kit;
String ctype = "text/plain";
boolean focus_root;
boolean manages_focus;
public JEditorPane()
{
}
public JEditorPane(String url)
throws IOException
{
this();
setPage(url);
}
public JEditorPane(String type, String text)
{
ctype = text;
setText(text);
}
public JEditorPane(URL url)
throws IOException
{
setPage(url);
}
protected EditorKit createDefaultEditorKit()
{ return new PlainEditorKit(); }
static EditorKit createEditorKitForContentType(String type)
{ return new PlainEditorKit(); }
void fireHyperlinkUpdate(HyperlinkEvent e)
public JEditorPane()
{
}
public AccessibleContext getAccessibleContext()
{ return null; }
String getContentType()
{ return ctype; }
EditorKit getEditorKit()
{ return kit; }
static String getEditorKitClassNameForContentType(String type)
{ return "text/plain"; }
EditorKit getEditorKitForContentType(String type)
{ return kit; }
public Dimension getPreferredSize()
{
//Returns the preferred size for the JEditorPane.
return super.getPreferredSize();
}
public boolean getScrollableTracksViewportHeight()
{ return false; }
public boolean getScrollableTracksViewportWidth()
{ return false; }
URL getPage()
{ return page_url; }
protected InputStream getStream(URL page)
{
try {
return page.openStream();
} catch (Exception e) {
System.out.println("Hhmmm, failed to open stream: " + e);
}
return null;
}
public String getText()
{ return super.getText(); }
public String getUIClassID()
{ return "EditorPaneUI"; }
public boolean isFocusCycleRoot()
{ return focus_root; }
public boolean isManagingFocus()
{ return manages_focus; }
protected String paramString()
{ return "JEditorPane"; }
protected void processComponentKeyEvent(KeyEvent e)
{
//Overridden to handle processing of tab/shift tab.
}
protected void processKeyEvent(KeyEvent e)
{
//Make sure that TAB and Shift-TAB events get consumed, so that awt doesn't attempt focus traversal.
}
void read(InputStream in, Object desc)
{
//This method initializes from a stream.
}
static void registerEditorKitForContentType(String type, String classname)
{
//Establishes the default bindings of type to classname.
}
static void registerEditorKitForContentType(String type, String classname, ClassLoader loader)
{
//Establishes the default bindings of type to classname.
}
void replaceSelection(String content)
{
//Replaces the currently selected content with new content represented by the given string.
}
protected void scrollToReference(String reference)
{
//Scrolls the view to the given reference location (that is, the value returned by the UL.getRef method for the URL being displayed).
}
void setContentType(String type)
{
ctype = type;
invalidate();
repaint();
}
void setEditorKit(EditorKit kit)
{
this.kit = kit;
invalidate();
repaint();
}
void setEditorKitForContentType(String type, EditorKit k)
{
ctype = type;
setEditorKit(k);
}
void setPage(String url)
throws IOException
{
// Sets the current URL being displayed.
}
void setPage(URL page)
throws IOException
{
// Sets the current URL being displayed.
}
public void setText(String t)
{
super.setText(t);
}
public void addHyperlinkListener(HyperlinkListener listener)
public JEditorPane(String url) throws IOException
{
listenerList.add (HyperlinkListener.class, listener);
setPage(url);
}
public void removeHyperlinkListener (HyperlinkListener listener)
public JEditorPane(String type, String text)
{
listenerList.remove (HyperlinkListener.class, listener);
ctype = text;
setText(text);
}
public JEditorPane(URL url) throws IOException
{
setPage(url);
}
protected EditorKit createDefaultEditorKit()
{
return new PlainEditorKit();
}
protected static EditorKit createEditorKitForContentType(String type)
{
return new PlainEditorKit();
}
/**
* Sends a given <code>HyperlinkEvent</code> to all registered listeners.
*
* @param event the event to send
*/
public void fireHyperlinkUpdate(HyperlinkEvent event)
{
HyperlinkListener[] listeners = getHyperlinkListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].hyperlinkUpdate(event);
}
public AccessibleContext getAccessibleContext()
{
return null;
}
public String getContentType()
{
return ctype;
}
public EditorKit getEditorKit()
{
return kit;
}
public static String getEditorKitClassNameForContentType(String type)
{
return "text/plain";
}
public EditorKit getEditorKitForContentType(String type)
{
return kit;
}
/**
* Returns the preferred size for the JEditorPane.
*/
public Dimension getPreferredSize()
{
return super.getPreferredSize();
}
public boolean getScrollableTracksViewportHeight()
{
return false;
}
public boolean getScrollableTracksViewportWidth()
{
return false;
}
public URL getPage()
{
return page_url;
}
protected InputStream getStream(URL page)
{
try
{
return page.openStream();
}
catch (Exception e)
{
System.out.println("Hhmmm, failed to open stream: " + e);
}
return null;
}
public String getText()
{
return super.getText();
}
public String getUIClassID()
{
return "EditorPaneUI";
}
public boolean isFocusCycleRoot()
{
return focus_root;
}
public boolean isManagingFocus()
{
return manages_focus;
}
protected String paramString()
{
return "JEditorPane";
}
/**
* Overridden to handle processing of tab/shift tab.
*/
protected void processComponentKeyEvent(KeyEvent e)
{
}
/**
* Make sure that TAB and Shift-TAB events get consumed, so that awt doesn't attempt focus traversal.
*/
protected void processKeyEvent(KeyEvent e)
{
}
/**
* This method initializes from a stream.
*/
public void read(InputStream in, Object desc)
{
}
/**
* Establishes the default bindings of type to classname.
*/
public static void registerEditorKitForContentType(String type,
String classname)
{
}
/**
* Establishes the default bindings of type to classname.
*/
public static void registerEditorKitForContentType(String type,
String classname,
ClassLoader loader)
{
}
/**
* 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).
*/
protected void scrollToReference(String reference)
{
}
public void setContentType(String type)
{
ctype = type;
invalidate();
repaint();
}
public void setEditorKit(EditorKit kit)
{
this.kit = kit;
invalidate();
repaint();
}
public void setEditorKitForContentType(String type, EditorKit k)
{
ctype = type;
setEditorKit(k);
}
/**
* Sets the current URL being displayed.
*/
public void setPage(String url) throws IOException
{
}
/**
* Sets the current URL being displayed.
*/
public void setPage(URL page) throws IOException
{
}
public void setText(String t)
{
super.setText(t);
}
/**
* Add a <code>HyperlinkListener</code> object to this editor pane.
*
* @param listener the listener to add
*/
public void addHyperlinkListener(HyperlinkListener listener)
{
listenerList.add(HyperlinkListener.class, listener);
}
/**
* Removes a <code>HyperlinkListener</code> object to this editor pane.
*
* @param listener the listener to remove
*/
public void removeHyperlinkListener(HyperlinkListener listener)
{
listenerList.remove(HyperlinkListener.class, listener);
}
/**
* Returns all added <code>HyperlinkListener</code> objects.
*
* @return array of listeners
*
* @since 1.4
*/
public HyperlinkListener[] getHyperlinkListeners()
{
return (HyperlinkListener[]) getListeners (HyperlinkListener.class);
return (HyperlinkListener[]) getListeners(HyperlinkListener.class);
}
} // class JEditorPane
}

View file

@ -61,55 +61,30 @@ public class JFileChooser extends JComponent implements Accessible {
private static final long serialVersionUID = 3162921138695327837L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* AccessibleJFileChooser
*/
protected class AccessibleJFileChooser extends AccessibleJComponent
{
private static final long serialVersionUID = 8205148454060169244L;
/**
* AccessibleJFileChooser
*/
protected class AccessibleJFileChooser extends AccessibleJComponent {
/**
* Constructor AccessibleJFileChooser
* @param component TODO
*/
protected AccessibleJFileChooser()
{
}
private static final long serialVersionUID = 3318922050345221200L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJFileChooser
* @param component TODO
*/
protected AccessibleJFileChooser(JFileChooser component) {
super(component);
// TODO
} // AccessibleJFileChooser()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.FILE_CHOOSER;
} // getAccessibleRole()
} // AccessibleJFileChooser
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.FILE_CHOOSER;
}
}
/**
* uiClassID
@ -969,16 +944,15 @@ public class JFileChooser extends JComponent implements Accessible {
return null; // TODO
} // paramString()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJFileChooser(this);
} // if
return accessibleContext;
} // getAccessibleContext()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJFileChooser();
} // JFileChooser
return accessibleContext;
}
}

View file

@ -1,5 +1,5 @@
/* JFormattedTextField.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -52,7 +52,7 @@ import javax.swing.text.NavigationFilter;
*/
public class JFormattedTextField extends JTextField
{
private static final long serialVersionUID = 2889768923115424035L;
private static final long serialVersionUID = 5464657870110180632L;
public abstract static class AbstractFormatter implements Serializable
{

View file

@ -59,10 +59,23 @@ import javax.accessibility.AccessibleContext;
*/
public class JFrame extends Frame implements WindowConstants, RootPaneContainer
{
protected AccessibleContext accessibleContext;
private static final long serialVersionUID = -3362141868504252139L;
protected AccessibleContext accessibleContext;
private int close_action = HIDE_ON_CLOSE;
private static boolean defaultLookAndFeelDecorated = false;
private int close_action = HIDE_ON_CLOSE;
public static void setDefaultLookAndFeelDecorated(boolean d)
{
defaultLookAndFeelDecorated = d;
}
public static boolean isDefaultLookAndFeelDecorated()
{
return defaultLookAndFeelDecorated;
}
/***************************************************
*
@ -111,10 +124,10 @@ public class JFrame extends Frame implements WindowConstants, RootPaneContainer
return d;
}
JMenuBar getJMenuBar()
public JMenuBar getJMenuBar()
{ return getRootPane().getJMenuBar(); }
void setJMenuBar(JMenuBar menubar)
public void setJMenuBar(JMenuBar menubar)
{ getRootPane().setJMenuBar(menubar); }

File diff suppressed because it is too large Load diff

View file

@ -331,9 +331,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public Icon getDisabledIcon()
{
//FIXME: We should be gray-scaling the active icon and then returning it
if (disabledIcon == null && activeIcon instanceof ImageIcon)
setDisabledIcon(activeIcon);
disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) activeIcon).getImage()));
return disabledIcon;
}

View file

@ -91,7 +91,9 @@ import javax.accessibility.Accessible;
*/
public class JLayeredPane extends JComponent implements Accessible
{
public static String LAYER_PROPERTY = "LAYER_PROPERTY";
private static final long serialVersionUID = 5534920399324590459L;
public static final String LAYER_PROPERTY = "layeredContainerLayer";
public static Integer FRAME_CONTENT_LAYER = new Integer (-30000);
@ -104,7 +106,7 @@ public class JLayeredPane extends JComponent implements Accessible
TreeMap layers; // Layer Number (Integer) -> Layer Size (Integer)
Hashtable componentToLayer; // Component -> Layer Number (Integer)
JLayeredPane()
public JLayeredPane()
{
layers = new TreeMap ();
componentToLayer = new Hashtable ();
@ -492,6 +494,8 @@ public class JLayeredPane extends JComponent implements Accessible
decrLayer (layer);
componentToLayer.remove (c);
super.remove (index);
revalidate();
repaint();
}
/**

View file

@ -39,6 +39,7 @@ package javax.swing;
import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
@ -107,26 +108,26 @@ public class JList extends JComponent implements Accessible, Scrollable
{
private static final long serialVersionUID = 4406629526391098046L;
/**
* Constant value used in "layoutOrientation" property. This value means
* that cells are laid out in multiple columns "newspaper style",
* filling horizontally first, then vertically.
*/
public static int HORIZONTAL_WRAP = 1;
/**
* Constant value used in "layoutOrientation" property. This value means
* that cells are laid out in a single vertical column. This is the default.
*/
public static int VERTICAL = 2;
public static final int VERTICAL = 0;
/**
* Constant value used in "layoutOrientation" property. This value means
* that cells are laid out in multiple columns "newspaper style", filling
* vertically first, then horizontally.
*/
public static int VERTICAL_WRAP = 3;
public static final int VERTICAL_WRAP = 1;
/**
* Constant value used in "layoutOrientation" property. This value means
* that cells are laid out in multiple columns "newspaper style",
* filling horizontally first, then vertically.
*/
public static final int HORIZONTAL_WRAP = 2;
/** Fired in a PropertyChangeEvent when the "cellRenderer" property changes. */
public static final String CELL_RENDERER_PROPERTY_CHANGED = "cellRenderer";
@ -559,6 +560,52 @@ public class JList extends JComponent implements Accessible, Scrollable
return selectionModel.getMinSelectionIndex();
}
/**
* Returns <code>true</code> if the model's selection is empty, otherwise
* <code>false</code>.
*
* @return The return value of {@link ListSelectionModel#isSelectionEmpty}
*/
public boolean isSelectionEmpty()
{
return selectionModel.isSelectionEmpty();
}
/**
* Returns the list index of the upper left or upper right corner of the
* {@link #visibleRect} property, depending on the {@link
* #componentOrientation} property.
*
* @return The index of the first visible list cell, or <code>-1</code>
* if none is visible.
*/
public int getFirstVisibleIndex()
{
ComponentOrientation or = getComponentOrientation();
Rectangle r = getVisibleRect();
if (or == ComponentOrientation.RIGHT_TO_LEFT)
r.translate((int) r.getWidth(), 0);
return getUI().locationToIndex(this, r.getLocation());
}
/**
* Returns the list index of the lower right or lower left corner of the
* {@link #visibleRect} property, depending on the {@link
* #componentOrientation} property.
*
* @return The index of the first visible list cell, or <code>-1</code>
* if none is visible.
*/
public int getLastVisibleIndex()
{
ComponentOrientation or = getComponentOrientation();
Rectangle r = getVisibleRect();
r.translate(0, (int) r.getHeight());
if (or == ComponentOrientation.LEFT_TO_RIGHT)
r.translate((int) r.getWidth(), 0);
return getUI().locationToIndex(this, r.getLocation());
}
/**
* Returns the indices of values in the {@link #model} property which are
* selected.
@ -681,6 +728,44 @@ public class JList extends JComponent implements Accessible, Scrollable
firePropertyChange(SELECTION_FOREGROUND_PROPERTY_CHANGED, old, c);
}
/**
* Sets the selection to cover only the specified value, if it
* exists in the model.
*
* @param obj The object to select
* @param scroll Whether to scroll the list to make the newly selected
* value visible
*
* @see #ensureIndexIsVisible
*/
public void setSelectedValue(Object obj, boolean scroll)
{
for (int i = 0; i < model.getSize(); ++i)
{
if (model.getElementAt(i).equals(obj))
{
setSelectedIndex(i);
if (scroll)
ensureIndexIsVisible(i);
break;
}
}
}
/**
* Scrolls this list to make the specified cell visible. This
* only works if the list is contained within a viewport.
*
* @param i The list index to make visible
*
* @see JComponent#scrollRectToVisible
*/
public void ensureIndexIsVisible(int i)
{
scrollRectToVisible(getUI().getCellBounds(this, i, i));
}
/**
* Sets the {@link #model} property of the list to a new anonymous
* {@link AbstractListModel} subclass which accesses the provided Object

File diff suppressed because it is too large Load diff

View file

@ -66,12 +66,25 @@ import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
* JMenuBar
*/
public class JMenuBar extends JComponent implements Accessible, MenuElement
{
/** Fired in a PropertyChangeEvent when the "borderPainted" property changes. */
public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted";
/** Fired in a PropertyChangeEvent when the "model" changes. */
public static final String MODEL_CHANGED_PROPERTY = "model";
private static final long serialVersionUID = -8191026883931977036L;
/** JMenuBar's model. It keeps track of selected menu's index */
private transient SingleSelectionModel selectionModel;
private boolean paintBorder;
/* borderPainted property indicating if the menuBar's border will be painted*/
private boolean borderPainted;
/* margin between menu bar's border and its menues*/
private Insets margin;
/**
@ -80,16 +93,16 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
public JMenuBar()
{
selectionModel = new DefaultSingleSelectionModel();
paintBorder = true;
borderPainted = true;
updateUI();
}
/**
* DOCUMENT ME!
* Adds menu to the menu bar
*
* @param c DOCUMENT ME!
* @param c menu to add
*
* @return DOCUMENT ME!
* @return reference to the added menu
*/
public JMenu add(JMenu c)
{
@ -107,20 +120,15 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
super.addNotify();
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* DOCUMENT ME!
* Returns reference to this menu bar
*
* @return DOCUMENT ME!
* @return reference to this menu bar
*/
public Component getComponent()
{
@ -128,23 +136,26 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Returns component at the specified index.
*
* @param i DOCUMENT ME!
* @param i index of the component to get
*
* @return DOCUMENT ME!
* @return component at the specified index. Null is returned if
* component at the specified index doesn't exist.
* @deprecated Replaced by getComponent(int)
*/
public Component getComponentAtIndex(int i)
{
return getComponentAt(i);
return getComponent(i);
}
/**
* DOCUMENT ME!
* Returns index of the specified component
*
* @param c DOCUMENT ME!
* @param c Component to search for
*
* @return DOCUMENT ME!
* @return index of the specified component. -1 is returned if
* specified component doesnt' exist in the menu bar.
*/
public int getComponentIndex(Component c)
{
@ -175,9 +186,9 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Returns margin betweeen menu bar's border and its menues
*
* @return DOCUMENT ME!
* @return margin between menu bar's border and its menues
*/
public Insets getMargin()
{
@ -188,11 +199,13 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Return menu at the specified index. If component at the
* specified index is not a menu, then null is returned.
*
* @param index DOCUMENT ME!
* @param index index to look for the menu
*
* @return DOCUMENT ME!
* @return menu at specified index, or null if menu doesn't exist
* at the specified index.
*/
public JMenu getMenu(int index)
{
@ -213,9 +226,9 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Returns selection model for this menu bar.
*
* @return DOCUMENT ME!
* @return selection mdoel for this menu bar.
*/
public SingleSelectionModel getSelectionModel()
{
@ -223,9 +236,10 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Method of MenuElement interface. It returns subcomponents
* of the menu bar, which are all the menues that it contains.
*
* @return DOCUMENT ME!
* @return MenuElement[] array containing menues in this menu bar
*/
public MenuElement[] getSubElements()
{
@ -238,19 +252,21 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
* Set the "UI" property of the menu bar, which is a look and feel class
* responsible for handling the menuBar's input events and painting it.
*
* @return The current "UI" property
*/
public MenuBarUI getUI()
{
return (MenuBarUI) ui;
}
/**
* DOCUMENT ME!
* This method returns a name to identify which look and feel class will be
* the UI delegate for the menu bar.
*
* @return DOCUMENT ME!
* @return The Look and Feel classID. "MenuItemUI"
*/
public String getUIClassID()
{
@ -258,39 +274,31 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Returns true if menu bar paints its border and false otherwise
*
* @return DOCUMENT ME!
* @return true if menu bar paints its border and false otherwise
*/
public boolean isBorderPainted()
{
return paintBorder;
return borderPainted;
}
/**
* DOCUMENT ME!
* Returns true if some menu in menu bar is selected.
*
* @return DOCUMENT ME!
*/
public boolean isManagingFocus()
{
return true;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
* @return true if some menu in menu bar is selected and false otherwise
*/
public boolean isSelected()
{
return false;
return selectionModel.isSelected();
}
/**
* DOCUMENT ME!
* This method does nothing by default. This method is need for the
* MenuElement interface to be implemented.
*
* @param isIncluded DOCUMENT ME!
* @param isIncluded true if menuBar is included in the selection
* and false otherwise
*/
public void menuSelectionChanged(boolean isIncluded)
{
@ -298,13 +306,14 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Paints border of the menu bar, if its borderPainted property is set to
* true.
*
* @param g DOCUMENT ME!
* @param g The graphics context with which to paint the border
*/
protected void paintBorder(Graphics g)
{
if (paintBorder)
if (borderPainted)
getBorder().paintBorder(this, g, 0, 0, getSize(null).width,
getSize(null).height);
}
@ -361,7 +370,14 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
*/
public void setBorderPainted(boolean b)
{
paintBorder = b;
boolean old = borderPainted;
borderPainted = b;
if (b != old)
{
firePropertyChange(BORDER_PAINTED_CHANGED_PROPERTY, old, b);
revalidate();
repaint();
}
}
/**
@ -384,27 +400,42 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Changes menu bar's selection to the specifies menu.
* This method updates selected index of menu bar's model,
* which results in a model firing change event.
*
* @param sel DOCUMENT ME!
* @param sel menu to select
*/
public void setSelected(Component sel)
{
int index = getComponentIndex(sel);
selectionModel.setSelectedIndex(index);
}
/**
* DOCUMENT ME!
* Sets menuBar's selection model to the one specified
*
* @param model DOCUMENT ME!
* @param model SingleSelectionModel that needs to be set for this menu bar
*/
public void setSelectionModel(SingleSelectionModel model)
{
selectionModel = model;
if (selectionModel != model)
{
SingleSelectionModel oldModel = selectionModel;
selectionModel = model;
firePropertyChange(MODEL_CHANGED_PROPERTY, oldModel,
this.selectionModel);
}
}
/**
* DOCUMENT ME!
* Set the "UI" property of the menu bar, which is a look and feel class
* responsible for handling menuBar's input events and painting it.
*
* @param ui DOCUMENT ME!
* @param ui The new "UI" property
*/
public void setUI(MenuBarUI ui)
{
@ -412,7 +443,8 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
}
/**
* DOCUMENT ME!
* Set the "UI" property to a class constructed, via the {@link
* UIManager}, from the current look and feel.
*/
public void updateUI()
{

View file

@ -61,12 +61,26 @@ import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
* <p>
* JMenuItem represents element in the menu. It inherits most of
* its functionality from AbstractButton, however its behavior somewhat
* varies from it. JMenuItem fire different kinds of events.
* PropertyChangeEvents are fired when menuItems properties are modified;
* ChangeEvents are fired when menuItem's state changes and actionEvents are
* fired when menu item is selected. In addition to this events menuItem also
* fire MenuDragMouseEvent and MenuKeyEvents when mouse is dragged over
* the menu item or associated key with menu item is invoked respectively.
* </p>
*/
public class JMenuItem extends AbstractButton implements Accessible,
MenuElement
{
private static final long serialVersionUID = -1681004643499461044L;
/** name for the UI delegate for this menuItem. */
private static final String uiClassID = "MenuItemUI";
/** Combination of keyboard keys that can be used to activate this menu item */
private KeyStroke accelerator;
/**
@ -74,44 +88,48 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem()
{
this(null, null);
super(null, null);
}
/**
* Creates a new JMenuItem object.
* Creates a new JMenuItem with the given icon.
*
* @param icon DOCUMENT ME!
* @param icon Icon that will be displayed on the menu item
*/
public JMenuItem(Icon icon)
{
this(null, icon);
// FIXME: The requestedFocusEnabled property should
// be set to false, when only icon is set for menu item.
super(null, icon);
}
/**
* Creates a new JMenuItem object.
* Creates a new JMenuItem with the given label.
*
* @param text DOCUMENT ME!
* @param text label for the menu item
*/
public JMenuItem(String text)
{
this(text, null);
super(text, null);
}
/**
* Creates a new JMenuItem object.
* Creates a new JMenuItem associated with the specified action.
*
* @param action DOCUMENT ME!
* @param action action for this menu item
*/
public JMenuItem(Action action)
{
// TODO
super(null, null);
super.setAction(action);
}
/**
* Creates a new JMenuItem object.
* Creates a new JMenuItem with specified text and icon.
* Text is displayed to the left of icon by default.
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param text label for this menu item
* @param icon icon that will be displayed on this menu item
*/
public JMenuItem(String text, Icon icon)
{
@ -121,8 +139,10 @@ public class JMenuItem extends AbstractButton implements Accessible,
/**
* Creates a new JMenuItem object.
*
* @param text DOCUMENT ME!
* @param mnemonic DOCUMENT ME!
* @param text label for this menu item
* @param mnemonic - Single key that can be used with a
* look-and-feel meta key to activate this menu item. However
* menu item should be visible on the screen when mnemonic is used.
*/
public JMenuItem(String text, int mnemonic)
{
@ -130,13 +150,17 @@ public class JMenuItem extends AbstractButton implements Accessible,
setMnemonic(mnemonic);
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* DOCUMENT ME!
*
* @param stream DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
* @throws ClassNotFoundException DOCUMENT ME!
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException
{
// TODO
}
/**
@ -148,24 +172,31 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
private void writeObject(ObjectOutputStream stream) throws IOException
{
// TODO
}
/**
* DOCUMENT ME!
* Initializes this menu item
*
* @param text DOCUMENT ME!
* @param icon DOCUMENT ME!
* @param text label for this menu item
* @param icon icon to be displayed for this menu item
*/
protected void init(String text, Icon icon)
{
// TODO
super.init(text, icon);
// 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;
}
/**
* DOCUMENT ME!
* Set the "UI" property of the menu item, which is a look and feel class
* responsible for handling menuItem's input events and painting it.
*
* @param ui DOCUMENT ME!
* @param ui The new "UI" property
*/
public void setUI(MenuItemUI ui)
{
@ -173,7 +204,8 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* This method sets this menuItem's UI to the UIManager's default for the
* current look and feel.
*/
public void updateUI()
{
@ -183,9 +215,10 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* 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. "MenuItemUI"
*/
public String getUIClassID()
{
@ -193,9 +226,10 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Returns true if button's model is armed and false otherwise. The
* button model is armed if menu item has focus or it is selected.
*
* @return $returnType$ DOCUMENT ME!
* @return $boolean$ true if button's model is armed and false otherwise
*/
public boolean isArmed()
{
@ -203,7 +237,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Sets menuItem's "ARMED" property
*
* @param armed DOCUMENT ME!
*/
@ -213,19 +247,20 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Enable or disable menu item. When menu item is disabled,
* its text and icon are grayed out if they exist.
*
* @param enabled DOCUMENT ME!
* @param enabled if true enable menu item, and disable otherwise.
*/
public void setEnabled(boolean enabled)
{
setEnabled(enabled);
super.setEnabled(enabled);
}
/**
* DOCUMENT ME!
* Return accelerator for this menu item.
*
* @return $returnType$ DOCUMENT ME!
* @return $KeyStroke$ accelerator for this menu item.
*/
public KeyStroke getAccelerator()
{
@ -233,9 +268,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Sets accelerator for this menu item.
*
* @param keystroke DOCUMENT ME!
* @param keystroke accelerator for this menu item.
*/
public void setAccelerator(KeyStroke keystroke)
{
@ -243,9 +278,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Configures menu items' properties from properties of the specified action.
* This method overrides configurePropertiesFromAction from AbstractButton
* to also set accelerator property.
*
* @param action DOCUMENT ME!
* @param action action to configure properties from
*/
protected void configurePropertiesFromAction(Action action)
{
@ -258,11 +295,13 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Creates PropertyChangeListener to listen for the changes in action
* properties.
*
* @param action DOCUMENT ME!
* @param action action to listen to for property changes
*
* @return $returnType$ DOCUMENT ME!
* @return $PropertyChangeListener$ Listener that listens to changes in
* action properties.
*/
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
{
@ -277,11 +316,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Process mouse events forwarded from MenuSelectionManager.
*
* @param event DOCUMENT ME!
* @param path DOCUMENT ME!
* @param manager DOCUMENT ME!
* @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 processMouseEvent(MouseEvent event, MenuElement[] path,
MenuSelectionManager manager)
@ -289,22 +328,15 @@ public class JMenuItem extends AbstractButton implements Accessible,
switch (event.getID())
{
case MouseEvent.MOUSE_CLICKED:
doClick();
break;
case MouseEvent.MOUSE_ENTERED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(true);
if (model.isPressed()
&& (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
model.setArmed(true);
else
model.setArmed(false);
}
break;
case MouseEvent.MOUSE_EXITED:
@ -314,7 +346,6 @@ public class JMenuItem extends AbstractButton implements Accessible,
ButtonModel model = item.getModel();
if (item.isRolloverEnabled())
model.setRollover(false);
model.setArmed(false);
}
break;
case MouseEvent.MOUSE_PRESSED:
@ -328,17 +359,6 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
break;
case MouseEvent.MOUSE_RELEASED:
if (event.getSource() instanceof JMenuItem)
{
JMenuItem item = (JMenuItem) event.getSource();
ButtonModel model = item.getModel();
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
model.setPressed(false);
model.setArmed(false);
manager.clearSelectedPath();
}
}
break;
case MouseEvent.MOUSE_MOVED:
break;
@ -372,9 +392,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* This method fires MenuDragMouseEvents to registered listeners.
* Different types of MenuDragMouseEvents are fired depending
* on the observed mouse event.
*
* @param event DOCUMENT ME!
* @param event Mouse
*/
public void processMenuDragMouseEvent(MenuDragMouseEvent event)
{
@ -396,7 +418,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* This method fires MenuKeyEvent to registered listeners.
* Different types of MenuKeyEvents are fired depending
* on the observed key event.
*
* @param event DOCUMENT ME!
*/
@ -406,9 +430,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that mouse entered menuItem while it was dragged
*/
protected void fireMenuDragMouseEntered(MenuDragMouseEvent event)
{
@ -419,9 +443,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that mouse has exited menu item, while it was dragged
*/
protected void fireMenuDragMouseExited(MenuDragMouseEvent event)
{
@ -432,9 +456,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Fires MenuDragMouseEvent to all of the menuItem's MouseInputListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that mouse is being dragged over the menuItem
*/
protected void fireMenuDragMouseDragged(MenuDragMouseEvent event)
{
@ -445,9 +469,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* This method fires a MenuDragMouseEvent to all the MenuItem's MouseInputListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that mouse was released while it was dragged over the menuItem
*/
protected void fireMenuDragMouseReleased(MenuDragMouseEvent event)
{
@ -458,50 +482,70 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that key associated with this menu was pressed
*/
protected void fireMenuKeyPressed(MenuKeyEvent event)
{
// TODO
EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);
for (int i = 0; i < ll.length; i++)
((MenuKeyListener) ll[i]).menuKeyPressed(event);
}
/**
* DOCUMENT ME!
* This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that key associated with this menu was released
*/
protected void fireMenuKeyReleased(MenuKeyEvent event)
{
// TODO
EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);
for (int i = 0; i < ll.length; i++)
((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
/**
* DOCUMENT ME!
* This method fires a MenuKeyEvent to all the MenuItem's MenuKeyListeners.
*
* @param event DOCUMENT ME!
* @param event The event signifying that key associated with this menu was typed.
* The key is typed when it was pressed and then released
*/
protected void fireMenuKeyTyped(MenuKeyEvent event)
{
// TODO
EventListener[] ll = listenerList.getListeners(MenuKeyListener.class);
for (int i = 0; i < ll.length; i++)
((MenuKeyListener) ll[i]).menuKeyTyped(event);
}
/**
* DOCUMENT ME!
* Method of the MenuElement interface.
* This method is invoked by MenuSelectionManager when selection of
* this menu item has changed. If this menu item was selected then
* arm it's model, and disarm the model otherwise. The menu item
* is considered to be selected, and thus highlighted when its model
* is armed.
*
* @param changed DOCUMENT ME!
* @param changed indicates selection status of this menu item. If changed is
* true then menu item is selected and deselected otherwise.
*/
public void menuSelectionChanged(boolean changed)
{
if (changed)
model.setArmed(true);
else
model.setArmed(false);
}
/**
* DOCUMENT ME!
* Method of the MenuElement interface.
*
* @return $returnType$ DOCUMENT ME!
* @return $MenuElement[]$ Returns array of sub-components for this menu
* item. By default menuItem doesn't have any subcomponents and so
* empty array is returned instead.
*/
public MenuElement[] getSubElements()
{
@ -509,9 +553,10 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Returns reference to the component that will paint this menu item.
*
* @return $returnType$ DOCUMENT ME!
* @return $Component$ Component that will paint this menu item.
* Simply returns reference to this menu item.
*/
public Component getComponent()
{
@ -519,9 +564,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Adds a MenuDragMouseListener to this menu item. When mouse
* is dragged over the menu item the MenuDragMouseEvents will be
* fired, and these listeners will be called.
*
* @param listener DOCUMENT ME!
* @param listener The new listener to add
*/
public void addMenuDragMouseListener(MenuDragMouseListener listener)
{
@ -529,9 +576,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Removes a MenuDragMouseListener from the menuItem's listener list.
*
* @param listener DOCUMENT ME!
* @param listener The listener to remove
*/
public void removeMenuDragMouseListener(MenuDragMouseListener listener)
{
@ -539,9 +586,10 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Adds an MenuKeyListener to this menu item. This listener will be
* invoked when MenuKeyEvents will be fired by this menu item.
*
* @param listener DOCUMENT ME!
* @param listener The new listener to add
*/
public void addMenuKeyListener(MenuKeyListener listener)
{
@ -549,9 +597,9 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* Removes an MenuKeyListener from the menuItem's listener list.
*
* @param listener DOCUMENT ME!
* @param listener The listener to remove
*/
public void removeMenuKeyListener(MenuKeyListener listener)
{
@ -559,9 +607,10 @@ public class JMenuItem extends AbstractButton implements Accessible,
}
/**
* DOCUMENT ME!
* A string that describes this JMenuItem. Normally only used
* for debugging.
*
* @return $returnType$ DOCUMENT ME!
* @return A string describing this JMenuItem
*/
protected String paramString()
{
@ -571,49 +620,33 @@ public class JMenuItem extends AbstractButton implements Accessible,
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJMenuItem(this);
accessibleContext = new AccessibleJMenuItem();
return accessibleContext;
}
/**
* DOCUMENT ME!
*/
protected class AccessibleJMenuItem extends AccessibleAbstractButton
implements ChangeListener
{
private static final long serialVersionUID = 6748924232082076534L;
/**
* Creates a new AccessibleJMenuItem object.
*
* @param component DOCUMENT ME!
*/
AccessibleJMenuItem(JMenuItem component)
AccessibleJMenuItem()
{
super(component);
// TODO
//super(component);
}
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
public void stateChanged(ChangeEvent event)
{
// TODO
}
/**
* DOCUMENT ME!
*
* @return $returnType$ DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.MENU_ITEM;

View file

@ -60,12 +60,13 @@ public class JOptionPane extends JComponent implements Accessible
*/
protected class AccessibleJOptionPane extends JComponent.AccessibleJComponent
{
private static final long serialVersionUID = 686071432213084821L;
/**
* Creates a new AccessibleJOptionPane object.
*/
protected AccessibleJOptionPane()
{
super(JOptionPane.this);
}
/**
@ -79,6 +80,8 @@ public class JOptionPane extends JComponent implements Accessible
}
}
private static final long serialVersionUID = 5231143276678566796L;
/** The value returned when cancel option is selected. */
public static final int CANCEL_OPTION = 2;
@ -418,21 +421,7 @@ public class JOptionPane extends JComponent implements Accessible
*/
public static JDesktopPane getDesktopPaneForComponent(Component parentComponent)
{
if (parentComponent == null)
return null;
if (parentComponent instanceof JDesktopPane)
return (JDesktopPane) parentComponent;
JDesktopPane parent = null;
while (parentComponent.getParent() != null)
{
parentComponent = parentComponent.getParent();
if (parentComponent instanceof JDesktopPane)
{
parent = (JDesktopPane) parentComponent;
break;
}
}
return parent;
return (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class, parentComponent);
}
/**
@ -445,21 +434,7 @@ public class JOptionPane extends JComponent implements Accessible
*/
public static Frame getFrameForComponent(Component parentComponent)
{
if (parentComponent == null)
return null;
if (parentComponent instanceof Frame)
return (Frame) parentComponent;
Frame parent = null;
while (parentComponent.getParent() != null)
{
parentComponent = parentComponent.getParent();
if (parentComponent instanceof Frame)
{
parent = (Frame) parentComponent;
break;
}
}
return parent;
return (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parentComponent);
}
/**

View file

@ -49,55 +49,31 @@ import javax.swing.text.Document;
* @author Andrew Selkirk
* @version 1.0
*/
public class JPasswordField extends JTextField {
public class JPasswordField extends JTextField
{
/**
* AccessibleJPasswordField
*/
protected class AccessibleJPasswordField extends AccessibleJTextField
{
private static final long serialVersionUID = -8477039424200681086L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJPasswordField
*/
protected AccessibleJPasswordField()
{
}
/**
* AccessibleJPasswordField
*/
protected class AccessibleJPasswordField extends AccessibleJTextField {
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJPasswordField
* @param component TODO
*/
protected AccessibleJPasswordField(JPasswordField component) {
super(component);
// TODO
} // AccessibleJPasswordField()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PASSWORD_TEXT;
} // getAccessibleRole()
} // AccessibleJPasswordField
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleRole
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.PASSWORD_TEXT;
}
}
/**
* uiClassID
@ -254,16 +230,15 @@ public class JPasswordField extends JTextField {
return null; // TODO
} // paramString()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJPasswordField(this);
} // if
return accessibleContext;
} // getAccessibleContext()
/**
* getAccessibleContext
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJPasswordField();
} // JPasswordField
return accessibleContext;
}
}

File diff suppressed because it is too large Load diff

View file

@ -85,14 +85,15 @@ public class JProgressBar extends JComponent implements SwingConstants,
protected class AccessibleJProgressBar extends AccessibleJComponent
implements AccessibleValue
{
private static final long serialVersionUID = -2938130009392721813L;
/**
* Constructor AccessibleJProgressBar
*
* @param component TODO
*/
protected AccessibleJProgressBar(JProgressBar component)
protected AccessibleJProgressBar()
{
super(component);
}
/**
@ -168,6 +169,8 @@ public class JProgressBar extends JComponent implements SwingConstants,
}
}
private static final long serialVersionUID = 1980046021813598781L;
/** Fired in a PropertyChangeEvent when the "borderPainted" property changes. */
public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted";
@ -661,7 +664,8 @@ public class JProgressBar extends JComponent implements SwingConstants,
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJProgressBar(this);
accessibleContext = new AccessibleJProgressBar();
return accessibleContext;
}
}

View file

@ -1,5 +1,5 @@
/* JRadioButton.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -42,6 +42,8 @@ import javax.accessibility.AccessibleContext;
public class JRadioButton extends JToggleButton
{
private static final long serialVersionUID = 7751949583255506856L;
public JRadioButton()
{
this(null, null);

View file

@ -49,6 +49,8 @@ import javax.accessibility.AccessibleRole;
*/
public class JRadioButtonMenuItem extends JMenuItem implements Accessible
{
private static final long serialVersionUID = 8482658191548521743L;
private static final String uiClassID = "RadioButtonMenuItemUI";
/**
@ -185,7 +187,7 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJRadioButtonMenuItem(this);
accessibleContext = new AccessibleJRadioButtonMenuItem();
return accessibleContext;
}
@ -195,16 +197,13 @@ public class JRadioButtonMenuItem extends JMenuItem implements Accessible
*/
protected class AccessibleJRadioButtonMenuItem extends AccessibleJMenuItem
{
private static final long serialVersionUID = 4381471510145292179L;
/**
* Creates a new AccessibleJRadioButtonMenuItem object.
*
* @param component DOCUMENT ME!
*/
protected AccessibleJRadioButtonMenuItem(JRadioButtonMenuItem component)
protected AccessibleJRadioButtonMenuItem()
{
super(component);
// TODO
}
/**

View file

@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package javax.swing;
import java.awt.BorderLayout;
@ -44,282 +43,296 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.LayoutManager2;
import java.io.Serializable;
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()
* 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())
* It is implemented by several 'layers' (pane() should be read as plane())
* each on top of the others
* where you can add components to.
* where you can add components to.
* (getContentPane(), getGlassPane(), getLayeredPane())
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JRootPane extends JComponent
{
// The class used to obtain the accessible role for this object.
static protected class AccessibleJRootPane
// The class used to obtain the accessible role for this object.
protected static class AccessibleJRootPane
{
private static final long serialVersionUID = 1082432482784468088L;
protected AccessibleJRootPane()
{
}
// Custom Layout Manager for JRootPane. It positions contentPane and
// menuBar withing its layeredPane.
protected class RootLayout extends Object implements LayoutManager2
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.ROOT_PANE;
}
}
// Custom Layout Manager for JRootPane. It positions contentPane and
// menuBar withing its layeredPane.
protected class RootLayout implements LayoutManager2, Serializable
{
private static final long serialVersionUID = -4100116998559815027L;
protected RootLayout()
{
public void addLayoutComponent(Component comp, Object constraints)
{
}
public void addLayoutComponent(String name, Component comp)
{
}
public float getLayoutAlignmentX(Container target)
{
return target.getAlignmentX();
}
public float getLayoutAlignmentY(Container target)
{
return target.getAlignmentY();
}
public void invalidateLayout(Container target)
{
}
public void layoutContainer(Container c)
{
Dimension menuBarSize;
Dimension containerSize = c.getSize(null);
Dimension contentPaneSize = contentPane.getPreferredSize();
/*
if size of top-level window wasn't set then just set
contentPane and menuBar to its preferred sizes.
Otherwise, if the size of top-level window was specified then
set menuBar to its preferred size and make content pane
to fit into the remaining space
+-------------------------------+
| JLayeredPane |
| +--------------------------+ |
| | menuBar | |
| +--------------------------+ |
| +--------------------------+ |
| |contentPane | |
| | | |
| | | |
| | | |
| +--------------------------+ |
+-------------------------------+
*/
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
contentPane.setBounds(0, menuBarSize.height, maxWidth,
contentPaneSize.height);
layeredPane.setSize(maxWidth,
menuBarSize.height + contentPaneSize.height);
}
else
{
contentPane.setBounds(0, 0, contentPaneSize.width,
contentPaneSize.height);
layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
}
}
else
{
if (menuBar != null)
{
menuBarSize = menuBar.getPreferredSize();
if (menuBarSize.height > containerSize.height)
menuBarSize.height = containerSize.height;
menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
int remainingHeight = containerSize.height - menuBarSize.height;
contentPane.setBounds(0, menuBarSize.height,
containerSize.width,
(containerSize.height - menuBarSize.height));
}
else
contentPane.setBounds(0, 0, containerSize.width,
containerSize.height);
layeredPane.setSize(containerSize.width, containerSize.height);
}
}
public Dimension maximumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension minimumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension preferredLayoutSize(Container c)
{
Dimension menuBarSize;
Dimension prefSize;
Dimension containerSize = c.getSize();
Dimension contentPaneSize = contentPane.getPreferredSize();
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
prefSize = new Dimension(maxWidth,
contentPaneSize.height
+ menuBarSize.height);
}
else
prefSize = contentPaneSize;
}
else
prefSize = c.getSize();
return prefSize;
}
public void removeLayoutComponent(Component comp)
{
}
}
protected Component glassPane;
protected JLayeredPane layeredPane;
protected JMenuBar menuBar;
protected Container contentPane;
void setJMenuBar(JMenuBar m)
{
menuBar = m;
getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
public void addLayoutComponent(Component comp, Object constraints)
{
}
JMenuBar getJMenuBar()
{ return menuBar; }
public void addLayoutComponent(String name, Component comp)
{
}
public float getLayoutAlignmentX(Container target)
{
return target.getAlignmentX();
}
public float getLayoutAlignmentY(Container target)
{
return target.getAlignmentY();
}
public void invalidateLayout(Container target)
{
}
public void layoutContainer(Container c)
{
Dimension menuBarSize;
Dimension containerSize = c.getSize(null);
Dimension contentPaneSize = contentPane.getPreferredSize();
/*
if size of top-level window wasn't set then just set
contentPane and menuBar to its preferred sizes.
Otherwise, if the size of top-level window was specified then
set menuBar to its preferred size and make content pane
to fit into the remaining space
+-------------------------------+
| JLayeredPane |
| +--------------------------+ |
| | menuBar | |
| +--------------------------+ |
| +--------------------------+ |
| |contentPane | |
| | | |
| | | |
| | | |
| +--------------------------+ |
+-------------------------------+
*/
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
menuBar.setBounds(0, 0, maxWidth, menuBarSize.height);
contentPane.setBounds(0, menuBarSize.height, maxWidth,
contentPaneSize.height);
layeredPane.setSize(maxWidth,
menuBarSize.height + contentPaneSize.height);
}
else
{
contentPane.setBounds(0, 0, contentPaneSize.width,
contentPaneSize.height);
layeredPane.setSize(contentPaneSize.width, contentPaneSize.height);
}
}
else
{
if (menuBar != null)
{
menuBarSize = menuBar.getPreferredSize();
if (menuBarSize.height > containerSize.height)
menuBarSize.height = containerSize.height;
menuBar.setBounds(0, 0, containerSize.width, menuBarSize.height);
int remainingHeight = containerSize.height - menuBarSize.height;
contentPane.setBounds(0, menuBarSize.height,
containerSize.width,
(containerSize.height - menuBarSize.height));
}
else
contentPane.setBounds(0, 0, containerSize.width,
containerSize.height);
layeredPane.setSize(containerSize.width, containerSize.height);
}
}
public Dimension maximumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension minimumLayoutSize(Container target)
{
return preferredLayoutSize(target);
}
public Dimension preferredLayoutSize(Container c)
{
Dimension menuBarSize;
Dimension prefSize;
Dimension containerSize = c.getSize();
Dimension contentPaneSize = contentPane.getPreferredSize();
if (containerSize.width == 0 && containerSize.height == 0)
{
if (menuBar != null)
{
int maxWidth;
menuBarSize = menuBar.getPreferredSize();
maxWidth = Math.max(menuBarSize.width, contentPaneSize.width);
prefSize =
new Dimension(maxWidth,
contentPaneSize.height + menuBarSize.height);
}
else
prefSize = contentPaneSize;
}
else
prefSize = c.getSize();
return prefSize;
}
public void removeLayoutComponent(Component comp)
{
}
}
protected Component glassPane;
protected JLayeredPane layeredPane;
protected JMenuBar menuBar;
protected Container contentPane;
public void setJMenuBar(JMenuBar m)
{
menuBar = m;
getLayeredPane().add(menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
}
public JMenuBar getJMenuBar()
{
return menuBar;
}
public boolean isValidateRoot()
{
return true;
}
public Container getContentPane()
{
if (contentPane == null)
{
setContentPane(createContentPane());
}
return contentPane;
}
public Container getContentPane()
{
if (contentPane == null)
setContentPane(createContentPane());
return contentPane;
}
public void setContentPane(Container p)
{
contentPane = p;
getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
}
public void setContentPane(Container p)
{
contentPane = p;
getLayeredPane().add(contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
}
protected void addImpl(Component comp,
Object constraints,
int index)
{
super.addImpl(comp, constraints, index);
}
protected void addImpl(Component comp, Object constraints, int index)
{
super.addImpl(comp, constraints, index);
}
public Component getGlassPane()
{
if (glassPane == null)
setGlassPane(createGlassPane());
return glassPane;
}
public Component getGlassPane()
{
if (glassPane == null)
setGlassPane(createGlassPane());
return glassPane;
}
public void setGlassPane(Component f)
{
if (glassPane != null)
remove(glassPane);
public void setGlassPane(Component f)
{
if (glassPane != null)
remove(glassPane);
glassPane = f;
glassPane = f;
glassPane.setVisible(false);
add(glassPane, 0);
}
glassPane.setVisible(false);
add(glassPane, 0);
}
public JLayeredPane getLayeredPane()
{
if (layeredPane == null)
setLayeredPane(createLayeredPane());
return layeredPane;
}
public void setLayeredPane(JLayeredPane f)
{
if (layeredPane != null)
remove(layeredPane);
layeredPane = f;
add(f, -1);
}
public JLayeredPane getLayeredPane()
{
if (layeredPane == null)
setLayeredPane(createLayeredPane());
return layeredPane;
}
JRootPane()
{
setLayout(createRootLayout());
getGlassPane();
getLayeredPane();
getContentPane();
setDoubleBuffered(true);
updateUI();
}
public void setLayeredPane(JLayeredPane f)
{
if (layeredPane != null)
remove(layeredPane);
protected LayoutManager createRootLayout() {
return new RootLayout();
}
layeredPane = f;
add(f, -1);
}
JComponent createContentPane()
{
JPanel p = new JPanel();
p.setName(this.getName()+".contentPane");
p.setLayout(new BorderLayout());
return p;
}
public JRootPane()
{
setLayout(createRootLayout());
getGlassPane();
getLayeredPane();
getContentPane();
setDoubleBuffered(true);
updateUI();
}
Component createGlassPane()
{
JPanel p = new JPanel();
p.setName(this.getName()+".glassPane");
p.setLayout(new BorderLayout());
p.setVisible(false);
return p;
}
protected LayoutManager createRootLayout()
{
return new RootLayout();
}
JLayeredPane createLayeredPane()
{
JLayeredPane l = new JLayeredPane();
l.setLayout(null);
return l;
}
protected JComponent createContentPane()
{
JPanel p = new JPanel();
p.setName(this.getName() + ".contentPane");
p.setLayout(new BorderLayout());
return p;
}
protected Component createGlassPane()
{
JPanel p = new JPanel();
p.setName(this.getName() + ".glassPane");
p.setLayout(new BorderLayout());
p.setVisible(false);
return p;
}
protected JLayeredPane createLayeredPane()
{
JLayeredPane l = new JLayeredPane();
l.setLayout(null);
return l;
}
public RootPaneUI getUI()
{

View file

@ -67,14 +67,16 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
protected class AccessibleJScrollBar extends JComponent.AccessibleJComponent
implements AccessibleValue
{
private static final long serialVersionUID = -7758162392045586663L;
/**
* Creates a new AccessibleJSlider object.
*
* @param value0 DOCUMENT ME!
*/
protected AccessibleJScrollBar(JScrollBar value0)
protected AccessibleJScrollBar()
{
super(value0);
super();
}
/**
@ -150,6 +152,8 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
}
}
private static final long serialVersionUID = -8195169869225066566L;
/** Fired in a PropertyChangeEvent when the "blockIncrement" changes. */
public static final String BLOCK_INCREMENT_CHANGED_PROPERTY = "blockIncrement";
@ -725,7 +729,7 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJScrollBar(this);
accessibleContext = new AccessibleJScrollBar();
return accessibleContext;
}
}

View file

@ -79,20 +79,23 @@ public class JScrollPane
extends JComponent
implements Accessible, ScrollPaneConstants
{
JViewport columnHeader;
JViewport rowHeader;
private static final long serialVersionUID = 5203525440012340014L;
protected JViewport columnHeader;
protected JViewport rowHeader;
Component lowerLeft;
Component lowerRight;
Component upperLeft;
Component upperRight;
protected Component lowerLeft;
protected Component lowerRight;
protected Component upperLeft;
protected Component upperRight;
JScrollBar horizontalScrollBar;
int horizontalScrollBarPolicy;
JScrollBar verticalScrollBar;
int verticalScrollBarPolicy;
protected JScrollBar horizontalScrollBar;
protected int horizontalScrollBarPolicy;
protected JScrollBar verticalScrollBar;
protected int verticalScrollBarPolicy;
JViewport viewport;
protected JViewport viewport;
Border viewportBorder;
boolean wheelScrollingEnabled;
ChangeListener scrollListener;

View file

@ -55,14 +55,15 @@ public class JSeparator extends JComponent implements SwingConstants,
*/
protected class AccessibleJSeparator extends AccessibleJComponent
{
private static final long serialVersionUID = 916332890553201095L;
/**
* Constructor AccessibleJSeparator
*
* @param component TODO
*/
protected AccessibleJSeparator(JSeparator component)
protected AccessibleJSeparator()
{
super(component);
}
/**
@ -76,6 +77,8 @@ public class JSeparator extends JComponent implements SwingConstants,
}
}
private static final long serialVersionUID = 125301223445282357L;
/** The orientation of the JSeparator. */
private transient int orientation = HORIZONTAL;
@ -198,7 +201,8 @@ public class JSeparator extends JComponent implements SwingConstants,
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJSeparator(this);
accessibleContext = new AccessibleJSeparator();
return accessibleContext;
}
}

View file

@ -122,14 +122,15 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
protected class AccessibleJSlider extends JComponent.AccessibleJComponent
implements AccessibleValue
{
private static final long serialVersionUID = -6301740148041106789L;
/**
* Creates a new AccessibleJSlider object.
*
* @param value0 DOCUMENT ME!
*/
protected AccessibleJSlider(JSlider value0)
protected AccessibleJSlider()
{
super(value0);
}
/**
@ -933,7 +934,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJSlider(this);
accessibleContext = new AccessibleJSlider();
return accessibleContext;
}
}

View file

@ -1,3 +1,40 @@
/* JSplitPane.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;
@ -26,14 +63,15 @@ public class JSplitPane extends JComponent implements Accessible
protected class AccessibleJSplitPane extends JComponent.AccessibleJComponent
implements AccessibleValue
{
private static final long serialVersionUID = -1788116871416305366L;
/**
* Creates a new AccessibleJSplitPane object.
*
* @param value0 DOCUMENT ME!
*/
protected AccessibleJSplitPane(JSplitPane value0)
protected AccessibleJSplitPane()
{
super(value0);
}
/**
@ -109,6 +147,8 @@ public class JSplitPane extends JComponent implements Accessible
}
}
private static final long serialVersionUID = -5634142046175988380L;
/** The constraints string used to add components to the bottom. */
public static final String BOTTOM = "bottom";
@ -311,7 +351,8 @@ public class JSplitPane extends JComponent implements Accessible
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJSplitPane(this);
accessibleContext = new AccessibleJSplitPane();
return accessibleContext;
}
@ -522,7 +563,7 @@ public class JSplitPane extends JComponent implements Accessible
*/
public void remove(int index)
{
Component component = getComponentAt(index);
Component component = getComponent(index);
if (component == leftComponent)
leftComponent = null;
else if (component == rightComponent)

View file

@ -79,14 +79,16 @@ public class JTabbedPane extends JComponent implements Serializable,
protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent
implements AccessibleSelection, ChangeListener
{
private static final long serialVersionUID = 7610530885966830483L;
/**
* Creates a new AccessibleJTabbedPane object.
*
* @param c DOCUMENT ME!
*/
public AccessibleJTabbedPane(JTabbedPane c)
public AccessibleJTabbedPane()
{
super(c);
super();
}
/**
@ -224,6 +226,12 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
protected class ModelListener implements ChangeListener, Serializable
{
private static final long serialVersionUID = 497359819958114132L;
protected ModelListener()
{
}
/**
* This method is called whenever the model is changed.
*
@ -304,7 +312,9 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
public void setComponent(Component c)
{
JTabbedPane.this.remove(component);
this.component = c;
JTabbedPane.this.add(c);
}
/**
@ -542,10 +552,10 @@ public class JTabbedPane extends JComponent implements Serializable,
protected SingleSelectionModel model;
/** Indicates that the TabbedPane is in scrolling mode. */
public static int SCROLL_TAB_LAYOUT = 1;
public static final int SCROLL_TAB_LAYOUT = 1;
/** Indicates that the TabbedPane is in wrap mode. */
public static int WRAP_TAB_LAYOUT = 0;
public static final int WRAP_TAB_LAYOUT = 0;
/** The current tabPlacement of the TabbedPane. */
protected int tabPlacement = SwingConstants.TOP;
@ -825,12 +835,12 @@ public class JTabbedPane extends JComponent implements Serializable,
checkIndex(index, -1, tabs.size());
if (index != getSelectedIndex())
{
if (getSelectedIndex() != -1)
if (getSelectedIndex() != -1 && getSelectedComponent() != null)
getSelectedComponent().hide();
if (index != -1)
if (index != -1 && getComponentAt(index) != null)
getComponentAt(index).show();
model.setSelectedIndex(index);
}
model.setSelectedIndex(index);
}
/**
@ -874,13 +884,17 @@ public class JTabbedPane extends JComponent implements Serializable,
// Hide the component so we don't see it. Do it before we parent it
// so we don't trigger a repaint.
component.hide();
super.add(component);
if (component != null)
{
component.hide();
super.add(component);
}
if (getSelectedIndex() == -1)
setSelectedIndex(0);
layout();
repaint();
}
/**
@ -1474,7 +1488,7 @@ public class JTabbedPane extends JComponent implements Serializable,
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJTabbedPane(this);
accessibleContext = new AccessibleJTabbedPane();
return accessibleContext;
}
}

View file

@ -58,6 +58,8 @@ public class JTable extends JComponent
implements TableModelListener, Scrollable, TableColumnModelListener,
ListSelectionListener, CellEditorListener, Accessible
{
private static final long serialVersionUID = 3876025080382781659L;
public static final int AUTO_RESIZE_ALL_COLUMNS = 4;
public static final int AUTO_RESIZE_LAST_COLUMN = 3;
public static final int AUTO_RESIZE_NEXT_COLUMN = 1;

View file

@ -0,0 +1,231 @@
/* JTextArea.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.Dimension;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;
public class JTextArea extends JTextComponent
{
private static final long serialVersionUID = -6141680179310439825L;
private int rows;
private int columns;
private boolean wrapping;
/**
* Creates a new <code>JTextArea</code> object.
*/
public JTextArea()
{
this(null, null, 0, 0);
}
/**
* Creates a new <code>JTextArea</code> object.
*
* @param text the initial text
*/
public JTextArea(String text)
{
this(null, text, 0, 0);
}
/**
* Creates a new <code>JTextArea</code> object.
*
* @param rows the number of rows
* @param columns the number of cols
*
* @exception IllegalArgumentException if rows or columns are negative
*/
public JTextArea(int rows, int columns)
{
this(null, null, rows, columns);
}
/**
* Creates a new <code>JTextArea</code> object.
*
* @param text the initial text
* @param rows the number of rows
* @param columns the number of cols
*
* @exception IllegalArgumentException if rows or columns are negative
*/
public JTextArea(String text, int rows, int columns)
{
this(null, text, rows, columns);
}
/**
* Creates a new <code>JTextArea</code> object.
*
* @param the document model to use
*/
public JTextArea(Document doc)
{
this(doc, null, 0, 0);
}
/**
* Creates a new <code>JTextArea</code> object.
*
* @param the document model to use
* @param text the initial text
* @param rows the number of rows
* @param columns the number of cols
*
* @exception IllegalArgumentException if rows or columns are negative
*/
public JTextArea(Document doc, String text, int rows, int columns)
{
setDocument(doc == null ? createDefaultModel() : doc);
setText(text);
setRows(rows);
setColumns(columns);
}
/**
* Appends some text.
*
* @param toAppend the text to append
*/
public void append(String toAppend)
{
setText(getText() + toAppend);
}
/**
* Creates the default document model.
*
* @return a new default model
*/
protected Document createDefaultModel()
{
return new PlainDocument();
}
public boolean getScrollableTracksViewportWidth()
{
return wrapping ? true : super.getScrollableTracksViewportWidth();
}
/**
* Returns the UI class ID string.
*
* @return the string "TextAreaUI"
*/
public String getUIClassID()
{
return "TextAreaUI";
}
/**
* Returns the current number of columns.
*
* @return number of columns
*/
public int getColumns()
{
return columns;
}
/**
* Sets the number of rows.
*
* @param columns number of columns
*
* @exception IllegalArgumentException if columns is negative
*/
public void setColumns(int columns)
{
if (columns < 0)
throw new IllegalArgumentException();
this.columns = columns;
}
/**
* Returns the current number of rows.
*
* @return number of rows
*/
public int getRows()
{
return rows;
}
/**
* Sets the number of rows.
*
* @param columns number of columns
*
* @exception IllegalArgumentException if rows is negative
*/
public void setRows(int rows)
{
if (rows < 0)
throw new IllegalArgumentException();
this.rows = rows;
}
/**
* Checks whethet line wrapping is enabled.
*
* @return true if line wrapping is enabled, false otherwise
*/
public boolean getLineWrap()
{
return wrapping;
}
/**
* Enables/disables line wrapping.
*
* @param wrapping true to enable line wrapping, false otherwise
*/
public void setLineWrap(boolean wrapping)
{
this.wrapping = wrapping;
}
}

View file

@ -1,4 +1,4 @@
/* JTextField.java --
/* JTextField.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,73 +35,185 @@ 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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.accessibility.AccessibleStateSet;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;
public class JTextField extends JEditorPane
public class JTextField extends JTextComponent
implements SwingConstants
{
/**
* AccessibleJTextField
*/
protected class AccessibleJTextField extends AccessibleJTextComponent {
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJTextField
* @param component TODO
*/
protected AccessibleJTextField(JTextField component) {
super(component);
// TODO
} // AccessibleJTextField()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleStateSet
* @returns AccessibleStateSet
*/
public AccessibleStateSet getAccessibleStateSet() {
return null; // TODO
} // getAccessibleStateSet()
} // AccessibleJTextField
Vector actions = new Vector();
public JTextField()
/**
* AccessibleJTextField
*/
protected class AccessibleJTextField extends AccessibleJTextComponent
{
private static final long serialVersionUID = 8255147276740453036L;
/**
* Constructor AccessibleJTextField
*/
protected AccessibleJTextField()
{
}
/**
* getAccessibleStateSet
* @return AccessibleStateSet
*/
public AccessibleStateSet getAccessibleStateSet()
{
return null;
}
}
public JTextField(int a)
{
}
private static final long serialVersionUID = 353853209832607592L;
public void addActionListener(ActionListener l)
{
actions.addElement(l);
}
public static final String notifyAction = "notify-field-accept";
private int columns;
public void removeActionListener(ActionListener l)
{
actions.removeElement(l);
}
/**
* Creates a new instance of <code>JTextField</code>.
*/
public JTextField()
{
this(null, null, 0);
}
public void selectAll()
{
}
/**
* Creates a new instance of <code>JTextField</code>.
*
* @param text the initial text
*/
public JTextField(String text)
{
this(null, text, 0);
}
/**
* Creates a new instance of <code>JTextField</code>.
*
* @param columns the number of columns
*
* @exception IllegalArgumentException if columns %lt; 0
*/
public JTextField(int columns)
{
this(null, null, columns);
}
/**
* Creates a new instance of <code>JTextField</code>.
*
* @param text the initial text
* @param columns the number of columns
*
* @exception IllegalArgumentException if columns %lt; 0
*/
public JTextField(String text, int columns)
{
this(null, text, columns);
}
/**
* Creates a new instance of <code>JTextField</code>.
*
* @param doc the document to use
* @param text the initial text
* @param columns the number of columns
*
* @exception IllegalArgumentException if columns %lt; 0
*/
public JTextField(Document doc, String text, int columns)
{
if (doc == null)
doc = createDefaultModel();
setDocument(doc);
setText(text);
setColumns(columns);
}
/**
* Creates the default model for this text field.
* This implementation returns an instance of <code>PlainDocument</code>.
*
* @return a new instance of the default model
*/
protected Document createDefaultModel()
{
return new PlainDocument();
}
/**
* Adds a new listener object to this text field.
*
* @param listener the listener to add
*/
public void addActionListener(ActionListener listener)
{
listenerList.add(ActionListener.class, listener);
}
/**
* Removes a listener object from this text field.
*
* @param listener the listener to remove
*/
public void removeActionListener(ActionListener listener)
{
listenerList.remove(ActionListener.class, listener);
}
/**
* Returns all registered <code>ActionListener</code> objects.
*
* @return an array of listeners
*/
public ActionListener[] getActionListeners()
{
return (ActionListener[]) getListeners(ActionListener.class);
}
/**
* Sends an action event to all registered
* <code>ActionListener</code> objects.
*/
protected void fireActionPerformed()
{
ActionEvent event = new ActionEvent(this, 0, notifyAction);
ActionListener[] listeners = getActionListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].actionPerformed(event);
}
/**
* Returns the number of columns of this text field.
*
* @return the number of columns
*/
public int getColumns()
{
return columns;
}
public void setColumns(int columns)
{
if (columns < 0)
throw new IllegalArgumentException();
this.columns = columns;
// FIXME: Invalidate layout.
}
public void selectAll()
{
}
}

View file

@ -47,6 +47,8 @@ public class JToggleButton extends AbstractButton implements Accessible
public static class ToggleButtonModel extends DefaultButtonModel
{
private static final long serialVersionUID = -1589950750899943974L;
public void setPressed(boolean b)
{
if (! isEnabled())
@ -62,6 +64,8 @@ public class JToggleButton extends AbstractButton implements Accessible
}
private static final long serialVersionUID = -3128248873429850443L;
public JToggleButton()
{
this(null, null);
@ -82,6 +86,12 @@ public class JToggleButton extends AbstractButton implements Accessible
this(text, null);
}
public JToggleButton(String text, boolean selected)
{
this(text, null);
setSelected(selected);
}
public JToggleButton(String text, Icon icon)
{
this(text, icon, false);
@ -96,17 +106,20 @@ public class JToggleButton extends AbstractButton implements Accessible
model.setSelected(selected);
}
/**
* Gets the AccessibleContext associated with this JToggleButton.
*/
public AccessibleContext getAccessibleContext()
{
//Gets the AccessibleContext associated with this JToggleButton.
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 L&F class that renders this component.
return "ToggleButtonUI";
}

View file

@ -40,7 +40,9 @@ package javax.swing;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
@ -59,58 +61,46 @@ import javax.swing.plaf.ToolBarUI;
public class JToolBar extends JComponent
implements SwingConstants, Accessible
{
/**
* AccessibleJToolBar
*/
protected class AccessibleJToolBar extends AccessibleJComponent
{
private static final long serialVersionUID = -5516888265903814215L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJToolBar
*/
protected AccessibleJToolBar()
{
}
/**
* AccessibleJToolBar
*/
protected class AccessibleJToolBar extends AccessibleJComponent {
/**
* getAccessibleStateSet
* @return AccessibleStateSet
*/
public AccessibleStateSet getAccessibleStateSet()
{
return null; // TODO
}
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJToolBar
* @param component TODO
*/
protected AccessibleJToolBar(JToolBar component) {
super(component);
// TODO
} // AccessibleJToolBar()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getAccessibleStateSet
* @returns AccessibleStateSet
*/
public AccessibleStateSet getAccessibleStateSet() {
return null; // TODO
} // getAccessibleStateSet()
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.TOOL_BAR;
} // getAccessibleRole()
} // AccessibleJToolBar
/**
* getAccessibleRole
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.TOOL_BAR;
}
}
/**
* Separator
*/
public static class Separator extends JSeparator {
private static final long serialVersionUID = -1656745644823105219L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
@ -196,7 +186,27 @@ public class JToolBar extends JComponent
} // 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
private static final long serialVersionUID = -1269915519555129643L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
@ -224,8 +234,13 @@ public class JToolBar extends JComponent
/**
* orientation
*/
private int orientation;
private int orientation = HORIZONTAL;
// protected transient DefaultJToolBarLayout toolbarLayout;
/** Fired in a PropertyChangeEvent when the "orientation" property changes.
*/
public static final String ORIENTATION_CHANGED_PROPERTY = "orientation";
//-------------------------------------------------------------
// Initialization ---------------------------------------------
@ -235,32 +250,37 @@ public class JToolBar extends JComponent
* Constructor JToolBar
*/
public JToolBar() {
// TODO
this(null);
} // JToolBar()
/**
* Constructor JToolBar
* @param orientation TODO
* @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)
*/
public JToolBar(int orientation) {
// TODO
this(null, orientation);
} // JToolBar()
/**
* Constructor JToolBar
* @param name TODO
* @param name Name assigned to undocked tool bar.
*/
public JToolBar(String name) {
// TODO
this(name, HORIZONTAL);
} // JToolBar()
/**
* Constructor JToolBar
* @param name TODO
* @param orientation TODO
* @param name Name assigned to undocked tool bar.
* @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)
*/
public JToolBar(String name, int orientation) {
// TODO
setName(name);
if (orientation != HORIZONTAL && orientation != VERTICAL)
throw new IllegalArgumentException(orientation + " is not a legal orientation");
this.orientation = orientation;
// toolbarLayout = new DefaultJToolBarLayout();
updateUI();
} // JToolBar()
@ -299,6 +319,7 @@ public class JToolBar extends JComponent
* @returns ToolBarUI
*/
public ToolBarUI getUI() {
System.out.println("ui = " + ui);
return (ToolBarUI) ui;
} // getUI()
@ -314,8 +335,7 @@ public class JToolBar extends JComponent
* updateUI
*/
public void updateUI() {
setUI((ToolBarUI) UIManager.get(this));
invalidate();
setUI((ToolBarUI)UIManager.getUI(this));
} // updateUI()
/**
@ -397,15 +417,31 @@ public class JToolBar extends JComponent
* @returns int
*/
public int getOrientation() {
return 0; // TODO
return this.orientation;
} // getOrientation()
/**
* setLayout
* @param mgr
*/
public void setLayout(LayoutManager mgr) {
super.setLayout(mgr);
} // setLayout()
/**
* setOrientation
* @param orientation TODO
* @param orientation
*/
public void setOrientation(int orientation) {
// TODO
if (orientation != HORIZONTAL && orientation != VERTICAL)
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);
}
} // setOrientation()
/**
@ -447,10 +483,11 @@ public class JToolBar extends JComponent
* @param constraints TODO
* @param index TODO
*/
/*
protected void addImpl(Component component, Object constraints, int index) {
// TODO
} // addImpl()
*/
/**
* paramString
* @returns String
@ -459,16 +496,15 @@ public class JToolBar extends JComponent
return null; // TODO
} // paramString()
/**
* getAccessibleContext
* @returns AccessibleContext
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJToolBar(this);
} // if
return accessibleContext;
} // getAccessibleContext()
} // JToolBar
/**
* getAccessibleContext
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
{
if (accessibleContext == null)
accessibleContext = new AccessibleJToolBar();
return accessibleContext;
}
}

View file

@ -42,12 +42,18 @@ import javax.accessibility.Accessible;
public class JToolTip extends JComponent implements Accessible
{
String text;
private static final long serialVersionUID = -1138929898906751643L;
String text;
JToolTip(String text)
{
this.text = text;
}
public JToolTip()
{
}
public void setTipText(String newText)
{
this.text = newText;
}
}

View file

@ -1,4 +1,4 @@
/* JTree.java --
/* JTree.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,79 +35,323 @@ 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.Dimension;
import java.awt.Rectangle;
import java.util.Hashtable;
import java.util.Vector;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeWillExpandListener;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.ExpandVetoException;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
public class JTree extends JComponent implements Scrollable, Accessible
public class JTree extends JComponent
implements Scrollable, Accessible
{
JTree()
{
updateUI();
}
public TreeUI getUI()
{
return (TreeUI) ui;
}
private static final long serialVersionUID = 7559816092864483649L;
public void setUI(TreeUI ui)
{
super.setUI(ui);
}
protected TreeModel treeModel;
public void updateUI()
{
setUI((TreeUI)UIManager.getUI(this));
}
/**
* Creates a new <code>JTree</code> object.
*/
public JTree()
{
treeModel = createTreeModel(null);
}
public String getUIClassID()
{
return "TreeUI";
}
/**
* Creates a new <code>JTree</code> object.
*
* @param value the initial nodes in the tree
*/
public JTree(Hashtable value)
{
treeModel = createTreeModel(value);
}
/**
* Creates a new <code>JTree</code> object.
*
* @param value the initial nodes in the tree
*/
public JTree(Object[] value)
{
treeModel = createTreeModel(value);
}
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* Creates a new <code>JTree</code> object.
*
* @param model the model to use
*/
public JTree(TreeModel model)
{
treeModel = model;
}
public Dimension getPreferredScrollableViewportSize()
{
return null;
}
/**
* Creates a new <code>JTree</code> object.
*
* @param root the root node
*/
public JTree(TreeNode root)
{
this(root, false);
}
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation,
int direction)
{
return 1;
}
/**
* Creates a new <code>JTree</code> object.
*
* @param root the root node
* @param asksAllowChildren if false, all nodes without children are leaf nodes.
* If true, only nodes that do not allow children are leaf nodes.
*/
public JTree(TreeNode root, boolean asksAllowChildren)
{
}
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation,
int direction)
{
return 1;
}
/**
* Creates a new <code>JTree</code> object.
*
* @param value the initial nodes in the tree
*/
public JTree(Vector value)
{
treeModel = createTreeModel(value);
}
public boolean getScrollableTracksViewportWidth()
{
return false;
}
/**
* Creates a new <code>TreeModel</code> object.
*
* @param value the values stored in the model
*/
protected static TreeModel createTreeModel(Object value)
{
// FIXME: Implement this.
return null;
}
public boolean getScrollableTracksViewportHeight()
{
return false;
}
public TreeUI getUI()
{
return (TreeUI) ui;
}
public void setUI(TreeUI ui)
{
super.setUI(ui);
}
public void updateUI()
{
setUI((TreeUI) UIManager.getUI(this));
}
public String getUIClassID()
{
return "TreeUI";
}
public AccessibleContext getAccessibleContext()
{
return null;
}
public Dimension getPreferredScrollableViewportSize()
{
return null;
}
public int getScrollableUnitIncrement(Rectangle visibleRect,
int orientation, int direction)
{
return 1;
}
public int getScrollableBlockIncrement(Rectangle visibleRect,
int orientation, int direction)
{
return 1;
}
public boolean getScrollableTracksViewportWidth()
{
return false;
}
public boolean getScrollableTracksViewportHeight()
{
return false;
}
/**
* Adds a <code>TreeExpansionListener</code> object to the tree.
*
* @param listener the listener to add
*/
public void addTreeExpansionListener(TreeExpansionListener listener)
{
listenerList.add(TreeExpansionListener.class, listener);
}
/**
* Removes a <code>TreeExpansionListener</code> object from the tree.
*
* @param listener the listener to remove
*/
public void removeTreeExpansionListener(TreeExpansionListener listener)
{
listenerList.remove(TreeExpansionListener.class, listener);
}
/**
* Returns all added <code>TreeExpansionListener</code> objects.
*
* @return an array of listeners
*/
public TreeExpansionListener[] getTreeExpansionListeners()
{
return (TreeExpansionListener[]) getListeners(TreeExpansionListener.class);
}
/**
* Notifies all listeners that the tree was collapsed.
*
* @param path the path to the node that was collapsed
*/
public void fireTreeCollapsed(TreePath path)
{
TreeExpansionEvent event = new TreeExpansionEvent(this, path);
TreeExpansionListener[] listeners = getTreeExpansionListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].treeCollapsed(event);
}
/**
* Notifies all listeners that the tree was expanded.
*
* @param path the path to the node that was expanded
*/
public void fireTreeExpanded(TreePath path)
{
TreeExpansionEvent event = new TreeExpansionEvent(this, path);
TreeExpansionListener[] listeners = getTreeExpansionListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].treeExpanded(event);
}
/**
* Adds a <code>TreeSelctionListener</code> object to the tree.
*
* @param listener the listener to add
*/
public void addTreeSelectionListener(TreeSelectionListener listener)
{
listenerList.add(TreeSelectionListener.class, listener);
}
/**
* Removes a <code>TreeSelectionListener</code> object from the tree.
*
* @param listener the listener to remove
*/
public void removeTreeSelectionListener(TreeSelectionListener listener)
{
listenerList.remove(TreeSelectionListener.class, listener);
}
/**
* Returns all added <code>TreeSelectionListener</code> objects.
*
* @return an array of listeners
*/
public TreeSelectionListener[] getTreeSelectionListeners()
{
return (TreeSelectionListener[]) getListeners(TreeSelectionListener.class);
}
/**
* Notifies all listeners when the selection of the tree changed.
*
* @param event the event to send
*/
protected void fireValueChanged(TreeSelectionEvent event)
{
TreeSelectionListener[] listeners = getTreeSelectionListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].valueChanged(event);
}
/**
* Adds a <code>TreeWillExpandListener</code> object to the tree.
*
* @param listener the listener to add
*/
public void addTreeWillExpandListener(TreeWillExpandListener listener)
{
listenerList.add(TreeWillExpandListener.class, listener);
}
/**
* Removes a <code>TreeWillExpandListener</code> object from the tree.
*
* @param listener the listener to remove
*/
public void removeTreeWillExpandListener(TreeWillExpandListener listener)
{
listenerList.remove(TreeWillExpandListener.class, listener);
}
/**
* Returns all added <code>TreeWillExpandListener</code> objects.
*
* @return an array of listeners
*/
public TreeWillExpandListener[] getTreeWillExpandListeners()
{
return (TreeWillExpandListener[]) getListeners(TreeWillExpandListener.class);
}
/**
* Notifies all listeners that the tree will collapse.
*
* @param path the path to the node that will collapse
*/
public void fireTreeWillCollapse(TreePath path)
throws ExpandVetoException
{
TreeExpansionEvent event = new TreeExpansionEvent(this, path);
TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].treeWillCollapse(event);
}
/**
* Notifies all listeners that the tree will expand.
*
* @param path the path to the node that will expand
*/
public void fireTreeWillExpand(TreePath path)
throws ExpandVetoException
{
TreeExpansionEvent event = new TreeExpansionEvent(this, path);
TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
for (int index = 0; index < listeners.length; ++index)
listeners[index].treeWillExpand(event);
}
}

View file

@ -45,6 +45,7 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import javax.accessibility.Accessible;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ViewportUI;
@ -91,19 +92,20 @@ import javax.swing.plaf.ViewportUI;
* the underlying child at position <code>(-VX,-VY)</code></p>
*
*/
public class JViewport extends JComponent
{
public static int BACKINGSTORE_SCROLL_MODE = 1;
public static int BLIT_SCROLL_MODE = 2;
public static int SIMPLE_SCROLL_MODE = 3;
private static final long serialVersionUID = -6925142919680527970L;
public static final int SIMPLE_SCROLL_MODE = 0;
public static final int BLIT_SCROLL_MODE = 1;
public static final int BACKINGSTORE_SCROLL_MODE = 2;
ChangeEvent changeEvent = new ChangeEvent(this);
int scrollMode;
boolean scrollUnderway;
boolean isViewSizeSet;
protected boolean scrollUnderway;
protected boolean isViewSizeSet;
/**
* The width and height of the Viewport's area in terms of view
@ -133,11 +135,23 @@ public class JViewport extends JComponent
public Dimension getExtentSize()
{
if (extentSize == null)
return getPreferredSize();
return toViewCoordinates(getSize());
else
return extentSize;
}
public Dimension toViewCoordinates(Dimension size)
{
return size;
}
public Point toViewCoordinates(Point p)
{
Point pos = getViewPosition();
return new Point(p.x + pos.x,
p.y + pos.y);
}
public void setExtentSize(Dimension newSize)
{
extentSize = newSize;
@ -146,10 +160,10 @@ public class JViewport extends JComponent
public Dimension getViewSize()
{
if (viewSize == null)
return getView().getPreferredSize();
else
if (isViewSizeSet)
return viewSize;
else
return getView().getSize();
}
@ -158,10 +172,17 @@ public class JViewport extends JComponent
viewSize = newSize;
Component view = getView();
if (view != null)
view.setSize(newSize);
view.setSize(viewSize);
isViewSizeSet = true;
fireStateChanged();
}
/**
* Get the viewport's position in view space. Despite confusing name,
* this really does return the viewport's (0,0) position in view space,
* not the view's position.
*/
public Point getViewPosition()
{
Component view = getView();

View file

@ -60,6 +60,8 @@ import javax.accessibility.AccessibleContext;
*/
public class JWindow extends Window implements Accessible, RootPaneContainer
{
private static final long serialVersionUID = 5420698392125238833L;
public final static int HIDE_ON_CLOSE = 0;
public final static int EXIT_ON_CLOSE = 1;
public final static int DISPOSE_ON_CLOSE = 2;
@ -114,13 +116,6 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
return d;
}
JMenuBar getJMenuBar()
{ return getRootPane().getJMenuBar(); }
void setJMenuBar(JMenuBar menubar)
{ getRootPane().setJMenuBar(menubar); }
public void setLayout(LayoutManager manager)
{ super.setLayout(manager); }

View file

@ -149,6 +149,7 @@ public class KeyStroke implements Serializable
* @param keyChar TODO
* @param onKeyRelease TODO
* @returns KeyStroke
* @deprecated Use getKeyStroke(char)
*/
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) {
KeyStroke key = getKeyStroke(keyChar);

View file

@ -1,4 +1,4 @@
/* LookAndFeel.java --
/* LookAndFeel.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,92 +35,134 @@ 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 javax.swing.text.JTextComponent;
public abstract class LookAndFeel
{
public UIDefaults getDefaults()
{
//This method is called once by UIManager.setLookAndFeel to create the look and feel specific defaults table.
return null;
}
/**
* This method is called once by UIManager.setLookAndFeel to create
* the look and feel specific defaults table.
*
* @return the UI defaults
*/
public UIDefaults getDefaults()
{
return null;
}
public abstract String getDescription();
public abstract String getID();
public abstract String getName();
public abstract String getDescription();
public void initialize()
{
//UIManager.setLookAndFeel calls this method before the first call (and typically the only call) to getDefaults().
}
public abstract String getID();
static void installBorder(JComponent c, String defaultBorderName)
{
//Convenience method for installing a component's default Border object on the specified component if either the border is currently null or already an instance of UIResource.
}
public abstract String getName();
public static void installColors(JComponent c, String defaultBgName, String defaultFgName)
{
//Convenience method for initializing a component's foreground and background color properties with values from the current defaults table.
}
/**
* UIManager.setLookAndFeel calls this method before the first call
* (and typically the only call) to getDefaults().
*/
public void initialize()
{
}
public static void installColorsAndFont(JComponent c, String defaultBgName, String defaultFgName, String defaultFontName)
{
//Convenience method for initializing a components foreground background and font properties with values from the current defaults table.
}
public abstract boolean isNativeLookAndFeel();
public abstract boolean isSupportedLookAndFeel();
/**
* Convenience method for installing a component's default Border object
* on the specified component if either the border is currently null
* or already an instance of UIResource.
*/
public static void installBorder(JComponent c, String defaultBorderName)
{
}
public static void loadKeyBindings(InputMap retMap, Object[] keys)
{
//Loads the bindings in keys into retMap.
}
/**
* Convenience method for initializing a component's foreground and
* background color properties with values from the current defaults table.
*/
public static void installColors(JComponent c, String defaultBgName, String defaultFgName)
{
}
public static ComponentInputMap makeComponentInputMap(JComponent c, Object[] keys)
{
// Creates a ComponentInputMap from keys.
return null;
}
/**
* Convenience method for initializing a components foreground background
* and font properties with values from the current defaults table.
*/
public static void installColorsAndFont(JComponent component,
String defaultBgName,
String defaultFgName,
String defaultFontName)
{
}
public static Object makeIcon(Class baseClass, String gifFile)
{
//Utility method that creates a UIDefaults.LazyValue that creates an ImageIcon UIResource for the specified gifFile filename.
return null;
}
public static InputMap makeInputMap(Object[] keys)
{
//Creates a InputMap from keys.
return null;
}
public abstract boolean isNativeLookAndFeel();
public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
{
// Convenience method for building lists of KeyBindings.
return null;
}
public abstract boolean isSupportedLookAndFeel();
public String toString()
{
//Returns a string that displays and identifies this object's properties.
return "LookAndFeel";
}
public void uninitialize()
{
//UIManager.setLookAndFeel calls this method just before we're replaced by a new default look and feel.
}
/**
* Loads the bindings in keys into retMap.
*/
public static void loadKeyBindings(InputMap retMap, Object[] keys)
{
}
public static void uninstallBorder(JComponent c)
{
//Convenience method for un-installing a component's default border on the specified component if the border is currently an instance of UIResource.
}
/**
* Creates a ComponentInputMap from keys.
*/
public static ComponentInputMap makeComponentInputMap(JComponent c,
Object[] keys)
{
return null;
}
/**
* Utility method that creates a UIDefaults.LazyValue that creates an
* ImageIcon UIResource for the specified gifFile filename.
*/
public static Object makeIcon(Class baseClass, String gifFile)
{
return null;
}
/**
* Creates a InputMap from keys.
*/
public static InputMap makeInputMap(Object[] keys)
{
return null;
}
/**
* Convenience method for building lists of KeyBindings.
*/
public static JTextComponent.KeyBinding[] makeKeyBindings(Object[] keyBindingList)
{
return null;
}
/**
* Returns a string that displays and identifies this object's properties.
*
* @return the string "LookAndFeel"
*/
public String toString()
{
return "LookAndFeel";
}
/**
* UIManager.setLookAndFeel calls this method just before we're replaced by
* a new default look and feel.
*/
public void uninitialize()
{
}
/**
* Convenience method for un-installing a component's default border on the
* specified component if the border is currently an instance of UIResource.
*/
public static void uninstallBorder(JComponent c)
{
}
}

View file

@ -1,4 +1,4 @@
/* MenuSelectionManager.java --
/* MenuSelectionManager.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,70 +35,111 @@ 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.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
* This class manages current menu selectection. It provides
* methods to clear and set current selected menu path.
* It also fires StateChange event to its registered
* listeners whenever selected path of the current menu hierarchy
* changes.
*
*/
public class MenuSelectionManager
{
protected ChangeEvent changeEvent;
protected EventListenerList listenerList = new EventListenerList ();
/** ChangeEvent fired when selected path changes*/
protected ChangeEvent changeEvent = new ChangeEvent(this);
/** List of listeners for this MenuSelectionManager */
protected EventListenerList listenerList = new EventListenerList();
/** Default manager for the current menu hierarchy*/
private static final MenuSelectionManager manager = new MenuSelectionManager();
private Vector selection = new Vector();
protected void fireStateChanged ()
/** Path to the currently selected menu */
private Vector selectedPath = new Vector();
/**
* Fires StateChange event to registered listeners
*/
protected void fireStateChanged()
{
ChangeListener[] listeners = getChangeListeners ();
ChangeListener[] listeners = getChangeListeners();
for (int i = 0; i < listeners.length; i++)
{
listeners [i].stateChanged (new ChangeEvent (this));
}
listeners[i].stateChanged(changeEvent);
}
public void addChangeListener (ChangeListener listener)
{
listenerList.add (ChangeListener.class, listener);
}
public void removeChangeListener (ChangeListener listener)
{
listenerList.remove (ChangeListener.class, listener);
}
/** @since 1.4 */
public ChangeListener[] getChangeListeners ()
{
return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
}
/**
* Unselects all the menu elements on the selection path
* Adds ChangeListener to this MenuSelectionManager
*
* @param listener ChangeListener to add
*/
public void clearSelectedPath ()
public void addChangeListener(ChangeListener listener)
{
for (int i = 0; i < selection.size (); i++)
((MenuElement) selection.get (i)).menuSelectionChanged (false);
selection.clear ();
listenerList.add(ChangeListener.class, listener);
}
public Component componentForPoint (Component source, Point sourcePoint)
/**
* Removes ChangeListener from the list of registered listeners
* for this MenuSelectionManager.
*
* @param listener ChangeListner to remove
*/
public void removeChangeListener(ChangeListener listener)
{
listenerList.remove(ChangeListener.class, listener);
}
/**
* Returns list of registered listeners with MenuSelectionManager
*
* @since 1.4
*/
public ChangeListener[] getChangeListeners()
{
return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
}
/**
* Unselects all the menu elements on the selection path
*/
public void clearSelectedPath()
{
// Send events from the bottom most item in the menu - hierarchy to the
// top most
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();
}
/**
* DOCUMENT ME!
*
* @param source DOCUMENT ME!
* @param sourcePoint DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public Component componentForPoint(Component source, Point sourcePoint)
{
throw new UnsupportedOperationException("not implemented");
}
@ -108,7 +149,7 @@ public class MenuSelectionManager
*
* @return default Manager
*/
public static MenuSelectionManager defaultManager ()
public static MenuSelectionManager defaultManager()
{
return manager;
}
@ -118,12 +159,12 @@ public class MenuSelectionManager
*
* @return Current selection path
*/
public MenuElement[] getSelectedPath ()
public MenuElement[] getSelectedPath()
{
MenuElement[] path = new MenuElement[selection.size ()];
MenuElement[] path = new MenuElement[selectedPath.size()];
for (int i = 0; i < path.length; i++)
path[i] = (MenuElement) selection.get (i);
path[i] = (MenuElement) selectedPath.get(i);
return path;
}
@ -135,17 +176,17 @@ public class MenuSelectionManager
* @param c Component for which to check
* @return True if specified component is part of current menu
*/
boolean isComponentPartOfCurrentMenu (Component c)
boolean isComponentPartOfCurrentMenu(Component c)
{
MenuElement[] subElements;
for (int i = 0; i < selection.size (); i++)
for (int i = 0; i < selectedPath.size(); i++)
{
subElements = ((MenuElement) selection.get (i)).getSubElements ();
for (int j = 0; j < subElements.length; j++)
{
if ((subElements[j].getComponent ()).equals (c))
return true;
}
subElements = ((MenuElement) selectedPath.get(i)).getSubElements();
for (int j = 0; j < subElements.length; j++)
{
if ((subElements[j].getComponent()).equals(c))
return true;
}
}
return false;
@ -156,7 +197,7 @@ public class MenuSelectionManager
*
* @param e DOCUMENT ME!
*/
public void processKeyEvent (KeyEvent e)
public void processKeyEvent(KeyEvent e)
{
throw new UnsupportedOperationException("not implemented");
}
@ -166,35 +207,20 @@ public class MenuSelectionManager
*
* @param event Mouse event
*/
public void processMouseEvent (MouseEvent event)
public void processMouseEvent(MouseEvent event)
{
Component c = ((MenuElement) event.getSource ()).getComponent ();
if (selection.size () == 0)
{
((MenuElement) event.getSource ()).processMouseEvent (event,
getPath (c),
manager);
return;
}
Component c = ((Component) event.getSource());
// find the index of the source component in the current menu hierarchy
int i = 0;
for (i = 0; i < selection.size (); i++)
{
MenuElement me = (MenuElement) selection.get (i);
if (me.getComponent ().equals (c))
break;
}
MenuElement[] path = getPath(c);
((MenuElement) c).processMouseEvent(event, path, manager);
// Forward event to all subcomponents of the source
Component subComp;
for (int j = i; j < selection.size (); j++)
// forward events to subcomponents
MenuElement[] subComponents = ((MenuElement) c).getSubElements();
for (int i = 0; i < subComponents.length; i++)
{
subComp = ((MenuElement)selection.get (j)).getComponent ();
((MenuElement) selection.get (j)).processMouseEvent (event,
getPath (subComp),
manager);
if (subComponents[i] instanceof JMenuItem)
subComponents[i].processMouseEvent(event, path, manager);
}
}
@ -203,68 +229,66 @@ public class MenuSelectionManager
*
* @param path new selection path
*/
public void setSelectedPath (MenuElement[] path)
public void setSelectedPath(MenuElement[] path)
{
if (path == null)
{
clearSelectedPath ();
return;
clearSelectedPath();
return;
}
fireStateChanged();
int i;
int minSize = path.length; // size of the smaller path.
if (path.length > selection.size ())
if (path.length > selectedPath.size())
{
// if new selected path contains more elements then current
// selection then first add all elements at
// the indexes > selection.size
for (i = selection.size (); i < path.length; i++)
{
selection.add (path[i]);
path[i].menuSelectionChanged (true);
}
// if new selected path contains more elements then current
// selection then first add all elements at
// the indexes > selectedPath.size
for (i = selectedPath.size(); i < path.length; i++)
{
selectedPath.add(path[i]);
path[i].menuSelectionChanged(true);
}
minSize = selection.size ();
minSize = selectedPath.size();
}
else if (path.length < selection.size ())
else if (path.length < selectedPath.size())
{
// if new selected path contains less elements then current
// selection then first remove all elements from the selection
// at the indexes > path.length
for (i = selection.size () - 1; i >= path.length; i--)
{
((MenuElement) selection.get (i)).menuSelectionChanged (false);
selection.remove (i);
}
// if new selected path contains less elements then current
// selection then first remove all elements from the selection
// at the indexes > path.length
for (i = selectedPath.size() - 1; i >= path.length; i--)
{
((MenuElement) selectedPath.get(i)).menuSelectionChanged(false);
selectedPath.remove(i);
}
minSize = path.length;
minSize = path.length;
}
// Now compare elements in new and current selection path at the
// same location and adjust selection until
// same menu elements will be encountered at the
// same index in both current and new selection path.
MenuElement oldSelection;
MenuElement oldSelectedPath;
for (i = minSize - 1; i >= 0; i--)
{
oldSelection = (MenuElement) selection.get (i);
oldSelectedPath = (MenuElement) selectedPath.get(i);
if (path[i].equals (oldSelection))
break;
if (path[i].equals(oldSelectedPath))
break;
oldSelection.menuSelectionChanged (false);
path[i].menuSelectionChanged (true);
selection.setElementAt (path[i], i);
oldSelectedPath.menuSelectionChanged(false);
path[i].menuSelectionChanged(true);
selectedPath.setElementAt(path[i], i);
}
}
/**
* Returns path to the specified component
*
@ -272,27 +296,21 @@ public class MenuSelectionManager
*
* @return path to the specified component
*/
private MenuElement[] getPath (Component c)
private MenuElement[] getPath(Component c)
{
Vector path = new Vector();
path.add (c);
Component parent = c.getParent ();
while (parent instanceof JMenu
|| parent instanceof JPopupMenu
|| parent instanceof JMenuItem
|| parent instanceof JMenuBar)
ArrayList path = new ArrayList();
while (c instanceof MenuElement)
{
path.add (parent);
parent = parent.getParent ();
path.add(0, (MenuElement) c);
if (c instanceof JPopupMenu)
c = ((JPopupMenu) c).getInvoker();
else
c = c.getParent();
}
MenuElement[] pathArray = new MenuElement[path.size ()];
for (int i = 0; i < path.size (); i++)
pathArray[i] = (MenuElement) path.get (path.size () - i - 1);
MenuElement[] pathArray = new MenuElement[path.size()];
path.toArray(pathArray);
return pathArray;
}
} // class MenuSelectionManager
}

View file

@ -1,5 +1,5 @@
/* ScrollPaneConstants.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -42,116 +42,110 @@ package javax.swing;
* @author Andrew Selkirk
* @version 1.0
*/
public interface ScrollPaneConstants {
public interface ScrollPaneConstants
{
/**
* VIEWPORT
*/
String VIEWPORT = "VIEWPORT";
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* VERTICAL_SCROLLBAR
*/
String VERTICAL_SCROLLBAR = "VERTICAL_SCROLLBAR";
/**
* VIEWPORT
*/
String VIEWPORT = "VIEWPORT";
/**
* HORIZONTAL_SCROLLBAR
*/
String HORIZONTAL_SCROLLBAR = "HORIZONTAL_SCROLLBAR";
/**
* VERTICAL_SCROLLBAR
*/
String VERTICAL_SCROLLBAR = "VERTICAL_SCROLLBAR";
/**
* ROW_HEADER
*/
String ROW_HEADER = "ROW_HEADER";
/**
* HORIZONTAL_SCROLLBAR
*/
String HORIZONTAL_SCROLLBAR = "HORIZONTAL_SCROLLBAR";
/**
* COLUMN_HEADER
*/
String COLUMN_HEADER = "COLUMN_HEADER";
/**
* ROW_HEADER
*/
String ROW_HEADER = "ROW_HEADER";
/**
* LOWER_LEFT_CORNER
*/
String LOWER_LEFT_CORNER = "LOWER_LEFT_CORNER";
/**
* COLUMN_HEADER
*/
String COLUMN_HEADER = "COLUMN_HEADER";
/**
* LOWER_RIGHT_CORNER
*/
String LOWER_RIGHT_CORNER = "LOWER_RIGHT_CORNER";
/**
* LOWER_LEFT_CORNER
*/
String LOWER_LEFT_CORNER = "LOWER_LEFT_CORNER";
/**
* UPPER_LEFT_CORNER
*/
String UPPER_LEFT_CORNER = "UPPER_LEFT_CORNER";
/**
* LOWER_RIGHT_CORNER
*/
String LOWER_RIGHT_CORNER = "LOWER_RIGHT_CORNER";
/**
* UPPER_RIGHT_CORNER
*/
String UPPER_RIGHT_CORNER = "UPPER_RIGHT_CORNER";
/**
* UPPER_LEFT_CORNER
*/
String UPPER_LEFT_CORNER = "UPPER_LEFT_CORNER";
/**
* LOWER_LEADING_CORNER
*/
String LOWER_LEADING_CORNER = "LOWER_LEADING_CORNER";
/**
* UPPER_RIGHT_CORNER
*/
String UPPER_RIGHT_CORNER = "UPPER_RIGHT_CORNER";
/**
* LOWER_TRAILING_CORNER
*/
String LOWER_TRAILING_CORNER = "LOWER_TRAILING_CORNER";
/**
* LOWER_LEADING_CORNER
*/
String LOWER_LEADING_CORNER = "LOWER_LEADING_CORNER";
/**
* UPPER_LEADING_CORNER
*/
String UPPER_LEADING_CORNER = "UPPER_LEADING_CORNER";
/**
* LOWER_TRAILING_CORNER
*/
String LOWER_TRAILING_CORNER = "LOWER_TRAILING_CORNER";
/**
* UPPER_TRAILING_CORNER
*/
String UPPER_TRAILING_CORNER = "UPPER_TRAILING_CORNER";
/**
* UPPER_LEADING_CORNER
*/
String UPPER_LEADING_CORNER = "UPPER_LEADING_CORNER";
/**
* VERTICAL_SCROLLBAR_POLICY
*/
String VERTICAL_SCROLLBAR_POLICY = "VERTICAL_SCROLLBAR_POLICY";
/**
* UPPER_TRAILING_CORNER
*/
String UPPER_TRAILING_CORNER = "UPPER_TRAILING_CORNER";
/**
* HORIZONTAL_SCROLLBAR_POLICY
*/
String HORIZONTAL_SCROLLBAR_POLICY = "HORIZONTAL_SCROLLBAR_POLICY";
/**
* VERTICAL_SCROLLBAR_POLICY
*/
String VERTICAL_SCROLLBAR_POLICY = "VERTICAL_SCROLLBAR_POLICY";
/**
* VERTICAL_SCROLLBAR_AS_NEEDED
*/
int VERTICAL_SCROLLBAR_AS_NEEDED = 20;
/**
* HORIZONTAL_SCROLLBAR_POLICY
*/
String HORIZONTAL_SCROLLBAR_POLICY = "HORIZONTAL_SCROLLBAR_POLICY";
/**
* VERTICAL_SCROLLBAR_NEVER
*/
int VERTICAL_SCROLLBAR_NEVER = 21;
/**
* VERTICAL_SCROLLBAR_AS_NEEDED
*/
int VERTICAL_SCROLLBAR_AS_NEEDED = 20;
/**
* VERTICAL_SCROLLBAR_ALWAYS
*/
int VERTICAL_SCROLLBAR_ALWAYS = 22;
/**
* VERTICAL_SCROLLBAR_NEVER
*/
int VERTICAL_SCROLLBAR_NEVER = 21;
/**
* HORIZONTAL_SCROLLBAR_AS_NEEDED
*/
int HORIZONTAL_SCROLLBAR_AS_NEEDED = 30;
/**
* VERTICAL_SCROLLBAR_ALWAYS
*/
int VERTICAL_SCROLLBAR_ALWAYS = 22;
/**
* HORIZONTAL_SCROLLBAR_NEVER
*/
int HORIZONTAL_SCROLLBAR_NEVER = 31;
/**
* HORIZONTAL_SCROLLBAR_AS_NEEDED
*/
int HORIZONTAL_SCROLLBAR_AS_NEEDED = 30;
/**
* HORIZONTAL_SCROLLBAR_NEVER
*/
int HORIZONTAL_SCROLLBAR_NEVER = 31;
/**
* HORIZONTAL_SCROLLBAR_ALWAYS
*/
int HORIZONTAL_SCROLLBAR_ALWAYS = 32;
} // ScrollPaneConstants
/**
* HORIZONTAL_SCROLLBAR_ALWAYS
*/
int HORIZONTAL_SCROLLBAR_ALWAYS = 32;
}

View file

@ -1,5 +1,5 @@
/* ScrollPaneLayout.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -63,17 +63,17 @@ public class ScrollPaneLayout
}
}
JViewport viewport;
JScrollBar verticalScrollBar;
JScrollBar horizontalScrollBar;
JViewport rowHeader;
JViewport columnHeader;
Component lowerLeft;
Component lowerRight;
Component upperLeft;
Component upperRight;
int verticalScrollBarPolicy;
int horizontalScrollBarPolicy;
protected JViewport viewport;
protected JScrollBar vsb;
protected JScrollBar hsb;
protected JViewport rowHead;
protected JViewport colHead;
protected Component lowerLeft;
protected Component lowerRight;
protected Component upperLeft;
protected Component upperRight;
protected int vsbPolicy;
protected int hsbPolicy;
public ScrollPaneLayout() {
@ -81,10 +81,10 @@ public class ScrollPaneLayout
public void syncWithScrollPane(JScrollPane scrollPane) {
viewport = scrollPane.getViewport();
verticalScrollBar = scrollPane.getVerticalScrollBar();
horizontalScrollBar = scrollPane.getHorizontalScrollBar();
verticalScrollBarPolicy = scrollPane.getVerticalScrollBarPolicy();
horizontalScrollBarPolicy = scrollPane.getHorizontalScrollBarPolicy();
vsb = scrollPane.getVerticalScrollBar();
hsb = scrollPane.getHorizontalScrollBar();
vsbPolicy = scrollPane.getVerticalScrollBarPolicy();
hsbPolicy = scrollPane.getHorizontalScrollBarPolicy();
lowerLeft = scrollPane.getCorner(LOWER_LEFT_CORNER);
lowerRight = scrollPane.getCorner(LOWER_RIGHT_CORNER);
upperLeft = scrollPane.getCorner(UPPER_LEFT_CORNER);
@ -101,13 +101,13 @@ public class ScrollPaneLayout
if (key == VIEWPORT)
viewport = (JViewport) component;
else if (key == VERTICAL_SCROLLBAR)
verticalScrollBar = (JScrollBar) component;
vsb = (JScrollBar) component;
else if (key == HORIZONTAL_SCROLLBAR)
horizontalScrollBar = (JScrollBar) component;
hsb = (JScrollBar) component;
else if (key == ROW_HEADER)
rowHeader = (JViewport) component;
rowHead = (JViewport) component;
else if (key == COLUMN_HEADER)
columnHeader = (JViewport) component;
colHead = (JViewport) component;
else if (key == LOWER_RIGHT_CORNER)
lowerRight = component;
else if (key == UPPER_RIGHT_CORNER)
@ -121,14 +121,14 @@ public class ScrollPaneLayout
public void removeLayoutComponent(Component component) {
if (component == viewport)
viewport = null;
else if (component == verticalScrollBar)
verticalScrollBar = null;
else if (component == horizontalScrollBar)
horizontalScrollBar = null;
else if (component == rowHeader)
rowHeader = null;
else if (component == columnHeader)
columnHeader = null;
else if (component == vsb)
vsb = null;
else if (component == hsb)
hsb = null;
else if (component == rowHead)
rowHead = null;
else if (component == colHead)
colHead = null;
else if (component == lowerRight)
lowerRight = null;
else if (component == upperRight)
@ -139,43 +139,53 @@ public class ScrollPaneLayout
upperLeft = null;
}
public int getVerticalScrollBarPolicy() {
return verticalScrollBarPolicy;
public int getVerticalScrollBarPolicy()
{
return vsbPolicy;
}
public void setVerticalScrollBarPolicy(int policy) {
verticalScrollBarPolicy = policy;
public void setVerticalScrollBarPolicy(int policy)
{
vsbPolicy = policy;
}
public int getHorizontalScrollBarPolicy() {
return horizontalScrollBarPolicy;
public int getHorizontalScrollBarPolicy()
{
return hsbPolicy;
}
public void setHorizontalScrollBarPolicy(int policy) {
horizontalScrollBarPolicy = policy;
public void setHorizontalScrollBarPolicy(int policy)
{
hsbPolicy = policy;
}
public JViewport getViewport() {
public JViewport getViewport()
{
return viewport;
}
public JScrollBar getHorizontalScrollBar() {
return horizontalScrollBar;
public JScrollBar getHorizontalScrollBar()
{
return hsb;
}
public JScrollBar getVerticalScrollBar() {
return verticalScrollBar;
public JScrollBar getVerticalScrollBar()
{
return vsb;
}
public JViewport getRowHeader() {
return rowHeader;
public JViewport getRowHeader()
{
return rowHead;
}
public JViewport getColumnHeader() {
return columnHeader;
public JViewport getColumnHeader()
{
return colHead;
}
public Component getCorner(String key) {
public Component getCorner(String key)
{
if (key == LOWER_RIGHT_CORNER)
return lowerRight;
else if (key == UPPER_RIGHT_CORNER)
@ -216,17 +226,17 @@ public class ScrollPaneLayout
if (viewport != null)
viewportSize.setSize(viewport.getPreferredSize());
if (columnHeader != null)
columnHeaderSize.setSize(columnHeader.getPreferredSize());
if (colHead != null)
columnHeaderSize.setSize(colHead.getPreferredSize());
if (rowHeader != null)
rowHeaderSize.setSize(rowHeader.getPreferredSize());
if (rowHead != null)
rowHeaderSize.setSize(rowHead.getPreferredSize());
if (verticalScrollBar != null)
verticalScrollBarSize.setSize(verticalScrollBar.getPreferredSize());
if (vsb != null)
verticalScrollBarSize.setSize(vsb.getPreferredSize());
if (horizontalScrollBar != null)
horizontalScrollBarSize.setSize(horizontalScrollBar.getPreferredSize());
if (hsb != null)
horizontalScrollBarSize.setSize(hsb.getPreferredSize());
/*
System.err.println("widths: [vp=" + viewportSize.width +
@ -285,19 +295,19 @@ public class ScrollPaneLayout
if (viewport != null)
viewportSize.setSize(viewport.getMinimumSize());
if (columnHeader != null)
columnHeaderSize.setSize(columnHeader.getMinimumSize());
if (colHead != null)
columnHeaderSize.setSize(colHead.getMinimumSize());
if (rowHeader != null)
rowHeaderSize.setSize(rowHeader.getMinimumSize());
if (rowHead != null)
rowHeaderSize.setSize(rowHead.getMinimumSize());
if (verticalScrollBar != null
&& verticalScrollBarPolicy != VERTICAL_SCROLLBAR_NEVER)
verticalScrollBarSize.setSize(verticalScrollBar.getMinimumSize());
if (vsb != null
&& vsbPolicy != VERTICAL_SCROLLBAR_NEVER)
verticalScrollBarSize.setSize(vsb.getMinimumSize());
if (horizontalScrollBar != null
&& horizontalScrollBarPolicy != HORIZONTAL_SCROLLBAR_NEVER)
horizontalScrollBarSize.setSize(horizontalScrollBar.getMinimumSize());
if (hsb != null
&& hsbPolicy != HORIZONTAL_SCROLLBAR_NEVER)
horizontalScrollBarSize.setSize(hsb.getMinimumSize());
return new Dimension(insetsSize.width
+ viewportSize.width
@ -338,8 +348,8 @@ public class ScrollPaneLayout
* x1 x2 x3 x4
*
*/
public void layoutContainer(Container parent) {
public void layoutContainer(Container parent)
{
if (parent instanceof JScrollPane)
{
JScrollPane sc = (JScrollPane) parent;
@ -358,13 +368,13 @@ public class ScrollPaneLayout
x4 = scrollPaneBounds.x + scrollPaneBounds.width;
y4 = scrollPaneBounds.y + scrollPaneBounds.height;
if (columnHeader != null)
y2 = columnHeader.getPreferredSize().height;
if (colHead != null)
y2 = colHead.getPreferredSize().height;
else
y2 = y1;
if (rowHeader != null)
x2 = rowHeader.getPreferredSize().width;
if (rowHead != null)
x2 = rowHead.getPreferredSize().width;
else
x2 = x1;
@ -372,24 +382,24 @@ public class ScrollPaneLayout
int hsbPolicy = sc.getHorizontalScrollBarPolicy();
boolean showVsb =
(verticalScrollBar != null)
(vsb != null)
&& ((vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS)
|| (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED
&& viewSize.height > viewportSize.height));
boolean showHsb =
(horizontalScrollBar != null)
(hsb != null)
&& ((hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS)
|| (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED
&& viewSize.width > viewportSize.width));
if (showVsb)
x3 = x4 - verticalScrollBar.getPreferredSize().width;
x3 = x4 - vsb.getPreferredSize().width;
else
x3 = x4;
if (showHsb)
y3 = y4 - horizontalScrollBar.getPreferredSize().height;
y3 = y4 - hsb.getPreferredSize().height;
else
y3 = y4;
@ -398,17 +408,17 @@ public class ScrollPaneLayout
if (viewport != null)
viewport.setBounds(new Rectangle(x2, y2, x3-x2, y3-y2));
if (columnHeader != null)
columnHeader.setBounds(new Rectangle(x2, y1, x3-x2, y2-y1));
if (colHead != null)
colHead.setBounds(new Rectangle(x2, y1, x3-x2, y2-y1));
if (rowHeader != null)
rowHeader.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));
if (rowHead != null)
rowHead.setBounds(new Rectangle(x1, y2, x2-x1, y3-y2));
if (showVsb)
verticalScrollBar.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
vsb.setBounds(new Rectangle(x3, y2, x4-x3, y3-y2));
if (showHsb)
horizontalScrollBar.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));
hsb.setBounds(new Rectangle(x2, y3, x3-x2, y4-y3));
if (upperLeft != null)
upperLeft.setBounds(new Rectangle(x1, y1, x2-x1, y2-y1));

View file

@ -51,6 +51,7 @@ import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
@ -375,8 +376,12 @@ public class SwingUtilities implements SwingConstants
return pt;
}
public static Point convertPoint(Component source, Point aPoint, Component destination)
{
return convertPoint(source, aPoint.x, aPoint.y, destination);
}
/**
* Converts a rectangle from the coordinate space of one component to
* another. This is equivalent to converting the rectangle from
@ -718,7 +723,6 @@ public class SwingUtilities implements SwingConstants
iconR.y = centerLine - iconR.height/2;
break;
}
// The two rectangles are laid out correctly now, but only assuming
// that their upper left corner is at (0,0). If we have any alignment other
// than TOP and LEFT, we need to adjust them.
@ -845,6 +849,43 @@ public class SwingUtilities implements SwingConstants
ownerFrame = new Frame();
return ownerFrame;
}
/**
* Checks if left mouse button was clicked.
*
* @param event the event to check
*
* @return true if left mouse was clicked, false otherwise.
*/
public static boolean isLeftMouseButton(MouseEvent event)
{
return ((event.getModifiers() & InputEvent.BUTTON1_DOWN_MASK)
== InputEvent.BUTTON1_DOWN_MASK);
}
/**
* Checks if middle mouse button was clicked.
*
* @param event the event to check
*
* @return true if middle mouse was clicked, false otherwise.
*/
public static boolean isMiddleMouseButton(MouseEvent event)
{
return ((event.getModifiers() & InputEvent.BUTTON2_DOWN_MASK)
== InputEvent.BUTTON2_DOWN_MASK);
}
/**
* Checks if right mouse button was clicked.
*
* @param event the event to check
*
* @return true if right mouse was clicked, false otherwise.
*/
public static boolean isRightMouseButton(MouseEvent event)
{
return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK)
== InputEvent.BUTTON3_DOWN_MASK);
}
}

View file

@ -47,44 +47,107 @@ import javax.swing.event.EventListenerList;
public class Timer implements Serializable
{
private static final long serialVersionUID = -1116180831621385484L;
protected EventListenerList listenerList = new EventListenerList();
int ticks;
static boolean verbose;
// This object manages a "queue" of virtual actionEvents, maintained as a
// simple long counter. When the timer expires, a new event is queued,
// and a dispatcher object is pushed into the system event queue. When
// the system thread runs the dispatcher, it will fire as many
// ActionEvents as have been queued, unless the timer is set to
// coalescing mode, in which case it will fire only one ActionEvent.
private long queue;
private Object queueLock = new Object();
private void queueEvent()
{
synchronized (queueLock)
{
queue++;
if (queue == 1)
SwingUtilities.invokeLater(new Runnable() { public void run() { drainEvents(); } });
}
}
private void drainEvents()
{
synchronized (queueLock)
{
if (isCoalesce())
{
if (queue > 0)
fireActionPerformed();
}
else
{
while(queue > 0)
{
fireActionPerformed();
queue--;
}
}
queue = 0;
}
}
static boolean logTimers;
boolean coalesce = true;
boolean repeats = true;
boolean running;
boolean repeat_ticks = true;
long interval, init_delay;
int ticks;
int delay;
int initialDelay;
class Waker extends Thread
private class Waker
extends Thread
{
public void run()
{
running = true;
try {
sleep(init_delay);
while (running)
{
sleep(interval);
try
{
if (verbose)
{
System.out.println("javax.swing.Timer -> clocktick");
}
ticks++;
fireActionPerformed();
if (! repeat_ticks)
break;
}
running = false;
} catch (Exception e) {
System.out.println("swing.Timer::" + e);
}
sleep(initialDelay);
while (running)
{
sleep(delay);
if (logTimers)
System.out.println("javax.swing.Timer -> clocktick");
if (! repeats)
break;
}
running = false;
}
catch (Exception e)
{
System.out.println("swing.Timer::" + e);
}
}
}
public Timer(int d, ActionListener listener)
{
delay = d;
if (listener != null)
addActionListener(listener);
}
public void setCoalesce(boolean c)
{
coalesce = c;
}
public boolean isCoalesce()
{
return coalesce;
}
public void addActionListener(ActionListener listener)
{
listenerList.add (ActionListener.class, listener);
@ -123,37 +186,47 @@ public class Timer implements Serializable
void fireActionPerformed ()
{
fireActionPerformed (new ActionEvent (this, ticks, "Timer"));
fireActionPerformed (new ActionEvent (this, ticks++, "Timer"));
}
public static void setLogTimers(boolean flag)
public static void setLogTimers(boolean lt)
{
verbose = flag;
logTimers = lt;
}
public static boolean getLogTimers()
{
return verbose;
return logTimers;
}
public void setDelay(int delay)
public void setDelay(int d)
{
interval = delay;
delay = d;
}
public int getDelay()
{
return (int)interval;
return delay;
}
public void setInitialDelay(int initialDelay)
public void setInitialDelay(int i)
{
init_delay = initialDelay;
initialDelay = i;
}
public void setRepeats(boolean flag)
public int getInitialDelay()
{
repeat_ticks = flag;
return initialDelay;
}
public void setRepeats(boolean r)
{
repeats = r;
}
public boolean isRepeats()
{
return repeats;
}
public boolean isRunning()
@ -171,6 +244,15 @@ public class Timer implements Serializable
new Waker().start();
}
public void restart()
{
synchronized (queueLock)
{
queue = 0;
}
start();
}
public void stop()
{
running = false;

View file

@ -71,7 +71,6 @@ public class ViewportLayout implements LayoutManager, Serializable
{
Scrollable sc = (Scrollable) view;
Dimension d = sc.getPreferredScrollableViewportSize();
// System.err.println(this + ".preferredLayoutSize() : scrollable -> " + d);
return d;
}
else
@ -83,20 +82,84 @@ public class ViewportLayout implements LayoutManager, Serializable
Component view = vp.getView();
return view.getMinimumSize();
}
/**
* Layout the view and viewport to respect the following rules. These are
* not precisely the rules described in sun's javadocs, but they are the
* rules which sun's swing implementation follows, if you watch its
* behavior:
*
* <ol>
*
* <li>If the port is larger than the view's minimum size, put the port
* at view position <code>(0,0)</code> and make the view's size equal to
* the port's.</li>
*
* <li>If the port is smaller than the view, leave the view at its
* minimum size. also, do not move the port, <em>unless</em> the port
* extends into space <em>past</em> the edge of the view. If so, move the
* port up or to the left, in view space, by the amount of empty space
* (keep the lower and right edges lined up)</li>
*
* </ol>
*
* @see JViewport#getViewSize
* @see JViewport#setViewSize
* @see JViewport#getViewPosition
* @see JViewport#setViewPosition
*/
public void layoutContainer(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
Rectangle portBounds = vp.getBounds();
// The way to interpret this function is basically to ignore the names
// of methods it calls, and focus on the variable names here. getViewRect
// doesn't, for example, return the view; it returns the port bounds in
// view space. Likwise setViewPosition doesn't reposition the view; it
// positions the port, in view coordinates.
JViewport port = (JViewport) parent;
Component view = port.getView();
// These dimensions and positions are in *view space*. Do not mix
// variables in here from port space (eg. parent.getBounds()). This
// function should be entirely in view space, because the methods on
// the viewport require inputs in view space.
Rectangle portBounds = port.getViewRect();
Dimension viewSize = port.getViewSize();
Dimension viewMinimum = view.getMinimumSize();
int width = Math.max(portBounds.width,
viewMinimum.width);
int height = Math.max(portBounds.height,
viewMinimum.height);
int x = Math.min(0, portBounds.width - width);
int y = Math.min(0, portBounds.height - height);
// System.err.println(this + ".layoutContainer() : width = " + width + ", height = " + height);
vp.setViewPosition(new Point(x, y));
vp.setViewSize(new Dimension(width, height));
Point portLowerRight = new Point(portBounds.x + portBounds.width,
portBounds.y + portBounds.height);
// vertical implementation of the above rules
if (portBounds.height >= viewMinimum.height)
{
portBounds.y = 0;
viewSize.height = portBounds.height;
}
else
{
viewSize.height = viewMinimum.height;
int overextension = portLowerRight.y - viewSize.height;
if (overextension > 0)
portBounds.y -= overextension;
}
// horizontal implementation of the above rules
if (portBounds.width >= viewMinimum.width)
{
portBounds.x = 0;
viewSize.width = portBounds.width;
}
else
{
viewSize.width = viewMinimum.width;
int overextension = portLowerRight.x - viewSize.width;
if (overextension > 0)
portBounds.x -= overextension;
}
port.setViewPosition(portBounds.getLocation());
port.setViewSize(viewSize);
}
}

View file

@ -87,68 +87,49 @@ public interface DocumentEvent {
} // ElementChange
/**
* EventType
*/
class EventType {
/**
* EventType
*/
class EventType
{
/**
* INSERT
*/
public static final EventType INSERT = new EventType("INSERT"); // TODO
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* REMOVE
*/
public static final EventType REMOVE = new EventType("REMOVE"); // TODO
/**
* INSERT
*/
EventType INSERT = new EventType("INSERT"); // TODO
/**
* CHANGE
*/
public static final EventType CHANGE = new EventType("CHANGE"); // TODO
/**
* REMOVE
*/
EventType REMOVE = new EventType("REMOVE"); // TODO
/**
* typeString
*/
private String type;
/**
* CHANGE
*/
EventType CHANGE = new EventType("CHANGE"); // TODO
/**
* Constructor EventType
* @param type TODO
*/
private EventType(String type)
{
this.type = type;
}
/**
* typeString
*/
private String type;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor EventType
* @param type TODO
*/
private EventType(String type) {
this.type = type;
} // EventType()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* toString
* @returns String
*/
public String toString() {
return type; // TODO
} // toString()
} // EventType
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* toString
* @returns String
*/
public String toString()
{
return type;
}
}
/**
* getType

View file

@ -1,5 +1,5 @@
/* UndoableEditListener.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -37,21 +37,20 @@ exception statement from your version. */
package javax.swing.event;
// Imports
import java.util.EventListener;
/**
* UndoableEditListener public interface
* @author Andrew Selkirk
* @author Ronald Veldema
*/
public interface UndoableEditListener extends EventListener {
/**
* Undoable edit has happened
* @param event Undoable Edit Event
*/
void undoableEditHappened(UndoableEditEvent event);
} // UndoableEditListener
public interface UndoableEditListener extends EventListener
{
/**
* Undoable edit has happened
*
* @param event Undoable Edit Event
*/
void undoableEditHappened(UndoableEditEvent event);
}

View file

@ -270,6 +270,8 @@ public class BorderUIResource
extends BevelBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = -1275542891108351642L;
/**
* Constructs a BevelBorderUIResource whose colors will be derived
* from the background of the enclosed component. The background
@ -399,6 +401,8 @@ public class BorderUIResource
extends CompoundBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = 7550017084975167341L;
/**
* Constructs a CompoundBorderUIResource with the specified inside
* and outside borders.
@ -441,6 +445,8 @@ public class BorderUIResource
extends EmptyBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = -4914187529340071708L;
/**
* Constructs an empty border given the number of pixels required
* on each side.
@ -496,6 +502,8 @@ public class BorderUIResource
extends EtchedBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = -8186391754165296656L;
/**
* Constructs an EtchedBorderUIResource that appears lowered into
* the surface. The colors will be derived from the background
@ -597,6 +605,8 @@ public class BorderUIResource
extends LineBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = -6171232338180172310L;
/**
* Constructs a LineBorderUIResource given its color. The border
* will be one pixel thick and have plain corners.
@ -652,6 +662,8 @@ public class BorderUIResource
extends MatteBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = -8107923147541851122L;
/**
* Constructs a MatteBorderUIResource given the width on each side
* and a fill color.
@ -731,6 +743,8 @@ public class BorderUIResource
extends TitledBorder
implements UIResource, Serializable
{
private static final long serialVersionUID = 7667113547406407427L;
/**
* Constructs a TitledBorderUIResource given the text of its title.
*

View file

@ -304,11 +304,7 @@ public class BasicButtonUI extends ButtonUI
Icon i = currentIcon(b);
if (i != null)
{
int x = iconRect.x;
int y = iconRect.y;
i.paintIcon(c, g, x, y);
}
i.paintIcon(c, g, iconRect.x, iconRect.y);
}
/**
@ -340,7 +336,7 @@ public class BasicButtonUI extends ButtonUI
*/
protected void paintButtonNormal(Graphics g, Rectangle area, JComponent b)
{
if (((AbstractButton)b).isContentAreaFilled())
if (((AbstractButton)b).isContentAreaFilled() && b.isOpaque())
{
g.setColor(b.getBackground());
g.fillRect(area.x, area.y, area.width, area.height);
@ -362,9 +358,18 @@ public class BasicButtonUI extends ButtonUI
Font f = c.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
g.setColor(c.getForeground());
BasicGraphicsUtils.drawString(g, text, 0,
textRect.x,
textRect.y + fm.getAscent());
if (c.isEnabled())
{
g.setColor(c.getForeground());
g.drawString(text, textRect.x, textRect.y + fm.getAscent());
}
else
{
g.setColor(c.getBackground().brighter());
g.drawString(text, textRect.x, textRect.y + fm.getAscent());
g.setColor(c.getBackground().darker());
g.drawString(text, textRect.x + 1, textRect.y + fm.getAscent() + 1);
}
}
}

View file

@ -0,0 +1,589 @@
/* BasicDesktopIconUI.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.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JInternalFrame.JDesktopIcon;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.event.MouseInputAdapter;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.DesktopIconUI;
import javax.swing.plaf.DesktopPaneUI;
/**
* This class acts as the UI delegate for JDesktopIcons for the Basic look and feel.
*/
public class BasicDesktopIconUI extends DesktopIconUI
{
/**
* This helper class handles mouse events that occur on the JDesktopIcon.
*/
public class MouseInputHandler extends MouseInputAdapter
{
/** The x offset from the MouseEvent coordinates to the top left corner. */
private transient int xOffset;
/** The y offset fromt he MouseEvent coordinates to the top left corner. */
private transient int yOffset;
/** A cached value of the JDesktopPane that parents this JDesktopIcon. */
private transient JDesktopPane pane;
/**
* This method is called when the mouse is dragged in the JDesktopIcon.
*
* @param e The MouseEvent.
*/
public void mouseDragged(MouseEvent e)
{
Rectangle b = desktopIcon.getBounds();
moveAndRepaint(desktopIcon, b.x + e.getX() - xOffset,
b.y + e.getY() - yOffset, b.width, b.height);
}
/**
* This method is called when the mouse is moved in the JDesktopIcon.
*
* @param e The MouseEvent.
*/
public void mouseMoved(MouseEvent e)
{
// Nothing to do.
}
/**
* This method is called when the mouse is pressed in the JDesktopIcon.
*
* @param e The MouseEvent.
*/
public void mousePressed(MouseEvent e)
{
xOffset = e.getX();
yOffset = e.getY();
pane = frame.getDesktopPane();
if (pane != null)
pane.getDesktopManager().beginDraggingFrame(desktopIcon);
}
/**
* This method is called when the mouse is released in the JDesktopIcon.
*
* @param e The MouseEvent.
*/
public void mouseReleased(MouseEvent e)
{
if (pane != null)
pane.getDesktopManager().endDraggingFrame(desktopIcon);
xOffset = 0;
yOffset = 0;
}
/**
* This method moves and repaints the JDesktopIcon to the given bounds.
*
* @param f The JComponent to move and repaint.
* @param newX The new x coordinate.
* @param newY The new y coordinate.
* @param newWidth The new width.
* @param newHeight The new height.
*/
public void moveAndRepaint(JComponent f, int newX, int newY, int newWidth,
int newHeight)
{
if (pane != null)
pane.getDesktopManager().dragFrame(f, newX, newY);
else
desktopIcon.setBounds(newX, newY, newWidth, newHeight);
}
}
/**
* This class acts as the border for the JDesktopIcon.
*/
private class DesktopIconBorder implements Border
{
/** The left inset value. */
int left = 10;
/** The top inset value. */
int top = 4;
/** The right inset value. */
int right = top;
/** The bottom inset value. */
int bottom = top;
/**
* This method returns the insets of the border.
*
* @param c The Component to find border insets for.
*
* @return The border insets.
*/
public Insets getBorderInsets(Component c)
{
return new Insets(top, left, bottom, right);
}
/**
* This method returns whether the border is opaque.
*
* @return Whether the border is opaque.
*/
public boolean isBorderOpaque()
{
return true;
}
/**
* This method paints the border.
*
* @param c The Component the border is in.
* @param g The Graphics object to paint with.
* @param x The x coordinate of the Component.
* @param y The y coordinate of the Component.
* @param width The width of the Component.
* @param height The height of the Component.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width,
int height)
{
g.translate(x, y);
Color saved = g.getColor();
g.setColor(Color.LIGHT_GRAY);
g.fillRect(0, 0, left, height);
g.fillRect(0, 0, width, top);
g.fillRect(0, height - bottom, width, bottom);
g.fillRect(width - right, 0, right, height);
g.setColor(Color.BLACK);
g.drawRect(0, 0, width - 1, height - 1);
int fHeight = height / 4;
int hLeft = left / 2;
g.setColor(Color.BLACK);
g.fillRect(hLeft, fHeight, 2, 2);
g.fillRect(hLeft, fHeight * 2, 2, 2);
g.fillRect(hLeft, fHeight * 3, 2, 2);
g.setColor(saved);
g.translate(-x, -y);
}
}
/** The static width and height of the iconSize. */
private static final int iconSize = 16;
/**
* This class represents the default frame icon when none
* is supplied by the JInternalFrame.
*/
static class InternalFrameDefaultMenuIcon implements Icon
{
/**
* This returns the icon height.
*
* @return The icon height.
*/
public int getIconHeight()
{
return iconSize;
}
/**
* This returns the icon width.
*
* @return The icon width.
*/
public int getIconWidth()
{
return iconSize;
}
/**
* This method paints the icon.
*
* @param c The Component this icon belongs to.
* @param g The Graphics object to paint with.
* @param x The x coordinate to paint at.
* @param y The y coordinate to paint at.
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
g.translate(x, y);
Color saved = g.getColor();
g.setColor(Color.BLUE);
g.fillRect(0, 0, iconSize, (int) ((double) iconSize / 3) + 1);
g.setColor(Color.WHITE);
g.fillRect(0, (int) ((double) iconSize / 3), iconSize, iconSize * 5 / 6);
g.setColor(Color.GRAY);
g.drawRect(0, 0, iconSize, iconSize);
g.setColor(saved);
g.translate(-x, -y);
}
}
/** The default JDesktopIcon width. */
private static final int iconWidth = 160;
/** The default JDesktopIcon height */
private static final int iconHeight = 35;
/** The JDesktopIcon this UI delegate represents. */
protected JDesktopIcon desktopIcon;
/** The JInternalFrame associated with the JDesktopIcon. */
protected JInternalFrame frame;
/** The MouseListener responsible for reacting to MouseEvents on the JDesktopIcon. */
private transient MouseInputListener mouseHandler;
/** The Button in the JDesktopIcon responsible for deiconifying it. */
private transient BoundButton button;
/** The PropertyChangeListener listening to the JDesktopIcon. */
private transient PropertyChangeListener propertyHandler;
/** The default icon used when no frame icon is given by the JInternalFrame. */
static Icon defaultIcon = new InternalFrameDefaultMenuIcon();
/**
* This is a helper class that is used in JDesktopIcon and gives the Button a predetermined size.
*/
private class BoundButton extends JButton
{
/**
* Creates a new BoundButton object.
*
* @param title The title of the button.
*/
public BoundButton(String title)
{
super(title);
}
/**
* This method returns a standard size (based on the defaults of the JDesktopIcon) and the insets.
*
* @return The preferred size of the JDesktopIcon.
*/
public Dimension getPreferredSize()
{
Insets insets = desktopIcon.getInsets();
return new Dimension(iconWidth - insets.left - insets.right,
iconHeight - insets.top - insets.bottom);
}
/**
* This method returns the minimum size of the button.
*
* @return The minimum size of the button.
*/
public Dimension getMinimumSize()
{
return getPreferredSize();
}
/**
* This method returns the maximum size of the button.
*
* @return The maximum size of the button.
*/
public Dimension getMaximumSize()
{
return getPreferredSize();
}
}
/**
* Creates a new BasicDesktopIconUI object.
*/
public BasicDesktopIconUI()
{
}
/**
* This method creates a new BasicDesktopIconUI for the given JComponent.
*
* @param c The JComponent to create a UI for.
*
* @return A new BasicDesktopIconUI.
*/
public static ComponentUI createUI(JComponent c)
{
return new BasicDesktopIconUI();
}
/**
* This method installs the UI for the given JComponent.
*
* @param c The JComponent to install this UI for.
*/
public void installUI(JComponent c)
{
if (c instanceof JDesktopIcon)
{
desktopIcon = (JDesktopIcon) c;
desktopIcon.setLayout(new BorderLayout());
frame = desktopIcon.getInternalFrame();
installDefaults();
installComponents();
installListeners();
desktopIcon.setOpaque(true);
}
}
/**
* This method uninstalls the UI for the given JComponent.
*
* @param c The JComponent to uninstall this UI for.
*/
public void uninstallUI(JComponent c)
{
desktopIcon.setOpaque(false);
uninstallListeners();
uninstallComponents();
uninstallDefaults();
frame = null;
desktopIcon.setLayout(null);
desktopIcon = null;
}
/**
* This method installs the necessary sub components for the JDesktopIcon.
*/
protected void installComponents()
{
// Try to create a button based on what the frame's
// state is currently
button = new BoundButton(frame.getTitle());
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setHorizontalTextPosition(SwingConstants.TRAILING);
Icon use = frame.getFrameIcon();
if (use == null)
use = defaultIcon;
button.setIcon(use);
desktopIcon.add(button, SwingConstants.CENTER);
}
/**
* This method uninstalls the sub components for the JDesktopIcon.
*/
protected void uninstallComponents()
{
desktopIcon.remove(button);
button = null;
}
/**
* This method installs the listeners needed by this UI.
*/
protected void installListeners()
{
mouseHandler = createMouseInputListener();
desktopIcon.addMouseMotionListener(mouseHandler);
desktopIcon.addMouseListener(mouseHandler);
propertyHandler = new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent e)
{
if (e.getPropertyName().equals(JInternalFrame.TITLE_PROPERTY))
button.setText(desktopIcon.getInternalFrame().getTitle());
else if (e.getPropertyName().equals(JInternalFrame.FRAME_ICON_PROPERTY))
{
Icon use = desktopIcon.getInternalFrame().getFrameIcon();
if (use == null)
use = defaultIcon;
button.setIcon(use);
}
desktopIcon.revalidate();
desktopIcon.repaint();
}
};
frame.addPropertyChangeListener(propertyHandler);
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
deiconize();
}
});
}
/**
* This method uninstalls the listeners needed by the UI.
*/
protected void uninstallListeners()
{
// button is nulled so no need to remove it.
frame.removePropertyChangeListener(propertyHandler);
propertyHandler = null;
desktopIcon.removeMouseMotionListener(mouseHandler);
desktopIcon.removeMouseListener(mouseHandler);
}
/**
* This method installs the defaults for the JDesktopIcon.
*/
protected void installDefaults()
{
// FIXME: Move border to defaults.
desktopIcon.setBorder(new DesktopIconBorder());
}
/**
* This method uninstalls the defaults for the JDesktopIcon.
*/
protected void uninstallDefaults()
{
desktopIcon.setBorder(null);
}
/**
* This method creates a new MouseInputListener for the JDesktopIcon.
*
* @return A new MouseInputListener.
*/
protected MouseInputListener createMouseInputListener()
{
return new MouseInputHandler();
}
/**
* This method returns the preferred size for the given JComponent.
*
* @param c The JComponent to find a preferred size for.
*
* @return The preferred size.
*/
public Dimension getPreferredSize(JComponent c)
{
return new Dimension(iconWidth, iconHeight);
}
/**
* This method returns the minimum size for the given JComponent.
*
* @param c The JComponent to find a minimum size for.
*
* @return The minimum size.
*/
public Dimension getMinimumSize(JComponent c)
{
return getPreferredSize(c);
}
/**
* This method returns the maximum size for the given JComponent.
*
* @param c The JComponent to find a maximum size for.
*
* @return The maximum size.
*/
public Dimension getMaximumSize(JComponent c)
{
return getPreferredSize(c);
}
/**
* This method returns the insets of the given JComponent.
*
* @param c The JComponent to find insets for.
*
* @return The insets of the given JComponent.
*/
public Insets getInsets(JComponent c)
{
return c.getInsets();
}
/**
* This method deiconizes the JInternalFrame associated with the JDesktopIcon.
*/
public void deiconize()
{
try
{
frame.setIcon(false);
}
catch (PropertyVetoException pve)
{
}
}
}

View file

@ -0,0 +1,459 @@
/* BasicDesktopPaneUI.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.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyVetoException;
import javax.swing.AbstractAction;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JInternalFrame.JDesktopIcon;
import javax.swing.KeyStroke;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.MouseInputAdapter;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.DesktopIconUI;
import javax.swing.plaf.DesktopPaneUI;
/**
* This class is the UI delegate for JDesktopPane for the Basic look and feel.
*/
public class BasicDesktopPaneUI extends DesktopPaneUI
{
/**
* This helper class is used to handle key events that cause JInternalFrames
* to be closed.
*/
protected class CloseAction extends AbstractAction
{
/**
* This method is called when the action is performed.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
if (desktop.getSelectedFrame() != null)
{
try
{
desktop.getSelectedFrame().setClosed(true);
}
catch (PropertyVetoException pve)
{
}
}
}
/**
* This method returns whether the action is enabled.
*
* @return Whether the action is enabled.
*/
public boolean isEnabled()
{
if (desktop.getSelectedFrame() != null)
return desktop.getSelectedFrame().isClosable();
return false;
}
}
/**
* This helper class is used to handle key events that cause JInternalFrames
* to be maximized.
*/
protected class MaximizeAction extends AbstractAction
{
/**
* This method is called when the action is performed.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
if (desktop.getSelectedFrame() != null)
{
try
{
desktop.getSelectedFrame().setMaximum(true);
}
catch (PropertyVetoException pve)
{
}
}
}
/**
* This method returns whether the action is enabled.
*
* @return Whether the action is enabled.
*/
public boolean isEnabled()
{
if (desktop.getSelectedFrame() != null)
return desktop.getSelectedFrame().isMaximizable();
return false;
}
}
/**
* This helper class is used to handle key events that cause JInternalFrames
* to be minimized.
*/
protected class MinimizeAction extends AbstractAction
{
/**
* This method is called when the action is performed.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
if (desktop.getSelectedFrame() != null)
{
try
{
desktop.getSelectedFrame().setIcon(true);
}
catch (PropertyVetoException pve)
{
}
}
}
/**
* This method returns whether the action is enabled.
*
* @return Whether the action is enabled.
*/
public boolean isEnabled()
{
if (desktop.getSelectedFrame() != null)
return desktop.getSelectedFrame().isIconifiable();
return false;
}
}
/**
* This helper class is used to handle key events that pass the SELECTED
* property to the next JInternalFrame in the JDesktopPane's list of
* children.
*/
protected class NavigateAction extends AbstractAction
{
/**
* This method is called when the action is performed.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
// This is supposed to set the next selected frame.
JInternalFrame[] frames = desktop.getAllFrames();
if (frames.length == 0)
return;
JInternalFrame sFrame = frames[0];
if (desktop.getSelectedFrame() != null)
sFrame = desktop.getSelectedFrame();
int i = 0;
for (; i < frames.length; i++)
if (frames[i] == sFrame)
break;
// FIXME: Navigate actions go reverse too.
if (i == frames.length)
i = 0;
desktop.setSelectedFrame(frames[i]);
}
/**
* This method returns whether the action is enabled.
*
* @return Whether this action is enabled.
*/
public boolean isEnabled()
{
// Always true.
return true;
}
}
/**
* This helper class is used to restore the JInternalFrame to its original
* size before maximizing or iconifying.
*/
protected class OpenAction extends AbstractAction
{
/**
* This method is called when the action is performed.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
JInternalFrame frame = desktop.getSelectedFrame();
if (frame != null)
{
try
{
if (frame.isIcon())
frame.setIcon(false);
else if (frame.isMaximum())
frame.setMaximum(false);
}
catch (PropertyVetoException pve)
{
}
}
}
/**
* This method returns whether the action is enabled.
*
* @return Whether this action is enabled.
*/
public boolean isEnabled()
{
// JInternalFrames are always restorable.
return true;
}
}
/** The KeyStroke associated with closing JInternalFrames. */
protected KeyStroke closeKey;
/** The KeyStroke associated with maximizing JInternalFrames. */
protected KeyStroke maximizeKey;
/** The KeyStroke associated with minimizing JInternalFrames. */
protected KeyStroke minimizeKey;
/**
* The KeyStroke associated with navigating (forward?) through
* JInternalFrames.
*/
protected KeyStroke navigateKey;
/**
* The KeyStroke associated with navigating (backward?) through
* JInternalFrames.
*/
protected KeyStroke navigateKey2;
/** The default desktop manager used with JDesktopPane. */
protected DesktopManager desktopManager;
/** The JDesktopPane this UI is used with. */
protected JDesktopPane desktop;
/**
* Creates a new BasicDesktopPaneUI object.
*/
public BasicDesktopPaneUI()
{
}
/**
* This method creates a BasicDesktopPaneUI for the given JComponent.
*
* @param c The JComponent to create a UI for.
*
* @return A new BasicDesktopPaneUI.
*/
public static ComponentUI createUI(JComponent c)
{
return new BasicDesktopPaneUI();
}
/**
* This method returns the maximum size for the given JComponent.
*
* @param c The JComponent to find a maximum size for.
*
* @return The maximum size for the given JComponent.
*/
public Dimension getMaximumSize(JComponent c)
{
return getPreferredSize(c);
}
/**
* This method returns the minimum size for the given JComponent.
*
* @param c The JComponent to find a minimum size for.
*
* @return The minimum size for the given JComponent.
*/
public Dimension getMinimumSize(JComponent c)
{
return getPreferredSize(c);
}
/**
* This method returns the preferred size for the given JComponent.
*
* @param c The JComponent to find a preferred size for.
*
* @return The preferred size for the given JComponent.
*/
public Dimension getPreferredSize(JComponent c)
{
// return null because JDesktopPanes don't have preferred sizes.
return null;
}
/**
* This method installs the defaults for the JDesktopPane provided by the
* current look and feel.
*/
protected void installDefaults()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
desktop.setBackground(defaults.getColor("Desktop.background"));
}
/**
* This method installs the desktop manager for the JDesktopPane.
*/
protected void installDesktopManager()
{
desktopManager = new DefaultDesktopManager();
desktop.setDesktopManager(desktopManager);
}
/**
* This method installs the keyboard actions for the JDesktopPane.
*/
protected void installKeyboardActions()
{
// FIXME: create actions and keystrokes.
registerKeyboardAction();
}
/**
* This method installs the UI for the given JComponent.
*
* @param c The JComponent to install this UI for.
*/
public void installUI(JComponent c)
{
if (c instanceof JDesktopPane)
{
desktop = (JDesktopPane) c;
installDefaults();
installDesktopManager();
installKeyboardActions();
}
}
/**
* This method registers the actions to the appropriate Action and Input
* maps.
*/
protected void registerKeyboardAction()
{
// FIXME: Do the binding.
// XXX: the gtk windows tend to intercept a lot of the
// key events for themselves. must figure a way past that
// before binding
}
/**
* This method reverses the work done by the installDefaults method.
*/
protected void uninstallDefaults()
{
desktop.setBackground(null);
}
/**
* This method reverses the work done by the installDesktopManager method.
*/
protected void uninstallDesktopManager()
{
desktopManager = null;
desktop.setDesktopManager(null);
}
/**
* This method reverses the work done by the installKeyboardActions method.
*/
protected void uninstallKeyboardActions()
{
unregisterKeyboardActions();
// FIXME: null the actions and keystrokes.
}
/**
* This method reverses the work done by the registerKeyboardActions method.
*/
protected void unregisterKeyboardActions()
{
// FIXME: unmap the keystrokes
}
/**
* This method uninstalls the UI for the given JComponent. It should reverse
* all the work done by the installUI method.
*
* @param c The JComponent to uninstall this UI for.
*/
public void uninstallUI(JComponent c)
{
uninstallKeyboardActions();
uninstallDesktopManager();
uninstallDefaults();
desktop = null;
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -110,6 +110,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"DesktopIconUI", "javax.swing.plaf.basic.BasicDesktopIconUI",
"DesktopPaneUI", "javax.swing.plaf.basic.BasicDesktopPaneUI",
"EditorPaneUI", "javax.swing.plaf.basic.BasicEditorPaneUI",
"FormattedTextFieldUI", "javax.swing.plaf.basic.BasicFormattedTextFieldUI",
"InternalFrameUI", "javax.swing.plaf.basic.BasicInternalFrameUI",
"LabelUI", "javax.swing.plaf.basic.BasicLabelUI",
"ListUI", "javax.swing.plaf.basic.BasicListUI",
@ -205,15 +206,15 @@ public abstract class BasicLookAndFeel extends LookAndFeel
private void loadResourceBundle(UIDefaults defaults)
{
ResourceBundle bundle;
Enumeration enum;
Enumeration e;
String key;
String value;
bundle = ResourceBundle.getBundle("resources/basic");
// Process Resources
enum = bundle.getKeys();
while (enum.hasMoreElements())
e = bundle.getKeys();
while (e.hasMoreElements())
{
key = (String) enum.nextElement();
key = (String) e.nextElement();
value = bundle.getString(key);
defaults.put(key, value);
}
@ -346,7 +347,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl F10", "maximize",
"ctrl alt shift F6","selectPreviousFrame"
}),
"Desktop.background", new ColorUIResource(0, 92, 92),
"Desktop.background", new ColorUIResource(175, 163, 236),
"DesktopIcon.border", new BorderUIResource.CompoundBorderUIResource(null,
null),
"EditorPane.background", new ColorUIResource(Color.white),
@ -419,7 +420,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"FocusManagerClassName", "TODO",
"FormView.resetButtonText", "Reset",
"FormView.submitButtonText", "Submit Query",
"InternalFrame.activeTitleBackground", new ColorUIResource(lightPurple),
"InternalFrame.activeTitleBackground", new ColorUIResource(162, 167, 241),
"InternalFrame.activeTitleForeground", new ColorUIResource(Color.black),
"InternalFrame.border", new BorderUIResource.CompoundBorderUIResource(null,
null),
@ -427,8 +428,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
// XXX Don't use gif
"InternalFrame.icon", new IconUIResource(new ImageIcon("icons/JavaCup.gif")),
"InternalFrame.iconifyIcon", BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.inactiveTitleBackground", new ColorUIResource(Color.gray),
"InternalFrame.inactiveTitleForeground", new ColorUIResource(Color.lightGray),
"InternalFrame.inactiveTitleBackground", new ColorUIResource(Color.lightGray),
"InternalFrame.inactiveTitleForeground", new ColorUIResource(Color.black),
"InternalFrame.maximizeIcon", BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.minimizeIcon", BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.titleFont", new FontUIResource("Dialog", Font.PLAIN, 12),
@ -703,7 +704,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl UP", "requestFocus",
"ctrl KP_UP", "requestFocus"
}),
"TabbedPane.background", new ColorUIResource(Color.GRAY),
"TabbedPane.background", new ColorUIResource(Color.LIGHT_GRAY),
"TabbedPane.contentBorderInsets", new InsetsUIResource(2, 2, 3, 3),
"TabbedPane.darkShadow", new ColorUIResource(Color.darkGray),
"TabbedPane.focus", new ColorUIResource(Color.black),

View file

@ -1,5 +1,5 @@
/* BasicMenuUI.java
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
/* BasicMenuBarUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -37,11 +37,13 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.awt.Dimension;
import javax.swing.BoxLayout;
import javax.swing.ButtonModel;
import javax.swing.Icon;
@ -70,18 +72,22 @@ import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuBarUI;
import javax.swing.plaf.MenuItemUI;
import java.awt.Insets;
import java.awt.GridLayout;
/**
* DOCUMENT ME!
* UI Delegate for JMenuBar.
*/
public class BasicMenuBarUI extends MenuBarUI
{
protected ChangeListener changeListener;
/*ContainerListener that listens to the ContainerEvents fired from menu bar*/
protected ContainerListener containerListener;
/*Property change listeners that listener to PropertyChangeEvent from menu bar*/
protected PropertyChangeListener propertyChangeListener;
/* menu bar for which this UI delegate is for*/
protected JMenuBar menuBar;
/**
@ -105,21 +111,23 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Creates ContainerListener() to listen for ContainerEvents
* fired by JMenuBar
*
* @return DOCUMENT ME!
* @return The ContainerListener
*/
protected ContainerListener createContainerListener()
protected ContainerListener createContainerListener()
{
return new ContainerHandler();
}
/**
* DOCUMENT ME!
* Factory method to create a BasicMenuBarUI for the given {@link
* JComponent}, which should be a {@link JMenuBar}.
*
* @param x DOCUMENT ME!
* @param b The {@link JComponent} a UI is being created for.
*
* @return DOCUMENT ME!
* @return A BasicMenuBarUI for the {@link JComponent}.
*/
public static ComponentUI createUI(JComponent x)
{
@ -127,11 +135,11 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Returns maximum size for the specified menu bar
*
* @param c DOCUMENT ME!
* @param c component for which to get maximum size
*
* @return DOCUMENT ME!
* @return Maximum size for the specified menu bar
*/
public Dimension getMaximumSize(JComponent c)
{
@ -140,11 +148,11 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Returns maximum allowed size of JMenuBar.
*
* @param c DOCUMENT ME!
* @param c menuBar for which to return maximum size
*
* @return DOCUMENT ME!
* @return Maximum size of the give menu bar.
*/
public Dimension getMinimumSize(JComponent c)
{
@ -153,11 +161,11 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Returns preferred size of JMenuBar.
*
* @param c DOCUMENT ME!
* @param c menuBar for which to return preferred size
*
* @return DOCUMENT ME!
* @return Preferred size of the give menu bar.
*/
public Dimension getPreferredSize(JComponent c)
{
@ -166,7 +174,8 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* Initializes any default properties that this UI has from the defaults for
* the Basic look and feel.
*/
protected void installDefaults()
{
@ -179,26 +188,29 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* This method installs the keyboard actions for the JMenuBar.
*/
protected void installKeyboardActions()
{
// FIXME: implement
}
/**
* DOCUMENT ME!
* This method installs the listeners needed for this UI to function.
*/
protected void installListeners()
{
{
menuBar.addContainerListener(containerListener);
menuBar.addPropertyChangeListener(propertyChangeListener);
menuBar.addPropertyChangeListener(propertyChangeListener);
}
/**
* DOCUMENT ME!
*
* @param c 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 The {@link JComponent} that is having this UI installed.
*/
public void installUI(JComponent c)
{
super.installUI(c);
@ -206,10 +218,12 @@ public class BasicMenuBarUI extends MenuBarUI
menuBar.setLayout(new BoxLayout(menuBar, BoxLayout.X_AXIS));
installDefaults();
installListeners();
installKeyboardActions();
}
/**
* DOCUMENT ME!
* This method uninstalls the defaults and nulls any objects created during
* install.
*/
protected void uninstallDefaults()
{
@ -220,10 +234,11 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* DOCUMENT ME!
* This method reverses the work done in installKeyboardActions.
*/
protected void uninstallKeyboardActions()
{
// FIXME: implement.
}
/**
@ -236,15 +251,18 @@ public class BasicMenuBarUI extends MenuBarUI
}
/**
* 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)
{
uninstallDefaults();
uninstallListeners();
menuBar= null;
uninstallListeners();
uninstallKeyboardActions();
menuBar = null;
}
protected class ChangeHandler implements ChangeListener
@ -254,21 +272,47 @@ public class BasicMenuBarUI extends MenuBarUI
}
}
/**
* This class handles ContainerEvents fired by JMenuBar
*/
protected class ContainerHandler implements ContainerListener
{
/**
* This method is called whenever menu is added to the menu bar
*
* @param e The ContainerEvent.
*/
public void componentAdded(ContainerEvent e)
{
System.out.println("BasicMenuBar...componentAdded.. listener");
}
/**
* 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");
}
}
/**
* This class handles PropertyChangeEvents fired from the JMenuBar
*/
protected class PropertyChangeHandler implements PropertyChangeListener
{
/**
* This method is called whenever one of the properties of the MenuBar
* changes.
*
* @param e The PropertyChangeEvent.
*/
public void propertyChange(PropertyChangeEvent e)
{
if (e.getPropertyName().equals(JMenuBar.BORDER_PAINTED_CHANGED_PROPERTY))
menuBar.repaint();
}
}
}

View file

@ -1,5 +1,5 @@
/* BasicMenuItemUI.java
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
/* BasicMenuItemUI.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,6 +35,7 @@ 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;
@ -43,12 +44,15 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
@ -75,7 +79,7 @@ import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
* UI Delegate for JMenuItem.
*/
public class BasicMenuItemUI extends MenuItemUI
{
@ -156,6 +160,10 @@ public class BasicMenuItemUI extends MenuItemUI
* String that separates description of the modifiers and the key
*/
private String acceleratorDelimiter;
/**
* PropertyChangeListener to listen for property changes in the menu item
*/
private PropertyChangeListener propertyChangeListener;
/**
@ -163,6 +171,9 @@ public class BasicMenuItemUI extends MenuItemUI
*/
private int defaultAcceleratorLabelGap = 4;
/**
* Creates a new BasicMenuItemUI object.
*/
public BasicMenuItemUI()
{
mouseInputListener = createMouseInputListener(menuItem);
@ -171,17 +182,25 @@ public class BasicMenuItemUI extends MenuItemUI
propertyChangeListener = new PropertyChangeHandler();
}
/**
* Create MenuDragMouseListener to listen for mouse dragged events.
*
* @param c menu item to listen to
*
* @return The MenuDragMouseListener
*/
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
{
return new MenuDragMouseHandler();
}
/**
* DOCUMENT ME!
* Creates MenuKeyListener to listen to key events occuring when menu item
* is visible on the screen.
*
* @param c DOCUMENT ME!
* @param c menu item to listen to
*
* @return $returnType$ DOCUMENT ME!
* @return The MenuKeyListener
*/
protected MenuKeyListener createMenuKeyListener(JComponent c)
{
@ -189,11 +208,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Handles mouse input events occuring for this menu item
*
* @param c DOCUMENT ME!
* @param c menu item to listen to
*
* @return $returnType$ DOCUMENT ME!
* @return The MouseInputListener
*/
protected MouseInputListener createMouseInputListener(JComponent c)
{
@ -201,11 +220,12 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Factory method to create a BasicMenuItemUI for the given {@link
* JComponent}, which should be a {@link JMenuItem}.
*
* @param c DOCUMENT ME!
* @param c The {@link JComponent} a UI is being created for.
*
* @return $returnType$ DOCUMENT ME!
* @return A BasicMenuItemUI for the {@link JComponent}.
*/
public static ComponentUI createUI(JComponent c)
{
@ -213,9 +233,9 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Programatically clicks menu item.
*
* @param msm DOCUMENT ME!
* @param msm MenuSelectionManager for the menu hierarchy
*/
protected void doClick(MenuSelectionManager msm)
{
@ -224,11 +244,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Returns maximum size for the specified menu item
*
* @param c DOCUMENT ME!
* @param c component for which to get maximum size
*
* @return $returnType$ DOCUMENT ME!
* @return Maximum size for the specified menu item.
*/
public Dimension getMaximumSize(JComponent c)
{
@ -236,11 +256,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Returns minimum size for the specified menu item
*
* @param c DOCUMENT ME!
* @param c component for which to get minimum size
*
* @return $returnType$ DOCUMENT ME!
* @return Minimum size for the specified menu item.
*/
public Dimension getMinimumSize(JComponent c)
{
@ -248,17 +268,18 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Returns path to this menu item.
*
* @return $returnType$ DOCUMENT ME!
* @return $MenuElement[]$ Returns array of menu elements
* that constitute a path to this menu item.
*/
public MenuElement[] getPath()
{
Vector path = new Vector();
ArrayList path = new ArrayList();
Component c = menuItem;
while (c instanceof MenuElement)
{
path.add(c);
path.add(0, (MenuElement) c);
if (c instanceof JPopupMenu)
c = ((JPopupMenu) c).getInvoker();
@ -266,54 +287,51 @@ public class BasicMenuItemUI extends MenuItemUI
c = c.getParent();
}
// convert from vector to array
MenuElement[] pathArray = new MenuElement[path.size()];
for (int i = 0; i < path.size(); i++)
pathArray[i] = (MenuElement) path.get(path.size() - i - 1);
path.toArray(pathArray);
return pathArray;
}
/**
* DOCUMENT ME!
* Returns preferred size for the given menu item.
*
* @param c DOCUMENT ME!
* @param checkIcon DOCUMENT ME!
* @param arrowIcon DOCUMENT ME!
* @param defaultTextIconGap DOCUMENT ME!
* @param c menu item for which to get preferred size
* @param checkIcon chech icon displayed in the given menu item
* @param arrowIcon arrow icon displayed in the given menu item
* @param defaultTextIconGap space between icon and text in the given menuItem
*
* @return $returnType$ DOCUMENT ME!
* @return $Dimension$ preferred size for the given menu item
*/
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,
Icon arrowIcon,
int defaultTextIconGap)
{
// TODO
// FIXME: Need to implement.
return null;
}
/**
* DOCUMENT ME!
* Returns preferred size of the given component
*
* @param c DOCUMENT ME!
* @param c component for which to return preferred size
*
* @return $returnType$ DOCUMENT ME!
* @return $Dimension$ preferred size for the given component
*/
public Dimension getPreferredSize(JComponent c)
{
AbstractButton b = (AbstractButton) c;
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(b,
JMenuItem m = (JMenuItem) c;
Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m,
defaultTextIconGap);
// if menu item has accelerator then take accelerator's size into account
// when calculating preferred size.
KeyStroke accelerator = ((JMenuItem) c).getAccelerator();
KeyStroke accelerator = m.getAccelerator();
Rectangle rect;
if (accelerator != null)
{
rect = getAcceleratorRect(accelerator,
b.getToolkit().getFontMetrics(acceleratorFont));
m.getToolkit().getFontMetrics(acceleratorFont));
// add width of accelerator's text
d.width = d.width + rect.width + defaultAcceleratorLabelGap;
@ -349,22 +367,22 @@ public class BasicMenuItemUI extends MenuItemUI
*/
protected String getPropertyPrefix()
{
// TODO
return null;
}
/**
* DOCUMENT ME!
* This method installs the components for this {@link JMenuItem}.
*
* @param menuItem DOCUMENT ME!
* @param menuItem The {@link JMenuItem} to install components for.
*/
protected void installComponents(JMenuItem menuItem)
{
// TODO
// FIXME: Need to implement
}
/**
* DOCUMENT ME!
* This method installs the defaults that are defined in the Basic look and
* feel for this {@link JMenuItem}.
*/
protected void installDefaults()
{
@ -376,7 +394,6 @@ public class BasicMenuItemUI extends MenuItemUI
menuItem.setForeground(defaults.getColor("MenuItem.foreground"));
menuItem.setMargin(defaults.getInsets("MenuItem.margin"));
menuItem.setOpaque(true);
acceleratorFont = defaults.getFont("MenuItem.acceleratorFont");
acceleratorForeground = defaults.getColor("MenuItem.acceleratorForeground");
acceleratorSelectionForeground = defaults.getColor("MenuItem.acceleratorSelectionForeground");
@ -386,15 +403,15 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method installs the keyboard actions for this {@link JMenuItem}.
*/
protected void installKeyboardActions()
{
// TODO
// FIXME: Need to implement
}
/**
* DOCUMENT ME!
* This method installs the listeners for the {@link JMenuItem}.
*/
protected void installListeners()
{
@ -405,9 +422,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* 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)
{
@ -418,10 +437,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Paints given menu item using specified graphics context
*
* @param g DOCUMENT ME!
* @param c DOCUMENT ME!
* @param g The graphics context used to paint this menu item
* @param c Menu Item to paint
*/
public void paint(Graphics g, JComponent c)
{
@ -430,11 +449,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Paints background of the menu item
*
* @param g DOCUMENT ME!
* @param menuItem DOCUMENT ME!
* @param bgColor DOCUMENT ME!
* @param g The graphics context used to paint this menu item
* @param menuItem menu item to paint
* @param bgColor Background color to use when painting menu item
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
@ -446,21 +465,22 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Paints specified menu item
*
* @param g DOCUMENT ME!
* @param c DOCUMENT ME!
* @param checkIcon DOCUMENT ME!
* @param arrowIcon DOCUMENT ME!
* @param background DOCUMENT ME!
* @param foreground DOCUMENT ME!
* @param defaultTextIconGap DOCUMENT ME!
* @param g The graphics context used to paint this menu item
* @param c menu item to paint
* @param checkIcon check icon to use when painting menu item
* @param arrowIcon arrow icon to use when painting menu item
* @param background Background color of the menu item
* @param foreground Foreground color of the menu item
* @param defaultTextIconGap space to use between icon and
* text when painting menu item
*/
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon,
Icon arrowIcon, Color background,
Color foreground, int defaultTextIconGap)
{
AbstractButton b = (AbstractButton) c;
JMenuItem m = (JMenuItem) c;
Rectangle tr = new Rectangle(); // text rectangle
Rectangle ir = new Rectangle(); // icon rectangle
Rectangle vr = new Rectangle(); // view rectangle
@ -468,41 +488,53 @@ public class BasicMenuItemUI extends MenuItemUI
Rectangle ar = new Rectangle(); // accelerator rectangle
Rectangle cr = new Rectangle(); // checkIcon rectangle
int vertAlign = b.getVerticalAlignment();
int horAlign = b.getHorizontalAlignment();
int vertTextPos = b.getVerticalTextPosition();
int horTextPos = b.getHorizontalTextPosition();
int vertAlign = m.getVerticalAlignment();
int horAlign = m.getHorizontalAlignment();
int vertTextPos = m.getVerticalTextPosition();
int horTextPos = m.getHorizontalTextPosition();
Font f = c.getFont();
Font f = m.getFont();
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
SwingUtilities.calculateInnerArea(b, br);
SwingUtilities.calculateInsetArea(br, b.getMargin(), vr);
paintBackground(g, (JMenuItem) c, c.getBackground());
SwingUtilities.calculateInnerArea(m, br);
SwingUtilities.calculateInsetArea(br, m.getInsets(), vr);
paintBackground(g, m, m.getBackground());
if ((b.getModel().isArmed() && b.getModel().isPressed()))
/* MenuItems insets are equal to menuItems margin, space between text and
menuItems border. We need to paint insets region as well. */
Insets insets = m.getInsets();
br.x -= insets.left;
br.y -= insets.top;
br.width += insets.right + insets.left;
br.height += insets.top + insets.bottom;
/* Menu item is considered to be highlighted when it is selected.
It is considered to be selected if menu item is inside some menu
and is armed or if it is both armed and pressed */
if (m.getModel().isArmed()
&& (m.getParent() instanceof MenuElement || m.getModel().isPressed()))
{
if (((AbstractButton) b).isContentAreaFilled())
if (m.isContentAreaFilled())
{
g.setColor(b.getBackground().darker());
g.setColor(m.getBackground().darker());
g.fillRect(br.x, br.y, br.width, br.height);
}
}
else
{
if (((AbstractButton) b).isContentAreaFilled())
if (m.isContentAreaFilled())
{
g.setColor(b.getBackground());
g.setColor(m.getBackground());
g.fillRect(br.x, br.y, br.width, br.height);
}
}
if (checkIcon != null)
{
SwingUtilities.layoutCompoundLabel(c, fm, null, checkIcon, vertAlign,
SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,
horAlign, vertTextPos, horTextPos,
vr, cr, tr, defaultTextIconGap);
checkIcon.paintIcon(c, g, cr.x, cr.y);
checkIcon.paintIcon(m, g, cr.x, cr.y);
// We need to calculate position of the menu text and position of
// user menu icon if there exists one relative to the check icon.
@ -518,25 +550,25 @@ public class BasicMenuItemUI extends MenuItemUI
int width = arrowIcon.getIconWidth();
int height = arrowIcon.getIconHeight();
arrowIcon.paintIcon(c, g, vr.width - width + defaultTextIconGap,
arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,
vr.y + 2);
}
}
// paint text and user menu icon if it exists
SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(),
SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),
vertAlign, horAlign, vertTextPos,
horTextPos, vr, ir, tr,
defaultTextIconGap);
paintText(g, (JMenuItem) c, tr, b.getText());
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 = b.getIcon();
Icon i = m.getIcon();
if (i != null)
{
int x = ir.x;
@ -548,30 +580,31 @@ public class BasicMenuItemUI extends MenuItemUI
// paint accelerator
String acceleratorText = "";
if (((JMenuItem) c).getAccelerator() != null)
if (m.getAccelerator() != null)
{
acceleratorText = getAcceleratorText(((JMenuItem) c).getAccelerator());
acceleratorText = getAcceleratorText(m.getAccelerator());
fm = g.getFontMetrics(acceleratorFont);
ar.width = fm.stringWidth(acceleratorText);
ar.x = br.width - ar.width;
vr.x = br.width - ar.width;
SwingUtilities.layoutCompoundLabel(c, fm, acceleratorText, null,
SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null,
vertAlign, horAlign, vertTextPos,
horTextPos, vr, ir, ar,
defaultTextIconGap);
paintAccelerator(g, (JMenuItem) c, ar, acceleratorText);
paintAccelerator(g, m, ar, acceleratorText);
}
}
/**
* DOCUMENT ME!
* Paints label for the given menu item
*
* @param g DOCUMENT ME!
* @param menuItem DOCUMENT ME!
* @param textRect DOCUMENT ME!
* @param text DOCUMENT ME!
* @param g The graphics context used to paint this menu item
* @param menuItem menu item for which to draw its label
* @param textRect rectangle specifiying position of the text relative to
* the given menu item
* @param text label of the menu item
*/
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect,
String text)
@ -586,17 +619,18 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method uninstalls the components for this {@link JMenuItem}.
*
* @param menuItem DOCUMENT ME!
* @param menuItem The {@link JMenuItem} to uninstall components for.
*/
protected void uninstallComponents(JMenuItem menuItem)
{
// TODO
// FIXME: need to implement
}
/**
* DOCUMENT ME!
* This method uninstalls the defaults and sets any objects created during
* install to null
*/
protected void uninstallDefaults()
{
@ -619,15 +653,15 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Uninstalls any keyboard actions.
*/
protected void uninstallKeyboardActions()
{
// TODO
// FIXME: need to implement
}
/**
* DOCUMENT ME!
* Unregisters all the listeners that this UI delegate was using.
*/
protected void uninstallListeners()
{
@ -638,9 +672,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* 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)
{
@ -650,10 +686,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method calls paint.
*
* @param g DOCUMENT ME!
* @param c DOCUMENT ME!
* @param g The graphics context used to paint this menu item
* @param c The menu item to paint
*/
public void update(Graphics g, JComponent c)
{
@ -661,11 +697,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Return text representation of the specified accelerator
*
* @param accelerator DOCUMENT ME!
* @param accelerator Accelerator for which to return string representation
*
* @return $returnType$ DOCUMENT ME!
* @return $String$ Text representation of the given accelerator
*/
private String getAcceleratorText(KeyStroke accelerator)
{
@ -686,12 +722,12 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Calculates and return rectange in which accelerator should be displayed
*
* @param accelerator DOCUMENT ME!
* @param fm DOCUMENT ME!
* @param accelerator accelerator for which to return the display rectangle
* @param fm The font metrics used to measure the text
*
* @return $returnType$ DOCUMENT ME!
* @return $Rectangle$ reactangle which will be used to display accelerator
*/
private Rectangle getAcceleratorRect(KeyStroke accelerator, FontMetrics fm)
{
@ -701,12 +737,13 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Paints accelerator inside menu item
*
* @param g DOCUMENT ME!
* @param menuItem DOCUMENT ME!
* @param acceleratorRect DOCUMENT ME!
* @param acceleratorText DOCUMENT ME!
* @param g The graphics context used to paint the border
* @param menuItem Menu item for which to draw accelerator
* @param acceleratorRect rectangle representing position
* of the accelerator relative to the menu item
* @param acceleratorText accelerator's text
*/
private void paintAccelerator(Graphics g, JMenuItem menuItem,
Rectangle acceleratorRect,
@ -720,7 +757,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This class handles mouse events occuring inside the menu item.
* Most of the events are forwarded for processing to MenuSelectionManager
* of the current menu hierarchy.
*
*/
protected class MouseInputHandler implements MouseInputListener
{
@ -732,9 +772,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method is called when mouse is clicked on the menu item.
* It forwards this event to MenuSelectionManager.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mouseClicked(MouseEvent e)
{
@ -743,9 +784,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method is called when mouse is dragged inside the menu item.
* It forwards this event to MenuSelectionManager.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mouseDragged(MouseEvent e)
{
@ -754,20 +796,29 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method is called when mouse enters menu item.
* When this happens menu item is considered to be selected and selection path
* in MenuSelectionManager is set. This event is also forwarded to MenuSelection
* Manager for further processing.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mouseEntered(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
Component source = (Component) e.getSource();
if (source.getParent() instanceof MenuElement)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(getPath());
manager.processMouseEvent(e);
}
}
/**
* DOCUMENT ME!
* This method is called when mouse exits menu item. The event is
* forwarded to MenuSelectionManager for processing.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mouseExited(MouseEvent e)
{
@ -776,9 +827,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method is called when mouse is inside the menu item.
* This event is forwarder to MenuSelectionManager for further processing.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mouseMoved(MouseEvent e)
{
@ -787,9 +839,10 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method is called when mouse is pressed. This event is forwarded to
* MenuSelectionManager for further processing.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mousePressed(MouseEvent e)
{
@ -798,57 +851,64 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This method is called when mouse is released. If the mouse is released
* inside this menuItem, then this menu item is considered to be chosen and
* the menu hierarchy should be closed.
*
* @param e DOCUMENT ME!
* @param e A {@link MouseEvent}.
*/
public void mouseReleased(MouseEvent e)
{
// FIXME: Should check if the mouse released while mouse cursor
// was indeed over the menu item. If this wasn't the case we probably
// should sent this event to MenuSelectionManager.
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
menuItem.doClick(0);
Rectangle size = menuItem.getBounds(); //this.getParent().getSize();
if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0
&& e.getY() < size.height)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
menuItem.doClick(0);
}
}
}
/**
* DOCUMENT ME!
* This class handles mouse dragged events.
*/
protected class MenuDragMouseHandler implements MenuDragMouseListener
{
/**
* DOCUMENT ME!
* Tbis method is invoked when mouse is dragged over the menu item.
*
* @param e DOCUMENT ME!
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
}
/**
* DOCUMENT ME!
* Tbis method is invoked when mouse enters the menu item while it is
* being dragged.
*
* @param e DOCUMENT ME!
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
}
/**
* DOCUMENT ME!
* Tbis method is invoked when mouse exits the menu item while
* it is being dragged
*
* @param e DOCUMENT ME!
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
}
/**
* DOCUMENT ME!
* Tbis method is invoked when mouse was dragged and released
* inside the menu item.
*
* @param e DOCUMENT ME!
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
@ -856,32 +916,34 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* This class handles key events occuring when menu item is visible on the
* screen.
*/
protected class MenuKeyHandler implements MenuKeyListener
{
/**
* DOCUMENT ME!
* This method is invoked when key has been pressed
*
* @param e DOCUMENT ME!
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyPressed(MenuKeyEvent e)
{
}
/**
* DOCUMENT ME!
* This method is invoked when key has been pressed
*
* @param e DOCUMENT ME!
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyReleased(MenuKeyEvent e)
{
}
/**
* DOCUMENT ME!
* This method is invoked when key has been typed
* It handles the mnemonic key for the menu item.
*
* @param e DOCUMENT ME!
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyTyped(MenuKeyEvent e)
{
@ -889,14 +951,15 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
* DOCUMENT ME!
* Helper class that listens for changes to the properties of the {@link
* JMenuItem}.
*/
protected class PropertyChangeHandler implements PropertyChangeListener
{
/**
* DOCUMENT ME!
* This method is called when one of the menu item's properties change.
*
* @param evt DOCUMENT ME!
* @param evt A {@link PropertyChangeEvent}.
*/
public void propertyChange(PropertyChangeEvent evt)
{

View file

@ -1,5 +1,5 @@
/* BasicMenuUI.java
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -53,6 +53,7 @@ import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
import javax.swing.UIDefaults;
@ -71,12 +72,16 @@ import javax.swing.plaf.MenuItemUI;
/**
* DOCUMENT ME!
* UI Delegate for JMenu
*/
public class BasicMenuUI extends BasicMenuItemUI
{
protected ChangeListener changeListener;
/* MenuListener listens to MenuEvents fired by JMenu */
protected MenuListener menuListener;
/* PropertyChangeListner that listens to propertyChangeEvents occuring in JMenu*/
protected PropertyChangeListener propertyChangeListener;
/**
@ -84,52 +89,53 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public BasicMenuUI()
{
mouseInputListener = createMouseInputListener(menuItem);
menuListener = createMenuListener(menuItem);
mouseInputListener = createMouseInputListener((JMenu) menuItem);
menuListener = createMenuListener((JMenu) menuItem);
propertyChangeListener = createPropertyChangeListener((JMenu) menuItem);
}
/**
* DOCUMENT ME!
* This method creates a new ChangeListener.
*
* @param c DOCUMENT ME!
*
* @return DOCUMENT ME!
* @return A new ChangeListener.
*/
protected ChangeListener createChangeListener(JComponent c)
{
return null;
return new ChangeHandler();
}
/**
* DOCUMENT ME!
* This method creates new MenuDragMouseListener to listen to mouse dragged events
* occuring in the Menu
*
* @param c DOCUMENT ME!
* @param c the menu to listen to
*
* @return DOCUMENT ME!
* @return The MenuDrageMouseListener
*/
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
{
return null;
return new MenuDragMouseHandler();
}
/**
* DOCUMENT ME!
* This method creates new MenuDragKeyListener to listen to key events
*
* @param c DOCUMENT ME!
* @param c the menu to listen to
*
* @return DOCUMENT ME!
* @return The MenuKeyListener
*/
protected MenuKeyListener createMenuKeyListener(JComponent c)
{
return null;
return new MenuKeyHandler();
}
/**
* DOCUMENT ME!
* This method creates new MenuListener to listen to menu events
* occuring in the Menu
*
* @param c DOCUMENT ME!
* @param c the menu to listen to
*
* @return DOCUMENT ME!
* @return The MenuListener
*/
protected MenuListener createMenuListener(JComponent c)
{
@ -137,11 +143,12 @@ public class BasicMenuUI extends BasicMenuItemUI
}
/**
* DOCUMENT ME!
* This method creates new MouseInputListener to listen to mouse input events
* occuring in the Menu
*
* @param c DOCUMENT ME!
* @param c the menu to listen to
*
* @return DOCUMENT ME!
* @return The MouseInputListener
*/
protected MouseInputListener createMouseInputListener(JComponent c)
{
@ -149,53 +156,50 @@ public class BasicMenuUI extends BasicMenuItemUI
}
/**
* DOCUMENT ME!
* This method creates newPropertyChangeListener to listen to property changes
* occuring in the Menu
*
* @param c DOCUMENT ME!
* @param c the menu to listen to
*
* @return DOCUMENT ME!
* @return The PropertyChangeListener
*/
protected PropertyChangeListener createPropertyChangeListener(JComponent c)
{
return null;
return new PropertyChangeHandler();
}
/**
* DOCUMENT ME!
* This method creates a new BasicMenuUI.
*
* @param x DOCUMENT ME!
* @param c The JComponent to create a UI for.
*
* @return DOCUMENT ME!
* @return A new BasicMenuUI.
*/
public static ComponentUI createUI(JComponent x)
public static ComponentUI createUI(JComponent c)
{
return new BasicMenuUI();
}
/**
* DOCUMENT ME!
* Get the component's maximum size.
*
* @param c DOCUMENT ME!
* @param c The JComponent for which to get maximum size
*
* @return DOCUMENT ME!
* @return The maximum size of the component
*/
public Dimension getMaximumSize(JComponent c)
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
protected String getPropertyPrefix()
{
return null;
}
/**
* DOCUMENT ME!
* Initializes any default properties that this UI has from the defaults for
* the Basic look and feel.
*/
protected void installDefaults()
{
@ -214,14 +218,17 @@ public class BasicMenuUI extends BasicMenuItemUI
}
/**
* DOCUMENT ME!
* Installs any keyboard actions. The list of keys that need to be bound are
* listed in Basic look and feel's defaults.
*
*/
protected void installKeyboardActions()
{
// FIXME: Need to implement
}
/**
* DOCUMENT ME!
* Creates and registers all the listeners for this UI delegate.
*/
protected void installListeners()
{
@ -229,17 +236,13 @@ public class BasicMenuUI extends BasicMenuItemUI
((JMenu) menuItem).addMenuListener(menuListener);
}
/**
* DOCUMENT ME!
*
* @param menu DOCUMENT ME!
*/
protected void setupPostTimer(JMenu menu)
{
}
/**
* DOCUMENT ME!
* This method uninstalls the defaults and sets any objects created during
* install to null
*/
protected void uninstallDefaults()
{
@ -255,30 +258,35 @@ public class BasicMenuUI extends BasicMenuItemUI
}
/**
* DOCUMENT ME!
* Uninstalls any keyboard actions. The list of keys used are listed in
* Basic look and feel's defaults.
*/
protected void uninstallKeyboardActions()
{
// FIXME: Need to implement
}
/**
* DOCUMENT ME!
* Unregisters all the listeners that this UI delegate was using. In
* addition, it will also null any listeners that it was using.
*/
protected void uninstallListeners()
{
((JMenu) menuItem).removeMouseListener(mouseInputListener);
((JMenu) menuItem).removeMenuListener(menuListener);
((JMenu) menuItem).removePropertyChangeListener(propertyChangeListener);
}
/**
* DOCUMENT ME!
* This class is used by menus to handle mouse events occuring in the
* menu.
*/
protected class MouseInputHandler implements MouseInputListener
{
protected MouseInputHandler()
{
}
public void mouseClicked(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
}
public void mouseDragged(MouseEvent e)
@ -289,34 +297,30 @@ public class BasicMenuUI extends BasicMenuItemUI
public void mouseEntered(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(getPath());
manager.processMouseEvent(e);
/* When mouse enters menu item, it should be considered selected
JMenu subMenu = (JMenu) menuItem;
int x = 0;
int y = 0;
// location of the popup menu is relative to the invoker
if (subMenu.isTopLevelMenu())
if (i) if this menu is a submenu in some other menu
(ii) or if this menu is in a menu bar and some other menu in a menu bar was just
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 mb = (JMenuBar) subMenu.getParent();
// Subtract menuBar's insets.bottom and popupMenu's insets.top,
// s.t. the space between menu bar and its popup menu is equal to
// menuBar's margin. By default menuBar's margin is Insets(0,0,0,0).
y = subMenu.getHeight() - mb.getInsets().bottom
- subMenu.getPopupMenu().getInsets().top + mb.getMargin().bottom;
// set new selection and forward this event to MenuSelectionManager
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.setSelectedPath(getPath());
manager.processMouseEvent(e);
}
else
x = subMenu.getWidth();
subMenu.getPopupMenu().show(subMenu, x, y);
}
public void mouseExited(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.processMouseEvent(e);
}
public void mouseMoved(MouseEvent e)
@ -325,6 +329,37 @@ public class BasicMenuUI extends BasicMenuItemUI
public void mousePressed(MouseEvent e)
{
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
JMenu menu = (JMenu) menuItem;
manager.processMouseEvent(e);
// Menu should be displayed when the menu is pressed only if
// it is top-level menu
if (menu.isTopLevelMenu())
{
if (menu.getPopupMenu().isVisible())
{
// If menu is visible and menu button was pressed..
// then need to cancel the menu
menu.fireMenuCanceled();
manager.clearSelectedPath();
}
else
{
// Display the menu
int x = 0;
int y = menu.getHeight();
menu.fireMenuSelected();
manager.setSelectedPath(getPath());
JMenuBar mb = (JMenuBar) menu.getParent();
// set selectedIndex of the selectionModel of a menuBar
mb.getSelectionModel().setSelectedIndex(mb.getComponentIndex(menu));
}
}
}
public void mouseReleased(MouseEvent e)
@ -334,18 +369,141 @@ public class BasicMenuUI extends BasicMenuItemUI
}
}
/**
* This class handles MenuEvents fired by the JMenu
*/
protected class MenuHandler implements MenuListener
{
/**
* This method is called when menu is cancelled. The menu is cancelled
* when its popup menu is closed without selection.
*
* @param e The MenuEvent.
*/
public void menuCanceled(MenuEvent e)
{
}
/**
* This method is called when menu is deselected.
*
* @param e The MenuEvent.
*/
public void menuDeselected(MenuEvent e)
{
}
/**
* This method is called when menu is selected.
*
* @param e The MenuEvent.
*/
public void menuSelected(MenuEvent e)
{
}
}
/**
* This class handles PropertyChangeEvents fired from the JMenu
*/
protected class PropertyChangeHandler implements PropertyChangeListener
{
/**
* This method is called whenever one of the properties of the menu item
* changes.
*
* @param e The PropertyChangeEvent.
*/
public void propertyChange(PropertyChangeEvent evt)
{
}
}
protected class ChangeHandler implements ChangeListener
{
public void stateChanged(ChangeEvent e)
{
// FIXME: It seems that this class is not used anywhere
}
}
/**
* This class handles mouse dragged events.
*/
protected class MenuDragMouseHandler implements MenuDragMouseListener
{
/**
* Tbis method is invoked when mouse is dragged over the menu item.
*
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
}
/**
* Tbis method is invoked when mouse enters the menu item while it is
* being dragged.
*
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
}
/**
* Tbis method is invoked when mouse exits the menu item while
* it is being dragged
*
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
}
/**
* Tbis method is invoked when mouse was dragged and released
* inside the menu item.
*
* @param e The MenuDragMouseEvent
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
}
}
/**
* This class handles key events occuring when menu item is visible on the
* screen.
*/
protected class MenuKeyHandler implements MenuKeyListener
{
/**
* This method is invoked when key has been pressed
*
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyPressed(MenuKeyEvent e)
{
}
/**
* This method is invoked when key has been pressed
*
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyReleased(MenuKeyEvent e)
{
}
/**
* This method is invoked when key has been typed
* It handles the mnemonic key for the menu item.
*
* @param e A {@link MenuKeyEvent}.
*/
public void menuKeyTyped(MenuKeyEvent e)
{
}
}
}

View file

@ -0,0 +1,118 @@
/* BasicPopupMenuSeparatorUI.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.JPopupMenu;
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 L&F UI delegate for JPopupMenu.Separator.
*/
public class BasicPopupMenuSeparatorUI extends BasicSeparatorUI
{
/**
* Creates a new BasicPopupMenuSeparatorUI object.
*/
public BasicPopupMenuSeparatorUI()
{
super();
}
/**
* Creates a new UI delegate for the given JComponent.
*
* @param c The JComponent to create a delegate for.
*
* @return A new BasicPopupMenuSeparatorUI
*/
public static ComponentUI createUI(JComponent c)
{
return new BasicPopupMenuSeparatorUI();
}
/**
* The Popup Menu Separator has two lines. The top line will be
* painted using highlight color and the bottom using shadow color.
*
* @param g The Graphics object to paint with
* @param c The JComponent to paint.
*/
public void paint(Graphics g, JComponent c)
{
if (! (c instanceof JPopupMenu.Separator))
return;
Rectangle r = new Rectangle();
SwingUtilities.calculateInnerArea(c, r);
Color saved = g.getColor();
int midAB = r.width / 2 + r.x;
int midAD = r.height / 2 + r.y;
g.setColor(highlight);
g.drawLine(r.x, midAD, r.x + r.width, midAD);
g.setColor(shadow);
g.drawLine(r.x, midAD + 1, r.x + r.width, midAD + 1);
}
/**
* 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 super.getPreferredSize(c);
}
}

View file

@ -134,8 +134,7 @@ public class BasicProgressBarUI extends ProgressBarUI
}
/** The timer used to move the bouncing box. */
private transient Timer animationTimer = new Timer();
private transient Timer animationTimer;
// The total number of frames must be an even number.
// The total number of frames is calculated from
@ -681,6 +680,8 @@ public class BasicProgressBarUI extends ProgressBarUI
* This method starts the animation timer. It is called
* when the propertyChangeListener detects that the progressBar
* has changed to indeterminate mode.
*
* @since 1.4
*/
protected void startAnimationTimer()
{
@ -692,6 +693,8 @@ public class BasicProgressBarUI extends ProgressBarUI
* This method stops the animation timer. It is called when
* the propertyChangeListener detects that the progressBar
* has changed to determinate mode.
*
* @since 1.4
*/
protected void stopAnimationTimer()
{
@ -794,7 +797,7 @@ public class BasicProgressBarUI extends ProgressBarUI
{
progressBar = (JProgressBar) c;
animationTimer = new Timer();
animationTimer = new Timer(200, null);
animationTimer.setRepeats(true);
installDefaults();

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