[multiple changes]

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

	* javax/swing/plaf/basic/BasicTextAreaUI.java
	(create): New method.
	* javax/swing/text/DefaultHighlighter.java
	(DefaultHighlightPainter.debugRect): Removed.
	* javax/swing/text/StyleContext.java
	(DEFAULT_STYLE): New field.

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

	* javax/swing/plaf/basic/BasicLookAndFeel.java
	(initComponentDefaults): Add keybindings for selection.backward and
	selection-forward for text components.
	* javax/swing/plaf/basic/BasicTextUI.java
	(paintSafely): Paint highlight only when something is actually
	selected.
	* javax/swing/text/DefaultCaret.java
	(handleHighlight): New method.
	(setSelectionVisible): Don't do anything when nothing changes.
	Handle highlight.
	(moveDot): Reimplemented. Handle highlight.
	(setDot): Set mark too. Handle highlight.
	(getSelectionPainter): New method.
	* javax/swing/text/DefaultEditorKit.java
	(defaultActions): Added new actions for text selection.
	* javax/swing/text/DefaultHighlighter.java
	(DefaultHighlightPainter): New inner class.
	(DefaultPainter): New field.
	(paint): Implemented.
	* javax/swing/text/PlainView.java
	(paint): Don't draw background here again.
	* javax/swing/text/Utilities.java
	(getTabbedTextWidth): Use width of ' ' instead of 'm' for tabsize.
	(drawTabbedText): Likewise.

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

	* javax/swing/JComponent.java
	(resetKeyboardActions): Add null checks.

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

	* javax/swing/DefaultButtonModel.java:
	Skip group notification when no group is set.

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

	* javax/swing/JColorChooser.java:
	Make a couple inner classes static, for jikes.

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

	* javax/swing/plaf/basic/BasicTextUI.java
	(RottView.modelToView): New method.
	(UpdateHandler): Renamed from EventHandler.
	(updateHandler): Renamed from eventHandler.
	(modelToView): Implemented.
	* javax/swing/text/AbstractDocument.java
	(BranchElement.getElement): Return null for non-existing indeces.
	(BranchElement.getElementIndex): Return 0 in some corner cases.
	* javax/swing/text/FieldView.java
	(modelToView): New method.
	* javax/swing/text/PlainView.java
	(modelToView): Made public.

2004-08-31  Kim Ho  <kho@redhat.com>

	* Makefile.am: New files.
	* Makefile.in: Regenerate.
	* gcj/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* java/awt/Color.java: Fix documentation.
	(RGBtoHSB): Use floats for conversions.
	* javax/swing/ButtonGroup.java: Run Jalopy.
	(setSelected): Reimplement.
	* javax/swing/DefaultButtonModel.java: Run Jalopy.
	(changeState): Let ButtonGroup know that the button
	is changing state.
	* javax/swing/JColorChooser.java: Implement.
	* javax/swing/JLabel.java: Run Jalopy.
	* javax/swing/JSpinner.java: Run Jalopy.
	(setValue): New method.
	* javax/swing/JTabbedPane.java: Run Jalopy.
	(removeTabAt): Call correct remove method.
	* javax/swing/SpinnerNumberModel.java: Run Jalopy.
	(getPreviousValue): Compare minimum value.
	* javax/swing/Timer.java: Run Jalopy.
	(run): Comment out println.
	* javax/swing/ToolTipManager.java:
	(mouseMoved): Get new tooltip text for location.
	* javax/swing/colorchooser/AbstractColorChooserPanel.java:
	Jalopy and Javadoc.
	* javax/swing/colorchooser/ColorChooserComponentFactory.java:
	Implement.
	* javax/swing/colorchooser/DefaultColorSelectionModel.java:
	Run Jalopy.
	(setSelectedColor): Fire ChangeEvent.
	* javax/swing/colorchooser/DefaultHSBChooserPanel.java:
	New file. Implement.
	* javax/swing/colorchooser/DefaultPreviewPanel.java:
	Ditto.
	* javax/swing/colorchooser/DefaultRGBChooserPanel.java:
	Ditto.
	* javax/swing/colorchooser/DefaultSwatchChooserPanel.java:
	Ditto.
	* javax/swing/plaf/basic/BasicArrowButton.java:
	(getArrow): Fix size of upward pointing button.
	* javax/swing/plaf/basic/BasicColorChooserUI.java:
	Implement.
	* javax/swing/plaf/basic/BasicSliderUI.java:
	(getWidthOfWidestLabel): Use preferred dimensions.
	(getHeightOfTallestLabel): Ditto.
	* javax/swing/plaf/basic/BasicSpinnerUI.java:
	Run Jalopy.
	(mousePressed): Disable changes to spinner if it is not enabled.
	* testsuite/Makefile.in: Regenerate.


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

	* javax/swing/plaf/basic/BasicTableHeaderUI.java,
	javax/swing/plaf/basic/BasicTableUI.java:
	Added copyright notice.

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

	* Makefile.am: Added new files.
	* Makefile.in: Regenerate.
	* javax/swing/ComboBoxEditor.java: Added javadocs.
	* javax/swing/ComboBoxModel.java: Likewise.
	* javax/swing/DefaultComboBoxModel.java: Implemented.
	* javax/swing/DefaultListCellRenderer.java: Added javadocs
	and ran through jalopy to fix formatting style.
	(getListCellRendererComponent): Use appropriate border
	if renderer has focus and use noFocusBorder when it doesn't.
	* javax/swing/JComboBox.java: Implemented.
	* javax/swing/JList.java:
	(locationToIndex): New Method. Implemented.
	(indexToLocation): New Method.
	* javax/swing/JPopupMenu.java:
	(visible): New field.
	(isVisible): Changed to use new field above.
	(setVisible): Likewise.
	* javax/swing/MutableComboBoxModel.java: Added javadocs.
	* javax/swing/plaf/basic/BasicArrowButton.java:
	(shadow): Changed default color to Color.gray.
	* javax/swing/plaf/basic/BasicComboBoxUI.java: New File.
	UI delegate for JComboBox.
	* javax/swing/plaf/basic/BasicComboPopup.java: New File.
	Popup menu containing list of JComboBox's items.
	* javax/swing/plaf/basic/BasicComboBoxEditor.java: New File.
	* javax/swing/plaf/basic/BasicComboBoxRenderer.java: New File.
	* javax/swing/plaf/basic/BasicComboBoxUI.java: New File.
	* javax/swing/plaf/basic/BasicComboPopup.java: New File.
	* javax/swing/plaf/basic/BasicPopupMenuUI.java:
	(popupMenuWillBecomeVisible): Set selected path to the first
	element only if it is of type MenuElement. Also fix formatting
	style.
	* javax/swing/plaf/basic/ComboPopup.java: Added javadocs and missing
	methods signatures.

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

	* javax/swing/text/AbstractDocument.java
	(createBranchElement): Use new constructor of BranchElement.
	(createLeafElement): Renamed arguments.
	(getRootElements): Implemented.
	(BranchElement.start): Removed.
	(BranchElement.end): Likewise.
	(BranchElement.BranchElement): Fixed arguments.
	(BranchElement.getEndOffset): Reimplemented.
	(BranchElement.getStartOffset): Likewis.
	* javax/swing/text/DefaultCaret.java
	(paint): Draw simple vertical line as caret instead of a rectangle.
	* javax/swing/text/JTextComponent.java
	(setText): Use doc directly.
	* javax/swing/text/PlainView.java
	(nextTabStop): Implemented.
	* javax/swing/text/Utilities.java
	(drawTabbedText): nextTabStop() returns an absolute x position.
	(getTabbedTextWidth): Likewise.

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

	* java/awt/Component.java
	(isFocusTraversable): Predicate on isLightweight()
	(setFocusable): Set isFocusTraversableOverridden.
	(requestFocus): Predicate peer dispatch on !isLightweight()
	(requestFocusInWindow): Likewise.
	(dispatchEventImpl): Coordinate with KeyboardFocusManager.
	* java/awt/Container.java
	(dispatchEventImpl): Predicate on event mask.
	(LightweightDispatcher): Remove focus machinery.
	* java/awt/DefaultFocusTraversalPolicy.java
	(accept): Expand predicate to include isFocusable().
	* java/awt/DefaultKeyboardFocusManager.java:
	Globally change c.dispatchEvent(e) to redispatchEvent(c,e)
	* java/awt/KeyboardFocusManager.java
	(redispatchEvent): Synchronize on event to prevent feedback.
	* javax/swing/AbstractButton.java
	(ButtonFocusListener): Remove class.
	(init): Set focusPainted, focusable.
	* javax/swing/ActionMap.java (get): Check parent for null.
	* javax/swing/InputMap.java (get): Likewise.
	* javax/swing/JComponent.java
	(inputMap_whenFocused): New InputMap.
	(inputMap_whenAncestorOfFocused): Likewise.
	(inputMap_whenInFocusedWindow): Likewise.
	(getActionForKeyStroke): Rewrite.
	(getConditionForKeystroke): Likewise.
	(ActionListenerProxy): New private class.
	(setInputMap): Implement.
	(getInputMap): Likewise.
	(setActionMap): Likewise.
	(getActionMap): Likewise.
	(processComponentKeyEvent): New empty method.
	(processKeyEvent): Implement.
	(processKeyBinding): Likewise.
	(resetKeyboardActions): Rewrite.
	* javax/swing/KeyStroke.java: Rewrite.
	* javax/swing/SwingUtilities.java
	(notifyAction): Implement.
	(replaceUIActionMap): Likewise.
	(replaceUIInputMap): Likewise.
	* javax/swing/plaf/basic/BasicButtonListener.java
	(focusGained): Implement.
	(focusLost): Repaint if focusPainted().
	(installKeyboardActions): Install pressed / released actions.
	(uninstallKeyboardActions): Implement.
	* javax/swing/plaf/basic/BasicButtonUI.java
	(focusColor): New field.
	(installDefaults): Load focus color, install input map.
	(installKeyboardActions): Implement.
	(uninstallKeyboardActions): Likewise.
	(paintFocus): Rewrite.
	* javax/swing/plaf/basic/BasicLookAndFeel.java
	(Button.focus): New default, midPurple.
	* javax/swing/plaf/basic/BasicTextUI.java
	(kit): Make static.
	(installUI): Get doc from kit, load defaults.
	(getKeymapName): Implement.
	(createKeymap): Likewise.
	(installKeyboardActions): Likewise.
	(getInputMap): Likewise.
	(getActionMap): Likewise.
	(createActionMap): Likewise.
	* javax/swing/text/AbstractDocument.java
	(getStartPosition): Implement.
	(getEndPosition): Likewise.
	* javax/swing/text/DefaultEditorKit.java
	(CopyAction): New class.
	(CutAction): Likewise.
	(DefaultKeyTypedAction): Likewise.
	(InsertBreakAction): Likewise.
	(InsertContentAction): Likewise.
	(InsertTabAction): Likewise.
	(PasteAction): Likewise.
	(defaultActions): New static table.
	(createCaret): Implement.
	(getActions): Likewise.
	* javax/swing/text/JTextComponent.java
	(KeymapWrapper): New private class.
	(KeymapActionMap): Likewise.
	(DefaultKeymap): New class.
	(keymaps): New static table.
	(keymap): New field.
	(getKeymap): Implement.
	(removeKeymap): Likewise.
	(addKeymap): Likewise.
	(setKeymap): Likewise.
	(loadKeymap): Likewise.
	(getActions): Likewise.
	(margin): New field.
	(JTextComponent): Build and install default keymap.
	* javax/swing/text/TextAction.java
	(textAction): Call super properly.
	(getTextComponent): Implement.
	* javax/swing/text/Utilities.java
	(drawTabbedText): Adjust position by ascent.

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

	PR AWT/17156

	* gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
	(setEnabled): Make it a native method.
	* java/awt/DefaultKeyboardFocusManager.java
	(postProcessKeyEvent): Only post event if the menu item
	is active.
	* java/awt/MenuItem.java:
	Private field 'enabled' should be true by default.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuItemPeer.c
	(setEnabled): New function.

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

	PR AWT/17059

	* gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
	(nativeSetHelpMenu): New native method declaration.
	(addHelpMenu): Call nativeSetHelpMenu().
	(addMenu): Remove.
	* java/awt/MenuBar.java
	(setHelpMenu): Call addNotify() on the new help menu.
	(add): Call addNotify() on the new menu.
	(addNotify): Set the help menu if one exists.
	* java/awt/peer/MenuBarPeer.java
	(addMenu): Remove.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuBarPeer.c
	(nativeSetHelpMenu): New method.

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

	* Makefile.am: Add new files.
	* Makefile.in: Regenerate.
	* javax/swing/Box.java: Fix setting of layout in ctor.
	* javax/swing/JScrollPane.java: Scroll headers as well.
	* javax/swing/JTable.java: Reimplement.
	* javax/swing/JViewPort.java: Only add non-null children.
	* javax/swing/ScrollPaneLayout.java: Correct header calculations.
	* javax/swing/Timer.java: Fix stopping null waker.
	* javax/swing/plaf/basic/BasicTableHeaderUI.java: New file.
	* javax/swing/plaf/basic/BasicTableUI.java: New file.
	* javax/swing/table/DefaultTableCellRenderer.java: Configure.
	* javax/swing/table/DefaultTableColumnModel.java: Flesh out.
	* javax/swing/table/DefaultTableModel.java: Clean up.
	* javax/swing/table/JTableHeader.java: Implement.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* javax/swing/JSpinner.java (getChangeListeners): Remove double
	semi-colon.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkClasspathFontPeerMetrics.c:
	Declare variables at top of functions/block.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics2D.c: Likewise.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* java/lang/Rectangle.java (intersects): Check r.width and r.height
	first.

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

	* javax/swing/text/PlainView.java
	(selectedColor): New field.
	(unselectedColor): Likewise.
	(font): Likewise.
	(updateMetrics): New method.
	(lineToRect): Likewise.
	(modelToView): Likewise.
	(drawSelectedText): Use color from JTextComponent ad draw with
	Utilities class.
	(drawUnselectedText): Likewise.
	(paint): Initialize helper fields.
	* javax/swing/text/View.java
	(getChildAllocation): New method.
	(getViewIndex): Likewise.
	(getToolTipText): Likewise.

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

	* javax/swing/text/Utilities.java
	(drawTabbedText): Reimplemented.
	(getTabbedTextWidth): Likewise.

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

	* javax/swing/plaf/basic/BasicTextUI.java
	(installDefaults): Install caret and highlighter.
	(modelToView): Use Bias.Forward when calling sibling.
	* javax/swing/text/AbstractDocument.java
	(ElementEdit): Implements DocumentEvent.ElementChange.
	(ElementEdit.ElementEdit): New method.
	(ElementEdit.getChildrenAdded): Likewise.
	(ElementEdit.getChildrenRemoved): Likewise.
	(ElementEdit.getElement): Likewise.
	(ElementEdit.getIndex): Likewise.
	* javax/swing/text/DefaultCaret.java
	(color): Removed.
	(textComponent): Renamed from parent, made private.
	(selectionVisible): Renamed from vis_sel, made private.
	(blinkRate): Renamed from blink, made private.
	(magicCaretPosition): Renamed from magic, made private.
	(visible): Renamed from vis, made private.
	(dot): Made private.
	(mark): Likewise.
	(deinstall): Remove as MouseMotionListener.
	(install): Initialize textComponent first. Add as MouseMotionListener.
	(paint): Reimplemented.
	* javax/swing/text/JTextComponent.java
	(setCaret): Deinstall old caret, install new one and fire property
	change after setting property.
	(setHighlighter): Deinstall old highlighter, install new one and fire
	property change after setting property.
	(setCaretColor): Fire property change after setting property.
	(setDisabledTextColor): Likewise.
	(setSelectedTextColor): Likewise.
	(setSelectionColor): Likewise.
	(modelToView): New method.

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

	* javax/swing/text/AbstractDocument.java
	(getText): Simplified.
	* javax/swing/text/Segment.java
	(current): New field.
	(current): Reimplemented.
	(first): Likewise.
	(getIndex): Likewise.
	(last): Likewise.
	(next): Likewise.
	(previous): Likewise.
	(setIndex): Likewise.

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

	* javax/swing/plaf/basic/BasicButtonUI.java
	(defaultTextIconGap): Made protected.
	(defaultTextShiftOffset): Likewise.
	(textShiftOffset): New field.
	(clearTextShiftOffset): New method.
	(getTextShiftOffset): Likewise.
	(setTextShiftOffset): Likewise.

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

	* javax/swing/plaf/basic/BasicTextUI.java
	(installUI): Add eventHandler as property listener.
	(uninstallUI): remove eventHandler as propert listener.
	(installDefaults): Added comment.
	(installListeners): Likewise.
	(installKeyboardActions): Likewise.
	(uninstallDefaults): Likewise.
	(uninstallListeners): Likewise.
	(uninstallKeyboardActions): Likewise.

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

	* javax/swing/text/AbstractDocument.java:
	Fixed some typos in comments.
	(insertString): Reimplemented.
	(remove): Likewise.
	(replace): New method.
	(children): Dont use fully qualified class name.
	(DefaultDocumentEvent.offset): Renamed from off.
	(DefaultDocumentEvent.length): Renamed from len.
	(DefaultDocumentEvent.type): New field.
	(DefaultDocumentEvent.DefaultDocumentEvent): New constructor.
	(DefaultDocumentEvent.getType): Implemented.

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

	* javax/swing/plaf/basic/BasicTextUI.java
	(RootView.textComponent): Removed.
	(RootView.RootView): Don't initialize textComponent.
	(RootView.getViewFactory): New method.
	(EventHandler): New inner class.
	(rootView): Initialize at instance creation.
	(eventHandler): New field.
	(installUI): Don't create view hierarchy directly,
	call modelChanged() instead.
	(modelChanged): New method.
	* javax/swing/text/JTextComponent.java
	(setDocument): Fire property change event.

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

	* javax/swing/plaf/basic/BasicTextUI.java
	(RootView.paint): Removed debug output.
	(paintSafely): Draw highlighter before text.
	(paintBackground): Use background color of text component.
	* javax/swing/plaf/basic/BasicToggleButtonUI.java:
	Reformatted.

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

	* javax/swing/plaf/basic/BasicToolBarUI.java
	(BasicToolBarUI): Fixed arguments for constructor.
	(createUI): Fixed creation of object.

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

	* javax/swing/DefaultListSelectionModel.java
	(fireValueChanged): Renamed from fireSelectionValueChanged,
	made protected.

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

	* javax/swing/text/TabSet.java
	(TabSet): Implements java.io.Serializable.
	* javax/swing/text/TabStop.java
	(TabStop): Implements java.io.Serializable.
	(TabStop): Made public.

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

	* javax/swing/JComponent.java
	(setUI): Fire PropertyChange.
	* javax/swing/JLabel.java
	(text): Renamed from labelText.
	(horizontalAlignment): New default vlaue.
	(icon): Renamed from activeIcon.
	(displayedMnemonic): Renamed from mnemonicKey, added default value.
	(displayedMnemonicIndex): Renamed from underlineChar.
	(setDisplayedMnemonic): Reimplemented.
	* javax/swing/JRadioButton.java
	(JRadioButton): New constructors.
	* javax/swing/JTextField.java
	(JTextField): Throw exception if colums < 0, initialitialz
	this.columns directly and initialize document with text conditionally.

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

	* javax/swing/plaf/basic/BasicFormattedTextFieldUI.java,
	javax/swing/plaf/basic/BasicPasswordFieldUI.java,
	javax/swing/plaf/basic/BasicTextAreaUI.java: New files.
	* javax/swing/text/FieldView.java
	(paint): Just call super method for now.
	* Makefile.am: Added new files.
	* Makefile.in: Regenerated.

2004-08-31  Ka-Hing Cheung  <kahing@javabsp.org>

	* javax/swing/AbstractSpinnerModel.java,
	javax/swing/JSpinner.java,
	javax/swing/SpinnerNumberModel.java,
	javax/swing/plaf/basic/BasicSpinnerUI.java:
	New files.
	* javax/swing/plaf/basic/BasicLookAndFeel.java
	(initClassDefaults): Added defaults for BasicSpinnerUI.

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

	* Makefile.am: Added new files.
	* Makefile.in: Regenerated.

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

	* javax/swing/TransferHandler.java,
	javax/swing/plaf/basic/ComboPopup.java: New files
	* Makefile.am: Added javax/swing/TransferHandler.java and
	javax/swing/plaf/basic/ComboPopup.java
	* Makefile.in: Regenerated.

2004-08-31  Roman Kennke  <roman@ontographics.com>

	* javax/swing/text/Utilities.java: New file.

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

	* Makefile.am: Added javax/swing/text/Utilities.java.
	* Makefile.in: Regenerated.

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

	* javax/swing/text/SimpleAttributeSet.java: New file.
	* javax/swing/text/StyleConstants.java: New file.
	* javax/swing/text/StyleContext.java: New file.
	* javax/swing/text/TabSet.java: New file.
	* javax/swing/text/TabStop.java: New file.
	* javax/swing/text/AbstactDocument.java:
	(AbstractElement): Implement attribute support.
	* javax/swing/text/AttributeSet.java
	(NameAttribute): New static field.
	(ResolveAttribute): New static field.
	* Makefile.am: Update for new files.
	* Makefile.in: Regenerate.

2004-08-31  Craig Black  <craig.black@aonix.com>

	* gnu/java/awt/peer/gtk/GdkGraphics.java
	(drawImage): Add support for scaling pixmaps.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
	(copyAndScalePixmap): New native method.

2004-08-31  Thomas Fitzsimmons  <fitzsim@redhat.com>

	PR AWT/16121
	* jni/gtk-peer/gthread-jni.c: Include stdio.h.  Eliminate
	type-punning compiler warnings using unions.
	(throw): Replace bzero with memset.

2004-08-31  Andreas Tobler  <a.tobler@schweiz.ch>
	    Thomas Fitzsimmons  <fitzsim@redhat.com>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: Move
	NSA_PB macros to gtkpeer.h.  Include gtkpeer.h.
	* jni/gtk-peer/gtkpeer.h: Move NSA_PB macros here.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(nativeSetIconImageFromDecoder): Use NSA_GET_PB_PTR macro.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
	#include gdk.h, not gtk.h. #include jni.h, native_state.h, string.h
	and stdlib.h, not gtkpeer.h.
	(*vm): New static variable.
	(areaPreparedID): Make static.
	(areaUpdatedID): Likewise.
	(area_prepared): Get and use JNIEnv through stored JavaVM *vm.
	(area_prepared): Likewise.
	(area_updated): Likewise.
	(closed): Likewise.
	(initStaticState): Initialize *vm javaVM.
	(pumpBytes): Use given env, not global gdk_env.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* java/awt/geom/CubicCurve2D.java (solveCubic): Removed duplicate
	comments.

2004-08-31  Sven de Marothy  <sven@physto.se>

	* java/awt/geom/CubicCurve2D.java: Reindent.
	(contains): Implemented.
	(intersects): Implemented.
	* java/awt/geom/QuadCurve2D.java: Likewise.
	* java/awt/geom/GeneralPath.java: Reindent and document.
	Fully (re)implemented using separate xpoints and ypoints
	float[] coords.
	* java/awt/geom/RoundRectangle2D.java: Several bugfixes (Bug #6007).

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

	* javax/swing/JMenuItem.java
	(getMenuDragMouseListeners): New method.
	(getMenuKeyListeners): Likewise.

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

	* javax/swing/AbstractButton.java
	(model): Made protected.
	(actionListener): Likewise.
	(changeListener): Likewise.
	(itemListener): Likewise.
	(multiClickThreshhold): New field.
	(getActionListeners): New method.
	(getChangeListeners): Likewise.
	(getItemListeners): Likewise.
	(fireItemStateChanged): Simplified implementation.
	(fireActionPerformed): Likewise.
	(fireStateChanged): Likewise.
	(getMultiClickThreshhold): New method.
	(setMultiClickThreshhold): Likewise.

2004-08-31  Tom Tromey  <tromey@redhat.com>

	* java/awt/image/Kernel.java (clone): Use super.clone().

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

	PR AWT/16682
	* gnu/java/awt/peer/gtk/GtkFramePeer.java
	(nativeSetIconImage): Rename to nativeSetIconImageFromDecoder.
	(nativeSetIconImageFromData): New native method declaration.
	(setIconImage): Handle images not produced from GdkPixbufDecoder.
	* gnu/java/awt/peer/gtk/GtkImage.java
	(getPixelCache): New method.
	(getColorModel): New method.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(nativeSetIconImage): Rename to nativeSetIconImageFromDecoder.
	(free_pixbuf_data): New helper function.
	(nativeSetIconImageFromData): New function.

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

	PR SWING/16576
	* javax/swing/JLayeredPane.java
	(setLayer): Permit changing layer after addition.
	(setPosition): Permit over-length positions.
	(layerToRange): Compare intValue()s.
	* javax/swing/Box.java (createHorizontalBox): Implement.
	(createRigidArea): Likewise.
	(createVerticalBox): Likewise.

2004-08-31  Kim Ho  <kho@redhat.com>

	* java/awt/Component.java:
	(processMouseEvent): Consume event after
	listeners process it.
	(processMouseMotionEvent): ditto.
	(processMouseWheelEvent): ditto.
	* java/awt/Container.java:
	(acquireComponentForMouseEvent):
	Do not dispatch to events that have been
	removed from the Container.
	(handleEvent): Consume the MouseEvents.
	* javax/swing/RepaintManager.java:
	(paintDirtyRegions): Do not add to list of
	damaged areas if the component has no root.

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

	* javax/swing/plaf/basic/BasicMenuItemUI.java: Clean ip imports.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* gnu/java/awt/peer/gtk/GtkToolkit.java (getFontPeer): Don't return
	null when a MissingResourceException is thrown. Should never happen.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* java/awt/EventQueue.java (postEvent): Throw NullPointerException
	when argument is null.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_addExposeFilter):
	Define hid at start of function.
	(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_removeExposeFilter):
	Likewise.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* gnu/java/awt/EmbeddedWindow.java: Reindent.
	* javax/swing/JButton.java: Reindent.
	* javax/swing/JCheckBox.java: Reindent.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* Makefile.am (gtk_c_source_files): Added
	jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c.
	(gtk_awt_peer_sources): Added
	gnu/java/awt/peer/gtk/GThreadMutex.java and
	gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java.
	* Makefile.in: Regenerated.

2004-08-31  Archie Cobbs  <archie@dellroad.org>

	* jni/gtk-peer/gthread-jni.c: don't #include nonexistent files

2004-08-31  Steven Augart  <augart@watson.ibm.com>

	* jni/gtk-peer/gthread-jni.c (c-font-lock-extra-types):
	Added jfieldID, jmethodID.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
	(Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): Initialize
	gdk_env before calling any gdk or gtk function.

	* gnu/java/awt/peer/gtk/GtkMainThread.java (gtkInitCalled): New field.
	(GtkMainThread): Call wait() in while loop waiting for gtkInitCalled.
	(run): Set gtkInitCalled.

2004-08-31  Steven Augart  <augart@watson.ibm.com>

	* gnu/java/awt/peer/gtk/GtkMainThread.java (run): Pass the value of
	the gnu.classpath.awt.gtk.portable.native.sync system property to C.

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
	(Java_gnu_java_awt_peer_gtk_GtkMainThread_gtkInit): New argument,
	portableNativeSync.  Delegate PORTABLE_NATIVE_SYNC work to
	init_glib_threads.
	(init_glib_threads): New function.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* jni/gtk-peer/gthread-jni.c: Define MIN_, MAX_ and NORM_
	PRIORITY when not already defined in header file.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* jni/gtk-peer/gthread-jni.c (setup_cache): Call
	ExceptionOccurred, not ExceptionCheck, when we don't have JNI 1.2.

2004-08-31  Steven Augart  <augart@watson.ibm.com>

	* gnu/native/jni/gtk-peer/gthread-jni.c: Indentation fixes.
	Implemented missing functions for GTK2.
	Added error handling.
	Renamed static functions out of the g_ namespace.
	Added TRACE_API_CALLS, EXPLAIN_TROUBLE, EXPLAIN_BROKEN,
	EXPLAIN_BADLY_BROKEN, and DELETE_LOCAL_REFS options.
	Rewrote global-reference code.
	Eliminated cascading errors.
	(mutex_trylock_jni_impl) Fully implemented.
	(cond_timed_wait_jni_impl) Went from millisecond to microsecond
	resolution.
	(setup_cache) New function.
	(mutex_cond_wait_jni_impl, mutex_cond_timed_wait_jni_impl) Fixed
	bug where they were not unlocking the GMutex associated with the
	condition variable during the wait on that condition variable.

	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,
	native/jni/gtk-peer/gthread-jni.c,
	native/jni/gtk-peer/gthread-jni.h
	(g_thread_jni_functions): Renamed to ...
	(portable_native_sync_jni_functions): this name.
	(gdk_vm): Renamed to...
	(the_vm): this name.

	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
	(gdk_vm): Removed duplicate definition.
	(gtkInit): Removed stray message to stdout.
	(gtkInit): Use g_malloc and g_free instead of malloc and free.
	(gtkInit): Fix a const assignment bug.
	(gtkInit): Simplified code.

	* gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java,
	native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c,
	native/jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.h,
	gnu/java/awt/peer/gtk/GThreadMutex.java:
	New files.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* javax/swing/Box.java: Put FIXME comment above class declaration.
	* javax/swing/JButton.java: Remove illegal L&F HTML from comments.
	* javax/swing/JCheckBox.java: Likewise.
	* javax/swing/JDialog.java: Likewise.
	* javax/swing/JRadioButton.java: Likewise.
	* javax/swing/JToggleButton.java: Likewise.
	* javax/swing/UIManager.java: Likewise.
	* javax/swing/border/TitledBorder.java: Likewise.
	* javax/swing/plaf/basic/BasicLabelUI.java: Likewise.
	* javax/swing/plaf/basic/BasicLookAndFeel.java: Likewise.
	* javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java: Likewise.
	* javax/swing/plaf/basic/BasicProgressBarUI.java: Likewise.
	* javax/swing/plaf/basic/BasicScrollBarUI.java: Likewise.
	* javax/swing/plaf/basic/BasicSeparatorUI.java: Likewise.
	* javax/swing/text/JTextComponent.java: Likewise.

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

	PR AWT/16682
	* gnu/java/awt/peer/gtk/GtkFramePeer.java
	(setIconImage): Add a FIXME for unhandled cases.

2004-08-31  Thomas Fitzsimmons  <fitzsim@redhat.com>

	PR AWT/16040
	* gnu/awt/LightweightRedirector.java: Call getModifiersEx, not
	getModifiers.  Replace old button masks with new ones.
	* gnu/awt/xlib/XEventLoop.java: Likewise.
	* gnu/java/awt/peer/gtk/GtkButtonPeer.java: Likewise.
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c: Likewise.
	* gnu/java/awt/peer/gtk/GtkListPeer.java: Likewise.
	* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java: Likewise.
	* java/awt/AWTKeyStroke.java: Remove old modifier masks.
	* java/awt/Component.java: Replace old modifier	masks with new
	ones.
	* java/awt/Container.java: Call getModifiersEx, not
	getModifiers.
	* java/awt/DefaultKeyboardFocusManager.java: Likewise.  Remove
	old modifier masks.
	* javax/swing/JMenuItem.java: Replace old button masks with new
	ones.
	* javax/swing/KeyStroke.java: Call getModifiersEx, not
	getModifiers.
	* javax/swing/SwingUtilities.java: Likewise.
	* javax/swing/plaf/basic/BasicButtonListener.java: Likewise.
	* javax/swing/plaf/basic/BasicInternalFrameUI.java: Likewise.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c: Replace old
	mask macros with new ones.
	* jni/gtk-peer/gtkpeer.h: Replace old button and modifier mask
	macros with new ones representing new masks.

2004-08-31  Craig Black  <craig.black@aonix.com>

	* gnu/java/awt/peer/gtk/GdkGraphics.java
	(drawRoundRect): Implemented.
	(fillRoundRect): Implemented.
	* gnu/java/awt/peer/gtk/GdkGraphics2D.java
	(drawRoundRect): Reimplemented to match GdkGraphics.
	(fillRoundRect): Reimplemented to match GdkGraphics.

2004-08-31  Mark Wielaard  <mark@klomp.org>

	* Makefile.in: Regenerated.

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

	* gnu/java/awt/EmbeddedWindow.java
	(addNotify): Use AccessController to allow execution of privileged
	code.

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

	* gnu/java/awt/EmbeddedWindow.java
	(static): Removed.
	(addNotify): Set peer via reflection.
	(setWindowPeer): Removed.
	* gnu/java/awt/natEmbeddedWindow.cc: Removed.
	* Makefile.am (nat_source_files):
	Removed gnu/java/awt/natEmbeddedWindow.cc.

2004-08-31  Bryce McKinlay  <mckinlay@redhat.com>

	* Makefile.am: Add  gnu/java/security/action/GetPropertyAction.java
	and gnu/java/security/action/SetAccessibleAction.java.

2004-08-31  Bryce McKinlay  <mckinlay@redhat.com>

	* gnu/java/security/action/GetPropertyAction.java (setParameters):
	Renamed from 'setName'. New 2-argument form with default value.
	(run): Pass default 'value' parameter to System.getProperty().
	* gnu/java/security/action/SetAccessibleAction.java: Fix javadoc
	typos.

2004-08-31  Bryce McKinlay  <mckinlay@redhat.com>

	* gnu/java/security/action/GetPropertyAction.java: New class.
	* gnu/java/security/action/SetAccessibleAction.java: New class.

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

	* gnu/java/awt/peer/gtk/GtkFramePeer.java
	(setIconImage): Check if image is null.

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

	* gnu/java/awt/peer/gtk/GtkFramePeer.java
	(create): Set the icon image.
	(nativeSetIconImage): New native method declaration.
	(setIconImage): Implement.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(nativeSetIconImage): New function.

2004-08-31  Dalibor Topic <robilad@kaffe.org>

	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFileDialogPeer.c
	(filenameFilterCallback): Declare local variable accepted before use.

2004-08-31  Dalibor Topic <robilad@kaffe.org>

	* gnu/java/awt/ComponentDataBlitOp.java:
	Cleaned up imports.

2004-08-31  Tom Tromey  <tromey@redhat.com>

	* gnu/java/awt/peer/GLightweightPeer.java,
	gnu/java/awt/peer/gtk/GdkGraphics2D.java,
	gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	javax/swing/JScrollPane.java: Removed
	redundant imports.

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

	* java/awt/DefaultKeyboardFocusManager.java
	(postProcessKeyEvent): Only activate MenuShortcuts on KEY_PRESSED
	event.  Fix shift modifier checking.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
	(accel_attach): Remove.
	(setupAccelGroup): Remove calls to accel_attach.

2004-08-31  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkArg.java: Remove file.
	* gnu/java/awt/peer/gtk/GtkArgList.java: Remove file.

	* Makefile.am (gtk_awt_peer_sources): Remove GtkArg.java and
	GtkArgList.java.
	(gtk_c_files): Use CAIRO_CFLAGS and PANGOFT2_CFLAGS, not _LIBS.
	* Makefile.in: Regenerate.
	* gnu/java/awt/peer/gtk/GtkButtonPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkButtonPeer.c
	(create(String)): New method.
	(create): Call new create method.
	(getArgs): Remove method.
	* gnu/java/awt/peer/gtk/GtkCheckboxPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkCheckboxPeer.c
	(nativeCreate): Rename to create.
	(gtkSetLabel): Rename to gtkButtonSetLabel.
	(gtkToggleButtonSetActive): New method.
	(create): Call gtkToggleButtonSetActive and gtkButtonSetLabel.
	(setState): Replace set call with gtkToggleButtonSetActive.
	(setLabel): Replace gtkSetLabel call with gtkButtonSetLabel.
	(getArgs): Remove method.
	* gnu/java/awt/peer/gtk/GtkComponentPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(gtkWidgetSetSensitive): New method.
	(gtkWidgetSetParent): Likewise.
	(GtkComponentPeer): Call setParent, setComponentBounds and
	setVisibleAndEnabled.
	(setParent): New method.
	(setComponentBounds): New method.
	(setVisibleAndEnabled): New method.
	(setEnabled): Call gtkWidgetSetSensitive.
	(getArgs): Remove method.
	Remove all set methods.
	* gnu/java/awt/peer/gtk/GtkDialogPeer.java (create): Call
	gtkWindowSetModal, setTitle and setResizable.
	(getArgs): Remove method.
	* gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
	(setComponentBounds): New method.
	* gnu/java/awt/peer/gtk/GtkFramePeer.java (setResizable):
	Replace set call with gtkWindowSetResizable.
	(getArgs): Remove method.
	(create): Call setTitle and setResizable.
	* gnu/java/awt/peer/gtk/GtkWindowPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
	(gtkWindowSetTitle): New method.
	(gtkWindowSetResizable): New method.
	(gtkWindowSetModal): New method.
	(setParent): New method.
	(setVisibleAndEnabled): New method.
	(getArgs): Remove method.
	(setTitle): Call gtkWindowSetTitle.
	(setResizable): Call gtkWindowSetResizable.
	* jni/gtk-peer/gtkpeer.h [DEBUG_LOCKING]: New define to turn on
	and off locking instrumentation.

2004-08-31  Kim Ho  <kho@redhat.com>

	* Makefile.am: Add new file.
	* Makefile.in: Regenerate.
	* gcj/Makefile.in: Regenerate
	* include/Makefile.in:
	* java/awt/Container.java:
	(acquireComponentForMouseEvent): Respect
	the event mask when looking for candidate.
	* javax/swing/JComponent.java:
	Remove toolTip field.
	(createToolTip): Create a tooltip on demand.
	(setToolTipText): Register with the ToolTipManager.
	(getToolTipText(MouseEvent)): Return getToolTipText().
	* javax/swing/JToolTip.java: Implement.
	* javax/swing/Timer.java: Jalopy.
	(restart): Call stop, then start.
	(stop): Interrupt the timer rather than wait for
	the timer to come to a stop naturally.
	* javax/swing/ToolTipManager.java: Implement.
	* javax/swing/plaf/basic/BasicLookAndFeel.java:
	Change ToolTip.background color.
	* javax/swing/plaf/basic/BasicToolTipUI.java:
	Implement.
	* testsuite/Makefile.in: Regenerate

2004-08-31  Jerry Quinn  <jlquinn@optonline.net>

	* java/awt/image/DirectColorModel.java (DirectColorModel): Fix
	constructor param comments.

2004-08-31  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* java/awt/Component.java: Document AWT 1.0 event handler
	methods.

2004-08-31  Roman Kennke  <roman@ontographics.com>

	* javax/swing/Box.java:
	(createGlue): Implemented
	(createHorizontalGlue): Implemented
	(createHorizontalStrut): Implemented
	(createVerticalGlue): Implemented
	(createVerticalStrut): Implemented

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

	* gnu/java/awt/peer/gtk/GtkChoicePeer.java
	(GtkChoicePeer): Do not automatically select first item.
	(getHistory): Remove.
	(nativeGetSelected): New method.
	(nativeRemoveAll): New method.
	(add): Use nativeGetSelected() instead of getHistory().
	(remove): Likewise.
	(removeAll): Call nativeRemoveAll().
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkChoicePeer.c
	(create): Migrate to GtkComboBox.
	(append): Likewise.
	(nativeAdd): Likewise.
	(nativeRemove): Likewise.
	(select): Likewise.
	(nativeRemoveAll): New method.
	(nativeGetSelected): New method.
	(selection_changed): New method.
	(getHistory): Remove.
	(item_activate): Remove.
	(item_removed): Remove.
	(connect_choice_item_selectable_hook): Remove.

2004-08-31  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java (create): Use tf
	variable in setEditable call.

	* gnu/java/awt/peer/gtk/GtkTextFieldPeer.java,
	jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c
	(gtkWidgetSetBackground): New method.
	(gtkWidgetSetForeground): Likewise.
	(create): Set peer's editable state based on awtComponent's.

	* java/awt/Button.java (Button()): Use empty string rather than
	null in no-label constructor.

2004-08-31  Roman Kennke  <roman@ontographics.com>

	* javax/swing/BoxLayout.java: Reimplement.

2004-08-31  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphics.java,
	gnu_java_awt_peer_gtk_GdkGraphics.c
	(initState(GtkComponentPeer)): Don't return array of colour
	values.
	(GdkGraphics(int,int)): Set default font to size 12.
	(GdkGraphics(GtkComponentPeer)): Set graphics colour to
	component's foreground colour.
	* gnu/java/awt/peer/gtk/GdkGraphics2D.java,
	gnu_java_awt_peer_gtk_GdkGraphics2D.c
	(initState(GtkComponentPeer)): Don't return array of colour
	values.
	(GdkGraphics2D(GtkComponentPeer)): Set foreground and background
	colours to component's colours.
	(current_colors_of_widget): Remove function.
	* gnu/java/awt/peer/gtk/GtkOffScreenImage.java (getGraphics):
	Return a new graphics object.
	* java/awt/Font.java (toString): Fix format.
	* java/awt/Graphics.java (toString): Likewise.

2004-08-31  Craig Black  <craig.black@aonix.com>

	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
	(addTearOff): New function.
	* gnu/java/awt/peer/gtk/GtkMenuPeer.java (addTearOff):
	New native method.
	(init): Call addTearOff() when menu.isTearOff().

2004-08-31  Bryce McKinlay  <mckinlay@redhat.com>

	* gnu/java/awt/ClasspathToolkit.java (createImageProducer): New.
	Default implementation.
	* gnu/java/awt/peer/gtk/GtkToolkit.java (createImageProducer): New.
	Implement using GdkPixbufDecoder.

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

	* gnu/java/awt/peer/gtk/GtkComponentPeer.java
	(GtkComponentPeer): Use gtkWidgetGetPreferredDimensions() for
	setting the size of GtkFileDialogPeers.
	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
	(gtkWidgetGetPreferredDimensions): For widgets extending GtkWindow,
	use their default sizes rather than their natural requisitions.

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

	* javax/swing/JFormattedTextField.java
	(JFormattedTextField): Implemented.
	* javax/swing/text/DefaultEditorKit.java
	(BeepAction): New inner class.
	* javax/swing/text/Segment.java
	(partialReturn): New field.
	(setPartialReturn): New method.
	(isPartialReturn): Likewise.
	* javax/swing/text/View.java
	(createFragment): Fixed typo.
	(getStartOffset): New method.
	(getEndOffset): Likewise.

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

	* javax/swing/table/DefaultTableColumnModel.java
	(serialVersionUID): Made private.
	(listenerList): Initialize.
	(changeEvent): Initialize.
	* javax/swing/table/JTableHeader.java
	(JTableHeader): New constructors.
	(createDefaultColumnModel): New method.
	* javax/swing/table/TableColumn.java
	(setHeaderRenderer): Simplified code.
	(setCellRenderer): Likewise.
	(setWidth): Likewise.

From-SVN: r86956
This commit is contained in:
Graydon Hoare 2004-09-02 05:10:34 +00:00
parent 1e8964cf94
commit 5757917258
130 changed files with 15538 additions and 5876 deletions

File diff suppressed because it is too large Load Diff

View File

@ -268,6 +268,7 @@ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextComponentPeer.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkTextFieldPeer.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c \
jni/gtk-peer/gnu_java_awt_peer_gtk_GThreadNativeMethodRunner.c \
jni/gtk-peer/gthread-jni.c \
jni/classpath/jcl.c \
jni/classpath/jnilink.c \
@ -284,8 +285,6 @@ gnu/java/awt/peer/gtk/GdkGraphics.java \
gnu/java/awt/peer/gtk/GdkGraphics2D.java \
gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java \
gnu/java/awt/peer/gtk/GdkPixbufDecoder.java \
gnu/java/awt/peer/gtk/GtkArg.java \
gnu/java/awt/peer/gtk/GtkArgList.java \
gnu/java/awt/peer/gtk/GtkButtonPeer.java \
gnu/java/awt/peer/gtk/GtkCanvasPeer.java \
gnu/java/awt/peer/gtk/GtkCheckboxGroupPeer.java \
@ -319,7 +318,10 @@ gnu/java/awt/peer/gtk/GtkTextAreaPeer.java \
gnu/java/awt/peer/gtk/GtkTextComponentPeer.java \
gnu/java/awt/peer/gtk/GtkTextFieldPeer.java \
gnu/java/awt/peer/gtk/GtkToolkit.java \
gnu/java/awt/peer/gtk/GtkWindowPeer.java
gnu/java/awt/peer/gtk/GtkWindowPeer.java \
gnu/java/awt/peer/gtk/GThreadMutex.java \
gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java
gtk_jni_headers = $(patsubst %.java,jniinclude/%.h,$(subst /,_,$(gtk_awt_peer_sources)))
@ -344,7 +346,8 @@ jni/classpath/primlib.h
lib_gnu_java_awt_peer_gtk_la_CFLAGS = \
-Ijniinclude -I$(srcdir)/jni/classpath \
-I$(srcdir)/jni/gtk-peer $(GTK_CFLAGS) $(LIBART_CFLAGS)
-I$(srcdir)/jni/gtk-peer $(PEDANTIC_CFLAGS) $(GTK_CFLAGS) $(LIBART_CFLAGS) \
$(CAIRO_CFLAGS) $(PANGOFT2_CFLAGS)
lib_gnu_java_awt_peer_gtk_la_GCJFLAGS = $(AM_GCJFLAGS) -fjni
lib_gnu_java_awt_peer_gtk_la_LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(LIBART_LIBS) $(CAIRO_LIBS) $(PANGOFT2_LIBS)
lib_gnu_java_awt_peer_gtk_la_DEPENDENCIES = $(gtk_jni_headers) libgcj-@gcc_version@.jar libgcj.la libgcj.spec
@ -1327,12 +1330,19 @@ javax/swing/border/TitledBorder.java \
javax/swing/GrayFilter.java \
javax/swing/AbstractAction.java \
javax/swing/AbstractButton.java \
javax/swing/AbstractSpinnerModel.java \
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/BasicColorChooserUI.java \
javax/swing/plaf/basic/BasicComboBoxUI.java \
javax/swing/plaf/basic/BasicComboBoxEditor.java \
javax/swing/plaf/basic/BasicComboBoxRenderer.java \
javax/swing/plaf/basic/BasicComboPopup.java \
javax/swing/plaf/basic/BasicDesktopIconUI.java \
javax/swing/plaf/basic/BasicDesktopPaneUI.java \
javax/swing/plaf/basic/BasicFormattedTextFieldUI.java \
javax/swing/plaf/basic/BasicGraphicsUtils.java \
javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \
javax/swing/plaf/basic/BasicInternalFrameUI.java \
@ -1343,6 +1353,7 @@ javax/swing/plaf/basic/BasicMenuBarUI.java \
javax/swing/plaf/basic/BasicMenuItemUI.java \
javax/swing/plaf/basic/BasicOptionPaneUI.java \
javax/swing/plaf/basic/BasicPanelUI.java \
javax/swing/plaf/basic/BasicPasswordFieldUI.java \
javax/swing/plaf/basic/BasicPopupMenuUI.java \
javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java \
javax/swing/plaf/basic/BasicProgressBarUI.java \
@ -1354,19 +1365,25 @@ javax/swing/plaf/basic/BasicScrollBarUI.java \
javax/swing/plaf/basic/BasicScrollPaneUI.java \
javax/swing/plaf/basic/BasicSeparatorUI.java \
javax/swing/plaf/basic/BasicSliderUI.java \
javax/swing/plaf/basic/BasicSpinnerUI.java \
javax/swing/plaf/basic/BasicSplitPaneDivider.java \
javax/swing/plaf/basic/BasicSplitPaneUI.java \
javax/swing/plaf/basic/BasicTabbedPaneUI.java \
javax/swing/plaf/basic/BasicTableUI.java \
javax/swing/plaf/basic/BasicTableHeaderUI.java \
javax/swing/plaf/basic/BasicTextAreaUI.java \
javax/swing/plaf/basic/BasicTextFieldUI.java \
javax/swing/plaf/basic/BasicTextUI.java \
javax/swing/plaf/basic/BasicToggleButtonUI.java \
javax/swing/plaf/basic/BasicToolBarSeparatorUI.java \
javax/swing/plaf/basic/BasicToolBarUI.java \
javax/swing/plaf/basic/BasicToolTipUI.java \
javax/swing/plaf/basic/BasicTreeUI.java \
javax/swing/plaf/basic/BasicViewportUI.java \
javax/swing/plaf/basic/BasicLookAndFeel.java \
javax/swing/plaf/basic/BasicBorders.java \
javax/swing/plaf/basic/BasicIconFactory.java \
javax/swing/plaf/basic/ComboPopup.java \
javax/swing/plaf/BorderUIResource.java \
javax/swing/plaf/UIResource.java \
javax/swing/plaf/ButtonUI.java \
@ -1415,6 +1432,10 @@ javax/swing/colorchooser/AbstractColorChooserPanel.java \
javax/swing/colorchooser/ColorChooserComponentFactory.java \
javax/swing/colorchooser/ColorSelectionModel.java \
javax/swing/colorchooser/DefaultColorSelectionModel.java \
javax/swing/colorchooser/DefaultPreviewPanel.java \
javax/swing/colorchooser/DefaultSwatchChooserPanel.java \
javax/swing/colorchooser/DefaultHSBChooserPanel.java \
javax/swing/colorchooser/DefaultRGBChooserPanel.java \
javax/swing/filechooser/FileFilter.java \
javax/swing/filechooser/FileSystemView.java \
javax/swing/filechooser/FileView.java \
@ -1460,6 +1481,7 @@ javax/swing/JRadioButton.java \
javax/swing/JRootPane.java \
javax/swing/JScrollBar.java \
javax/swing/JScrollPane.java \
javax/swing/JSpinner.java \
javax/swing/JTabbedPane.java \
javax/swing/JTextArea.java \
javax/swing/JTextField.java \
@ -1474,11 +1496,15 @@ javax/swing/ListModel.java \
javax/swing/ListSelectionModel.java \
javax/swing/LookAndFeel.java \
javax/swing/Scrollable.java \
javax/swing/SpinnerModel.java \
javax/swing/SpinnerNumberModel.java \
javax/swing/Spring.java \
javax/swing/SpringLayout.java \
javax/swing/SwingConstants.java \
javax/swing/SwingUtilities.java \
javax/swing/Timer.java \
javax/swing/ToolTipManager.java \
javax/swing/TransferHandler.java \
javax/swing/UIDefaults.java \
javax/swing/UIManager.java \
javax/swing/UnsupportedLookAndFeelException.java \
@ -1550,12 +1576,18 @@ javax/swing/text/PlainDocument.java \
javax/swing/text/PlainView.java \
javax/swing/text/Position.java \
javax/swing/text/Segment.java \
javax/swing/text/SimpleAttributeSet.java \
javax/swing/text/Style.java \
javax/swing/text/StyleConstants.java \
javax/swing/text/StyleContext.java \
javax/swing/text/StyledDocument.java \
javax/swing/text/StyledEditorKit.java \
javax/swing/text/TabExpander.java \
javax/swing/text/TabableView.java \
javax/swing/text/TabExpander.java \
javax/swing/text/TabSet.java \
javax/swing/text/TabStop.java \
javax/swing/text/TextAction.java \
javax/swing/text/Utilities.java \
javax/swing/text/View.java \
javax/swing/text/ViewFactory.java \
javax/swing/text/html/HTML.java \
@ -1638,7 +1670,6 @@ javax/swing/ProgressMonitor.java \
javax/swing/ProgressMonitorInputStream.java \
javax/swing/RepaintManager.java \
javax/swing/ScrollPaneLayout.java \
javax/swing/ToolTipManager.java \
javax/swing/ViewportLayout.java
rmi_java_source_files = \

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ public class LightweightRedirector
MouseEvent redirected = new MouseEvent(source, event.getID(),
event.getWhen(),
event.getModifiers(),
event.getModifiersEx(),
x, y,
event.getClickCount(),
event.isPopupTrigger());
@ -157,20 +157,20 @@ public class LightweightRedirector
*/
int getButtonNumber(InputEvent event)
{
int modifiers = event.getModifiers();
int modifiers = event.getModifiersEx();
modifiers &=
InputEvent.BUTTON1_MASK |
InputEvent.BUTTON2_MASK |
InputEvent.BUTTON3_MASK;
InputEvent.BUTTON1_DOWN_MASK |
InputEvent.BUTTON2_DOWN_MASK |
InputEvent.BUTTON3_DOWN_MASK;
switch (modifiers)
{
case InputEvent.BUTTON1_MASK:
case InputEvent.BUTTON1_DOWN_MASK:
return 1;
case InputEvent.BUTTON2_MASK:
case InputEvent.BUTTON2_DOWN_MASK:
return 2;
case InputEvent.BUTTON3_MASK:
case InputEvent.BUTTON3_DOWN_MASK:
return 3;
case 0:
return 0;

View File

@ -197,13 +197,13 @@ public class XEventLoop implements Runnable
switch (buttonEvt.button)
{
case 1:
modifiers = InputEvent.BUTTON1_MASK;
modifiers = InputEvent.BUTTON1_DOWN_MASK;
break;
case 2:
modifiers = InputEvent.BUTTON2_MASK;
modifiers = InputEvent.BUTTON2_DOWN_MASK;
break;
case 3:
modifiers = InputEvent.BUTTON2_MASK;
modifiers = InputEvent.BUTTON2_DOWN_MASK;
break;
}

View File

@ -1,5 +1,5 @@
/* GLightweightPeer.java --
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -45,7 +45,6 @@ import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;

View File

@ -64,7 +64,7 @@ public class GdkGraphics extends Graphics
static final int GDK_COPY = 0, GDK_XOR = 2;
native int[] initState (GtkComponentPeer component);
native void initState (GtkComponentPeer component);
native void initState (int width, int height);
native void copyState (GdkGraphics g);
@ -84,15 +84,15 @@ public class GdkGraphics extends Graphics
initState (width, height);
color = Color.black;
clip = new Rectangle (0, 0, width, height);
font = new Font ("Dialog", Font.PLAIN, 10);
font = new Font ("Dialog", Font.PLAIN, 12);
}
GdkGraphics (GtkComponentPeer component)
{
this.component = component;
int rgb[] = initState (component);
color = new Color (rgb[0], rgb[1], rgb[2]);
font = component.awtComponent.getFont();
initState (component);
color = component.awtComponent.getForeground ();
font = component.awtComponent.getFont ();
Dimension d = component.awtComponent.getSize ();
clip = new Rectangle (0, 0, d.width, d.height);
}
@ -126,6 +126,11 @@ public class GdkGraphics extends Graphics
native public void dispose ();
native void copyPixmap (Graphics g, int x, int y, int width, int height);
native void copyAndScalePixmap (Graphics g, boolean flip_x, boolean flip_y,
int src_x, int src_y,
int src_width, int src_height,
int dest_x, int dest_y,
int dest_width, int dest_height);
public boolean drawImage (Image img, int x, int y,
Color bgcolor, ImageObserver observer)
{
@ -161,7 +166,10 @@ public class GdkGraphics extends Graphics
{
if (img instanceof GtkOffScreenImage)
{
throw new RuntimeException ();
copyAndScalePixmap (img.getGraphics (), false, false,
0, 0, img.getWidth (null), img.getHeight (null),
x, y, width, height);
return true;
}
GtkImage image = (GtkImage) img;
@ -186,7 +194,60 @@ public class GdkGraphics extends Graphics
{
if (img instanceof GtkOffScreenImage)
{
throw new RuntimeException ();
int dx_start, dy_start, d_width, d_height;
int sx_start, sy_start, s_width, s_height;
boolean x_flip = false;
boolean y_flip = false;
if (dx1 < dx2)
{
dx_start = dx1;
d_width = dx2 - dx1;
}
else
{
dx_start = dx2;
d_width = dx1 - dx2;
x_flip ^= true;
}
if (dy1 < dy2)
{
dy_start = dy1;
d_height = dy2 - dy1;
}
else
{
dy_start = dy2;
d_height = dy1 - dy2;
y_flip ^= true;
}
if (sx1 < sx2)
{
sx_start = sx1;
s_width = sx2 - sx1;
}
else
{
sx_start = sx2;
s_width = sx1 - sx2;
x_flip ^= true;
}
if (sy1 < sy2)
{
sy_start = sy1;
s_height = sy2 - sy1;
}
else
{
sy_start = sy2;
s_height = sy1 - sy2;
y_flip ^= true;
}
copyAndScalePixmap (img.getGraphics (), x_flip, y_flip,
sx_start, sy_start, s_width, s_height,
dx_start, dy_start, d_width, d_height);
return true;
}
GtkImage image = (GtkImage) img;
@ -238,13 +299,48 @@ public class GdkGraphics extends Graphics
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
// System.out.println ("drawRoundRect called [UNIMPLEMENTED]");
if (arcWidth > width)
arcWidth = width;
if (arcHeight > height)
arcHeight = height;
int xx = x + width - arcWidth;
int yy = y + height - arcHeight;
drawArc (x, y, arcWidth, arcHeight, 90, 90);
drawArc (xx, y, arcWidth, arcHeight, 0, 90);
drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
drawArc (x, yy, arcWidth, arcHeight, 180, 90);
int y1 = y + arcHeight / 2;
int y2 = y + height - arcHeight / 2;
drawLine (x, y1, x, y2);
drawLine (x + width, y1, x + width, y2);
int x1 = x + arcWidth / 2;
int x2 = x + width - arcWidth / 2;
drawLine (x1, y, x2, y);
drawLine (x1, y + height, x2, y + height);
}
public void fillRoundRect (int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
// System.out.println ("fillRoundRect called [UNIMPLEMENTED]");
if (arcWidth > width)
arcWidth = width;
if (arcHeight > height)
arcHeight = height;
int xx = x + width - arcWidth;
int yy = y + height - arcHeight;
fillArc (x, y, arcWidth, arcHeight, 90, 90);
fillArc (xx, y, arcWidth, arcHeight, 0, 90);
fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
fillArc (x, yy, arcWidth, arcHeight, 180, 90);
fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
}
public Shape getClip ()

View File

@ -1,5 +1,5 @@
/* GdkGraphics2D.java
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -48,7 +48,6 @@ import java.util.HashMap;
import java.util.Map;
import java.text.AttributedCharacterIterator;
import java.util.Map;
import java.util.Stack;
import java.lang.Integer;
import gnu.java.awt.ClasspathToolkit;
@ -88,7 +87,7 @@ public class GdkGraphics2D extends Graphics2D
private Stack stateStack;
native private int[] initState (GtkComponentPeer component);
native private void initState (GtkComponentPeer component);
native private void initState (int width, int height);
native private void copyState (GdkGraphics2D g);
native public void dispose ();
@ -169,10 +168,10 @@ public class GdkGraphics2D extends Graphics2D
GdkGraphics2D (GtkComponentPeer component)
{
this.component = component;
int rgb[] = initState (component);
initState (component);
setColor (new Color (rgb[0], rgb[1], rgb[2]));
setBackground (new Color (rgb[3], rgb[4], rgb[5]));
setColor (component.awtComponent.getForeground ());
setBackground (component.awtComponent.getBackground ());
setPaint (getColor());
setFont (new Font("SansSerif", Font.PLAIN, 12));
setTransform (new AffineTransform ());
@ -1478,14 +1477,28 @@ public class GdkGraphics2D extends Graphics2D
public void drawRoundRect(int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
int x1 = x + arcWidth, x2 = x + width - arcWidth;
int y1 = y + arcHeight, y2 = y + height - arcHeight;
fillRect (x1, y, x2 - x1, height);
fillRect (x, y1, width, y2 - y1);
fillArc (x, y, arcWidth, arcHeight, 90, 90);
fillArc (x1, y, arcWidth, arcHeight, 0, 90);
fillArc (x2, y2, arcWidth, arcHeight, 270, 90);
fillArc (x, y2, arcWidth, arcHeight, 180, 90);
if (arcWidth > width)
arcWidth = width;
if (arcHeight > height)
arcHeight = height;
int xx = x + width - arcWidth;
int yy = y + height - arcHeight;
drawArc (x, y, arcWidth, arcHeight, 90, 90);
drawArc (xx, y, arcWidth, arcHeight, 0, 90);
drawArc (xx, yy, arcWidth, arcHeight, 270, 90);
drawArc (x, yy, arcWidth, arcHeight, 180, 90);
int y1 = y + arcHeight / 2;
int y2 = y + height - arcHeight / 2;
drawLine (x, y1, x, y2);
drawLine (x + width, y1, x + width, y2);
int x1 = x + arcWidth / 2;
int x2 = x + width - arcWidth / 2;
drawLine (x1, y, x2, y);
drawLine (x1, y + height, x2, y + height);
}
public void drawString (String str, int x, int y)
@ -1527,14 +1540,21 @@ public class GdkGraphics2D extends Graphics2D
public void fillRoundRect (int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
int x1 = x + arcWidth, x2 = x + width - arcWidth;
int y1 = y + arcHeight, y2 = y + height - arcHeight;
fillRect (x1, y, x2 - x1, height);
fillRect (x, y1, width, y2 - y1);
if (arcWidth > width)
arcWidth = width;
if (arcHeight > height)
arcHeight = height;
int xx = x + width - arcWidth;
int yy = y + height - arcHeight;
fillArc (x, y, arcWidth, arcHeight, 90, 90);
fillArc (x1, y, arcWidth, arcHeight, 0, 90);
fillArc (x2, y2, arcWidth, arcHeight, 270, 90);
fillArc (x, y2, arcWidth, arcHeight, 180, 90);
fillArc (xx, y, arcWidth, arcHeight, 0, 90);
fillArc (xx, yy, arcWidth, arcHeight, 270, 90);
fillArc (x, yy, arcWidth, arcHeight, 180, 90);
fillRect (x, y + arcHeight / 2, width, height - arcHeight + 1);
fillRect (x + arcWidth / 2, y, width - arcWidth + 1, height);
}
public Font getFont ()

View File

@ -50,12 +50,13 @@ import java.awt.peer.ButtonPeer;
public class GtkButtonPeer extends GtkComponentPeer
implements ButtonPeer
{
native void create ();
native void create (String label);
public native void connectJObject ();
public native void connectSignals ();
native void gtkSetFont (String name, int style, int size);
native void gtkSetLabel(String label);
native void gtkSetLabel (String label);
native void gtkWidgetSetForeground (int red, int green, int blue);
native void gtkActivate ();
@ -64,6 +65,11 @@ public class GtkButtonPeer extends GtkComponentPeer
super (b);
}
void create ()
{
create (((Button) awtComponent).getLabel ());
}
public void setLabel (String label)
{
gtkSetLabel(label);
@ -78,10 +84,10 @@ public class GtkButtonPeer extends GtkComponentPeer
p.translate(((Component) me.getSource()).getX(),
((Component) me.getSource()).getY());
if (!me.isConsumed ()
&& (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0
&& (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0
&& awtComponent.getBounds().contains(p))
postActionEvent (((Button)awtComponent).getActionCommand (),
me.getModifiers ());
me.getModifiersEx ());
}
if (e.getID () == KeyEvent.KEY_PRESSED)
@ -90,18 +96,11 @@ public class GtkButtonPeer extends GtkComponentPeer
if (!ke.isConsumed () && ke.getKeyCode () == KeyEvent.VK_SPACE)
{
postActionEvent (((Button) awtComponent).getActionCommand (),
ke.getModifiers ());
ke.getModifiersEx ());
gtkActivate ();
}
}
super.handleEvent (e);
}
public void getArgs (Component component, GtkArgList args)
{
super.getArgs (component, args);
args.add ("label", ((Button)component).getLabel ());
}
}

View File

@ -52,39 +52,39 @@ public class GtkCheckboxPeer extends GtkComponentPeer
// The current state of the GTK checkbox.
private boolean currentState;
public native void nativeCreate (GtkCheckboxGroupPeer group,
boolean state);
public native void create (GtkCheckboxGroupPeer group);
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
public native void connectSignals ();
native void gtkSetFont (String name, int style, int size);
public native void gtkSetLabel (String label);
native void gtkButtonSetLabel (String label);
native void gtkToggleButtonSetActive (boolean is_active);
public GtkCheckboxPeer (Checkbox c)
{
super (c);
}
// We can't fully use the ordinary getArgs code here, due to
// oddities of this particular widget. In particular we must be
// able to switch between a checkbutton and a radiobutton
// dynamically.
// FIXME: we must be able to switch between a checkbutton and a
// radiobutton dynamically.
public void create ()
{
CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup ();
Checkbox checkbox = (Checkbox) awtComponent;
CheckboxGroup g = checkbox.getCheckboxGroup ();
old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g);
currentState = ((Checkbox)awtComponent).getState();
nativeCreate (old_group, currentState);
create (old_group);
gtkToggleButtonSetActive (checkbox.getState ());
gtkButtonSetLabel (checkbox.getLabel ());
}
public void setState (boolean state)
{
if (currentState != state)
set ("active", state);
gtkToggleButtonSetActive (state);
}
public void setLabel (String label)
{
gtkSetLabel (label);
gtkButtonSetLabel (label);
}
public void setCheckboxGroup (CheckboxGroup group)
@ -100,13 +100,6 @@ public class GtkCheckboxPeer extends GtkComponentPeer
}
}
public void getArgs (Component component, GtkArgList args)
{
super.getArgs (component, args);
args.add ("active", ((Checkbox) component).getState ());
args.add ("label", ((Checkbox) component).getLabel ());
}
// Override the superclass postItemEvent so that the peer doesn't
// need information that we have.
public void postItemEvent (Object item, int stateChange)

View File

@ -58,25 +58,22 @@ public class GtkChoicePeer extends GtkComponentPeer
items[i] = c.getItem (i);
append (items);
// Must set our state before notifying listeners
((Choice) awtComponent).select (c.getItem (0));
postItemEvent (c.getItem (0), ItemEvent.SELECTED);
}
}
native void create ();
native void append (String items[]);
native int getHistory ();
native int nativeGetSelected ();
native void nativeAdd (String item, int index);
native void nativeRemove (int index);
native void nativeRemoveAll ();
native public void select (int position);
public void add (String item, int index)
{
int before = getHistory();
int before = nativeGetSelected();
nativeAdd (item, index);
@ -92,11 +89,11 @@ public class GtkChoicePeer extends GtkComponentPeer
public void remove (int index)
{
int before = getHistory();
int before = nativeGetSelected();
int after;
nativeRemove (index);
after = getHistory();
after = nativeGetSelected();
/* Generate an ItemEvent if we are removing the currently selected item
and there are at least one item left. */
@ -110,7 +107,7 @@ public class GtkChoicePeer extends GtkComponentPeer
public void removeAll ()
{
nativeRemove (-1);
nativeRemoveAll();
}
public void addItem (String item, int position)

View File

@ -61,7 +61,6 @@ import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.PaintEvent;
@ -93,6 +92,8 @@ public class GtkComponentPeer extends GtkGenericPeer
native void gtkWidgetSetCursor (int type);
native void gtkWidgetSetBackground (int red, int green, int blue);
native void gtkWidgetSetForeground (int red, int green, int blue);
native void gtkWidgetSetSensitive (boolean sensitive);
native void gtkWidgetSetParent (ComponentPeer parent);
native void gtkWidgetRequestFocus ();
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
int keyCode, int keyLocation);
@ -115,37 +116,59 @@ public class GtkComponentPeer extends GtkGenericPeer
this.awtComponent = awtComponent;
insets = new Insets (0, 0, 0, 0);
create ();
GtkArgList args = new GtkArgList ();
getArgs (awtComponent, args);
args.setArgs (this);
create ();
connectJObject ();
connectSignals ();
setParent ();
if (awtComponent.getForeground () != null)
setForeground (awtComponent.getForeground ());
if (awtComponent.getBackground () != null)
setBackground (awtComponent.getBackground ());
if (awtComponent.getFont() != null)
setFont(awtComponent.getFont());
connectJObject ();
connectSignals ();
setCursor (awtComponent.getCursor ());
if (this instanceof GtkFileDialogPeer && awtComponent.getHeight() == 0
&& awtComponent.getWidth() == 0)
if (awtComponent.getForeground () != null)
setForeground (awtComponent.getForeground ());
if (awtComponent.getBackground () != null)
setBackground (awtComponent.getBackground ());
if (awtComponent.getFont() != null)
setFont(awtComponent.getFont());
setCursor (awtComponent.getCursor ());
setComponentBounds ();
Rectangle bounds = awtComponent.getBounds ();
setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
setVisibleAndEnabled ();
}
void setParent ()
{
ComponentPeer p;
Component component = awtComponent;
do
{
int[] dims = new int[2];
gtkWidgetGetDimensions(dims);
((GtkFileDialogPeer) this).setBoundsCallback((Window)awtComponent,
awtComponent.getX(),
awtComponent.getY(),
dims[0], dims[1]);
component = component.getParent ();
p = component.getPeer ();
}
while (p instanceof java.awt.peer.LightweightPeer);
Rectangle bounds = awtComponent.getBounds ();
setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
if (p != null)
gtkWidgetSetParent (p);
}
/*
* Set the bounds of this peer's AWT Component based on dimensions
* returned by the native windowing system. Most Components impose
* their dimensions on the peers so the default implementation does
* nothing. However some peers, like GtkFileDialogPeer, need to
* pass their size back to the AWT Component.
*/
void setComponentBounds ()
{
}
void setVisibleAndEnabled ()
{
setVisible (awtComponent.isVisible ());
setEnabled (awtComponent.isEnabled ());
}
public int checkImage (Image image, int width, int height,
@ -260,12 +283,12 @@ public class GtkComponentPeer extends GtkGenericPeer
break;
case KeyEvent.KEY_PRESSED:
ke = (KeyEvent) event;
gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiers (),
gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiersEx (),
ke.getKeyCode (), ke.getKeyLocation ());
break;
case KeyEvent.KEY_RELEASED:
ke = (KeyEvent) event;
gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiers (),
gtkWidgetDispatchKeyEvent (ke.getID (), ke.getWhen (), ke.getModifiersEx (),
ke.getKeyCode (), ke.getKeyLocation ());
break;
}
@ -417,7 +440,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public void setEnabled (boolean b)
{
set ("sensitive", b);
gtkWidgetSetSensitive (b);
}
public void setFont (Font f)
@ -506,45 +529,6 @@ public class GtkComponentPeer extends GtkGenericPeer
item, stateChange));
}
public void getArgs (Component component, GtkArgList args)
{
args.add ("sensitive", component.isEnabled ());
ComponentPeer p;
do
{
component = component.getParent ();
p = component.getPeer ();
} while (p instanceof java.awt.peer.LightweightPeer);
if (p != null)
args.add ("parent", p);
}
native void set (String name, String value);
native void set (String name, boolean value);
native void set (String name, int value);
native void set (String name, float value);
native void set (String name, Object value);
void set (GtkArg arg)
{
String name = arg.getName ();
Object value = arg.getValue ();
if (value instanceof Boolean)
set (name, ((Boolean)value).booleanValue ());
else if (value instanceof Integer)
set (name, ((Integer)value).intValue ());
else if (value instanceof Float)
set (name, ((Float)value).floatValue ());
else if (value instanceof String)
set (name, ((String) value));
else
set (name, value);
}
public GraphicsConfiguration getGraphicsConfiguration ()
{
// FIXME: just a stub for now.

View File

@ -85,17 +85,11 @@ public class GtkDialogPeer extends GtkWindowPeer
{
// Create a decorated dialog window.
create (GDK_WINDOW_TYPE_HINT_DIALOG, true);
}
public void getArgs (Component component, GtkArgList args)
{
super.getArgs (component, args);
Dialog dialog = (Dialog) awtComponent;
Dialog dialog = (Dialog) component;
args.add ("title", dialog.getTitle ());
args.add ("modal", dialog.isModal ());
args.add ("allow_shrink", dialog.isResizable ());
args.add ("allow_grow", dialog.isResizable ());
gtkWindowSetModal (dialog.isModal ());
setTitle (dialog.getTitle ());
setResizable (dialog.isResizable ());
}
}

View File

@ -42,6 +42,7 @@ import java.awt.AWTEvent;
import java.awt.Dialog;
import java.awt.FileDialog;
import java.awt.Graphics;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.awt.peer.FileDialogPeer;
import java.io.FilenameFilter;
@ -81,6 +82,20 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
super (fd);
}
void setComponentBounds ()
{
if (awtComponent.getHeight () == 0
&& awtComponent.getWidth () == 0)
{
int[] dims = new int[2];
gtkWidgetGetPreferredDimensions (dims);
((GtkFileDialogPeer) this).setBoundsCallback ((Window) awtComponent,
awtComponent.getX (),
awtComponent.getY (),
dims[0], dims[1]);
}
}
public void setFile (String fileName)
{
/* If nothing changed do nothing. This usually happens because

View File

@ -47,6 +47,7 @@ import java.awt.MenuBar;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.peer.FramePeer;
import java.awt.peer.MenuBarPeer;
@ -115,10 +116,9 @@ public class GtkFramePeer extends GtkWindowPeer
setSize (awtComponent.getWidth() - insets.left - insets.right,
awtComponent.getHeight() - insets.top - insets.bottom
+ menuBarHeight);
set ("allow_shrink", resizable);
set ("allow_grow", resizable);
}
gtkWindowSetResizable (resizable);
}
protected void postInsetsChangedEvent (int top, int left,
int bottom, int right)
{
@ -137,24 +137,46 @@ public class GtkFramePeer extends GtkWindowPeer
{
// Create a normal decorated window.
create (GDK_WINDOW_TYPE_HINT_NORMAL, true);
setMenuBar(((Frame) awtComponent).getMenuBar());
awtComponent.setForeground(java.awt.SystemColor.windowText);
}
public void getArgs (Component component, GtkArgList args)
{
super.getArgs (component, args);
Frame frame = (Frame) component;
args.add ("title", frame.getTitle ());
args.add ("allow_shrink", frame.isResizable ());
args.add ("allow_grow", frame.isResizable ());
Frame frame = (Frame) awtComponent;
setMenuBar (frame.getMenuBar ());
setTitle (frame.getTitle ());
setResizable (frame.isResizable ());
setIconImage(frame.getIconImage());
}
native void nativeSetIconImageFromDecoder (GdkPixbufDecoder decoder);
native void nativeSetIconImageFromData (int[] pixels, int width, int height);
public void setIconImage (Image image)
{
/* TODO: Waiting on Toolkit Image routines */
if (image != null)
{
GtkImage img = (GtkImage) image;
// FIXME: Image should be loaded, but if not, do image loading here.
if (img.isLoaded())
{
if (img.getSource() instanceof GdkPixbufDecoder)
{
nativeSetIconImageFromDecoder((GdkPixbufDecoder) img.getSource());
}
else
{
int[] pixels = img.getPixelCache();
ColorModel model = img.getColorModel();
int[] data = new int[pixels.length * 4];
for (int i = 0; i < pixels.length; i++)
{
data[i * 4] = model.getRed(pixels[i]);
data[i * 4 + 1] = model.getGreen(pixels[i]);
data[i * 4 + 2] = model.getBlue(pixels[i]);
data[i * 4 + 3] = model.getAlpha(pixels[i]);
}
nativeSetIconImageFromData(data, img.getWidth(null), img.getHeight(null));
}
}
}
}
public Graphics getGraphics ()

View File

@ -89,6 +89,18 @@ public class GtkImage extends Image implements ImageConsumer
this.observer = observer;
}
public synchronized int[]
getPixelCache ()
{
return pixelCache;
}
public synchronized ColorModel
getColorModel ()
{
return model;
}
public synchronized int
getWidth (ImageObserver observer)
{

View File

@ -144,7 +144,7 @@ public class GtkListPeer extends GtkComponentPeer
// multiple click.
MouseEvent me = (MouseEvent) e;
if (!me.isConsumed ()
&& (me.getModifiers () & MouseEvent.BUTTON1_MASK) != 0
&& (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0
&& me.getClickCount() == 2)
{
String selectedItem = ((List) awtComponent).getSelectedItem ();
@ -153,7 +153,7 @@ public class GtkListPeer extends GtkComponentPeer
// something is selected.
if (selectedItem != null)
postActionEvent (((List) awtComponent).getSelectedItem (),
me.getModifiers ());
me.getModifiersEx ());
}
}
@ -167,7 +167,7 @@ public class GtkListPeer extends GtkComponentPeer
// Enter only generates an Action event if something is
// selected.
if (selectedItem != null)
postActionEvent (selectedItem, ke.getModifiers ());
postActionEvent (selectedItem, ke.getModifiersEx ());
}
}

View File

@ -43,7 +43,18 @@ public class GtkMainThread extends GtkGenericPeer implements Runnable
private static Thread mainThread = null;
private static Object mainThreadLock = new Object();
static native void gtkInit();
// Whether the gtk+ subsystem has been initialized.
private boolean gtkInitCalled = false;
/**
* Call gtk_init. It is very important that this happen before any other
* gtk calls.
*
* @param portableNativeSync 1 if the Java property
* gnu.classpath.awt.gtk.portable.native.sync is set to "true". 0 if it is
* set to "false". -1 if unset.
*/
static native void gtkInit(int portableNativeSync);
native void gtkMain();
public GtkMainThread()
@ -59,18 +70,38 @@ public class GtkMainThread extends GtkGenericPeer implements Runnable
synchronized (this)
{
mainThread.start();
try {
wait();
} catch (InterruptedException e) { }
while (!gtkInitCalled)
{
try
{
wait();
}
catch (InterruptedException e) { }
}
}
}
public void run()
{
/* Pass the value of the gnu.classpath.awt.gtk.portable.native.sync system
* property to C. */
int portableNativeSync;
String portNatSyncProp =
System.getProperty("gnu.classpath.awt.gtk.portable.native.sync");
if (portNatSyncProp == null)
portableNativeSync = -1; // unset
else if (Boolean.valueOf(portNatSyncProp).booleanValue())
portableNativeSync = 1; // true
else
portableNativeSync = 0; // false
synchronized (this)
{
gtkInit();
notify();
gtkInit(portableNativeSync);
gtkInitCalled = true;
notifyAll();
}
gtkMain();
}

View File

@ -56,15 +56,12 @@ public class GtkMenuBarPeer extends GtkMenuComponentPeer
create ();
}
native void nativeSetHelpMenu(MenuPeer menuPeer);
/* In Gnome, help menus are no longer right flushed. */
public void addHelpMenu (Menu menu)
{
addMenu (menu);
}
public void addMenu (Menu menu)
{
addMenu ((MenuPeer) menu.getPeer ());
nativeSetHelpMenu((MenuPeer) menu.getPeer());
}
native public void delMenu (int index);

View File

@ -89,10 +89,8 @@ public class GtkMenuItemPeer extends GtkMenuComponentPeer
setEnabled (true);
}
public void setEnabled (boolean b)
{
// do nothing, for now.
}
native public void setEnabled (boolean b);
native public void setLabel (String label);
protected void postMenuActionEvent ()

View File

@ -52,11 +52,15 @@ public class GtkMenuPeer extends GtkMenuItemPeer
native void create (String label);
native void addItem (MenuItemPeer item, int key, boolean shiftModifier);
native void setupAccelGroup (GtkGenericPeer container);
native void addTearOff ();
public GtkMenuPeer (Menu menu)
{
super (menu);
if (menu.isTearOff())
addTearOff();
MenuContainer parent = menu.getParent ();
if (parent instanceof Menu)
setupAccelGroup ((GtkGenericPeer)((Menu)parent).getPeer ());

View File

@ -76,7 +76,10 @@ public class GtkOffScreenImage extends Image
public Graphics getGraphics ()
{
return g;
if (g instanceof GdkGraphics2D)
return new GdkGraphics2D ((GdkGraphics2D) this.g);
else
return new GdkGraphics ((GdkGraphics) this.g);
}
public Object getProperty (String name, ImageObserver observer)

View File

@ -50,6 +50,8 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
implements TextFieldPeer
{
native void create (int width);
native void gtkWidgetSetBackground (int red, int green, int blue);
native void gtkWidgetSetForeground (int red, int green, int blue);
void create ()
{
@ -76,6 +78,8 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
int text_width = cols * fm.getMaxAdvance ();
create (text_width);
setEditable (tf.isEditable ());
}
native int gtkEntryGetBorderWidth ();
@ -162,7 +166,7 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
if (!ke.isConsumed ()
&& ke.getKeyCode () == KeyEvent.VK_ENTER)
postActionEvent (getText (), ke.getModifiers ());
postActionEvent (getText (), ke.getModifiersEx ());
}
super.handleEvent (e);

View File

@ -60,6 +60,10 @@ public class GtkWindowPeer extends GtkContainerPeer
private boolean hasBeenShown = false;
private int oldState = Frame.NORMAL;
native void gtkWindowSetTitle (String title);
native void gtkWindowSetResizable (boolean resizable);
native void gtkWindowSetModal (boolean modal);
native void create (int type, boolean decorated,
int width, int height,
GtkWindowPeer parent,
@ -92,6 +96,16 @@ public class GtkWindowPeer extends GtkContainerPeer
create (GDK_WINDOW_TYPE_HINT_NORMAL, false);
}
void setParent ()
{
setVisible (awtComponent.isVisible ());
setEnabled (awtComponent.isEnabled ());
}
void setVisibleAndEnabled ()
{
}
native void connectJObject ();
native void connectSignals ();
@ -100,12 +114,6 @@ public class GtkWindowPeer extends GtkContainerPeer
super (window);
}
public void getArgs (Component component, GtkArgList args)
{
args.add ("visible", component.isVisible ());
args.add ("sensitive", component.isEnabled ());
}
native public void toBack ();
native public void toFront ();
@ -120,7 +128,7 @@ public class GtkWindowPeer extends GtkContainerPeer
public void setTitle (String title)
{
set ("title", title);
gtkWindowSetTitle (title);
}
native void setSize (int width, int height);
@ -132,8 +140,7 @@ public class GtkWindowPeer extends GtkContainerPeer
// was resizable.
setSize (awtComponent.getWidth() - insets.left - insets.right,
awtComponent.getHeight() - insets.top - insets.bottom);
set ("allow_shrink", resizable);
set ("allow_grow", resizable);
gtkWindowSetResizable (resizable);
}
native void setBoundsCallback (Window window,

View File

@ -409,13 +409,13 @@ public class AWTKeyStroke implements Serializable
{
token = t.nextToken();
if ("shift".equals(token))
modifiers |= KeyEvent.SHIFT_MASK | KeyEvent.SHIFT_DOWN_MASK;
modifiers |= KeyEvent.SHIFT_DOWN_MASK;
else if ("ctrl".equals(token) || "control".equals(token))
modifiers |= KeyEvent.CTRL_MASK | KeyEvent.CTRL_DOWN_MASK;
modifiers |= KeyEvent.CTRL_DOWN_MASK;
else if ("meta".equals(token))
modifiers |= KeyEvent.META_MASK | KeyEvent.META_DOWN_MASK;
modifiers |= KeyEvent.META_DOWN_MASK;
else if ("alt".equals(token))
modifiers |= KeyEvent.ALT_MASK | KeyEvent.ALT_DOWN_MASK;
modifiers |= KeyEvent.ALT_DOWN_MASK;
else if ("button1".equals(token))
modifiers |= KeyEvent.BUTTON1_DOWN_MASK;
else if ("button2".equals(token))

View File

@ -101,7 +101,7 @@ private transient ActionListener action_listeners;
public
Button()
{
this(null);
this("");
}
/*************************************************************************/

View File

@ -506,7 +506,7 @@ public class Color implements Paint, Serializable
/**
* Returns the RGB value for this color, in the sRGB color space. The blue
* value will be in bits 0-7, green in 8-15, red in 6-23, and alpha value in
* value will be in bits 0-7, green in 8-15, red in 16-23, and alpha value in
* 24-31.
*
* @return the RGB value for this color
@ -772,9 +772,9 @@ public class Color implements Paint, Serializable
if (red == max)
array[0] = (green - blue) / delta;
else if (green == max)
array[0] = 1 / 3 + (blue - red) / delta;
array[0] = 1f / 3 + (blue - red) / delta;
else
array[0] = 2 / 3 + (red - green) / delta;
array[0] = 2f / 3 + (red - green) / delta;
if (array[0] < 0)
array[0]++;
}

View File

@ -58,6 +58,7 @@ import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.PaintEvent;
import java.awt.event.WindowEvent;
import java.awt.im.InputContext;
import java.awt.im.InputMethodRequests;
import java.awt.image.BufferStrategy;
@ -2262,7 +2263,7 @@ public abstract class Component
* This method simply calls handleEvent and returns the result.
*
* @param e the event to handle
* @return the result of handling <code>e</code>
* @return true if the event was handled, false otherwise
* @deprecated use {@link #dispatchEvent(AWTEvent)} instead
*/
public boolean postEvent(Event e)
@ -3028,6 +3029,7 @@ public abstract class Component
mouseListener.mouseReleased(e);
break;
}
e.consume();
}
/**
@ -3055,6 +3057,7 @@ public abstract class Component
mouseMotionListener.mouseMoved(e);
break;
}
e.consume();
}
/**
@ -3073,7 +3076,10 @@ public abstract class Component
{
if (mouseWheelListener != null
&& e.id == MouseEvent.MOUSE_WHEEL)
{
mouseWheelListener.mouseWheelMoved(e);
e.consume();
}
}
/**
@ -3205,135 +3211,145 @@ public abstract class Component
}
/**
* AWT 1.0 mouse event handler.
* AWT 1.0 MOUSE_DOWN event handler. This method is meant to be
* overridden by components providing their own MOUSE_DOWN handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
* @param y the y coordinate, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processMouseEvent(MouseEvent)} instead
*/
public boolean mouseDown(Event evt, int x, int y)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 mouse event.
* AWT 1.0 MOUSE_DRAG event handler. This method is meant to be
* overridden by components providing their own MOUSE_DRAG handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
* @param y the y coordinate, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processMouseMotionEvent(MouseEvent)} instead
*/
public boolean mouseDrag(Event evt, int x, int y)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 mouse event.
* AWT 1.0 MOUSE_UP event handler. This method is meant to be
* overridden by components providing their own MOUSE_UP handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
* @param y the y coordinate, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processMouseEvent(MouseEvent)} instead
*/
public boolean mouseUp(Event evt, int x, int y)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 mouse event.
* AWT 1.0 MOUSE_MOVE event handler. This method is meant to be
* overridden by components providing their own MOUSE_MOVE handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
* @param y the y coordinate, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processMouseMotionEvent(MouseEvent)} instead
*/
public boolean mouseMove(Event evt, int x, int y)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 mouse event.
* AWT 1.0 MOUSE_ENTER event handler. This method is meant to be
* overridden by components providing their own MOUSE_ENTER handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
* @param y the y coordinate, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processMouseEvent(MouseEvent)} instead
*/
public boolean mouseEnter(Event evt, int x, int y)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 mouse event.
* AWT 1.0 MOUSE_EXIT event handler. This method is meant to be
* overridden by components providing their own MOUSE_EXIT handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
* @param y the y coordinate, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processMouseEvent(MouseEvent)} instead
*/
public boolean mouseExit(Event evt, int x, int y)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 key press event.
* AWT 1.0 KEY_PRESS and KEY_ACTION event handler. This method is
* meant to be overridden by components providing their own key
* press handler. The default implementation simply returns false.
*
* @param evt the event to handle
* @param key the key pressed, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processKeyEvent(KeyEvent)} instead
*/
public boolean keyDown(Event evt, int key)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 key press event.
* AWT 1.0 KEY_RELEASE and KEY_ACTION_RELEASE event handler. This
* method is meant to be overridden by components providing their
* own key release handler. The default implementation simply
* returns false.
*
* @param evt the event to handle
* @param key the key pressed, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processKeyEvent(KeyEvent)} instead
*/
public boolean keyUp(Event evt, int key)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 action event processor.
* AWT 1.0 ACTION_EVENT event handler. This method is meant to be
* overridden by components providing their own action event
* handler. The default implementation simply returns false.
*
* @param evt the event to handle
* @param what the object acted on, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated in classes which support actions, use
* <code>processActionEvent(ActionEvent)</code> instead
*/
public boolean action(Event evt, Object what)
{
// XXX Add backward compatibility handling.
return false;
}
@ -3377,30 +3393,32 @@ public abstract class Component
}
/**
* AWT 1.0 focus event.
* AWT 1.0 GOT_FOCUS event handler. This method is meant to be
* overridden by components providing their own GOT_FOCUS handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param what the Object focused, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processFocusEvent(FocusEvent)} instead
*/
public boolean gotFocus(Event evt, Object what)
{
// XXX Add backward compatibility handling.
return false;
}
/**
* AWT 1.0 focus event.
* AWT 1.0 LOST_FOCUS event handler. This method is meant to be
* overridden by components providing their own LOST_FOCUS handler.
* The default implementation simply returns false.
*
* @param evt the event to handle
* @param what the Object focused, ignored
* @return false: since the method was deprecated, the return has no meaning
* @return false
* @deprecated use {@link #processFocusEvent(FocusEvent)} instead
*/
public boolean lostFocus(Event evt, Object what)
{
// XXX Add backward compatibility handling.
return false;
}
@ -3415,7 +3433,7 @@ public abstract class Component
*/
public boolean isFocusTraversable()
{
return enabled && visible && (peer == null || peer.isFocusTraversable());
return enabled && visible && (peer == null || isLightweight() || peer.isFocusTraversable());
}
/**
@ -3430,7 +3448,11 @@ public abstract class Component
}
/**
* Specify whether this component can receive focus.
* Specify whether this component can receive focus. This method also
* sets the {@link #isFocusTraversableOverridden} field to 1, which
* appears to be the undocumented way {@link
* DefaultFocusTraversalPolicy#accept()} determines whether to respect
* the {@link #isFocusable()} method of the component.
*
* @param focusable the new focusable status
* @since 1.4
@ -3439,6 +3461,7 @@ public abstract class Component
{
firePropertyChange("focusable", this.focusable, focusable);
this.focusable = focusable;
this.isFocusTraversableOverridden = 1;
}
/**
@ -3697,7 +3720,7 @@ public abstract class Component
Window toplevel = (Window) parent;
if (toplevel.isFocusableWindow ())
{
if (peer != null)
if (peer != null && !isLightweight())
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
@ -3783,7 +3806,7 @@ public abstract class Component
Window toplevel = (Window) parent;
if (toplevel.isFocusableWindow ())
{
if (peer != null)
if (peer != null && !isLightweight())
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
@ -3904,6 +3927,7 @@ public abstract class Component
if (focusedWindow == toplevel)
{
if (peer != null
&& !isLightweight()
&& !(this instanceof Window))
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
@ -4495,23 +4519,23 @@ p * <li>the set of backward traversal keys
int id = e.getID ();
int oldMods = 0;
int mods = ie.getModifiers ();
int mods = ie.getModifiersEx ();
if ((mods & InputEvent.BUTTON2_MASK) != 0)
if ((mods & InputEvent.BUTTON2_DOWN_MASK) != 0)
oldMods |= Event.META_MASK;
else if ((mods & InputEvent.BUTTON3_MASK) != 0)
else if ((mods & InputEvent.BUTTON3_DOWN_MASK) != 0)
oldMods |= Event.ALT_MASK;
if ((mods & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0)
if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0)
oldMods |= Event.SHIFT_MASK;
if ((mods & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0)
if ((mods & InputEvent.CTRL_DOWN_MASK) != 0)
oldMods |= Event.CTRL_MASK;
if ((mods & (InputEvent.META_MASK | InputEvent.META_DOWN_MASK)) != 0)
if ((mods & InputEvent.META_DOWN_MASK) != 0)
oldMods |= Event.META_MASK;
if ((mods & (InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0)
if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
oldMods |= Event.ALT_MASK;
if (e instanceof MouseEvent)
@ -4673,7 +4697,8 @@ p * <li>the set of backward traversal keys
*
* @param e the event to dispatch
*/
void dispatchEventImpl(AWTEvent e)
void dispatchEventImpl (AWTEvent e)
{
Event oldEvent = translateEvent (e);
@ -4681,7 +4706,30 @@ p * <li>the set of backward traversal keys
postEvent (oldEvent);
if (eventTypeEnabled (e.id))
processEvent(e);
{
// the trick we use to communicate between dispatch and redispatch
// is to have KeyboardFocusManager.redispatch synchronize on the
// object itself. we then do not redispatch to KeyboardFocusManager
// if we are already holding the lock.
if (! Thread.holdsLock(e))
{
switch (e.id)
{
case WindowEvent.WINDOW_GAINED_FOCUS:
case WindowEvent.WINDOW_LOST_FOCUS:
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
case KeyEvent.KEY_TYPED:
case FocusEvent.FOCUS_GAINED:
case FocusEvent.FOCUS_LOST:
if (KeyboardFocusManager
.getCurrentKeyboardFocusManager()
.dispatchEvent(e))
return;
}
}
processEvent (e);
}
}
/**

View File

@ -1505,10 +1505,11 @@ public class Container extends Component
void dispatchEventImpl(AWTEvent e)
{
// Give lightweight dispatcher a chance to handle it.
if (dispatcher != null
if (eventTypeEnabled (e.id)
&& dispatcher != null
&& dispatcher.handleEvent (e))
return;
if ((e.id <= ContainerEvent.CONTAINER_LAST
&& e.id >= ContainerEvent.CONTAINER_FIRST)
&& (containerListener != null
@ -1586,7 +1587,6 @@ public class Container extends Component
{
if (dispatcher == null)
dispatcher = new LightweightDispatcher (this);
dispatcher.enableEvents (component[i].eventMask);
}
@ -1831,7 +1831,6 @@ class LightweightDispatcher implements Serializable
{
private static final long serialVersionUID = 5184291520170872969L;
private Container nativeContainer;
private Component focus;
private Cursor nativeCursor;
private long eventMask;
@ -1845,11 +1844,6 @@ class LightweightDispatcher implements Serializable
nativeContainer = c;
}
void enableEvents(long l)
{
eventMask |= l;
}
void acquireComponentForMouseEvent(MouseEvent me)
{
int x = me.getX ();
@ -1863,8 +1857,9 @@ class LightweightDispatcher implements Serializable
{
candidate =
SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
if (candidate == null)
if (candidate == null || (candidate.eventMask & me.getID()) == 0)
{
candidate = null;
p = SwingUtilities.convertPoint(parent, p.x, p.y, parent.parent);
parent = parent.parent;
}
@ -1881,21 +1876,25 @@ class LightweightDispatcher implements Serializable
&& lastComponentEntered.isShowing()
&& lastComponentEntered != candidate)
{
Point tp =
SwingUtilities.convertPoint(nativeContainer,
x, y, lastComponentEntered);
MouseEvent exited = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen (),
me.getModifiers (),
tp.x, tp.y,
me.getClickCount (),
me.isPopupTrigger (),
me.getButton ());
lastComponentEntered.dispatchEvent (exited);
// Old candidate could have been removed from
// the nativeContainer so we check first.
if (SwingUtilities.isDescendingFrom(lastComponentEntered, nativeContainer))
{
Point tp =
SwingUtilities.convertPoint(nativeContainer,
x, y, lastComponentEntered);
MouseEvent exited = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen (),
me.getModifiersEx (),
tp.x, tp.y,
me.getClickCount (),
me.isPopupTrigger (),
me.getButton ());
lastComponentEntered.dispatchEvent (exited);
}
lastComponentEntered = null;
}
// If we have a candidate, maybe enter it.
if (candidate != null)
{
@ -1911,7 +1910,7 @@ class LightweightDispatcher implements Serializable
MouseEvent entered = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_ENTERED,
me.getWhen (),
me.getModifiers (),
me.getModifiersEx (),
cp.x, cp.y,
me.getClickCount (),
me.isPopupTrigger (),
@ -1929,7 +1928,8 @@ class LightweightDispatcher implements Serializable
// - MOUSE_RELEASED
// - MOUSE_PRESSED: another button pressed while the first is held down
// - MOUSE_DRAGGED
mouseEventTarget = pressedComponent;
if (SwingUtilities.isDescendingFrom(pressedComponent, nativeContainer))
mouseEventTarget = pressedComponent;
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
{
// Don't dispatch CLICKED events whose target is not the same as the
@ -1943,9 +1943,6 @@ class LightweightDispatcher implements Serializable
boolean handleEvent(AWTEvent e)
{
if ((eventMask & e.getID()) == 0)
return false;
if (e instanceof MouseEvent)
{
MouseEvent me = (MouseEvent) e;
@ -1979,12 +1976,10 @@ class LightweightDispatcher implements Serializable
pressedComponent = null;
break;
}
if (newEvt.isConsumed())
e.consume();
}
}
else if (e instanceof KeyEvent && focus != null)
{
focus.processKeyEvent((KeyEvent) e);
}
return e.isConsumed();
}

View File

@ -92,19 +92,17 @@ public class DefaultFocusTraversalPolicy
&& comp.enabled)
{
if (comp.isFocusTraversableOverridden != 0
&& comp.isFocusTraversable ())
return true;
else
{
if (!(comp instanceof Canvas
|| comp instanceof Panel
|| comp instanceof Label
|| comp instanceof ScrollPane
|| comp instanceof Scrollbar
|| comp instanceof Window
|| comp.isLightweight ()))
return true;
}
&& (comp.isFocusTraversable () || comp.isFocusable()))
return true;
if (!(comp instanceof Canvas
|| comp instanceof Panel
|| comp instanceof Label
|| comp instanceof ScrollPane
|| comp instanceof Scrollbar
|| comp instanceof Window
|| comp.isLightweight ()))
return true;
}
return false;
}

View File

@ -155,7 +155,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
&& e.id != WindowEvent.WINDOW_DEACTIVATED)
return false;
target.dispatchEvent (e);
redispatchEvent(target, e);
return true;
}
else if (e instanceof FocusEvent)
@ -197,7 +197,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
setGlobalPermanentFocusOwner (null);
}
target.dispatchEvent (e);
redispatchEvent(target, e);
return true;
}
@ -258,7 +258,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
Component focusOwner = getGlobalPermanentFocusOwner ();
if (focusOwner != null)
focusOwner.dispatchEvent (e);
redispatchEvent(focusOwner, e);
// Loop through all registered KeyEventPostProcessors, giving
// each a chance to process this event.
@ -284,10 +284,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
// Check if this event represents a menu shortcut.
// MenuShortcuts are activated by Ctrl- KeyEvents.
int modifiers = e.getModifiers ();
if ((modifiers & KeyEvent.CTRL_MASK) != 0
|| (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)
// MenuShortcuts are activated by Ctrl- KeyEvents, only on KEY_PRESSED.
int modifiers = e.getModifiersEx ();
if (e.getID() == KeyEvent.KEY_PRESSED
&& (modifiers & KeyEvent.CTRL_DOWN_MASK) != 0)
{
Window focusedWindow = getGlobalFocusedWindow ();
if (focusedWindow instanceof Frame)
@ -311,17 +311,21 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
MenuItem item = menu.getItem (j);
MenuShortcut shortcut = item.getShortcut ();
if (shortcut != null)
if (item.isEnabled() && shortcut != null)
{
// Dispatch a new ActionEvent if this is a
// Shift- KeyEvent and the shortcut requires
// the Shift modifier, or if the shortcut
// doesn't require the Shift modifier.
if ((shortcut.usesShiftModifier ()
&& ((modifiers & KeyEvent.SHIFT_MASK) != 0
|| (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0)
|| !shortcut.usesShiftModifier ())
&& shortcut.getKey () == e.getKeyCode ())
// Dispatch a new ActionEvent if:
//
// a) this is a Shift- KeyEvent, and the
// shortcut requires the Shift modifier
//
// or, b) this is not a Shift- KeyEvent, and the
// shortcut does not require the Shift
// modifier.
if (shortcut.getKey () == e.getKeyCode ()
&& ((shortcut.usesShiftModifier ()
&& (modifiers & KeyEvent.SHIFT_DOWN_MASK) != 0)
|| (! shortcut.usesShiftModifier ()
&& (modifiers & KeyEvent.SHIFT_DOWN_MASK) == 0)))
{
item.dispatchEvent (new ActionEvent (item,
ActionEvent.ACTION_PERFORMED,
@ -347,7 +351,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
// KEY_PRESSED TAB is a focus traversal keystroke, we also need to
// consume KEY_RELEASED and KEY_TYPED TAB key events).
AWTKeyStroke oppositeKeystroke = AWTKeyStroke.getAWTKeyStroke (e.getKeyCode (),
e.getModifiers (),
e.getModifiersEx (),
!(e.id == KeyEvent.KEY_RELEASED));
Set forwardKeystrokes = comp.getFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
@ -439,7 +443,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component previous = policy.getComponentBefore (focusCycleRoot, focusComp);
previous.requestFocusInWindow ();
if (previous != null)
previous.requestFocusInWindow ();
}
public void focusNextComponent (Component comp)
@ -449,7 +454,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component next = policy.getComponentAfter (focusCycleRoot, focusComp);
next.requestFocusInWindow ();
if (next != null)
next.requestFocusInWindow ();
}
public void upFocusCycle (Component comp)
@ -461,7 +467,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
FocusTraversalPolicy policy = focusCycleRoot.getFocusTraversalPolicy ();
Component defaultComponent = policy.getDefaultComponent (focusCycleRoot);
defaultComponent.requestFocusInWindow ();
if (defaultComponent != null)
defaultComponent.requestFocusInWindow ();
}
else
{
@ -481,7 +488,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
FocusTraversalPolicy policy = cont.getFocusTraversalPolicy ();
Component defaultComponent = policy.getDefaultComponent (cont);
defaultComponent.requestFocusInWindow ();
if (defaultComponent != null)
defaultComponent.requestFocusInWindow ();
setGlobalCurrentFocusCycleRoot (cont);
}
}

View File

@ -1265,12 +1265,28 @@ equals(Object obj)
public String
toString()
{
return(getClass().getName()
+ "(logical=" + getName ()
+ ",family=" + getFamily ()
+ ",name=" + getFontName ()
+ ",style=" + getStyle ()
+ ",size=" + getSize ());
String styleString = "";
switch (getStyle ())
{
case 0:
styleString = "plain";
break;
case 1:
styleString = "bold";
break;
case 2:
styleString = "italic";
break;
default:
styleString = "unknown";
}
return getClass ().getName ()
+ "[family=" + getFamily ()
+ ",name=" + getFontName ()
+ ",style=" + styleString
+ ",size=" + getSize () + "]";
}

View File

@ -732,14 +732,14 @@ finalize()
/*************************************************************************/
/**
* Returns a string representation of this object.
*
* @param A string representation of this object.
*/
* Returns a string representation of this object.
*
* @param A string representation of this object.
*/
public String
toString()
{
return(super.toString());
return getClass ().getName () + "[font=" + getFont () + ",color=" + getColor () + "]";
}
public boolean

View File

@ -740,8 +740,11 @@ public abstract class KeyboardFocusManager
public final void redispatchEvent (Component target, AWTEvent e)
{
e.setSource (target);
dispatchEvent (e);
synchronized (e)
{
e.setSource (target);
target.dispatchEvent (e);
}
}
public abstract boolean dispatchKeyEvent (KeyEvent e);

View File

@ -128,15 +128,15 @@ setHelpMenu(Menu menu)
helpMenu.removeNotify ();
helpMenu.parent = null;
}
helpMenu = menu;
if (menu.parent != null)
menu.parent.remove (menu);
if (menu.parent != null)
menu.parent.remove (menu);
menu.parent = this;
if (peer != null)
{
menu.addNotify();
MenuBarPeer mp = (MenuBarPeer) peer;
mp.addHelpMenu (menu);
}
@ -163,8 +163,7 @@ add(Menu menu)
if (peer != null)
{
MenuBarPeer mp = (MenuBarPeer) peer;
mp.addMenu (menu);
menu.addNotify();
}
return(menu);
@ -269,6 +268,11 @@ addNotify()
Menu mi = (Menu)e.nextElement();
mi.addNotify();
}
if (helpMenu != null)
{
helpMenu.addNotify();
((MenuBarPeer) peer).addHelpMenu(helpMenu);
}
}
/*************************************************************************/

View File

@ -77,7 +77,7 @@ private String actionCommand;
/**
* @serial Indicates whether or not this menu item is enabled.
*/
private boolean enabled;
private boolean enabled = true;
/**
* @serial The mask of events that are enabled for this menu item.

View File

@ -542,7 +542,7 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable
*/
public boolean intersects(Rectangle r)
{
return width > 0 && height > 0 && r.width > 0 && r.height > 0
return r.width > 0 && r.height > 0 && width > 0 && height > 0
&& r.x < x + width && r.x + r.width > x
&& r.y < y + height && r.y + r.height > y;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* RoundRectangle2D.java -- represents a rectangle with rounded corners
Copyright (C) 2000, 2002, 2003 Free Software Foundation
Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation
This file is part of GNU Classpath.
@ -39,6 +39,7 @@ package java.awt.geom;
import java.util.NoSuchElementException;
/** This class implements a rectangle with rounded corners.
* @author Tom Tromey <tromey@cygnus.com>
* @date December 3, 2000
@ -60,12 +61,12 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param arcHeight The arc height
*/
public abstract void setRoundRect(double x, double y, double w, double h,
double arcWidth, double arcHeight);
double arcWidth, double arcHeight);
/** Create a RoundRectangle2D. This is protected because this class
* is abstract and cannot be instantiated.
*/
protected RoundRectangle2D()
protected RoundRectangle2D()
{
}
@ -87,8 +88,11 @@ public abstract class RoundRectangle2D extends RectangularShape
// Now check to see if the point is in range of an arc.
double dy = Math.min(Math.abs(my - y), Math.abs(my + mh - y));
double dx = Math.min(Math.abs(mx - x), Math.abs(mx + mw - x));
double aw = getArcWidth();
double ah = getArcHeight();
// The arc dimensions are that of the corresponding ellipse
// thus a 90 degree segment is half of that.
double aw = getArcWidth() / 2.0;
double ah = getArcHeight() / 2.0;
if (dx > aw || dy > ah)
return true;
@ -112,8 +116,8 @@ public abstract class RoundRectangle2D extends RectangularShape
{
// We have to check all four points here (for ordinary rectangles
// we can just check opposing corners).
return (contains(x, y) && contains(x + w, h)
&& contains(x, y + h) && contains(x + w, y + h));
return (contains(x, y) && contains(x, y + h) && contains(x + w, y + h)
&& contains(x + w, y));
}
/** Return a new path iterator which iterates over this rectangle.
@ -128,154 +132,161 @@ public abstract class RoundRectangle2D extends RectangularShape
final double arcwidth = getArcWidth();
final double archeight = getArcHeight();
return new PathIterator()
{
/** We iterate clockwise around the rectangle, starting in the
* upper left. This variable tracks our current point, which
* can be on either side of a given corner. */
private int current = 0;
/** Child path iterator, used for corners. */
private PathIterator corner;
/** This is used when rendering the corners. We re-use the arc
* for each corner. */
private Arc2D arc = new Arc2D.Double();
/** Temporary array used by getPoint. */
private double[] temp = new double[2];
public int getWindingRule()
{
return WIND_NON_ZERO;
}
/** We iterate counterclockwise around the rectangle, starting in the
* upper right. This variable tracks our current point, which
* can be on either side of a given corner. */
private int current = 0;
public boolean isDone()
{
return current > 9;
}
/** Child path iterator, used for corners. */
private PathIterator corner;
private void getPoint(int val)
{
switch (val)
{
case 0:
case 8:
temp[0] = minx;
temp[1] = miny + archeight;
break;
case 1:
temp[0] = minx + arcwidth;
temp[1] = miny;
break;
case 2:
temp[0] = maxx - arcwidth;
temp[1] = maxy;
break;
case 3:
temp[0] = maxx;
temp[1] = miny + archeight;
break;
case 4:
temp[0] = maxx;
temp[1] = maxy - archeight;
break;
case 5:
temp[0] = maxx - arcwidth;
temp[1] = maxy;
break;
case 6:
temp[0] = minx + arcwidth;
temp[1] = maxy;
break;
case 7:
temp[0] = minx;
temp[1] = maxy - archeight;
break;
}
}
/** This is used when rendering the corners. We re-use the arc
* for each corner. */
private Arc2D arc = new Arc2D.Double();
public void next()
{
if (current >= 8)
++current;
else if (corner != null)
{
// We're iterating through the corner. Work on the child
// iterator; if it finishes, reset and move to the next
// point along the rectangle.
corner.next();
if (corner.isDone())
{
corner = null;
++current;
}
}
else
{
// Make an arc between this point on the rectangle and
// the next one, and then iterate over this arc.
getPoint(current);
double x1 = temp[0];
double y1 = temp[1];
getPoint(current + 1);
arc.setFrameFromDiagonal(x1, y1, temp[0], temp[1]);
arc.setAngles(x1, y1, temp[0], temp[1]);
corner = arc.getPathIterator(at);
}
}
/** Temporary array used by getPoint. */
private double[] temp = new double[2];
public int currentSegment(float[] coords)
{
if (corner != null)
{
int r = corner.currentSegment(coords);
if (r == SEG_MOVETO)
r = SEG_LINETO;
return r;
}
public int getWindingRule()
{
return WIND_NON_ZERO;
}
if (current < 9)
{
getPoint(current);
coords[0] = (float) temp[0];
coords[1] = (float) temp[1];
}
else if (current == 9)
return SEG_CLOSE;
else
throw new NoSuchElementException("rect iterator out of bounds");
public boolean isDone()
{
return current > 9;
}
if (at != null)
at.transform(coords, 0, coords, 0, 1);
return current == 0 ? SEG_MOVETO : SEG_LINETO;
}
private void getPoint(int val)
{
switch (val)
{
case 0:
case 8:
temp[0] = maxx;
temp[1] = miny + archeight;
break;
case 7:
temp[0] = maxx;
temp[1] = maxy - archeight;
break;
case 6:
temp[0] = maxx - arcwidth;
temp[1] = maxy;
break;
case 5:
temp[0] = minx + arcwidth;
temp[1] = maxy;
break;
case 4:
temp[0] = minx;
temp[1] = maxy - archeight;
break;
case 3:
temp[0] = minx;
temp[1] = miny + archeight;
break;
case 2:
temp[0] = minx + arcwidth;
temp[1] = miny;
break;
case 1:
temp[0] = maxx - arcwidth;
temp[1] = miny;
break;
}
}
public int currentSegment(double[] coords)
{
if (corner != null)
{
int r = corner.currentSegment(coords);
if (r == SEG_MOVETO)
r = SEG_LINETO;
return r;
}
public void next()
{
if (current >= 8)
++current;
else if (corner != null)
{
// We're iterating through the corner. Work on the child
// iterator; if it finishes, reset and move to the next
// point along the rectangle.
corner.next();
if (corner.isDone())
{
corner = null;
++current;
}
}
else
{
// Make an arc between this point on the rectangle and
// the next one, and then iterate over this arc.
getPoint(current);
double x1 = temp[0];
double y1 = temp[1];
getPoint(current + 1);
Rectangle2D.Double r = new Rectangle2D.Double(Math.min(x1,
temp[0]),
Math.min(y1,
temp[1]),
Math.abs(x1
- temp[0]),
Math.abs(y1
- temp[1]));
arc.setArc(r, (current >> 1) * 90.0, 90.0, Arc2D.OPEN);
corner = arc.getPathIterator(at);
}
}
if (current < 9)
{
getPoint(current);
coords[0] = temp[0];
coords[1] = temp[1];
}
else if (current == 9)
return SEG_CLOSE;
else
throw new NoSuchElementException("rect iterator out of bounds");
public int currentSegment(float[] coords)
{
if (corner != null)
{
int r = corner.currentSegment(coords);
if (r == SEG_MOVETO)
r = SEG_LINETO;
return r;
}
if (at != null)
at.transform(coords, 0, coords, 0, 1);
return current == 0 ? SEG_MOVETO : SEG_LINETO;
}
};
if (current < 9)
{
getPoint(current);
coords[0] = (float) temp[0];
coords[1] = (float) temp[1];
}
else if (current == 9)
return SEG_CLOSE;
else
throw new NoSuchElementException("rect iterator out of bounds");
if (at != null)
at.transform(coords, 0, coords, 0, 1);
return current == 0 ? SEG_MOVETO : SEG_LINETO;
}
public int currentSegment(double[] coords)
{
if (corner != null)
{
int r = corner.currentSegment(coords);
if (r == SEG_MOVETO)
r = SEG_LINETO;
return r;
}
if (current < 9)
{
getPoint(current);
coords[0] = temp[0];
coords[1] = temp[1];
}
else if (current == 9)
return SEG_CLOSE;
else
throw new NoSuchElementException("rect iterator out of bounds");
if (at != null)
at.transform(coords, 0, coords, 0, 1);
return current == 0 ? SEG_MOVETO : SEG_LINETO;
}
};
}
/** Return true if the given rectangle intersects this shape.
@ -286,14 +297,9 @@ public abstract class RoundRectangle2D extends RectangularShape
*/
public boolean intersects(double x, double y, double w, double h)
{
// Here we can use the same code we use for an ordinary rectangle.
double mx = getX();
double mw = getWidth();
if (x < mx || x >= mx + mw || x + w < mx || x + w >= mx + mw)
return false;
double my = getY();
double mh = getHeight();
return y >= my && y < my + mh && y + h >= my && y + h < my + mh;
// Check if any corner is within the rectangle
return (contains(x, y) || contains(x, y + h) || contains(x + w, y + h)
|| contains(x + w, y));
}
/** Set the boundary of this round rectangle.
@ -315,7 +321,7 @@ public abstract class RoundRectangle2D extends RectangularShape
public void setRoundRect(RoundRectangle2D rr)
{
setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(),
rr.getArcWidth(), rr.getArcHeight());
rr.getArcWidth(), rr.getArcHeight());
}
/** A subclass of RoundRectangle which keeps its parameters as
@ -353,8 +359,8 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param arcWidth The arc width
* @param arcHeight The arc height
*/
public Double(double x, double y, double w, double h,
double arcWidth, double arcHeight)
public Double(double x, double y, double w, double h, double arcWidth,
double arcHeight)
{
this.x = x;
this.y = y;
@ -405,7 +411,7 @@ public abstract class RoundRectangle2D extends RectangularShape
}
public void setRoundRect(double x, double y, double w, double h,
double arcWidth, double arcHeight)
double arcWidth, double arcHeight)
{
this.x = x;
this.y = y;
@ -451,8 +457,8 @@ public abstract class RoundRectangle2D extends RectangularShape
* @param arcWidth The arc width
* @param arcHeight The arc height
*/
public Float(float x, float y, float w, float h,
float arcWidth, float arcHeight)
public Float(float x, float y, float w, float h, float arcWidth,
float arcHeight)
{
this.x = x;
this.y = y;
@ -503,7 +509,7 @@ public abstract class RoundRectangle2D extends RectangularShape
}
public void setRoundRect(float x, float y, float w, float h,
float arcWidth, float arcHeight)
float arcWidth, float arcHeight)
{
this.x = x;
this.y = y;
@ -514,7 +520,7 @@ public abstract class RoundRectangle2D extends RectangularShape
}
public void setRoundRect(double x, double y, double w, double h,
double arcWidth, double arcHeight)
double arcWidth, double arcHeight)
{
this.x = (float) x;
this.y = (float) y;

View File

@ -60,7 +60,6 @@ public class DirectColorModel extends PackedColorModel
* @param rmask the bits describing the red component of a pixel
* @param gmask the bits describing the green component of a pixel
* @param bmask the bits describing the blue component of a pixel
* @param amask the bits describing the alpha component of a pixel
*/
public DirectColorModel(int pixelBits, int rmask, int gmask, int bmask)
{
@ -82,6 +81,7 @@ public class DirectColorModel extends PackedColorModel
* @param rmask the bits describing the red component of a pixel
* @param gmask the bits describing the green component of a pixel
* @param bmask the bits describing the blue component of a pixel
* @param amask the bits describing the alpha component of a pixel
*/
public DirectColorModel(int pixelBits,
int rmask, int gmask, int bmask, int amask)

View File

@ -117,7 +117,7 @@ public class Kernel implements Cloneable
throws IllegalArgumentException
{
if (data == null)
return (float[])this.data.clone();
return (float[])this.data.clone();
if (data.length < this.data.length)
throw new IllegalArgumentException();
@ -131,6 +131,13 @@ public class Kernel implements Cloneable
*/
public Object clone()
{
return new Kernel(width, height, data);
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
throw (Error) new InternalError().initCause(e); // Impossible
}
}
}

View File

@ -43,7 +43,6 @@ import java.awt.Menu;
public interface MenuBarPeer extends MenuComponentPeer
{
void addHelpMenu(Menu menu);
void addMenu(Menu menu);
void delMenu(int index);
} // interface MenuBarPeer

View File

@ -51,7 +51,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EventListener;
import javax.accessibility.AccessibleAction;
import javax.accessibility.AccessibleIcon;
@ -214,24 +213,28 @@ public abstract class AbstractButton extends JComponent
Action action;
/** The button's current state. */
ButtonModel model;
protected ButtonModel model;
/** The margin between the button's border and its label. */
Insets margin;
/** a hint to the look and feel class, suggesting which character in the
/** A hint to the look and feel class, suggesting which character in the
* button's label should be underlined when drawing the label. */
int mnemonicIndex;
/** Listener the button uses to receive ActionEvents from its model. */
ActionListener actionListener;
protected ActionListener actionListener;
/** Listener the button uses to receive ItemEvents from its model. */
ItemListener itemListener;
protected ItemListener itemListener;
/** Listener the button uses to receive ChangeEvents from its model. */
ChangeListener changeListener;
protected ChangeListener changeListener;
/** The time in miliseconds in which clicks get coalesced into a single
* <code>ActionEvent</code>. */
long multiClickThreshhold;
/** Listener the button uses to receive PropertyChangeEvents from its
Action. */
PropertyChangeListener actionPropertyChangeListener;
@ -296,9 +299,9 @@ public abstract class AbstractButton extends JComponent
/** Fired in a PropertyChangeEvent when the "verticalTextPosition" property changes. */
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition";
/**
/**
* A Java Accessibility extension of the AbstractButton.
*/
*/
protected abstract class AccessibleAbstractButton
extends AccessibleJComponent implements AccessibleAction, AccessibleValue,
AccessibleText
@ -430,7 +433,7 @@ public abstract class AbstractButton extends JComponent
}
public String getSelectedText()
{
{
return null; // TODO
}
@ -440,33 +443,6 @@ public abstract class AbstractButton extends JComponent
}
}
/**
* Helper class used to subscribe to FocusEvents received by the button.
*/
private class ButtonFocusListener implements FocusListener
{
/**
* Possibly repaint the model in response to loss of focus.
*
* @param event The loss-of-focus event
*/
public void focusLost(FocusEvent event)
{
if (AbstractButton.this.isFocusPainted())
AbstractButton.this.repaint();
}
/**
* Possibly repaint the button in response to acquisition of focus.
*
* @param event The gained-focus event
*/
public void focusGained(FocusEvent event)
{
if (AbstractButton.this.isFocusPainted())
AbstractButton.this.repaint();
}
}
/**
* Creates a new AbstractButton object.
@ -549,12 +525,12 @@ public abstract class AbstractButton extends JComponent
borderPainted = true;
contentAreaFilled = true;
iconTextGap = 4;
focusPainted = true;
setFocusable(true);
setAlignmentX(LEFT_ALIGNMENT);
setAlignmentY(CENTER_ALIGNMENT);
addFocusListener(new ButtonFocusListener());
setDisplayedMnemonicIndex(-1);
}
@ -601,6 +577,18 @@ public abstract class AbstractButton extends JComponent
listenerList.remove(ActionListener.class, l);
}
/**
* Returns all added <code>ActionListener</code> objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public ActionListener[] getActionListeners()
{
return (ActionListener[]) listenerList.getListeners(ActionListener.class);
}
/**
* Adds an ItemListener to the button's listener list. When the button's
* model changes state (between any of ARMED, ENABLED, PRESSED, ROLLOVER
@ -624,6 +612,18 @@ public abstract class AbstractButton extends JComponent
listenerList.remove(ItemListener.class, l);
}
/**
* Returns all added <code>ItemListener</code> objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public ItemListener[] getItemListeners()
{
return (ItemListener[]) listenerList.getListeners(ItemListener.class);
}
/**
* Adds a ChangeListener to the button's listener list. When the button's
* model changes any of its (non-bound) properties, these listeners will be
@ -646,6 +646,18 @@ public abstract class AbstractButton extends JComponent
listenerList.remove(ChangeListener.class, l);
}
/**
* Returns all added <code>ChangeListener</code> objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public ChangeListener[] getChangeListeners()
{
return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
}
/**
* Calls {@link ItemListener.itemStateChanged} on each ItemListener in
* the button's listener list.
@ -655,9 +667,10 @@ public abstract class AbstractButton extends JComponent
public void fireItemStateChanged(ItemEvent e)
{
e.setSource(this);
EventListener[] ll = listenerList.getListeners(ItemListener.class);
for (int i = 0; i < ll.length; i++)
((ItemListener)ll[i]).itemStateChanged(e);
ItemListener[] listeners = getItemListeners();
for (int i = 0; i < listeners.length; i++)
listeners[i].itemStateChanged(e);
}
/**
@ -669,9 +682,10 @@ public abstract class AbstractButton extends JComponent
public void fireActionPerformed(ActionEvent e)
{
e.setSource(this);
EventListener[] ll = listenerList.getListeners(ActionListener.class);
for (int i = 0; i < ll.length; i++)
((ActionListener)ll[i]).actionPerformed(e);
ActionListener[] listeners = getActionListeners();
for (int i = 0; i < listeners.length; i++)
listeners[i].actionPerformed(e);
}
/**
@ -683,9 +697,10 @@ public abstract class AbstractButton extends JComponent
*/
public void fireStateChanged(ChangeEvent e)
{
EventListener[] ll = listenerList.getListeners(ChangeListener.class);
for (int i = 0; i < ll.length; i++)
((ChangeListener)ll[i]).stateChanged(changeEvent);
ChangeListener[] listeners = getChangeListeners();
for (int i = 0; i < listeners.length; i++)
listeners[i].stateChanged(changeEvent);
}
/**
@ -1879,4 +1894,33 @@ public abstract class AbstractButton extends JComponent
public void updateUI()
{
}
/**
* Returns the current time in milliseconds in which clicks gets coalesced
* into a single <code>ActionEvent</code>.
*
* @return the time in milliseconds
*
* @since 1.4
*/
public long getMultiClickThreshhold()
{
return multiClickThreshhold;
}
/**
* Sets the time in milliseconds in which clicks gets coalesced into a single
* <code>ActionEvent</code>.
*
* @param threshhold the time in milliseconds
*
* @since 1.4
*/
public void setMultiClickThreshhold(long threshhold)
{
if (threshhold < 0)
throw new IllegalArgumentException();
multiClickThreshhold = threshhold;
}
}

View File

@ -86,8 +86,8 @@ public class ActionMap
{
Object result = actionMap.get(key);
if (result == null)
result = parent.get(key);
if (result == null && parent != null)
result = parent.get(key);
return (Action) result;
}

View File

@ -47,7 +47,11 @@ import java.awt.Dimension;
import java.awt.AWTError;
/**
* Needs some work I guess....
* A component that uses a {@link BoxLayout} as Layout Manager.
*
* In addition to that, this class provides a set of static methods for
* creating some filler components ('struts' and 'glue') for use in
* containers that are laid out using BoxLayout.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
@ -69,7 +73,10 @@ public class Box extends JComponent implements Accessible
return null;
}
}
/**
* A component that servers as a filler in BoxLayout controlled containers.
*/
public static class Filler extends JComponent implements Accessible
{
private static final long serialVersionUID = -1204263191910183998L;
@ -93,11 +100,25 @@ public class Box extends JComponent implements Accessible
private transient Dimension min, pref, max;
/**
* Creates a new instance of Filler.
*
* @param min the minimum size of the filler.
* @param pref the preferred size of the filler.
* @param max the maximum size of the filler.
*/
public Filler(Dimension min, Dimension pref, Dimension max)
{
changeShape(min, pref, max);
}
/**
* Changes the dimensions of this Filler.
*
* @param min the new minimum size of the filler.
* @param pref the new preferred size of the filler.
* @param max the new maximum size of the filler.
*/
public void changeShape(Dimension min, Dimension pref, Dimension max)
{
this.min = min;
@ -113,65 +134,137 @@ public class Box extends JComponent implements Accessible
return accessibleContext;
}
/**
* Returns the maximum size of this Filler.
*
* @return the maximum size of this Filler.
*/
public Dimension getMaximumSize()
{
return max;
}
/**
* Returns the minimum size of this Filler.
*
* @return the minimum size of this Filler.
*/
public Dimension getMinimumSize()
{
return min;
}
/**
* Returns the preferred size of this Filler.
*
* @return the preferred size of this Filler.
*/
public Dimension getPreferredSize()
{
return pref;
}
}
/**
* Creates a new Box component, that lays out its children according
* to the <code>axis</code> parameter.
*
* @param axis the orientation of the BoxLayout.
*
* @see BoxLayout#X_AXIS
* @see BoxLayout#Y_AXIS
* @see BoxLayout#LINE_AXIS
* @see BoxLayout#PAGE_AXIS
*/
public Box(int axis)
{
setLayout(new BoxLayout(this, axis));
super.setLayout(new BoxLayout(this, axis));
}
/**
* Creates a filler component which acts as glue between components.
* It does not take space unless some extra space is available. If extra
* space is available, this component can expand in both X and Y directions.
*
* @return a glue-like filler component.
*/
public static Component createGlue()
{
return null;
Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0),
new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)
);
return glue;
}
public static Box createHorizontalBox()
{
return null;
return new Box(BoxLayout.X_AXIS);
}
/**
* Creates a filler component which acts as glue between components.
* It does not take space unless some extra space is available. If extra
* space is available, this component can expand in the X direction.
*
* @return a glue-like filler component.
*/
public static Component createHorizontalGlue()
{
return null;
return createGlue();
}
/**
* Creates a filler component which acts as strut between components.
* It will fill exactly the specified horizontal size.
*
* @param width the width of this strut in pixels.
*
* @return a strut-like filler component.
*/
public static Component createHorizontalStrut(int width)
{
return null;
Filler strut = new Filler(new Dimension(width, 0),
new Dimension(width, 0),
new Dimension(width, Integer.MAX_VALUE));
return strut;
}
public static Component createRigidArea(Dimension d)
{
return null;
return new Filler(d, d, d);
}
public static Box createVerticalBox()
{
return null;
return new Box(BoxLayout.Y_AXIS);
}
/**
* Creates a filler component which acts as glue between components.
* It does not take space unless some extra space is available. If extra
* space is available, this component can expand in the Y direction.
*
* @return a glue-like filler component.
*/
public static Component createVerticalGlue()
{
return null;
return createGlue();
}
/**
* Creates a filler component which acts as strut between components.
* It will fill exactly the specified vertical size.
*
* @param height the height of this strut in pixels.
*
* @return a strut-like filler component.
*/
public static Component createVerticalStrut(int height)
{
return null;
Filler strut = new Filler(new Dimension(0, height),
new Dimension(0, height),
new Dimension(Integer.MAX_VALUE, height));
return strut;
}
public void setLayout(LayoutManager l)

View File

@ -42,15 +42,11 @@ import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.LayoutManager2;
import java.io.Serializable;
/**
* A layout for swing components.
* This implementation delegates its methods to
* java.awt.GridLayout to do its work.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
@ -86,11 +82,6 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
private Container container;
/*
* Internal layout.
*/
private GridLayout grid;
/*
* Current type of component layouting. Defaults to X_AXIS.
*/
@ -108,75 +99,41 @@ public class BoxLayout implements LayoutManager2, Serializable
{
int width = 0;
int height = 0;
ComponentOrientation orientation = container.getComponentOrientation();
this.container = container;
this.way = way;
switch (way)
{
case X_AXIS:
width = 1;
break;
case Y_AXIS:
height = 1;
break;
case LINE_AXIS:
if (orientation.isHorizontal())
height = 1;
else
width = 1;
break;
case PAGE_AXIS:
if (!orientation.isHorizontal())
height = 1;
else
width = 1;
break;
default:
throw new AWTError("Invalid value for way");
}
grid = new GridLayout(width, height);
}
/**
* Adds a component to the layout.
* Adds a component to the layout. Not used in BoxLayout.
*
* @param name The name of the component to add.
* @param component the component to add to the layout.
*/
public void addLayoutComponent(String name, Component component)
{
if (way == X_AXIS
|| (way == LINE_AXIS
&& component.getComponentOrientation().isHorizontal())
|| (way == PAGE_AXIS
&& !component.getComponentOrientation().isHorizontal()))
grid.setColumns(grid.getColumns() + 1);
else
grid.setRows(grid.getRows() + 1);
}
/**
* Removes a component from the layout.
* Removes a component from the layout. Not used in BoxLayout.
*
* @param component The component to remove from the layout.
*/
public void removeLayoutComponent(Component component)
{
grid.removeLayoutComponent(component);
if (way == X_AXIS
|| (way == LINE_AXIS
&& component.getComponentOrientation().isHorizontal())
|| (way == PAGE_AXIS
&& !component.getComponentOrientation().isHorizontal()))
grid.setColumns(grid.getColumns() - 1);
else
grid.setRows(grid.getRows() - 1);
}
private boolean isHorizontalIn(Container parent)
{
ComponentOrientation orientation = parent.getComponentOrientation();
return this.way == X_AXIS
|| (this.way == LINE_AXIS
&& orientation.isHorizontal())
|| (this.way == PAGE_AXIS
&& (!orientation.isHorizontal()));
}
/**
* Returns the preferred size of the layout.
*
@ -188,8 +145,38 @@ public class BoxLayout implements LayoutManager2, Serializable
{
if (parent != container)
throw new AWTError("invalid parent");
int x = 0;
int y = 0;
Component[] children = parent.getComponents();
if (isHorizontalIn(parent))
{
// sum up preferred widths of components, find maximum of preferred
// heights
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getPreferredSize();
x += sz.width;
y = Math.max(y, sz.height);
}
}
else
{
// sum up preferred heights of components, find maximum of
// preferred widths
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getPreferredSize();
y += sz.height;
x = Math.max(x, sz.width);
}
}
return grid.preferredLayoutSize(parent);
return new Dimension(x, y);
}
/**
@ -203,8 +190,38 @@ public class BoxLayout implements LayoutManager2, Serializable
{
if (parent != container)
throw new AWTError("invalid parent");
int x = 0;
int y = 0;
Component[] children = parent.getComponents();
if (isHorizontalIn(parent))
{
// sum up preferred widths of components, find maximum of preferred
// heights
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getMinimumSize();
x += sz.width;
y = Math.max(y, sz.height);
}
}
else
{
// sum up preferred heights of components, find maximum of
// preferred widths
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getMinimumSize();
y += sz.height;
x = Math.max(x, sz.width);
}
}
return grid.minimumLayoutSize(parent);
return new Dimension(x, y);
}
/**
@ -216,19 +233,69 @@ public class BoxLayout implements LayoutManager2, Serializable
{
if (parent != container)
throw new AWTError("invalid parent");
grid.layoutContainer(parent);
}
Dimension size = parent.getSize();
Component[] children = parent.getComponents();
if (isHorizontalIn(parent))
{
int x = 0;
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getPreferredSize();
int width = sz.width;
int height = sz.height;
int cy = 0;
if (height > size.height)
{
height = size.height;
}
else
{
cy = (int) ((size.height - height) * comp.getAlignmentY());
}
comp.setSize(width, height);
comp.setLocation(x, cy);
x = x + width;
}
}
else
{
int y = 0;
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getPreferredSize();
int width = sz.width;
int height = sz.height;
int cx = 0;
if (width > size.width)
{
width = size.width;
}
else
{
cx = (int) ((size.width - width) * comp.getAlignmentX());
}
comp.setSize(width, height);
comp.setLocation(cx, y);
y = y + height;
}
}
}
/**
* Adds a component to the layout.
* Adds a component to the layout. Not used in BoxLayout
*
* @param child The component to add to the layout.
* @param constraints The constraints for the component in the layout.
*/
public void addLayoutComponent(Component child, Object constraints)
{
addLayoutComponent("", child);
}
/**
@ -284,7 +351,37 @@ public class BoxLayout implements LayoutManager2, Serializable
{
if (parent != container)
throw new AWTError("invalid parent");
return preferredLayoutSize(parent);
int x = 0;
int y = 0;
Component[] children = parent.getComponents();
if (isHorizontalIn(parent))
{
// sum up preferred widths of components, find maximum of preferred
// heights
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getMaximumSize();
x += sz.width;
y = Math.max(y, sz.height);
}
}
else
{
// sum up preferred heights of components, find maximum of
// preferred widths
for (int index = 0; index < children.length; index++)
{
Component comp = children[index];
Dimension sz = comp.getMaximumSize();
y += sz.height;
x = Math.max(x, sz.width);
}
}
return new Dimension(x, y);
}
}

View File

@ -42,19 +42,18 @@ import java.util.Enumeration;
import java.util.Vector;
public class ButtonGroup
implements Serializable
/**
* DOCUMENT ME!
*/
public class ButtonGroup implements Serializable
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 4259076101881721375L;
/**
* The buttons added to this button group.
*/
/** The buttons added to this button group. */
protected Vector buttons = new Vector();
/**
* The currently selected button model.
*/
/** The currently selected button model. */
ButtonModel sel;
/**
@ -99,17 +98,24 @@ public class ButtonGroup
/**
* Returns the currently selected button model.
*
* @return the currently selected button model,
* null if none was selected yet
* @return the currently selected button model, null if none was selected
* yet
*/
public ButtonModel getSelection()
{
return sel;
}
/**
* DOCUMENT ME!
*
* @param m DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
AbstractButton FindButton(ButtonModel m)
{
for (int i = 0;i < buttons.size(); i++)
for (int i = 0; i < buttons.size(); i++)
{
AbstractButton a = (AbstractButton) buttons.get(i);
if (a.getModel() == m)
@ -119,46 +125,40 @@ public class ButtonGroup
}
/**
* Sets the currently selected button model. Only one button of a group
* can be selected at a time.
* 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))
if ((sel != m || b) && (! b || sel == m))
return;
if (b && sel != m)
{
// clicked on same item twice.
System.out.println("PRESSED TWICE:" + m + ", sel=" + sel);
return;
ButtonModel old = sel;
sel = m;
if (old != null)
old.setSelected(false);
AbstractButton button = FindButton(old);
if (button != null)
button.repaint();
}
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;
else if (! b && sel == m)
m.setSelected(true);
}
/**
* Checks if the given <code>ButtonModel</code> is selected
* in this button group.
* Checks if the given <code>ButtonModel</code> is selected in this button
* group.
*
* @return true of given <code>ButtonModel</code> is selected,
* false otherwise
* @param m DOCUMENT ME!
*
* @return true of given <code>ButtonModel</code> is selected, false
* otherwise
*/
public boolean isSelected(ButtonModel m)
{

View File

@ -42,49 +42,56 @@ import java.awt.event.ActionListener;
/**
* ComboBoxEditor
* @author Andrew Selkirk
* @version 1.0
*
* @author Andrew Selkirk
* @author Olga Rodimina
* @version 1.0
*/
public interface ComboBoxEditor {
public interface ComboBoxEditor
{
/**
* This method returns component that will be used by the combo box to
* display/edit currently selected item in the combo box.
*
* @return Component that will be used by the combo box to display/edit
* currently selected item
*/
Component getEditorComponent();
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Sets item that should be editted when any editting operation is performed
* by the user. The value is always equal to the currently selected value
* in the combo box. Thus, whenever a different value is selected from the
* combo box list then this method should be called to change editting item
* to the new selected item.
*
* @param selectedItem item that is currently selected in the combo box
*/
void setItem(Object item);
/**
* getEditorComponent
* @returns Component
*/
Component getEditorComponent();
/**
* This method returns item that is currently editable.
*
* @return Item in the combo box that is currently editable
*/
Object getItem();
/**
* setItem
* @param item TODO
*/
void setItem(Object item);
/**
* getItem
* @returns Object
*/
Object getItem();
/**
* selectAll
*/
void selectAll();
/**
* addActionListener
* @param listener TODO
*/
void addActionListener(ActionListener listener);
/**
* removeActionListener
* @param listener TODO
*/
void removeActionListener(ActionListener listener);
/**
* selectAll
*/
void selectAll();
/**
* This method adds specified ActionListener to this ComboBoxEditor.
*
* @param listener
*/
void addActionListener(ActionListener listener);
/**
* This method removes given ActionListener from this ComboBoxEditor.
*
* @param listener TODO
*/
void removeActionListener(ActionListener listener);
} // ComboBoxEditor

View File

@ -37,28 +37,32 @@ exception statement from your version. */
package javax.swing;
/**
* ComboBoxModel
* @author Andrew Selkirk
* @version 1.0
* ComboBoxModel is a data model for JComboBox. This model keeps
* track of elements contained in the JComboBox as well as the current
* combo box selection. Whenever selection in the JComboBox changes, the
* ComboBoxModel should fire ListDataEvents to ComboBox's ListDataListeners.
*
* @author Andrew Selkirk
* @version 1.0
*/
public interface ComboBoxModel extends ListModel {
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* setSelectedItem
* @param item TODO
*/
void setSelectedItem(Object item);
/**
* getSelectedItem
* @returns Object
*/
Object getSelectedItem();
public interface ComboBoxModel extends ListModel
{
/**
* This method sets the selected item in the combo box. Class
* implementing this interface should fire ListDataEvents to
* all registered ListDataListeners to indicated that the
* selection has changed.
*
* @param item item in the combo box that should be selected
*/
void setSelectedItem(Object item);
/**
* The method returns currently selected item in the combo box
*
* @returns item that is currently selected in the combo box.
*/
Object getSelectedItem();
} // ComboBoxModel

View File

@ -1,4 +1,4 @@
/* DefaultButtonModel.java --
/* DefaultButtonModel.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -44,87 +44,103 @@ import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.io.Serializable;
import java.util.EventListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
* The purpose of this class is to model the dynamic state of an abstract
* button. The concrete button type holding this state may be a a "toggle"
* button (checkbox, radio button) or a "push" button (menu button, button).
*
* If the model is disabled, only the "selected" property can be changed.
* An attempt to change the "armed", "rollover" or "pressed" properties
* while the model is disabled will be blocked.
* If the model is disabled, only the "selected" property can be changed. An
* attempt to change the "armed", "rollover" or "pressed" properties while
* the model is disabled will be blocked. Any successful (non-blocked) change
* to the model's properties will trigger the firing of a ChangeEvent. Any
* change to the "selected" property will trigger the firing of an ItemEvent
* in addition to ChangeEvent. This is true whether the model is enabled or
* not. One other state change is special: the transition from "enabled,
* armed and pressd" to "enabled, armed and not-pressed". This is considered
* the "trailing edge" of a successful mouse click, and therefore fires an
* ActionEvent in addition to a ChangeEvent. In all other respects this class
* is just a container of boolean flags.
*
* Any successful (non-blocked) change to the model's properties will
* trigger the firing of a ChangeEvent.
*
* Any change to the "selected" property will trigger the firing of an
* ItemEvent in addition to ChangeEvent. This is true whether the model is
* enabled or not.
*
* One other state change is special: the transition from "enabled, armed
* and pressd" to "enabled, armed and not-pressed". This is considered the
* "trailing edge" of a successful mouse click, and therefore fires an
* ActionEvent in addition to a ChangeEvent.
*
* In all other respects this class is just a container of boolean flags.
*
* @author Graydon Hoare (graydon@redhat.com)
* @author Graydon Hoare (graydon_at_redhat.com)
*/
public class DefaultButtonModel implements ButtonModel, Serializable
{
/** DOCUMENT ME! */
static final long serialVersionUID = -5342609566534980231L;
/** 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. */
/**
* 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.
*/
public static final int ARMED = 1;
/** State constant indicating that the button is enabled. Buttons cannot
be pressed or selected unless they are enabled. */
/**
* State constant indicating that the button is enabled. Buttons cannot be
* pressed or selected unless they are enabled.
*/
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.*/
/**
* 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.
*/
public static final int PRESSED = 4;
/** State constant indicating that the mouse is currently positioned over
the button. */
/**
* State constant indicating that the mouse is currently positioned over the
* button.
*/
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). */
/**
* State constant indicating that the button is selected. This constant is
* only meaningful for toggle-type buttons (radio buttons, checkboxes).
*/
public static final int SELECTED = 2;
/** Represents the "state properties" (armed, enabled, pressed, rollover
and selected) by a bitwise combination of integer constants. */
/**
* Represents the "state properties" (armed, enabled, pressed, rollover and
* selected) by a bitwise combination of integer constants.
*/
protected int stateMask = ENABLED;
/** List of ItemListeners, ChangeListeners, and ActionListeners
registered on this model. */
protected EventListenerList listenerList = new EventListenerList();;
/**
* List of ItemListeners, ChangeListeners, and ActionListeners registered on
* this model.
*/
protected EventListenerList listenerList = new EventListenerList();
;
/** The single ChangeEvent this model (re)uses to call its
ChangeListeners. */
/** The single ChangeEvent this model (re)uses to call its ChangeListeners. */
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. */
/**
* The group this model belongs to. Only one button in a group may be
* selected at any given time.
*/
protected ButtonGroup group;
/** The key code (one of {@link java.awt.event.KeyEvent} VK_*) used to
press this button via a keyboard interface. */
/**
* The key code (one of {@link java.awt.event.KeyEvent} VK_) used to press
* this button via a keyboard interface.
*/
protected int mnemonic = KeyEvent.VK_UNDEFINED;
/** The string used as the "command" property of any ActionEvent this
model sends. */
/**
* The string used as the "command" property of any ActionEvent this model
* sends.
*/
protected String actionCommand;
/**
* Creates a new DefaultButtonModel object.
*/
public DefaultButtonModel()
{
}
@ -135,10 +151,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*
* @return <code>null</code>
*/
public Object[] getSelectedObjects()
{
return null;
}
public Object[] getSelectedObjects()
{
return null;
}
/**
* Returns a specified class of listeners.
@ -151,10 +167,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
return listenerList.getListeners(listenerType);
}
/**
* Add an ActionListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
* Add an ActionListener to the model. Usually only called to subscribe an
* AbstractButton's listener to the model.
*
* @param l The listener to add
*/
@ -162,10 +178,10 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
listenerList.add(ActionListener.class, l);
}
/**
* Remove an ActionListener to the model. Usually only called to
* unsubscribe an AbstractButton's listener to the model.
* Remove an ActionListener to the model. Usually only called to unsubscribe
* an AbstractButton's listener to the model.
*
* @param l The listener to remove
*/
@ -185,8 +201,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
* Add an ItemListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
* Add an ItemListener to the model. Usually only called to subscribe an
* AbstractButton's listener to the model.
*
* @param l The listener to add
*/
@ -196,8 +212,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
* Remove an ItemListener to the model. Usually only called to
* unsubscribe an AbstractButton's listener to the model.
* Remove an ItemListener to the model. Usually only called to unsubscribe
* an AbstractButton's listener to the model.
*
* @param l The listener to remove
*/
@ -217,8 +233,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
* Add a ChangeListener to the model. Usually only called to subscribe
* an AbstractButton's listener to the model.
* Add a ChangeListener to the model. Usually only called to subscribe an
* AbstractButton's listener to the model.
*
* @param l The listener to add
*/
@ -228,8 +244,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
* Remove a ChangeListener to the model. Usually only called to
* unsubscribe an AbstractButton's listener to the model.
* Remove a ChangeListener to the model. Usually only called to unsubscribe
* an AbstractButton's listener to the model.
*
* @param l The listener to remove
*/
@ -258,61 +274,60 @@ public class DefaultButtonModel implements ButtonModel, Serializable
public void fireItemStateChanged(ItemEvent e)
{
ItemListener[] ll = getItemListeners();
for (int i = 0; i < ll.length; i++)
ll[i].itemStateChanged(e);
}
/**
* Inform each ActionListener in the {@link listenerList} that an
* ActionEvent has occurred. This happens in response to the any change
* to the {@link stateMask} field which makes the enabled, armed and
* pressed properties all simultaneously <code>true</code>.
* ActionEvent has occurred. This happens in response to the any change to
* the {@link stateMask} field which makes the enabled, armed and pressed
* properties all simultaneously <code>true</code>.
*
* @param e The ActionEvent to fire
*/
public void fireActionPerformed(ActionEvent e)
{
ActionListener[] ll = getActionListeners();
for (int i = 0; i < ll.length; i++)
ll[i].actionPerformed(e);
}
/**
* Inform each ChangeListener in the {@link listenerList} that a
* ChangeEvent has occurred. This happens in response to the any change
* to a property of the model.
*
* @param event The ChangeEvent to fire
* Inform each ChangeListener in the {@link listenerList} that a ChangeEvent
* has occurred. This happens in response to the any change to a property
* of the model.
*/
public void fireStateChanged()
{
ChangeListener[] ll = getChangeListeners();
for (int i = 0; i < ll.length; i++)
ll[i].stateChanged(changeEvent);
}
/**
* Helper method to fire a ChangeEvent with the model as the event's
* source.
* Helper method to fire a ChangeEvent with the model as the event's source.
*
* @param stateflag DOCUMENT ME!
* @param b DOCUMENT ME!
*/
protected void changeState(int stateflag, boolean b)
{
{
int oldstate = stateMask;
int newstate;
if (b)
newstate = oldstate | stateflag;
else
newstate = oldstate & ~stateflag;
newstate = oldstate & ~ stateflag;
if (oldstate == newstate)
return;
if ((stateflag != SELECTED)
&& (stateflag != ENABLED)
if ((stateflag != SELECTED) && (stateflag != ENABLED)
&& (stateMask & ENABLED) == 0)
return;
@ -320,35 +335,38 @@ public class DefaultButtonModel implements ButtonModel, Serializable
fireStateChanged();
if ((oldstate & SELECTED) == 0
&& (newstate & SELECTED) == SELECTED)
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
null, ItemEvent.SELECTED));
else if ((oldstate & SELECTED) == SELECTED
&& (newstate & SELECTED) == 0)
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
null, ItemEvent.DESELECTED));
else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED)
&&
((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0))
if ((oldstate & SELECTED) == 0 && (newstate & SELECTED) == SELECTED)
{
fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
actionCommand));
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
null, ItemEvent.SELECTED));
if (group != null)
group.setSelected(this, true);
}
}
else if ((oldstate & SELECTED) == SELECTED && (newstate & SELECTED) == 0)
{
fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
null, ItemEvent.DESELECTED));
if (group != null)
group.setSelected(this, false);
}
else if (((oldstate & ARMED) == ARMED && (oldstate & PRESSED) == PRESSED)
&& ((newstate & ARMED) == ARMED && (newstate & PRESSED) == 0))
fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
actionCommand));
}
/**
* Get the value of the model's "armed" property.
*
* @return The current "armed" property
*
* @return The current "armed" property
*/
public boolean isArmed()
{
return (stateMask & ARMED) == ARMED;
}
/**
* Set the value of the model's "armed" property.
*
@ -365,9 +383,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable
* @return The current "enabled" property.
*/
public boolean isEnabled()
{
{
return (stateMask & ENABLED) == ENABLED;
}
}
/**
* Set the value of the model's "enabled" property.
@ -385,9 +403,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable
* @param p The new "pressed" property
*/
public void setPressed(boolean p)
{
{
changeState(PRESSED, p);
}
}
/**
* Get the value of the model's "pressed" property.
@ -409,7 +427,6 @@ public class DefaultButtonModel implements ButtonModel, Serializable
changeState(ROLLOVER, r);
}
/**
* Set the value of the model's "selected" property.
*
@ -436,9 +453,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable
* @return The current "rollover" property
*/
public boolean isRollover()
{
{
return (stateMask & ROLLOVER) == ROLLOVER;
}
}
/**
* Get the value of the model's "mnemonic" property.
@ -446,7 +463,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
* @return The current "mnemonic" property
*/
public int getMnemonic()
{
{
return mnemonic;
}
@ -459,15 +476,15 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
if (mnemonic != key)
{
mnemonic = key;
fireStateChanged();
mnemonic = key;
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.
* 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.
*
* @param s The new "actionCommand" property.
*/
@ -475,11 +492,11 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
if (actionCommand != s)
{
actionCommand = s;
fireStateChanged();
actionCommand = s;
fireStateChanged();
}
}
}
/**
* Returns the current value of the model's "actionCommand" property.
*
@ -491,9 +508,9 @@ 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 model in a given group can have their "selected" property be
* 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 model in a given group can have their "selected" property be
* <code>true</code> at a time.
*
* @param g The new "group" property
@ -502,8 +519,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
if (group != g)
{
group = g;
fireStateChanged();
group = g;
fireStateChanged();
}
}

View File

@ -38,146 +38,191 @@ exception statement from your version. */
package javax.swing;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Vector;
/**
* DefaultComboBoxModel
* @author Andrew Selkirk
* @version 1.0
* DefaultComboBoxModel is a data model for JComboBox. This model keeps track
* of elements contained in the JComboBox as well as the current combo box
* selection. Whenever selection in the JComboBox changes, the ComboBoxModel
* will fire ListDataEvents to ComboBox's ListDataListeners.
*
* @author Andrew Selkirk
* @author Olga Rodimina
* @version 1.0
*/
public class DefaultComboBoxModel extends AbstractListModel
implements MutableComboBoxModel, Serializable
public class DefaultComboBoxModel extends AbstractListModel
implements MutableComboBoxModel, Serializable
{
static final long serialVersionUID = 6698657703676921904L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* List containing items in the combo box
*/
private Vector list;
/**
* list
*/
private Vector list;
/**
* Currently selected item in the combo box list
*/
private Object selectedItem = null;
/**
* selectedItem
*/
private Object selectedItem;
/**
* Constructor DefaultComboBoxModel. Create empty JComboBox.
*/
public DefaultComboBoxModel()
{
list = new Vector();
}
/**
* Constructs new DefaultComboBoxModel object and initializes its item list
* to values in the given array.
*
* @param items array containing items of the combo box.
*/
public DefaultComboBoxModel(Object[] items)
{
list = new Vector(Arrays.asList(items));
}
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Consturcts new DefaultComboBoxModel object and initializes its item list
* to values in the given vector.
*
* @param vector Vector containing items for this combo box.
*/
public DefaultComboBoxModel(Vector vector)
{
this.list = vector;
}
/**
* Constructor DefaultComboBoxModel
*/
public DefaultComboBoxModel() {
// TODO
} // DefaultComboBoxModel()
/**
* This method adds element to the combo box list. It fires ListDataEvent
* indicating that component was added to the combo box to all of the
* JComboBox's registered ListDataListeners.
*
* @param object item to add to the combo box list
*/
public void addElement(Object object)
{
list.add(object);
fireIntervalAdded(this, list.size(), list.size());
}
/**
* Constructor DefaultComboBoxModel
* @param items TODO
*/
public DefaultComboBoxModel(Object[] items) {
// TODO
} // DefaultComboBoxModel()
/**
* This method removes element at the specified index from the combo box
* list. It fires ListDataEvent indicating that component was removed from
* the combo box list to all of the JComboBox's registered
* ListDataListeners.
*
* @param index index specifying location of the element to remove in the
* combo box list.
*/
public void removeElementAt(int index)
{
list.remove(index);
fireIntervalRemoved(this, index, index);
}
/**
* Constructor DefaultComboBoxModel
* @param vector TODO
*/
public DefaultComboBoxModel(Vector vector) {
// TODO
} // DefaultComboBoxModel()
/**
* This method inserts given object to the combo box list at the specified
* index. It fires ListDataEvent indicating that component was inserted to
* the combo box list to all of the JComboBox's registered
* ListDataListeners.
*
* @param object element to insert
* @param index index specifing position in the list where given element
* should be inserted.
*/
public void insertElementAt(Object object, int index)
{
list.insertElementAt(object, index);
fireIntervalAdded(this, index, index);
}
/**
* Removes given object from the combo box list. It fires ListDataEvent
* indicating that component was removed from the combo box list to all of
* the JComboBox's registered ListDataListeners.
*
* @param object Element that will be removed from the combo box list
*/
public void removeElement(Object object)
{
int index = getIndexOf(object);
if (index != -1)
removeElementAt(index);
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* Removes all the items from the JComboBox's item list. It fires
* ListDataEvent indicating that all the elements were removed from the
* combo box list to all of the JComboBox's registered ListDataListeners.
*/
public void removeAllElements()
{
int listSize = getSize();
list.clear();
fireIntervalAdded(this, 0, listSize - 1);
}
/**
* addElement
* @param object TODO
*/
public void addElement(Object object) {
// TODO
} // addElement()
/**
* Returns number of items in the combo box list
*
* @return number of items in the combo box list
*/
public int getSize()
{
return list.size();
}
/**
* removeElementAt
* @param index TODO
*/
public void removeElementAt(int index) {
// TODO
} // removeElementAt()
/**
* Selects given object in the combo box list. This method fires
* ListDataEvent to all registered ListDataListeners of the JComboBox. The
* start and end index of the event is set to -1 to indicate combo box's
* selection has changed, and not its contents.
*
* @param object item to select in the JComboBox
*/
public void setSelectedItem(Object object)
{
selectedItem = object;
fireContentsChanged(this, -1, -1);
}
/**
* insertElementAt
* @param object TODO
* @param index TODO
*/
public void insertElementAt(Object object, int index) {
// TODO
} // insertElementAt()
/**
* Returns currently selected item in the combo box list
*
* @return currently selected item in the combo box list
*/
public Object getSelectedItem()
{
return selectedItem;
}
/**
* removeElement
* @param object TODO
*/
public void removeElement(Object object) {
// TODO
} // removeElement()
/**
* Returns element in the combo box list located at the given index
*
* @param index specifying location of the element in the list
*
* @return return element in the combo box list located at the given index
*/
public Object getElementAt(int index)
{
return list.elementAt(index);
}
/**
* removeAllElements
*/
public void removeAllElements() {
// TODO
} // removeAllElements()
/**
* getSize
* @returns int
*/
public int getSize() {
return 0; // TODO
} // getSize()
/**
* setSelectedItem
* @param object TODO
*/
public void setSelectedItem(Object object) {
// TODO
} // setSelectedItem()
/**
* getSelectedItem
* @returns Object
*/
public Object getSelectedItem() {
return null; // TODO
} // getSelectedItem()
/**
* getElementAt
* @param index TODO
* @returns Object
*/
public Object getElementAt(int index) {
return null; // TODO
} // getElementAt()
/**
* getIndexOf
* @param object TODO
* @returns int
*/
public int getIndexOf(Object object) {
return 0; // TODO
} // getIndexOf()
} // DefaultComboBoxModel
/**
* Returns index of the specified object in the combo box list.
*
* @param object element to look for in the combo box list .
*
* @return Index specifying position of the specified element in combo box
* list.
*/
public int getIndexOf(Object object)
{
return list.indexOf(object);
}
}

View File

@ -41,16 +41,18 @@ import java.awt.Component;
import java.awt.Rectangle;
import java.io.Serializable;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
/**
* DefaultListCellRenderer
* DefaultListCellRenderer. This class is responsible for rendering list
* cells.
*
* @author Andrew Selkirk
* @version 1.0
*/
public class DefaultListCellRenderer
extends JLabel implements ListCellRenderer, Serializable
public class DefaultListCellRenderer extends JLabel implements ListCellRenderer,
Serializable
{
static final long serialVersionUID = 7708947179685189462L;
@ -62,19 +64,22 @@ public class DefaultListCellRenderer
}
}
/** noFocusBorder */
protected static Border noFocusBorder = null; // TODO
/**
* This border is used whenever renderer doesn't have a focus.
*/
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
/**
* getListCellRendererComponent
*
* @param list TODO
* @param value TODO
* @param index TODO
* @param isSelected TODO
* @param cellHasFocus TODO
* @param list JList list for the 'value'
* @param value object that should be rendered in the cell
* @param index index of the cell
* @param isSelected draw cell highlighted if isSelected is true
* @param cellHasFocus draw focus rectangle around cell if the cell has
* focus
*
* @return Component
* @return Component that will be painted to the desired cell.
*/
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
@ -86,31 +91,87 @@ public class DefaultListCellRenderer
if (isSelected)
{
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
}
else
{
setBackground(list.getBackground());
setForeground(list.getForeground());
setBackground(list.getBackground());
setForeground(list.getForeground());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
// Use focusCellHighlightBorder when renderer has focus and
// noFocusBorder otherwise
if (cellHasFocus)
setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
else
setBorder(noFocusBorder);
return this;
}
public void validate() {}
public void revalidate() {}
public void repaint(long tm, int x, int y, int w, int h) {}
public void repaint(Rectangle rect) {}
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue){}
public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {}
public void firePropertyChange(String propertyName, char oldValue, char newValue) {}
public void firePropertyChange(String propertyName, short oldValue, short newValue) {}
public void firePropertyChange(String propertyName, int oldValue, int newValue) {}
public void firePropertyChange(String propertyName, long oldValue, long newValue) {}
public void firePropertyChange(String propertyName, float oldValue, float newValue) {}
public void firePropertyChange(String propertyName, double oldValue, double newValue) {}
public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {}
public void validate()
{
}
public void revalidate()
{
}
public void repaint(long tm, int x, int y, int w, int h)
{
}
public void repaint(Rectangle rect)
{
}
protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue)
{
}
public void firePropertyChange(String propertyName, byte oldValue,
byte newValue)
{
}
public void firePropertyChange(String propertyName, char oldValue,
char newValue)
{
}
public void firePropertyChange(String propertyName, short oldValue,
short newValue)
{
}
public void firePropertyChange(String propertyName, int oldValue,
int newValue)
{
}
public void firePropertyChange(String propertyName, long oldValue,
long newValue)
{
}
public void firePropertyChange(String propertyName, float oldValue,
float newValue)
{
}
public void firePropertyChange(String propertyName, double oldValue,
double newValue)
{
}
public void firePropertyChange(String propertyName, boolean oldValue,
boolean newValue)
{
}
}

View File

@ -264,7 +264,7 @@ public class DefaultListSelectionModel implements Cloneable,
{
end = i;
}
fireSelectionValueChanged(beg, end, valueIsAdjusting);
fireValueChanged(beg, end, valueIsAdjusting);
}
/**
@ -409,7 +409,7 @@ public class DefaultListSelectionModel implements Cloneable,
int hi = Math.max(index0, index1);
sel.set(lo, hi+1);
fireSelectionValueChanged(lo, hi, valueIsAdjusting);
fireValueChanged(lo, hi, valueIsAdjusting);
}
@ -429,7 +429,7 @@ public class DefaultListSelectionModel implements Cloneable,
int lo = Math.min(index0, index1);
int hi = Math.max(index0, index1);
sel.clear(lo, hi+1);
fireSelectionValueChanged(lo, hi, valueIsAdjusting);
fireValueChanged(lo, hi, valueIsAdjusting);
}
/**
@ -439,7 +439,7 @@ public class DefaultListSelectionModel implements Cloneable,
{
int sz = sel.size();
sel.clear();
fireSelectionValueChanged(0, sz, valueIsAdjusting);
fireValueChanged(0, sz, valueIsAdjusting);
}
/**
@ -460,7 +460,7 @@ public class DefaultListSelectionModel implements Cloneable,
int lo = Math.min(index0, index1);
int hi = Math.max(index0, index1);
sel.set(lo, hi+1);
fireSelectionValueChanged(lo, hi, valueIsAdjusting);
fireValueChanged(lo, hi, valueIsAdjusting);
}
/**
@ -522,8 +522,8 @@ public class DefaultListSelectionModel implements Cloneable,
* @param isAdjusting Whether this change is part of a seqence of adjustments
* made to the selection, such as during interactive scrolling
*/
public void fireSelectionValueChanged(int firstIndex, int lastIndex,
boolean isAdjusting)
protected void fireValueChanged(int firstIndex, int lastIndex,
boolean isAdjusting)
{
ListSelectionEvent evt = new ListSelectionEvent(this, firstIndex,
lastIndex, isAdjusting);

View File

@ -89,9 +89,9 @@ public class InputMap
{
Object result = inputMap.get(keystroke);
if (result == null)
result = parent.get(keystroke);
return result;
if (result == null && parent != null)
result = parent.get(keystroke);
return result;
}
/**

View File

@ -114,7 +114,7 @@ public class JCheckBox extends JToggleButton
}
/**
* Returns a string that specifies the name of the L&amp;F class
* Returns a string that specifies the name of the Look and Feel class
* that renders this component.
*/
public String getUIClassID()

View File

@ -35,11 +35,16 @@ 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.AWTError;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
@ -47,314 +52,521 @@ import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.colorchooser.AbstractColorChooserPanel;
import javax.swing.colorchooser.ColorChooserComponentFactory;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.colorchooser.DefaultColorSelectionModel;
import javax.swing.plaf.ColorChooserUI;
/**
* JColorChooser
* @author Andrew Selkirk
* @version 1.0
* The JColorChooser is a Swing widget that offers users different ways to
* select a color. By default, three different panels are presented to the
* user that are capable of changing the selected color. There are three ways
* to utilize JColorChooser. The first is to build a JColorChooser and add it
* to the content pane. The second is to use the createDialog method to
* create a JDialog that holds a JColorChooser. The third is to show a
* JColorChooser in a JDialog directly using the showDialog method.
*/
public class JColorChooser extends JComponent implements Accessible {
public class JColorChooser extends JComponent implements Accessible
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 9168066781620640889L;
//-------------------------------------------------------------
// Classes ----------------------------------------------------
//-------------------------------------------------------------
/**
* AccessibleJColorChooser
*/
protected class AccessibleJColorChooser extends JComponent.AccessibleJComponent {
/**
* AccessibleJColorChooser
*/
protected class AccessibleJColorChooser
extends JComponent.AccessibleJComponent
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -2038297864782299082L;
private static final long serialVersionUID = -2038297864782299082L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* Constructor AccessibleJColorChooser
*/
protected AccessibleJColorChooser()
{
}
/**
* getAccessibleRole
*
* @return AccessibleRole
*/
public AccessibleRole getAccessibleRole()
{
return AccessibleRole.COLOR_CHOOSER;
} // getAccessibleRole()
} // AccessibleJColorChooser
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/** The model used with the JColorChooser. */
private ColorSelectionModel selectionModel;
/**
* Constructor AccessibleJColorChooser
* @param component TODO
*/
protected AccessibleJColorChooser()
/** The preview panel associated with the JColorChooser. */
private JComponent previewPanel;
/**
* The set of AbstractColorChooserPanels associated with the JColorChooser.
*/
private AbstractColorChooserPanel[] chooserPanels;
/** A Drag and Drop property. */
private boolean dragEnabled;
/**
* The property fired by the JColorChooser when the selectionModel property
* changes.
*/
public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
/**
* The property fired by the JColorChooser when the previewPanel property
* changes.
*/
public static final String PREVIEW_PANEL_PROPERTY = "previewPanel";
/**
* The property fired by the JColorChooser when the chooserPanels property
* changes.
*/
public static final String CHOOSER_PANELS_PROPERTY = "chooserPanels";
/** accessibleContext */
protected AccessibleContext accessibleContext;
/**
* This method creates a new JColorChooser with the default initial color.
*/
public JColorChooser()
{
this(new DefaultColorSelectionModel());
} // JColorChooser()
/**
* This method creates a new JColorChooser with the given initial color.
*
* @param initial The initial color.
*/
public JColorChooser(Color initial)
{
this(new DefaultColorSelectionModel(initial));
} // JColorChooser()
/**
* This method creates a new JColorChooser with the given model. The model
* will dictate what the initial color for the JColorChooser is.
*
* @param model The Model to use with the JColorChooser.
*/
public JColorChooser(ColorSelectionModel model)
{
if (model == null)
model = new DefaultColorSelectionModel();
selectionModel = model;
updateUI();
} // JColorChooser()
/**
* This method sets the current color for the JColorChooser.
*
* @param color The new color for the JColorChooser.
*/
public void setColor(Color color)
{
if (color != null)
selectionModel.setSelectedColor(color);
} // setColor()
/**
* This method sets the current color for the JColorChooser using RGB
* values.
*
* @param r The red value.
* @param g The green value.
* @param b The blue value.
*/
public void setColor(int r, int g, int b)
{
selectionModel.setSelectedColor(new Color(r, g, b));
} // setColor()
/**
* This method sets the current color for the JColorChooser using the
* integer value. Bits 0-7 represent the blue value. Bits 8-15 represent
* the green value. Bits 16-23 represent the red value.
*
* @param color The new current color of the JColorChooser.
*/
public void setColor(int color)
{
setColor(new Color(color, false));
} // setColor()
/**
* This method shows a JColorChooser inside a JDialog. The JDialog will
* block until it is hidden. The JDialog comes with three buttons: OK,
* Cancel, and Reset. Pressing OK or Cancel hide the JDialog. Pressing
* Reset will reset the JColorChooser to its initial value.
*
* @param component The Component that parents the JDialog.
* @param title The title displayed in the JDialog.
* @param initial The initial color.
*
* @return The selected color.
*/
public static Color showDialog(Component component, String title,
Color initial)
{
JColorChooser choose = new JColorChooser(initial);
JDialog dialog = createDialog(component, title, true, choose, null, null);
dialog.getContentPane().add(choose);
dialog.pack();
dialog.show();
return choose.getColor();
} // showDialog()
/**
* This is a helper method to make the given JDialog block until it is
* hidden.
*
* @param dialog The JDialog to block.
*/
private static void makeModal(JDialog dialog)
{
try
{
synchronized (dialog)
{
while (dialog.isVisible())
dialog.wait();
}
}
catch (InterruptedException e)
{
}
}
/**
* getAccessibleRole
* @returns AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.COLOR_CHOOSER;
} // getAccessibleRole()
/**
* This is a helper method to find the first Frame or Dialog ancestor of the
* given Component.
*
* @param c The Component to find ancestors for.
*
* @return A Frame or Dialog ancestor. Null if none are found.
*/
private static Component findParent(Component c)
{
Component parent = SwingUtilities.getAncestorOfClass(Frame.class, c);
if (parent != null)
return parent;
parent = SwingUtilities.getAncestorOfClass(Dialog.class, c);
return parent;
}
/**
* This method will take the given JColorChooser and place it in a JDialog
* with the given modal property. Three buttons are displayed in the
* JDialog: OK, Cancel and Reset. If OK or Cancel are pressed, the JDialog
* is hidden. If Reset is pressed, then the JColorChooser will take on its
* default color value. The given okListener will be registered to the OK
* button and the cancelListener will be registered to the Cancel button.
* If the modal property is set, then the JDialog will block until it is
* hidden.
*
* @param component The Component that will parent the JDialog.
* @param title The title displayed in the JDialog.
* @param modal The modal property.
* @param chooserPane The JColorChooser to place in the JDialog.
* @param okListener The ActionListener to register to the OK button.
* @param cancelListener The ActionListener to register to the Cancel
* button.
*
* @return A JDialog with the JColorChooser inside of it.
*
* @throws AWTError If the component is not a suitable parent.
*/
public static JDialog createDialog(Component component, String title,
boolean modal, JColorChooser chooserPane,
ActionListener okListener,
ActionListener cancelListener)
{
Component parent = findParent(component);
if (parent == null)
throw new AWTError("No suitable parent found for Component.");
JDialog dialog;
if (parent instanceof Frame)
dialog = new ModalDialog((Frame) parent, title);
else
dialog = new ModalDialog((Dialog) parent, title);
dialog.setModal(modal);
} // AccessibleJColorChooser
dialog.getContentPane().setLayout(new BorderLayout());
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
ActionListener al = new DefaultOKCancelListener(dialog);
/**
* uiClassID
*/
private static final String uiClassID = "ColorChooserUI";
JButton ok = new JButton("OK");
ok.addActionListener(okListener);
ok.addActionListener(al);
/**
* selectionModel
*/
private ColorSelectionModel selectionModel;
JButton cancel = new JButton("Cancel");
cancel.addActionListener(cancelListener);
cancel.addActionListener(al);
/**
* previewPanel
*/
private JComponent previewPanel;
JButton reset = new JButton("Reset");
reset.addActionListener(new DefaultResetListener(chooserPane));
/**
* chooserPanels
*/
private AbstractColorChooserPanel[] chooserPanels;
dialog.getContentPane().add(chooserPane, BorderLayout.NORTH);
/**
* SELECTION_MODEL_PROPERTY
*/
public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
panel.add(ok);
panel.add(cancel);
panel.add(reset);
/**
* PREVIEW_PANEL_PROPERTY
*/
public static final String PREVIEW_PANEL_PROPERTY = "previewPanel";
dialog.getContentPane().add(panel, BorderLayout.SOUTH);
/**
* CHOOSER_PANELS_PROPERTY
*/
public static final String CHOOSER_PANELS_PROPERTY = "chooserPanels";
return dialog;
} // createDialog()
/**
* accessibleContext
*/
protected AccessibleContext accessibleContext;
/**
* This method returns the UI Component used for this JColorChooser.
*
* @return The UI Component for this JColorChooser.
*/
public ColorChooserUI getUI()
{
return (ColorChooserUI) ui;
} // getUI()
/**
* This method sets the UI Component used for this JColorChooser.
*
* @param ui The UI Component to use with this JColorChooser.
*/
public void setUI(ColorChooserUI ui)
{
super.setUI(ui);
} // setUI()
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* This method resets the UI Component property to the Look and Feel
* default.
*/
public void updateUI()
{
setUI((ColorChooserUI) UIManager.getUI(this));
revalidate();
} // updateUI()
/**
* Constructor JColorChooser
*/
public JColorChooser() {
// TODO
} // JColorChooser()
/**
* This method returns a String identifier for the UI Class to be used with
* the JColorChooser.
*
* @return The String identifier for the UI Class.
*/
public String getUIClassID()
{
return "ColorChooserUI";
} // getUIClassID()
/**
* Constructor JColorChooser
* @param initial TODO
*/
public JColorChooser(Color initial) {
// TODO
} // JColorChooser()
/**
* This method returns the current color for the JColorChooser.
*
* @return The current color for the JColorChooser.
*/
public Color getColor()
{
return selectionModel.getSelectedColor(); // TODO
} // getColor()
/**
* Constructor JColorChooser
* @param model TODO
*/
public JColorChooser(ColorSelectionModel model) {
// TODO
} // JColorChooser()
/**
* This method changes the previewPanel property for the JTabbedPane. The
* previewPanel is responsible for indicating the current color of the
* JColorChooser.
*
* @param component The Component that will act as the previewPanel.
*/
public void setPreviewPanel(JComponent component)
{
if (component != previewPanel)
{
JComponent old = previewPanel;
previewPanel = component;
firePropertyChange(PREVIEW_PANEL_PROPERTY, old, previewPanel);
}
} // setPreviewPanel()
/**
* This method returns the current previewPanel used with this
* JColorChooser.
*
* @return The current previewPanel.
*/
public JComponent getPreviewPanel()
{
return previewPanel; // TODO
} // getPreviewPanel()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* This method adds the given AbstractColorChooserPanel to the list of the
* JColorChooser's chooserPanels.
*
* @param panel The AbstractColorChooserPanel to add.
*/
public void addChooserPanel(AbstractColorChooserPanel panel)
{
if (panel == null)
return;
AbstractColorChooserPanel[] old = chooserPanels;
AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[(old == null)
? 1
: old.length
+ 1];
if (old != null)
System.arraycopy(old, 0, newPanels, 0, old.length);
newPanels[newPanels.length - 1] = panel;
chooserPanels = newPanels;
panel.installChooserPanel(this);
firePropertyChange(CHOOSER_PANELS_PROPERTY, old, newPanels);
} // addChooserPanel()
/**
* writeObject
* @param stream TODO
* @exception IOException TODO
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
// TODO
} // writeObject()
/**
* This method removes the given AbstractColorChooserPanel from the
* JColorChooser's list of chooserPanels.
*
* @param panel The AbstractColorChooserPanel to remove.
*
* @return The AbstractColorChooserPanel that was removed.
*/
public AbstractColorChooserPanel removeChooserPanel(AbstractColorChooserPanel panel)
{
int index = -1;
for (int i = 0; i < chooserPanels.length; i++)
if (panel == chooserPanels[i])
{
index = i;
break;
}
/**
* setColor
* @param color TODO
*/
public void setColor(Color color) {
// TODO
} // setColor()
if (index == -1)
return null;
/**
* setColor
* @param r TODO
* @param g TODO
* @param b TODO
*/
public void setColor(int r, int g, int b) {
// TODO
} // setColor()
AbstractColorChooserPanel[] old = chooserPanels;
if (chooserPanels.length == 1)
chooserPanels = null;
else
{
AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[chooserPanels.length
- 1];
System.arraycopy(chooserPanels, 0, newPanels, 0, index);
System.arraycopy(chooserPanels, index, newPanels, index - 1,
chooserPanels.length - index);
chooserPanels = newPanels;
}
panel.uninstallChooserPanel(this);
firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels);
return panel;
}
/**
* setColor
* @param color TODO
*/
public void setColor(int color) {
// TODO
} // setColor()
/**
* This method sets the chooserPanels property for this JColorChooser.
*
* @param panels The new set of AbstractColorChooserPanels to use.
*/
public void setChooserPanels(AbstractColorChooserPanel[] panels)
{
if (panels != chooserPanels)
{
if (chooserPanels != null)
for (int i = 0; i < chooserPanels.length; i++)
if (chooserPanels[i] != null)
chooserPanels[i].uninstallChooserPanel(this);
/**
* showDialog
* @param component TODO
* @param title TODO
* @param initial TODO
* @returns Color
*/
public static Color showDialog(Component component, String title,
Color initial) {
return null; // TODO
} // showDialog()
AbstractColorChooserPanel[] old = chooserPanels;
chooserPanels = panels;
/**
* createDialog
* @param component TODO
* @param title TODO
* @param modal TODO
* @param chooserPane TODO
* @param okListener TODO
* @param cancelListener TODO
* @returns JDialog
*/
public static JDialog createDialog(Component component, String title,
boolean modal, JColorChooser chooserPane,
ActionListener okListener, ActionListener cancelListener) {
return null; // TODO
} // createDialog()
if (panels != null)
for (int i = 0; i < panels.length; i++)
if (panels[i] != null)
panels[i].installChooserPanel(this);
/**
* getUI
* @returns ColorChooserUI
*/
public ColorChooserUI getUI() {
return (ColorChooserUI) ui;
} // getUI()
firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels);
}
} // setChooserPanels()
/**
* setUI
* @param ui TODO
*/
public void setUI(ColorChooserUI ui) {
super.setUI(ui);
} // setUI()
/**
* This method returns the AbstractColorChooserPanels used with this
* JColorChooser.
*
* @return The AbstractColorChooserPanels used with this JColorChooser.
*/
public AbstractColorChooserPanel[] getChooserPanels()
{
return chooserPanels;
} // getChooserPanels()
/**
* updateUI
*/
public void updateUI() {
setUI((ColorChooserUI) UIManager.get(this));
invalidate();
} // updateUI()
/**
* This method returns the ColorSelectionModel used with this JColorChooser.
*
* @return The ColorSelectionModel.
*/
public ColorSelectionModel getSelectionModel()
{
return selectionModel;
} // getSelectionModel()
/**
* getUIClassID
* @returns String
*/
public String getUIClassID() {
return uiClassID;
} // getUIClassID()
/**
* This method sets the ColorSelectionModel to be used with this
* JColorChooser.
*
* @param model The ColorSelectionModel to be used with this JColorChooser.
*
* @throws AWTError If the given model is null.
*/
public void setSelectionModel(ColorSelectionModel model)
{
if (model == null)
throw new AWTError("ColorSelectionModel is not allowed to be null.");
selectionModel = model;
} // setSelectionModel()
/**
* getColor
* @returns Color
*/
public Color getColor() {
return null; // TODO
} // getColor()
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean getDragEnabled()
{
return dragEnabled;
}
/**
* setPreviewPanel
* @param component TODO
*/
public void setPreviewPanel(JComponent component) {
// TODO
} // setPreviewPanel()
/**
* DOCUMENT ME!
*
* @param b DOCUMENT ME!
*/
public void setDragEnabled(boolean b)
{
dragEnabled = b;
}
/**
* getPreviewPanel
* @returns JComponent
*/
public JComponent getPreviewPanel() {
return null; // TODO
} // getPreviewPanel()
/**
* addChooserPanel
* @param panel TODO
*/
public void addChooserPanel(AbstractColorChooserPanel panel) {
// TODO
} // addChooserPanel()
/**
* removeChooserPanel
* @param panel TODO
* @returns AbstractColorChooserPanel
*/
public AbstractColorChooserPanel removeChooserPanel(
AbstractColorChooserPanel panel) {
return null; // TODO
} // removeChooserPanel()
/**
* setChooserPanels
* @param panels TODO
*/
public void setChooserPanels(AbstractColorChooserPanel[] panels) {
// TODO
} // setChooserPanels()
/**
* getChooserPanels
* @returns AbstractColorChooserPanel[]
*/
public AbstractColorChooserPanel[] getChooserPanels() {
return null; // TODO
} // getChooserPanels()
/**
* getSelectionModel
* @returns ColorSelectionModel
*/
public ColorSelectionModel getSelectionModel() {
return null; // TODO
} // getSelectionModel()
/**
* setSelectionModel
* @param model TODO
*/
public void setSelectionModel(ColorSelectionModel model) {
// TODO
} // setSelectionModel()
/**
* paramString
* @returns String
*/
protected String paramString() {
return null; // TODO
} // paramString()
/**
* This method returns a String describing the JColorChooser.
*
* @return A String describing the JColorChooser.
*/
protected String paramString()
{
return "JColorChooser";
} // paramString()
/**
* getAccessibleContext
*
* @return AccessibleContext
*/
public AccessibleContext getAccessibleContext()
@ -364,4 +576,130 @@ public class JColorChooser extends JComponent implements Accessible {
return accessibleContext;
}
/**
* A helper class that hides a JDialog when the action is performed.
*/
static class DefaultOKCancelListener implements ActionListener
{
/** The JDialog to hide. */
private JDialog dialog;
/**
* Creates a new DefaultOKCancelListener with the given JDialog to hide.
*
* @param dialog The JDialog to hide.
*/
public DefaultOKCancelListener(JDialog dialog)
{
super();
this.dialog = dialog;
}
/**
* This method hides the JDialog when called.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
dialog.hide();
}
}
/**
* This method resets the JColorChooser color to the initial color when the
* action is performed.
*/
static class DefaultResetListener implements ActionListener
{
/** The JColorChooser to reset. */
private JColorChooser chooser;
/** The initial color. */
private Color init;
/**
* Creates a new DefaultResetListener with the given JColorChooser.
*
* @param chooser The JColorChooser to reset.
*/
public DefaultResetListener(JColorChooser chooser)
{
super();
this.chooser = chooser;
init = chooser.getColor();
}
/**
* This method resets the JColorChooser to its initial color.
*
* @param e The ActionEvent.
*/
public void actionPerformed(ActionEvent e)
{
chooser.setColor(init);
}
}
/**
* This is a custom JDialog that will notify when it is hidden and the modal
* property is set.
*/
static class ModalDialog extends JDialog
{
/** The modal property. */
private boolean modal;
/**
* Creates a new ModalDialog object with the given parent and title.
*
* @param parent The parent of the JDialog.
* @param title The title of the JDialog.
*/
public ModalDialog(Frame parent, String title)
{
super(parent, title);
}
/**
* Creates a new ModalDialog object with the given parent and title.
*
* @param parent The parent of the JDialog.
* @param title The title of the JDialog.
*/
public ModalDialog(Dialog parent, String title)
{
super(parent, title);
}
/**
* This method sets the modal property.
*
* @param modal The modal property.
*/
public void setModal(boolean modal)
{
this.modal = modal;
}
/**
* This method shows the ModalDialog.
*/
public void show()
{
super.show();
if (modal)
makeModal(this);
}
/**
* This method hides the ModalDialog.
*/
public synchronized void hide()
{
super.hide();
notifyAll();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@ exception statement from your version. */
package javax.swing;
import java.awt.AWTEvent;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@ -48,11 +49,13 @@ import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.awt.image.ImageObserver;
@ -192,22 +195,12 @@ public abstract class JComponent extends Container implements Serializable
Border border;
/**
* A tooltip associated with this component.
*
* @see #setToolTip
* @see #getToolTip
* @see #toolTipText
*/
JToolTip toolTip;
/**
* The text to show in the tooltip associated with this component.
* The text to show in the tooltip associated with this component.
*
* @see #setToolTipText
* @see #getToolTipText
* @see #toolTip
*/
String toolTipText;
String toolTipText;
/**
* <p>Whether to double buffer this component when painting. This flag
@ -325,6 +318,11 @@ public abstract class JComponent extends Container implements Serializable
* first client property.
*/
private Hashtable clientProperties;
private InputMap inputMap_whenFocused;
private InputMap inputMap_whenAncestorOfFocused;
private InputMap inputMap_whenInFocusedWindow;
private ActionMap actionMap;
/**
* A lock held during recursive painting; this is used to serialize
@ -757,18 +755,6 @@ public abstract class JComponent extends Container implements Serializable
return null;
}
/**
* Get the ActionListener (typically an {@link Action} object) which is
* associated with a particular keystroke.
*
* @param aKeyStroke The keystroke to retrieve the action of
*
* @return The action associated with the specified keystroke
*/
public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke)
{
return null;
}
/**
* Get the value of the {@link #alignmentX} property.
@ -875,24 +861,6 @@ public abstract class JComponent extends Container implements Serializable
return g;
}
/**
* Return the condition that determines whether a registered action
* occurs in response to the specified keystroke.
*
* @param aKeyStroke The keystroke to return the condition of
*
* @return One of the values {@link #UNDEFINED_CONDITION}, {@link
* #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link
* #WHEN_IN_FOCUSED_WINDOW}
*
* @see #registerKeyboardAction
* @see #unregisterKeyboardAction
* @see #resetKeyboardActiond
*/
public int getConditionForKeyStroke(KeyStroke aKeyStroke)
{
return UNDEFINED_CONDITION;
}
/**
* Get the value of the {@link #debugGraphicsOptions} property.
@ -1113,11 +1081,9 @@ public abstract class JComponent extends Container implements Serializable
*/
public JToolTip createToolTip()
{
if (toolTip == null)
{
toolTip = new JToolTip();
JToolTip toolTip = new JToolTip();
toolTip.setComponent(this);
toolTip.setTipText(toolTipText);
}
return toolTip;
}
@ -1145,7 +1111,22 @@ public abstract class JComponent extends Container implements Serializable
*/
public void setToolTipText(String text)
{
if (text == null)
{
ToolTipManager.sharedInstance().unregisterComponent(this);
toolTipText = null;
return;
}
// XXX: The tip text doesn't get updated unless you set it to null
// and then to something not-null. This is consistent with the behaviour
// of Sun's ToolTipManager.
String oldText = toolTipText;
toolTipText = text;
if (oldText == null)
ToolTipManager.sharedInstance().registerComponent(this);
}
/**
@ -1172,7 +1153,7 @@ public abstract class JComponent extends Container implements Serializable
*/
public String getToolTipText(MouseEvent event)
{
return toolTipText;
return getToolTipText();
}
/**
@ -1519,6 +1500,51 @@ public abstract class JComponent extends Container implements Serializable
registerKeyboardAction(act, null, stroke, cond);
}
/*
* There is some charmingly undocumented behavior sun seems to be using
* to simulate the old register/unregister keyboard binding API. It's not
* clear to me why this matters, but we shall endeavour to follow suit.
*
* Two main thing seem to be happening when you do registerKeyboardAction():
*
* - no actionMap() entry gets created, just an entry in inputMap()
*
* - the inputMap() entry is a proxy class which invokes the the
* binding's actionListener as a target, and which clobbers the command
* name sent in the ActionEvent, providing the binding command name
* instead.
*
* This much you can work out just by asking the input and action maps
* what they contain after making bindings, and watching the event which
* gets delivered to the recipient. Beyond that, it seems to be a
* sun-private solution so I will only immitate it as much as it matters
* to external observers.
*/
private static class ActionListenerProxy
extends AbstractAction
{
ActionListener target;
String bindingCommandName;
public ActionListenerProxy(ActionListener li,
String cmd)
{
target = li;
bindingCommandName = cmd;
}
public void actionPerformed(ActionEvent e)
{
ActionEvent derivedEvent = new ActionEvent(e.getSource(),
e.getID(),
bindingCommandName,
e.getModifiers());
target.actionPerformed(derivedEvent);
}
}
/**
* An obsolete method to register a keyboard action on this component.
* You should use <code>getInputMap</code> and <code>getActionMap</code>
@ -1543,8 +1569,185 @@ public abstract class JComponent extends Container implements Serializable
KeyStroke stroke,
int cond)
{
getInputMap(cond).put(stroke, new ActionListenerProxy(act, cmd));
}
public final void setInputMap(int condition, InputMap map)
{
enableEvents(AWTEvent.KEY_EVENT_MASK);
switch (condition)
{
case WHEN_FOCUSED:
inputMap_whenFocused = map;
break;
case WHEN_ANCESTOR_OF_FOCUSED_COMPONENT:
inputMap_whenAncestorOfFocused = map;
break;
case WHEN_IN_FOCUSED_WINDOW:
inputMap_whenInFocusedWindow = map;
break;
case UNDEFINED_CONDITION:
default:
throw new IllegalArgumentException();
}
}
public final InputMap getInputMap(int condition)
{
enableEvents(AWTEvent.KEY_EVENT_MASK);
switch (condition)
{
case WHEN_FOCUSED:
if (inputMap_whenFocused == null)
inputMap_whenFocused = new InputMap();
return inputMap_whenFocused;
case WHEN_ANCESTOR_OF_FOCUSED_COMPONENT:
if (inputMap_whenAncestorOfFocused == null)
inputMap_whenAncestorOfFocused = new InputMap();
return inputMap_whenAncestorOfFocused;
case WHEN_IN_FOCUSED_WINDOW:
if (inputMap_whenInFocusedWindow == null)
inputMap_whenInFocusedWindow = new InputMap();
return inputMap_whenInFocusedWindow;
case UNDEFINED_CONDITION:
default:
return null;
}
}
public final InputMap getInputMap()
{
return getInputMap(WHEN_FOCUSED);
}
public final ActionMap getActionMap()
{
if (actionMap == null)
actionMap = new ActionMap();
return actionMap;
}
public final void setActionMap(ActionMap map)
{
actionMap = map;
}
/**
* @deprecated As of 1.3 KeyStrokes can be registered with multiple
* simultaneous conditions.
*
* Return the condition that determines whether a registered action
* occurs in response to the specified keystroke.
*
* @param aKeyStroke The keystroke to return the condition of
*
* @return One of the values {@link #UNDEFINED_CONDITION}, {@link
* #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link
* #WHEN_IN_FOCUSED_WINDOW}
*
* @see #registerKeyboardAction
* @see #unregisterKeyboardAction
* @see #resetKeyboardActiond
*/
public int getConditionForKeyStroke(KeyStroke ks)
{
if (inputMap_whenFocused != null
&& inputMap_whenFocused.get(ks) != null)
return WHEN_FOCUSED;
else if (inputMap_whenAncestorOfFocused != null
&& inputMap_whenAncestorOfFocused.get(ks) != null)
return WHEN_ANCESTOR_OF_FOCUSED_COMPONENT;
else if (inputMap_whenInFocusedWindow != null
&& inputMap_whenInFocusedWindow.get(ks) != null)
return WHEN_IN_FOCUSED_WINDOW;
else
return UNDEFINED_CONDITION;
}
/**
* @deprecated Use {@link #getActionMap()}
*
* Get the ActionListener (typically an {@link Action} object) which is
* associated with a particular keystroke.
*
* @param aKeyStroke The keystroke to retrieve the action of
*
* @return The action associated with the specified keystroke
*/
public ActionListener getActionForKeyStroke(KeyStroke ks)
{
Object cmd = getInputMap().get(ks);
if (cmd != null)
{
if (cmd instanceof ActionListenerProxy)
return (ActionListenerProxy) cmd;
else if (cmd instanceof String)
return getActionMap().get(cmd);
}
return null;
}
/**
* A hook for subclasses which want to customize event processing.
*/
protected void processComponentKeyEvent(KeyEvent e)
{
}
/**
* Override the default key dispatch system from Component to hook into
* the swing {@link InputMap} / {@link ActionMap} system.
*
* See <a
* href="http://java.sun.com/products/jfc/tsc/special_report/kestrel/keybindings.html">this
* report</a> for more details, it's somewhat complex.
*/
protected void processKeyEvent(KeyEvent e)
{
processComponentKeyEvent(e);
// FIXME: this needs to be elaborated significantly, to do all the
// focus / ancestor / window searching for the various binding modes.
if (! e.isConsumed() &&
processKeyBinding(KeyStroke.getKeyStrokeForEvent(e),
e, WHEN_FOCUSED, e.getID() == KeyEvent.KEY_PRESSED))
e.consume();
}
protected boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
{
if (isEnabled())
{
Action act = null;
InputMap map = getInputMap(condition);
if (map != null)
{
Object cmd = map.get(ks);
if (cmd != null)
{
if (cmd instanceof ActionListenerProxy)
act = (Action) cmd;
else
act = (Action) getActionMap().get(cmd);
}
}
if (act != null && act.isEnabled())
return SwingUtilities.notifyAction(act, ks, e, this, e.getModifiers());
}
return false;
}
/**
* Remove a keyboard action registry.
*
@ -1568,6 +1771,14 @@ public abstract class JComponent extends Container implements Serializable
*/
public void resetKeyboardActions()
{
if (inputMap_whenFocused != null)
inputMap_whenFocused.clear();
if (inputMap_whenAncestorOfFocused != null)
inputMap_whenAncestorOfFocused.clear();
if (inputMap_whenInFocusedWindow != null)
inputMap_whenInFocusedWindow.clear();
if (actionMap != null)
actionMap.clear();
}
@ -1875,11 +2086,14 @@ public abstract class JComponent extends Container implements Serializable
if (ui != null)
ui.uninstallUI(this);
ComponentUI oldUI = ui;
ui = newUI;
if (ui != null)
ui.installUI(this);
firePropertyChange("UI", oldUI, newUI);
revalidate();
repaint();
}

View File

@ -135,7 +135,7 @@ public class JFormattedTextField extends JTextField
public JFormattedTextField ()
{
throw new InternalError ("not implemented");
this((AbstractFormatterFactory) null);
}
public JFormattedTextField (Format format)
@ -150,7 +150,7 @@ public class JFormattedTextField extends JTextField
public JFormattedTextField (AbstractFormatterFactory factory)
{
throw new InternalError ("not implemented");
this(factory, null);
}
public JFormattedTextField (AbstractFormatterFactory factory, Object value)

View File

@ -38,8 +38,9 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
import java.awt.Image;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.KeyEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.Icon;
@ -48,7 +49,7 @@ import javax.swing.plaf.LabelUI;
/**
* <p>
* A swing widget that displays a text message and/or an icon.
* A swing widget that displays a text message and/or an icon.
* </p>
*/
public class JLabel extends JComponent implements Accessible, SwingConstants
@ -63,10 +64,10 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
protected Component labelFor;
/** The label's text. */
private transient String labelText;
private transient String text;
/** Where the label will be positioned horizontally. */
private transient int horizontalAlignment = CENTER;
private transient int horizontalAlignment = LEADING;
/** Where the label text will be placed horizontally relative to the icon. */
private transient int horizontalTextPosition = TRAILING;
@ -78,16 +79,16 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
private transient int verticalTextPosition = CENTER;
/** The icon painted when the label is enabled. */
private transient Icon activeIcon;
private transient Icon icon;
/** The icon painted when the label is disabled. */
private transient Icon disabledIcon;
/** The label's mnemnonic key. */
private transient char mnemonicKey;
private transient int displayedMnemonic = KeyEvent.VK_UNDEFINED;
/** The index of the menemonic character in the text. */
private transient int underlinedChar = -1;
private transient int displayedMnemonicIndex = -1;
/** The gap between the icon and the text. */
private transient int iconTextGap = 4;
@ -102,10 +103,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* changes.
*/
public static final String DISPLAYED_MNEMONIC_CHANGED_PROPERTY = "displayedMnemonic";
/**
* Fired in a PropertyChangeEvent when the "displayedMnemonicIndex"
* property changes. */
* Fired in a PropertyChangeEvent when the "displayedMnemonicIndex" property
* changes.
*/
public static final String DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY = "displayedMnemonicIndex";
/**
@ -145,8 +147,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition";
/**
* Creates a new horizontally and vertically centered JLabel object with no text and no
* icon.
* Creates a new horizontally and vertically centered JLabel object with no
* text and no icon.
*/
public JLabel()
{
@ -154,8 +156,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
* Creates a new horizontally and vertically centered JLabel object with no text and the
* given icon.
* Creates a new horizontally and vertically centered JLabel object with no
* text and the given icon.
*
* @param image The icon to use with the label.
*/
@ -165,8 +167,9 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
* Creates a new vertically centered JLabel object with no text and the given icon and
* horizontal alignment. By default, the text is TRAILING the image.
* Creates a new vertically centered JLabel object with no text and the
* given icon and horizontal alignment. By default, the text is TRAILING
* the image.
*
* @param image The icon to use with the label.
* @param horizontalAlignment The horizontal alignment of the label.
@ -177,8 +180,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
* Creates a new horizontally and vertically centered JLabel object with no icon and the
* given text.
* Creates a new horizontally and vertically centered JLabel object with no
* icon and the given text.
*
* @param text The text to use with the label.
*/
@ -188,8 +191,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
* Creates a new vertically centered JLabel object with no icon and the given text and
* horizontal alignment.
* Creates a new vertically centered JLabel object with no icon and the
* given text and horizontal alignment.
*
* @param text The text to use with the label.
* @param horizontalAlignment The horizontal alignment of the label.
@ -200,8 +203,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
}
/**
* Creates a new vertically centered JLabel object with the given text, icon, and horizontal
* alignment.
* Creates a new vertically centered JLabel object with the given text,
* icon, and horizontal alignment.
*
* @param text The text to use with the label.
* @param icon The icon to use with the label.
@ -209,8 +212,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public JLabel(String text, Icon icon, int horizontalAlignment)
{
labelText = text;
activeIcon = icon;
this.text = text;
this.icon = icon;
this.horizontalAlignment = horizontalAlignment;
updateUI();
}
@ -273,24 +276,25 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public String getText()
{
return labelText;
return text;
}
/**
* This method changes the "text" property. The given text will be painted
* in the label.
*
* @param text The label's text.
* @param newText The label's text.
*/
public void setText(String text)
public void setText(String newText)
{
if (text != labelText)
if (text != newText)
{
String oldText = labelText;
labelText = text;
firePropertyChange(TEXT_CHANGED_PROPERTY, oldText, labelText);
if (labelText != null && labelText.length() <= underlinedChar)
setDisplayedMnemonicIndex(labelText.length() - 1);
String oldText = text;
text = newText;
firePropertyChange(TEXT_CHANGED_PROPERTY, oldText, newText);
if (text != null && text.length() <= displayedMnemonicIndex)
setDisplayedMnemonicIndex(text.length() - 1);
}
}
@ -302,37 +306,39 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public Icon getIcon()
{
return activeIcon;
return icon;
}
/**
* This method changes the "icon" property. This icon (the active icon) will
* be the one displayed when the label is enabled.
*
* @param icon The active icon.
* @param newIcon The active icon.
*/
public void setIcon(Icon icon)
public void setIcon(Icon newIcon)
{
if (icon != activeIcon)
if (icon != newIcon)
{
Icon oldIcon = activeIcon;
activeIcon = icon;
firePropertyChange(ICON_CHANGED_PROPERTY, oldIcon, activeIcon);
Icon oldIcon = icon;
icon = newIcon;
firePropertyChange(ICON_CHANGED_PROPERTY, oldIcon, newIcon);
}
}
/**
* This method returns the disabled icon. The disabled icon is painted when
* the label is disabled. If the disabled icon is null and the active icon is
* an ImageIcon, this method returns a grayed version of the icon. The grayed
* version of the icon becomes the disabledIcon.
* the label is disabled. If the disabled icon is null and the active icon
* is an ImageIcon, this method returns a grayed version of the icon. The
* grayed version of the icon becomes the disabledIcon.
*
* @return The disabled icon.
*/
public Icon getDisabledIcon()
{
if (disabledIcon == null && activeIcon instanceof ImageIcon)
disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) activeIcon).getImage()));
if (disabledIcon == null && icon instanceof ImageIcon)
disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) icon)
.getImage()));
return disabledIcon;
}
@ -340,16 +346,15 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* This method changes the "disabledIcon" property. This icon (the disabled
* icon) will be the one displayed when the label is disabled.
*
* @param disabledIcon The disabled icon.
* @param newIcon The disabled icon.
*/
public void setDisabledIcon(Icon disabledIcon)
public void setDisabledIcon(Icon newIcon)
{
if (disabledIcon != this.disabledIcon)
if (disabledIcon != newIcon)
{
Icon oldDisabledIcon = this.disabledIcon;
this.disabledIcon = disabledIcon;
firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldDisabledIcon,
this.disabledIcon);
Icon oldIcon = disabledIcon;
disabledIcon = newIcon;
firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldIcon, newIcon);
}
}
@ -358,11 +363,19 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* label is used as a label for another component, the label will give
* focus to that component when the mnemonic is activated.
*
* @param key The keycode to use for the mnemonic.
* @param mnemonic The keycode to use for the mnemonic.
*/
public void setDisplayedMnemonic(int key)
public void setDisplayedMnemonic(int mnemonic)
{
setDisplayedMnemonic((char) key);
if (displayedMnemonic != mnemonic)
{
firePropertyChange(DISPLAYED_MNEMONIC_CHANGED_PROPERTY,
displayedMnemonic, mnemonic);
displayedMnemonic = mnemonic;
if (text != null)
setDisplayedMnemonicIndex(text.indexOf(mnemonic));
}
}
/**
@ -370,19 +383,11 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* label is used as a label for another component, the label will give
* focus to that component when the mnemonic is activated.
*
* @param aChar The character to use for the mnemonic.
* @param mnemonic The character to use for the mnemonic.
*/
public void setDisplayedMnemonic(char aChar)
public void setDisplayedMnemonic(char mnemonic)
{
if (aChar != mnemonicKey)
{
char oldKey = mnemonicKey;
mnemonicKey = aChar;
firePropertyChange(DISPLAYED_MNEMONIC_CHANGED_PROPERTY, oldKey,
mnemonicKey);
if (labelText != null)
setDisplayedMnemonicIndex(labelText.indexOf(mnemonicKey));
}
setDisplayedMnemonic((int) mnemonic);
}
/**
@ -392,7 +397,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public int getDisplayedMnemonic()
{
return (int) mnemonicKey;
return (int) displayedMnemonic;
}
/**
@ -401,27 +406,26 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* no mnemonic. If the index is less than -1 or if the index is equal to
* the length, this method will throw an IllegalArgumentException.
*
* @param index The index of the character to underline.
* @param newIndex The index of the character to underline.
*
* @throws IllegalArgumentException If index less than -1 or index equals
* length.
*/
public void setDisplayedMnemonicIndex(int index)
public void setDisplayedMnemonicIndex(int newIndex)
throws IllegalArgumentException
{
if (index < -1 || labelText != null && index >= labelText.length())
if (newIndex < -1 || (text != null && newIndex >= text.length()))
throw new IllegalArgumentException();
if (labelText == null || labelText.charAt(index) != mnemonicKey)
index = -1;
if (index != underlinedChar)
{
int oldIndex = underlinedChar;
underlinedChar = index;
firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY,
oldIndex, underlinedChar);
}
if (text == null || text.charAt(newIndex) != displayedMnemonic)
newIndex = -1;
if (newIndex != displayedMnemonicIndex)
{
firePropertyChange(DISPLAYED_MNEMONIC_INDEX_CHANGED_PROPERTY,
displayedMnemonicIndex, newIndex);
displayedMnemonicIndex = newIndex;
}
}
/**
@ -432,7 +436,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public int getDisplayedMnemonicIndex()
{
return underlinedChar;
return displayedMnemonicIndex;
}
/**
@ -490,16 +494,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* This method changes the "iconTextGap" property. The iconTextGap
* determines how much space there is between the icon and the text.
*
* @param iconTextGap The gap between the icon and the text.
* @param newGap The gap between the icon and the text.
*/
public void setIconTextGap(int iconTextGap)
public void setIconTextGap(int newGap)
{
if (iconTextGap != this.iconTextGap)
if (iconTextGap != newGap)
{
int oldIconTextGap = this.iconTextGap;
this.iconTextGap = iconTextGap;
firePropertyChange(ICON_TEXT_GAP_CHANGED_PROPERTY, oldIconTextGap,
iconTextGap);
firePropertyChange(ICON_TEXT_GAP_CHANGED_PROPERTY, iconTextGap, newGap);
iconTextGap = newGap;
}
}
@ -632,11 +634,12 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
int h)
{
Icon currIcon = (isEnabled()) ? activeIcon : disabledIcon;
Icon currIcon = isEnabled() ? icon : disabledIcon;
//Is this the correct way to check for image equality?
// XXX: Is this the correct way to check for image equality?
if (currIcon != null && currIcon instanceof ImageIcon)
return (((ImageIcon) currIcon).getImage() == img);
return false;
}
@ -664,15 +667,14 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
{
if (c != labelFor)
{
Component oldLabelFor = labelFor;
firePropertyChange(LABEL_FOR_CHANGED_PROPERTY, labelFor, c);
labelFor = c;
firePropertyChange(LABEL_FOR_CHANGED_PROPERTY, oldLabelFor, labelFor);
}
}
/**
* This method overrides setFont so that we can call for a repaint
* after the font is changed.
* This method overrides setFont so that we can call for a repaint after the
* font is changed.
*
* @param f The font for this label.
*/

View File

@ -153,7 +153,7 @@ public class JLayeredPane extends JComponent implements Accessible
Map.Entry pair = (Map.Entry) i.next();
Integer layerNum = (Integer) pair.getKey ();
Integer layerSz = (Integer) pair.getValue ();
if (layerNum == layer)
if (layerNum.intValue() == layer.intValue())
{
ret[0] = ret[1] - layerSz.intValue ();
return ret;
@ -314,7 +314,7 @@ public class JLayeredPane extends JComponent implements Accessible
int bot = range[1];
if (position == -1)
position = (bot - top) - 1;
int targ = top + position;
int targ = Math.min(top + position, bot-1);
int curr = -1;
Component[] comps = getComponents();
@ -539,7 +539,8 @@ public class JLayeredPane extends JComponent implements Accessible
int layer,
int position)
{
componentToLayer.put (c, getObjectForLayer (layer));
remove(c);
add(c, getObjectForLayer (layer));
setPosition(c, position);
revalidate();
repaint();

View File

@ -588,6 +588,28 @@ public class JList extends JComponent implements Accessible, Scrollable
return getUI().locationToIndex(this, r.getLocation());
}
/**
* Returns index of the cell to which specified location is closest to
* @param location for which to look for in the list
*
* @return index of the cell to which specified location is closest to.
*/
public int locationToIndex(Point location) {
return getUI().locationToIndex(this, location);
}
/**
* Returns location of the cell located at the specified index in the list.
* @param index of the cell for which location will be determined
*
* @return location of the cell located at the specified index in the list.
*/
public Point indexToLocation(int index){
//FIXME: Need to implement.
return null;
}
/**
* Returns the list index of the lower right or lower left corner of the
* {@link #visibleRect} property, depending on the {@link

View File

@ -313,7 +313,8 @@ public class JMenuItem extends AbstractButton implements Accessible,
MenuSelectionManager manager)
{
// Fire MenuDragMouseEvents if mouse is being dragged.
boolean dragged = (event.getModifiers() & InputEvent.BUTTON1_MASK) != 0;
boolean dragged
= (event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0;
if (dragged)
processMenuDragMouseEvent(createMenuDragMouseEvent(event, path, manager));
@ -335,11 +336,11 @@ public class JMenuItem extends AbstractButton implements Accessible,
setArmed(false);
break;
case MouseEvent.MOUSE_PRESSED:
if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
{
model.setArmed(true);
model.setPressed(true);
}
if ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)
{
model.setArmed(true);
model.setPressed(true);
}
break;
case MouseEvent.MOUSE_RELEASED:
break;
@ -588,6 +589,18 @@ public class JMenuItem extends AbstractButton implements Accessible,
listenerList.remove(MenuDragMouseListener.class, listener);
}
/**
* Returns all added MenuDragMouseListener objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public MenuDragMouseListener[] getMenuDragMouseListeners()
{
return (MenuDragMouseListener[]) listenerList.getListeners(MenuDragMouseListener.class);
}
/**
* Adds an MenuKeyListener to this menu item. This listener will be
* invoked when MenuKeyEvents will be fired by this menu item.
@ -609,6 +622,18 @@ public class JMenuItem extends AbstractButton implements Accessible,
listenerList.remove(MenuKeyListener.class, listener);
}
/**
* Returns all added MenuKeyListener objects.
*
* @return an array of listeners
*
* @since 1.4
*/
public MenuKeyListener[] getMenuKeyListeners()
{
return (MenuKeyListener[]) listenerList.getListeners(MenuKeyListener.class);
}
/**
* A string that describes this JMenuItem. Normally only used
* for debugging.

View File

@ -144,6 +144,9 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
/* Location of the popup */
private Point popupLocation;
/* Field indicating if popup menu is visible or not */
private boolean visible = false;
/* Bound Property indicating visibility of the popup menu*/
public static final String VISIBLE_CHANGED_PROPERTY = "visible";
@ -564,7 +567,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
public boolean isVisible()
{
return super.isVisible();
return visible;
}
/**
@ -577,7 +580,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
public void setVisible(boolean visible)
{
boolean old = isVisible();
super.setVisible(visible);
this.visible = visible;
if (old != isVisible())
{
firePropertyChange(VISIBLE_CHANGED_PROPERTY, old, (boolean) isVisible());
@ -615,7 +618,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
.getLayeredPane();
Point p = new Point(popupLocation.x, popupLocation.y);
SwingUtilities.convertPointFromScreen(p, layeredPane);
popup.show(p.x, p.y, size.width, size.height);
popup.show(p.x, p.y, size.width, size.height);
}
else
{

View File

@ -44,33 +44,47 @@ public class JRadioButton extends JToggleButton
{
private static final long serialVersionUID = 7751949583255506856L;
public JRadioButton()
{
this(null, null);
}
public JRadioButton(Action a)
{
this();
setAction(a);
}
public JRadioButton()
{
this(null, null);
}
public JRadioButton(Action a)
{
this();
setAction(a);
}
public JRadioButton(Icon icon)
{
this(null, icon);
}
public JRadioButton(Icon icon)
{
this(null, icon);
}
public JRadioButton(String text)
{
this(text, null);
}
public JRadioButton(String text, Icon icon)
{
super(text, icon);
borderPainted = false;
contentAreaFilled = false;
}
public JRadioButton(Icon icon, boolean selected)
{
this(null, icon, selected);
}
public JRadioButton(String text)
{
this(text, null);
}
public JRadioButton(String text, boolean selected)
{
this(text, null, selected);
}
public JRadioButton(String text, Icon icon)
{
super(text, icon);
borderPainted = false;
contentAreaFilled = false;
}
public JRadioButton(String text, Icon icon, boolean selected)
{
}
public AccessibleContext getAccessibleContext()
{

View File

@ -41,7 +41,6 @@ package javax.swing;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Point;
@ -510,7 +509,8 @@ public class JScrollPane
else
{
// otherwise we got a change update from either the VSB or
// HSB model, and we need to update the viewport position to
// HSB model, and we need to update the viewport positions of
// both the main viewport and any row or column headers to
// match.
int xpos = 0;
@ -527,6 +527,20 @@ public class JScrollPane
if (vp != null
&& vp.getViewPosition() != pt)
vp.setViewPosition(pt);
pt.x = 0;
if (rowHeader != null
&& rowHeader.getViewPosition() != pt)
rowHeader.setViewPosition(pt);
pt.x = xpos;
pt.y = 0;
if (columnHeader != null
&& columnHeader.getViewPosition() != pt)
columnHeader.setViewPosition(pt);
}
}
};

View File

@ -44,7 +44,6 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.io.Serializable;
import java.util.Vector;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@ -79,12 +78,11 @@ public class JTabbedPane extends JComponent implements Serializable,
protected class AccessibleJTabbedPane extends JComponent.AccessibleJComponent
implements AccessibleSelection, ChangeListener
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 7610530885966830483L;
/**
* Creates a new AccessibleJTabbedPane object.
*
* @param c DOCUMENT ME!
*/
public AccessibleJTabbedPane()
{
@ -226,12 +224,16 @@ public class JTabbedPane extends JComponent implements Serializable,
*/
protected class ModelListener implements ChangeListener, Serializable
{
/** DOCUMENT ME! */
private static final long serialVersionUID = 497359819958114132L;
/**
* Creates a new ModelListener object.
*/
protected ModelListener()
{
}
/**
* This method is called whenever the model is changed.
*
@ -387,7 +389,8 @@ public class JTabbedPane extends JComponent implements Serializable,
return title;
}
private static final long serialVersionUID = 1614381073220130939L;
/** DOCUMENT ME! */
private static final long serialVersionUID = 1614381073220130939L;
/**
* This method sets the title of the tab.
@ -398,7 +401,7 @@ public class JTabbedPane extends JComponent implements Serializable,
{
title = text;
if (title != null && title.length() <= underlinedChar)
setDisplayedMnemonicIndex(title.length() - 1);
setDisplayedMnemonicIndex(title.length() - 1);
}
/**
@ -817,16 +820,21 @@ public class JTabbedPane extends JComponent implements Serializable,
* This method checks the index.
*
* @param index The index to check.
* @param start DOCUMENT ME!
* @param end DOCUMENT ME!
*
* @throws IndexOutOfBoundsException DOCUMENT ME!
*/
private void checkIndex(int index, int start, int end)
{
if (index < start || index >= end)
throw new IndexOutOfBoundsException("Index < " + start + " || Index >= " + end);
throw new IndexOutOfBoundsException("Index < " + start + " || Index >= "
+ end);
}
/**
* This method sets the selected index. This method
* will hide the old component and show the new component.
* This method sets the selected index. This method will hide the old
* component and show the new component.
*
* @param index The index to set it at.
*/
@ -839,7 +847,7 @@ public class JTabbedPane extends JComponent implements Serializable,
getSelectedComponent().hide();
if (index != -1 && getComponentAt(index) != null)
getComponentAt(index).show();
model.setSelectedIndex(index);
model.setSelectedIndex(index);
}
}
@ -867,8 +875,8 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method inserts tabs into JTabbedPane. This includes
* adding the component to the JTabbedPane and hiding it.
* This method inserts tabs into JTabbedPane. This includes adding the
* component to the JTabbedPane and hiding it.
*
* @param title The title of the tab.
* @param icon The tab's icon.
@ -885,11 +893,11 @@ 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.
if (component != null)
{
component.hide();
super.add(component);
}
{
component.hide();
super.add(component);
}
if (getSelectedIndex() == -1)
setSelectedIndex(0);
@ -934,15 +942,14 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method adds a tab to the JTabbedPane.
* The title of the tab is the Component's name.
* If the Component is an instance of UIResource, it doesn't
* add the tab and instead add the component directly to the
* This method adds a tab to the JTabbedPane. The title of the tab is the
* Component's name. If the Component is an instance of UIResource, it
* doesn't add the tab and instead add the component directly to the
* JTabbedPane.
*
* @param component The associated component.
*
* @return The Component that was added.
* @return The Component that was added.
*/
public Component add(Component component)
{
@ -954,17 +961,16 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method adds a tab to the JTabbedPane.
* If the Component is an instance of UIResource, it doesn't
* add the tab and instead add the component directly to the
* JTabbedPane.
* This method adds a tab to the JTabbedPane. If the Component is an
* instance of UIResource, it doesn't add the tab and instead add the
* component directly to the JTabbedPane.
*
* @param title The title of the tab.
* @param component The associated component.
*
* @return The Component that was added.
*/
public Component add(String title, Component component)
public Component add(String title, Component component)
{
if (component instanceof UIResource)
super.add(component);
@ -974,10 +980,9 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method adds a tab to the JTabbedPane.
* If the Component is an instance of UIResource, it doesn't
* add the tab and instead add the component directly to the
* JTabbedPane.
* This method adds a tab to the JTabbedPane. If the Component is an
* instance of UIResource, it doesn't add the tab and instead add the
* component directly to the JTabbedPane.
*
* @param component The associated component.
* @param index The index to insert the tab at.
@ -994,12 +999,11 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method adds a tab to the JTabbedPane.
* If the Component is an instance of UIResource, it doesn't
* add the tab and instead add the component directly to the
* JTabbedPane. If the constraints object is an icon, it
* will be used as the tab's icon. If the constraints object
* is a string, we will use it as the title.
* This method adds a tab to the JTabbedPane. If the Component is an
* instance of UIResource, it doesn't add the tab and instead add the
* component directly to the JTabbedPane. If the constraints object is an
* icon, it will be used as the tab's icon. If the constraints object is a
* string, we will use it as the title.
*
* @param component The associated component.
* @param constraints The constraints object.
@ -1010,12 +1014,11 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method adds a tab to the JTabbedPane.
* If the Component is an instance of UIResource, it doesn't
* add the tab and instead add the component directly to the
* JTabbedPane. If the constraints object is an icon, it
* will be used as the tab's icon. If the constraints object
* is a string, we will use it as the title.
* This method adds a tab to the JTabbedPane. If the Component is an
* instance of UIResource, it doesn't add the tab and instead add the
* component directly to the JTabbedPane. If the constraints object is an
* icon, it will be used as the tab's icon. If the constraints object is a
* string, we will use it as the title.
*
* @param component The associated component.
* @param constraints The constraints object.
@ -1037,27 +1040,25 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* The tab and it's associated component are removed. After
* the component has been removed from the JTabbedPane, it's
* set visible to ensure that it can be seen.
* The tab and it's associated component are removed. After the component
* has been removed from the JTabbedPane, it's set visible to ensure that
* it can be seen.
*
* @param index The index of the tab to remove.
*
* @throws IndexOutOfBoundsException If the index is not in range.
*/
public void removeTabAt(int index)
{
checkIndex(index, 0, tabs.size());
Component c = getComponentAt(index);
super.remove(c);
super.remove(index);
c.show();
tabs.remove(index);
}
/**
* This method removes the component from the JTabbedPane. After
* the component has been removed from the JTabbedPane, it's
* set visible to ensure that it can be seen.
* This method removes the component from the JTabbedPane. After the
* component has been removed from the JTabbedPane, it's set visible to
* ensure that it can be seen.
*
* @param component The Component to remove.
*/
@ -1071,8 +1072,8 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method removes the tab and component from the JTabbedPane.
* It simply calls removeTabAt(int index).
* This method removes the tab and component from the JTabbedPane. It simply
* calls removeTabAt(int index).
*
* @param index The index of the tab to remove.
*/
@ -1082,8 +1083,8 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method removes all tabs and associated components
* from the JTabbedPane.
* This method removes all tabs and associated components from the
* JTabbedPane.
*/
public void removeAll()
{
@ -1102,8 +1103,7 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method returns the number of runs used
* to paint the JTabbedPane.
* This method returns the number of runs used to paint the JTabbedPane.
*
* @return The number of runs.
*/
@ -1204,8 +1204,8 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method returns whether this tab is enabled.
* Disabled tabs cannot be selected.
* This method returns whether this tab is enabled. Disabled tabs cannot be
* selected.
*
* @param index The index of the tab.
*
@ -1244,8 +1244,7 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method returns the bounds of the tab given
* the index.
* This method returns the bounds of the tab given the index.
*
* @param index The index of the tab.
*
@ -1441,9 +1440,9 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method returns a tab index given an (x,y) location. The origin
* of the (x,y) pair will be the JTabbedPane's top left position. The
* tab returned will be the one that contains the point. This method is
* This method returns a tab index given an (x,y) location. The origin of
* the (x,y) pair will be the JTabbedPane's top left position. The tab
* returned will be the one that contains the point. This method is
* delegated to the UI.
*
* @param x The x coordinate of the point.
@ -1470,8 +1469,8 @@ public class JTabbedPane extends JComponent implements Serializable,
}
/**
* This method returns a string representation of this JTabbedPane. It
* is mainly used for debugging purposes.
* This method returns a string representation of this JTabbedPane. It is
* mainly used for debugging purposes.
*
* @return A string representation of this JTabbedPane.
*/

File diff suppressed because it is too large Load Diff

View File

@ -137,9 +137,15 @@ public class JTextField extends JTextComponent
*/
public JTextField(Document doc, String text, int columns)
{
if (columns < 0)
throw new IllegalArgumentException();
this.columns = columns;
setDocument(doc == null ? createDefaultModel() : doc);
setText(text);
setColumns(columns);
if (text != null)
setText(text);
}
/**

View File

@ -1,4 +1,4 @@
/* JToolTip.java --
/* JToolTip.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,25 +35,160 @@ 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.AWTEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
import javax.swing.plaf.ToolTipUI;
/**
* This class is used to display ToolTips. ToolTips are small floating windows
* that display text when the mouse comes to rest over a Component. ToolTips
* are set for JComponents using JComponent.setToolTipText(String).
*/
public class JToolTip extends JComponent implements Accessible
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -1138929898906751643L;
/**
* DOCUMENT ME!
*/
protected class AccessibleJToolTip extends AccessibleJComponent
{
/**
* Creates a new AccessibleJToolTip object.
*/
protected AccessibleJToolTip()
{
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public String getAccessibleDescription()
{
return null;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleRole getAccessibleRole()
{
return null;
}
}
/** The text to display in the JToolTip. */
String text;
/** The JComponent this JToolTip is used for. */
JComponent component;
/**
* Creates a new JToolTip object.
*/
public JToolTip()
{
disableEvents(AWTEvent.MOUSE_EVENT_MASK);
updateUI();
}
public void setTipText(String newText)
/**
* This method returns the text this JToolTip displays.
*
* @return The text that this JToolTip displays.
*/
public String getTipText()
{
this.text = newText;
return text;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
return null;
}
/**
* This method returns the JComponent this JToolTip displays for.
*
* @return The JComponent this JToolTip displays for.
*/
public JComponent getComponent()
{
return component;
}
/**
* This method returns the UI responsible for displaying this JToolTip.
*
* @return The UI responsible for displaying this JToolTip.
*/
public ToolTipUI getUI()
{
return (ToolTipUI) ui;
}
/**
* This method returns the String identifier for the UI class.
*
* @return The String identifier for the UI class.
*/
public String getUIClassID()
{
return "ToolTipUI";
}
/**
* This method returns a debugging String describing the JToolTip.
*
* @return A debugging String describing the JToolTip.
*/
protected String paramString()
{
return "JToolTip";
}
/**
* This method sets the JComponent that the JToolTip displays for.
*
* @param c The JComponent that the JToolTip displays for.
*/
public void setComponent(JComponent c)
{
component = c;
}
/**
* This method sets the text that the JToolTip displays.
*
* @param tipText The text that the JToolTip displays.
*/
public void setTipText(String tipText)
{
text = tipText;
}
/**
* This method resets the UI used to the Look and Feel default.
*/
public void updateUI()
{
setUI((ToolTipUI) UIManager.getUI(this));
revalidate();
repaint();
}
}

View File

@ -249,8 +249,13 @@ public class JViewport extends JComponent
public void setView(Component v)
{
add(v);
fireStateChanged();
while (getComponentCount() > 0)
remove(0);
if (v != null)
{
add(v);
fireStateChanged();
}
}
public void revalidate()

View File

@ -37,235 +37,69 @@ exception statement from your version. */
package javax.swing;
import java.awt.AWTKeyStroke;
import java.awt.event.KeyEvent;
import java.io.Serializable;
/**
* KeyStroke
* @author Andrew Selkirk
* @version 1.0
*/
public class KeyStroke implements Serializable
public class KeyStroke
extends AWTKeyStroke
implements Serializable
{
static final long serialVersionUID = -9060180771037902530L;
private KeyStroke() {
}
protected KeyStroke(char keyChar, int keyCode, int modifiers,
boolean onKeyRelease)
{
super(keyChar, keyCode, modifiers, onKeyRelease);
}
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
static
{
AWTKeyStroke.registerSubclass(KeyStroke.class);
}
/**
* keyChar
*/
private char keyChar = 0;
public static KeyStroke getKeyStroke(char keyChar)
{
return (KeyStroke) getAWTKeyStroke(keyChar);
}
/**
* keyCode
*/
private int keyCode = 0;
/**
* @deprecated Use {@link #getKeyStroke(char)}
*
* This method, unlike all the other factory methods on this object,
* returns a non-cached, non-shared object. New code should not use it.
*/
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease)
{
return new KeyStroke(keyChar, KeyEvent.VK_UNDEFINED, 0, onKeyRelease);
}
/**
* modifiers
*/
private int modifiers = 0;
public static KeyStroke getKeyStroke(Character keyChar, int modifiers)
{
return (KeyStroke) getAWTKeyStroke(keyChar, modifiers);
}
/**
* onKeyRelease
*/
private boolean onKeyRelease = false;
public static KeyStroke getKeyStroke(int keyCode, int modifiers,
boolean onKeyRelease)
{
return (KeyStroke) getAWTKeyStroke(keyCode, modifiers, onKeyRelease);
}
public static KeyStroke getKeyStroke(int keyCode, int modifiers)
{
return (KeyStroke) getAWTKeyStroke(keyCode, modifiers);
}
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
public static KeyStroke getKeyStroke(String str)
{
return (KeyStroke) getAWTKeyStroke(str);
}
/**
* Constructor KeyStroke
*/
private KeyStroke() {
} // KeyStroke()
public static KeyStroke getKeyStrokeForEvent(KeyEvent event)
{
return (KeyStroke) getAWTKeyStrokeForEvent(event);
}
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* hashCode
* @returns int
*/
public int hashCode() {
return 0; // TODO
} // hashCode()
/**
* equals
* @param object TODO
* @returns boolean
*/
public boolean equals(Object object) {
// Variables
KeyStroke key;
if (object instanceof KeyStroke) {
key = (KeyStroke) object;
if (key.keyChar == keyChar &&
key.keyCode == keyCode &&
key.modifiers == modifiers &&
key.onKeyRelease == onKeyRelease) {
return true;
} // if
} // if
return false;
} // equals()
/**
* toString
* @returns String
*/
public String toString() {
return null; // TODO
} // toString()
/**
* getKeyStroke
* @param keyChar TODO
* @returns KeyStroke
*/
public static KeyStroke getKeyStroke(char keyChar) {
// Variables
KeyStroke key;
key = new KeyStroke();
key.keyChar = keyChar;
return key;
} // getKeyStroke()
/**
* getKeyStroke - deprecated
* @param keyChar TODO
* @param onKeyRelease TODO
* @returns KeyStroke
* @deprecated Use getKeyStroke(char)
*/
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) {
KeyStroke key = getKeyStroke(keyChar);
key.onKeyRelease = onKeyRelease;
return key;
} // getKeyStroke()
/**
* getKeyStroke
* @param keyChar TODO
* @param modifiers TODO
* @returns KeyStroke
*/
public static KeyStroke getKeyStroke(Character keyChar, int modifiers) {
KeyStroke key = getKeyStroke(keyChar.charValue());
key.modifiers = modifiers;
return key;
} // getKeyStroke()
/**
* getKeyStroke
* @param keyCode TODO
* @param modifiers TODO
* @param onKeyRelease TODO
* @returns KeyStroke
*/
public static KeyStroke getKeyStroke(int keyCode, int modifiers,
boolean onKeyRelease) {
// Variables
KeyStroke key;
key = new KeyStroke();
key.keyCode = keyCode;
key.modifiers = modifiers;
key.onKeyRelease = onKeyRelease;
return key;
} // getKeyStroke()
/**
* getKeyStroke
* @param keyCode TODO
* @param modifiers TODO
* @returns KeyStroke
*/
public static KeyStroke getKeyStroke(int keyCode, int modifiers) {
return getKeyStroke(keyCode, modifiers, false);
} // getKeyStroke()
/**
* getKeyStroke
* @param string TODO
* @returns KeyStroke
*/
public static KeyStroke getKeyStroke(String string) {
return null; // TODO
} // getKeyStroke()
/**
* getKeyStrokeForEvent
* @param event TODO
* @returns KeyStroke
*/
public static KeyStroke getKeyStrokeForEvent(KeyEvent event) {
// Variables
int eventID;
int eventMod;
// Get Event ID
eventID = event.getID();
eventMod = event.getModifiers();
// Check for KEY_TYPED event
if (eventID == KeyEvent.KEY_TYPED) {
return getKeyStroke(event.getKeyChar(), eventMod);
// KEY_PRESSED or KEY_RELEASED event
} else {
return getKeyStroke(event.getKeyCode(), eventMod);
} // if
} // getKeyStrokeForEvent()
/**
* getKeyChar
* @returns char
*/
public char getKeyChar() {
return keyChar;
} // getKeyChar()
/**
* getKeyCode
* @returns int
*/
public int getKeyCode() {
return keyCode;
} // getKeyCode()
/**
* getModifiers
* @returns int
*/
public int getModifiers() {
return modifiers; // TODO
} // getModifiers()
/**
* isOnKeyRelease
* @returns boolean
*/
public boolean isOnKeyRelease() {
return onKeyRelease;
} // isOnKeyRelease()
} // KeyStroke
}

View File

@ -38,40 +38,46 @@ exception statement from your version. */
package javax.swing;
/**
* MutableComboBoxModel
* @author Andrew Selkirk
* @version 1.0
* MutableComboBoxModel is interface for data model that keeps track of the
* components data and provides methods to insert and remove elements from
* it. The Classes implementing this interface should fire appropriate
* events indicating the undergoing change in the data model.
*
* @author Andrew Selkirk
* @author Olga Rodimina
* @version 1.0
*/
public interface MutableComboBoxModel extends ComboBoxModel {
public interface MutableComboBoxModel extends ComboBoxModel
{
/**
* This method adds given object to its data model.
*
* @param object element to add to the data model.
*/
void addElement(Object object);
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* addElement
* @param object TODO
*/
void addElement(Object object);
/**
* removeElementAt
* @param index TODO
*/
void removeElementAt(int index);
/**
* insertElementAt
* @param object TODO
* @param index TODO
*/
void insertElementAt(Object object, int index);
/**
* removeElement
* @param object TODO
*/
void removeElement(Object object);
/**
* This method removes elements located at the given index in the data
* model.
*
* @param index index specifying location of the element to remove.
*/
void removeElementAt(int index);
/**
* This method inserts givent element to the data model, at the specified
* index.
*
* @param object element to insert
* @param index index specifying the position in the data model where the
* given element should be inserted.
*/
void insertElementAt(Object object, int index);
/**
* This method removes given element from the data model
*
* @param element to remove.
*/
void removeElement(Object object);
} // MutableComboBoxModel

View File

@ -431,6 +431,9 @@ public class RepaintManager
if (damaged.width == 0 || damaged.height == 0)
continue;
JRootPane root = comp.getRootPane();
// If the component has no root, no repainting will occur.
if (root == null)
continue;
Rectangle rootDamage = SwingUtilities.convertRectangle(comp, damaged, root);
if (! roots.containsKey(root))
{
@ -450,7 +453,7 @@ public class RepaintManager
Map.Entry ent = (Map.Entry) i.next();
JRootPane root = (JRootPane) ent.getKey();
Rectangle rect = (Rectangle) ent.getValue();
root.paintImmediately(rect);
root.paintImmediately(rect);
}
}

View File

@ -82,6 +82,8 @@ public class ScrollPaneLayout
public void syncWithScrollPane(JScrollPane scrollPane) {
viewport = scrollPane.getViewport();
rowHead = scrollPane.getRowHeader();
colHead = scrollPane.getColumnHeader();
vsb = scrollPane.getVerticalScrollBar();
hsb = scrollPane.getHorizontalScrollBar();
vsbPolicy = scrollPane.getVerticalScrollBarPolicy();
@ -389,12 +391,12 @@ public class ScrollPaneLayout
y4 = scrollPaneBounds.y + scrollPaneBounds.height;
if (colHead != null)
y2 = colHead.getPreferredSize().height;
y2 = y1 + colHead.getPreferredSize().height;
else
y2 = y1;
if (rowHead != null)
x2 = rowHead.getPreferredSize().width;
x2 = x1 + rowHead.getPreferredSize().width;
else
x2 = x1;

View File

@ -51,9 +51,13 @@ import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.InputMapUIResource;
/**
@ -441,7 +445,7 @@ public class SwingUtilities implements SwingConstants
destination);
return new MouseEvent(destination, sourceEvent.getID(),
sourceEvent.getWhen(), sourceEvent.getModifiers(),
sourceEvent.getWhen(), sourceEvent.getModifiersEx(),
newpt.x, newpt.y, sourceEvent.getClickCount(),
sourceEvent.isPopupTrigger(), sourceEvent.getButton());
}
@ -863,7 +867,7 @@ public class SwingUtilities implements SwingConstants
*/
public static boolean isLeftMouseButton(MouseEvent event)
{
return ((event.getModifiers() & InputEvent.BUTTON1_DOWN_MASK)
return ((event.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK)
== InputEvent.BUTTON1_DOWN_MASK);
}
@ -876,7 +880,7 @@ public class SwingUtilities implements SwingConstants
*/
public static boolean isMiddleMouseButton(MouseEvent event)
{
return ((event.getModifiers() & InputEvent.BUTTON2_DOWN_MASK)
return ((event.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK)
== InputEvent.BUTTON2_DOWN_MASK);
}
@ -889,7 +893,7 @@ public class SwingUtilities implements SwingConstants
*/
public static boolean isRightMouseButton(MouseEvent event)
{
return ((event.getModifiers() & InputEvent.BUTTON3_DOWN_MASK)
return ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK)
== InputEvent.BUTTON3_DOWN_MASK);
}
@ -911,4 +915,103 @@ public class SwingUtilities implements SwingConstants
return true;
}
}
public static boolean notifyAction(Action action,
KeyStroke ks,
KeyEvent event,
Object sender,
int modifiers)
{
if (action != null && action.isEnabled())
{
String name = (String) action.getValue(Action.ACTION_COMMAND_KEY);
if (name == null
&& event.getKeyChar() != KeyEvent.CHAR_UNDEFINED)
name = new String(new char[] {event.getKeyChar()});
action.actionPerformed(new ActionEvent(sender,
ActionEvent.ACTION_PERFORMED,
name, modifiers));
return true;
}
return false;
}
/**
* <p>Change the shared, UI-managed {@link ActionMap} for a given
* component. ActionMaps are arranged in a hierarchy, in order to
* encourage sharing of common actions between components. The hierarchy
* unfortunately places UI-managed ActionMaps at the <em>end</em> of the
* parent-pointer chain, as illustrated:</p>
*
* <pre>
* [{@link javax.swing.JComponent#getActionMap()}]
* --&gt; [{@link javax.swing.ActionMap}]
* parent --&gt; [{@link javax.swing.text.KeymapActionMap}]
* parent --&gt; [{@link javax.swing.plaf.ActionMapUIResource}]
* </pre>
*
* <p>Our goal with this method is to replace the first ActionMap along
* this chain which is an instance of {@link ActionMapUIResource}, since
* these are the ActionMaps which are supposed to be shared between
* components.</p>
*
* <p>If the provided ActionMap is <code>null</code>, we interpret the
* call as a request to remove the UI-managed ActionMap from the
* component's ActionMap parent chain.</p>
*/
public static void replaceUIActionMap(JComponent component,
ActionMap uiActionMap)
{
ActionMap child = component.getActionMap();
if (child == null)
component.setActionMap(uiActionMap);
else
{
while(child.getParent() != null
&& !(child.getParent() instanceof ActionMapUIResource))
child = child.getParent();
if (child != null)
child.setParent(uiActionMap);
}
}
/**
* <p>Change the shared, UI-managed {@link InputMap} for a given
* component. InputMaps are arranged in a hierarchy, in order to
* encourage sharing of common input mappings between components. The
* hierarchy unfortunately places UI-managed InputMaps at the
* <em>end</em> of the parent-pointer chain, as illustrated:</p>
*
* <pre>
* [{@link javax.swing.JComponent#getInputMap()}]
* --&gt; [{@link javax.swing.InputMap}]
* parent --&gt; [{@link javax.swing.text.KeymapWrapper}]
* parent --&gt; [{@link javax.swing.plaf.InputMapUIResource}]
* </pre>
*
* <p>Our goal with this method is to replace the first InputMap along
* this chain which is an instance of {@link InputMapUIResource}, since
* these are the InputMaps which are supposed to be shared between
* components.</p>
*
* <p>If the provided InputMap is <code>null</code>, we interpret the
* call as a request to remove the UI-managed InputMap from the
* component's InputMap parent chain.</p>
*/
public static void replaceUIInputMap(JComponent component,
int condition,
InputMap uiInputMap)
{
InputMap child = component.getInputMap(condition);
if (child == null)
component.setInputMap(condition, uiInputMap);
else
{
while(child.getParent() != null
&& !(child.getParent() instanceof InputMapUIResource))
child = child.getParent();
if (child != null)
child.setParent(uiInputMap);
}
}
}

View File

@ -1,4 +1,4 @@
/* Timer.java --
/* Timer.java --
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -35,22 +35,26 @@ 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.io.Serializable;
import java.util.EventListener;
import javax.swing.event.EventListenerList;
/**
* DOCUMENT ME!
*/
public class Timer implements Serializable
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -1116180831621385484L;
/** DOCUMENT ME! */
protected EventListenerList listenerList = new EventListenerList();
// 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
@ -58,79 +62,127 @@ public class Timer implements Serializable
// ActionEvents as have been queued, unless the timer is set to
// coalescing mode, in which case it will fire only one ActionEvent.
/** DOCUMENT ME! */
private long queue;
/** DOCUMENT ME! */
private Object queueLock = new Object();
/** DOCUMENT ME! */
private Waker waker;
/**
* DOCUMENT ME!
*/
private void queueEvent()
{
synchronized (queueLock)
{
queue++;
if (queue == 1)
SwingUtilities.invokeLater(new Runnable() { public void run() { drainEvents(); } });
queue++;
if (queue == 1)
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
drainEvents();
}
});
}
}
/**
* DOCUMENT ME!
*/
private void drainEvents()
{
synchronized (queueLock)
{
if (isCoalesce())
{
if (queue > 0)
fireActionPerformed();
}
else
{
while(queue > 0)
{
fireActionPerformed();
queue--;
}
}
queue = 0;
if (isCoalesce())
{
if (queue > 0)
fireActionPerformed();
}
else
{
while (queue > 0)
{
fireActionPerformed();
queue--;
}
}
queue = 0;
}
}
static boolean logTimers;
/** DOCUMENT ME! */
boolean coalesce = true;
/** DOCUMENT ME! */
boolean repeats = true;
/** DOCUMENT ME! */
boolean running;
/** DOCUMENT ME! */
int ticks;
/** DOCUMENT ME! */
int delay;
/** DOCUMENT ME! */
int initialDelay;
private class Waker
extends Thread
/**
* DOCUMENT ME!
*/
private class Waker extends Thread
{
/**
* DOCUMENT ME!
*/
public void run()
{
running = true;
try
try
{
sleep(initialDelay);
sleep(initialDelay);
while (running)
{
sleep(delay);
queueEvent();
if (logTimers)
System.out.println("javax.swing.Timer -> clocktick");
if (! repeats)
break;
}
running = false;
}
catch (Exception e)
while (running)
{
try
{
sleep(delay);
}
catch (InterruptedException e)
{
return;
}
queueEvent();
if (logTimers)
System.out.println("javax.swing.Timer -> clocktick");
if (! repeats)
break;
}
running = false;
}
catch (Exception e)
{
System.out.println("swing.Timer::" + e);
// System.out.println("swing.Timer::" + e);
}
}
}
/**
* Creates a new Timer object.
*
* @param d DOCUMENT ME!
* @param listener DOCUMENT ME!
*/
public Timer(int d, ActionListener listener)
{
delay = d;
@ -139,123 +191,214 @@ public class Timer implements Serializable
addActionListener(listener);
}
/**
* DOCUMENT ME!
*
* @param c DOCUMENT ME!
*/
public void setCoalesce(boolean c)
{
coalesce = c;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isCoalesce()
{
return coalesce;
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void addActionListener(ActionListener listener)
{
listenerList.add (ActionListener.class, listener);
listenerList.add(ActionListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listener DOCUMENT ME!
*/
public void removeActionListener(ActionListener listener)
{
listenerList.remove (ActionListener.class, listener);
listenerList.remove(ActionListener.class, listener);
}
/**
* DOCUMENT ME!
*
* @param listenerType DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @since 1.3
*/
public EventListener[] getListeners (Class listenerType)
public EventListener[] getListeners(Class listenerType)
{
return listenerList.getListeners (listenerType);
return listenerList.getListeners(listenerType);
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @since 1.4
*/
public ActionListener[] getActionListeners ()
public ActionListener[] getActionListeners()
{
return (ActionListener[]) listenerList.getListeners (ActionListener.class);
return (ActionListener[]) listenerList.getListeners(ActionListener.class);
}
protected void fireActionPerformed (ActionEvent event)
/**
* DOCUMENT ME!
*
* @param event DOCUMENT ME!
*/
protected void fireActionPerformed(ActionEvent event)
{
ActionListener[] listeners = getActionListeners();
for (int i = 0; i < listeners.length; i++)
{
listeners [i].actionPerformed (event);
}
listeners[i].actionPerformed(event);
}
void fireActionPerformed ()
/**
* DOCUMENT ME!
*/
void fireActionPerformed()
{
fireActionPerformed (new ActionEvent (this, ticks++, "Timer"));
fireActionPerformed(new ActionEvent(this, ticks++, "Timer"));
}
/**
* DOCUMENT ME!
*
* @param lt DOCUMENT ME!
*/
public static void setLogTimers(boolean lt)
{
logTimers = lt;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static boolean getLogTimers()
{
return logTimers;
}
/**
* DOCUMENT ME!
*
* @param d DOCUMENT ME!
*/
public void setDelay(int d)
{
delay = d;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getDelay()
{
return delay;
}
/**
* DOCUMENT ME!
*
* @param i DOCUMENT ME!
*/
public void setInitialDelay(int i)
{
initialDelay = i;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getInitialDelay()
{
return initialDelay;
}
/**
* DOCUMENT ME!
*
* @param r DOCUMENT ME!
*/
public void setRepeats(boolean r)
{
repeats = r;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isRepeats()
{
return repeats;
}
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public boolean isRunning()
{
return running;
}
/**
* DOCUMENT ME!
*/
public void start()
{
if (isRunning())
{
System.err.println("attempt to start a running timer");
return;
}
new Waker().start();
return;
waker = new Waker();
waker.start();
}
/**
* DOCUMENT ME!
*/
public void restart()
{
synchronized (queueLock)
{
queue = 0;
}
stop();
start();
}
/**
* DOCUMENT ME!
*/
public void stop()
{
running = false;
if (waker != null)
waker.interrupt();
synchronized (queueLock)
{
queue = 0;
}
}
}

View File

@ -37,315 +37,608 @@ exception statement from your version. */
package javax.swing;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Panel;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.JComponent;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
/**
* ToolTipManager
*
* @author Andrew Selkirk
* This class is responsible for the registration of JToolTips to Components
* and for displaying them when appropriate.
*/
public class ToolTipManager extends MouseAdapter
implements MouseMotionListener
public class ToolTipManager extends MouseAdapter implements MouseMotionListener
{
/**
* stillInsideTimerAction
*/
protected class stillInsideTimerAction
implements ActionListener
/**
* This ActionListener is associated with the Timer that listens to whether
* the JToolTip can be hidden after four seconds.
*/
protected class stillInsideTimerAction implements ActionListener
{
/**
* Constructor stillInsideTimerAction
*/
/**
* This method creates a new stillInsideTimerAction object.
*/
protected stillInsideTimerAction()
{
// TODO
}
/**
* actionPerformed
* @param event TODO
*/
/**
* This method hides the JToolTip when the Timer has finished.
*
* @param event The ActionEvent.
*/
public void actionPerformed(ActionEvent event)
{
// TODO
hideTip();
}
}
/**
* outsideTimerAction
*/
protected class outsideTimerAction
implements ActionListener
/**
* This Actionlistener is associated with the Timer that listens to whether
* the mouse cursor has re-entered the JComponent in time for an immediate
* redisplay of the JToolTip.
*/
protected class outsideTimerAction implements ActionListener
{
/**
* Constructor outsideTimerAction
*/
/**
* This method creates a new outsideTimerAction object.
*/
protected outsideTimerAction()
{
// TODO
}
/**
* actionPerformed
* @param value0 TODO
*/
/**
* This method is called when the Timer that listens to whether the mouse
* cursor has re-entered the JComponent has run out.
*
* @param event The ActionEvent.
*/
public void actionPerformed(ActionEvent event)
{
// TODO
}
}
/**
* insideTimerAction
*/
protected class insideTimerAction
implements ActionListener
/**
* This ActionListener is associated with the Timer that listens to whether
* it is time for the JToolTip to be displayed after the mouse has entered
* the JComponent.
*/
protected class insideTimerAction implements ActionListener
{
/**
* Constructor insideTimerAction
*/
/**
* This method creates a new insideTimerAction object.
*/
protected insideTimerAction()
{
// TODO
}
/**
* actionPerformed
* @param event TODO
*/
/**
* This method displays the JToolTip when the Mouse has been still for the
* delay.
*
* @param event The ActionEvent.
*/
public void actionPerformed(ActionEvent event)
{
// TODO
showTip();
if (insideTimer != null)
insideTimer.start();
}
}
/**
* enterTimer
*/
Timer enterTimer;
/**
* The Timer that determines whether the Mouse has been still long enough
* for the JToolTip to be displayed.
*/
Timer enterTimer;
/**
* exitTimer
*/
Timer exitTimer;
/**
* The Timer that determines whether the Mouse has re-entered the JComponent
* quickly enough for the JToolTip to be displayed immediately.
*/
Timer exitTimer;
/**
* insideTimer
*/
Timer insideTimer;
/**
* The Timer that determines whether the JToolTip has been displayed long
* enough for it to be hidden.
*/
Timer insideTimer;
/**
* toolTipText
*/
String toolTipText;
/** A global enabled setting for the ToolTipManager. */
private transient boolean enabled = true;
/**
* mouseEvent
*/
MouseEvent mouseEvent;
/** lightWeightPopupEnabled */
protected boolean lightWeightPopupEnabled = true;
/**
* showImmediately
*/
boolean showImmediately;
/** heavyWeightPopupEnabled */
protected boolean heavyWeightPopupEnabled = false;
/**
* tip
*/
JToolTip tip;
/** The shared instance of the ToolTipManager. */
private static ToolTipManager shared;
/**
* enabled
*/
boolean enabled;
/** The current component the tooltip is being displayed for. */
private static Component currentComponent;
/**
* timerEnter
*/
private long timerEnter;
/** The current tooltip. */
private static JToolTip currentTip;
/**
* lightWeightPopupEnabled
*/
protected boolean lightWeightPopupEnabled;
/** The last known position of the mouse cursor. */
private static Point currentPoint;
/**
* heavyWeightPopupEnabled
*/
protected boolean heavyWeightPopupEnabled;
/**
* The panel that holds the tooltip when the tooltip is displayed fully
* inside the current container.
*/
private static Container containerPanel;
/**
* Constructor ToolTipManager
*/
/**
* The window used when the tooltip doesn't fit inside the current
* container.
*/
private static JWindow tooltipWindow;
/**
* Creates a new ToolTipManager and sets up the timers.
*/
ToolTipManager()
{
// TODO
enterTimer = new Timer(750, new insideTimerAction());
enterTimer.setRepeats(false);
insideTimer = new Timer(4000, new stillInsideTimerAction());
insideTimer.setRepeats(false);
exitTimer = new Timer(500, new outsideTimerAction());
exitTimer.setRepeats(false);
}
/**
* sharedInstance
* @return ToolTipManager
*/
/**
* This method returns the shared instance of ToolTipManager used by all
* JComponents.
*
* @return The shared instance of ToolTipManager.
*/
public static ToolTipManager sharedInstance()
{
return null; // TODO
if (shared == null)
shared = new ToolTipManager();
return shared;
}
/**
* setEnabled
* @param enabled TODO
*/
/**
* This method sets whether ToolTips are enabled or disabled for all
* JComponents.
*
* @param enabled Whether ToolTips are enabled or disabled for all
* JComponents.
*/
public void setEnabled(boolean enabled)
{
// TODO
if (! enabled)
{
enterTimer.stop();
exitTimer.stop();
insideTimer.stop();
}
this.enabled = enabled;
}
/**
* isEnabled
* @return boolean
*/
/**
* This method returns whether ToolTips are enabled.
*
* @return Whether ToolTips are enabled.
*/
public boolean isEnabled()
{
return false; // TODO
return enabled;
}
/**
* isLightWeightPopupEnabled
* @return boolean
*/
/**
* This method returns whether LightweightToolTips are enabled.
*
* @return Whether LighweightToolTips are enabled.
*/
public boolean isLightWeightPopupEnabled()
{
return false; // TODO
return lightWeightPopupEnabled;
}
/**
* setLightWeightPopupEnabled
* @param enabled TODO
*/
/**
* This method sets whether LightweightToolTips are enabled. If you mix
* Lightweight and Heavyweight components, you must set this to false to
* ensure that the ToolTips popup above all other components.
*
* @param enabled Whether LightweightToolTips will be enabled.
*/
public void setLightWeightPopupEnabled(boolean enabled)
{
// TODO
lightWeightPopupEnabled = enabled;
heavyWeightPopupEnabled = ! enabled;
}
/**
* getInitialDelay
* @return int
*/
/**
* This method returns the initial delay before the ToolTip is shown when
* the mouse enters a Component.
*
* @return The initial delay before the ToolTip is shown.
*/
public int getInitialDelay()
{
return 0; // TODO
return enterTimer.getDelay();
}
/**
* setInitialDelay
* @param delay TODO
*/
/**
* This method sets the initial delay before the ToolTip is shown when the
* mouse enters a Component.
*
* @param delay The initial delay before the ToolTip is shown.
*/
public void setInitialDelay(int delay)
{
// TODO
enterTimer.setDelay(delay);
}
/**
* getDismissDelay
* @return int
*/
/**
* This method returns the time the ToolTip will be shown before being
* hidden.
*
* @return The time the ToolTip will be shown before being hidden.
*/
public int getDismissDelay()
{
return 0; // TODO
return insideTimer.getDelay();
}
/**
* setDismissDelay
* @param delay TODO
*/
/**
* This method sets the time the ToolTip will be shown before being hidden.
*
* @param delay The time the ToolTip will be shown before being hidden.
*/
public void setDismissDelay(int delay)
{
// TODO
insideTimer.setDelay(delay);
}
/**
* getReshowDelay
* @return int
*/
/**
* This method returns the amount of delay where if the mouse re-enters a
* Component, the tooltip will be shown immediately.
*
* @return The reshow delay.
*/
public int getReshowDelay()
{
return 0; // TODO
return exitTimer.getDelay();
}
/**
* setReshowDelay
* @param delay TODO
*/
/**
* This method sets the amount of delay where if the mouse re-enters a
* Component, the tooltip will be shown immediately.
*
* @param delay The reshow delay.
*/
public void setReshowDelay(int delay)
{
// TODO
exitTimer.setDelay(delay);
}
/**
* registerComponent
* @param component TODO
*/
/**
* This method registers a JComponent with the ToolTipManager.
*
* @param component The JComponent to register with the ToolTipManager.
*/
public void registerComponent(JComponent component)
{
// TODO
component.addMouseListener(this);
component.addMouseMotionListener(this);
}
/**
* unregisterComponent
* @param component TODO
*/
/**
* This method unregisters a JComponent with the ToolTipManager.
*
* @param component The JComponent to unregister with the ToolTipManager.
*/
public void unregisterComponent(JComponent component)
{
// TODO
component.removeMouseMotionListener(this);
component.removeMouseListener(this);
}
/**
* mouseEntered
* @param event TODO
*/
/**
* This method is called whenever the mouse enters a JComponent registered
* with the ToolTipManager. When the mouse enters within the period of time
* specified by the reshow delay, the tooltip will be displayed
* immediately. Otherwise, it must wait for the initial delay before
* displaying the tooltip.
*
* @param event The MouseEvent.
*/
public void mouseEntered(MouseEvent event)
{
// TODO
if (currentComponent != null
&& getContentPaneDeepestComponent(event) == currentComponent)
return;
currentPoint = event.getPoint();
currentComponent = (Component) event.getSource();
if (exitTimer.isRunning())
{
exitTimer.stop();
showTip();
insideTimer.start();
return;
}
// This should always be stopped unless we have just fake-exited.
if (! enterTimer.isRunning())
enterTimer.start();
}
/**
* mouseExited
* @param event TODO
*/
/**
* This method is called when the mouse exits a JComponent registered with
* the ToolTipManager. When the mouse exits, the tooltip should be hidden
* immediately.
*
* @param event The MouseEvent.
*/
public void mouseExited(MouseEvent event)
{
// TODO
if (getContentPaneDeepestComponent(event) == currentComponent)
return;
currentPoint = event.getPoint();
currentComponent = null;
hideTip();
if (! enterTimer.isRunning() && insideTimer.isRunning())
exitTimer.start();
if (enterTimer.isRunning())
enterTimer.stop();
if (insideTimer.isRunning())
insideTimer.stop();
}
/**
* mousePressed
* @param event TODO
*/
/**
* This method is called when the mouse is pressed on a JComponent
* registered with the ToolTipManager. When the mouse is pressed, the
* tooltip (if it is shown) must be hidden immediately.
*
* @param event The MouseEvent.
*/
public void mousePressed(MouseEvent event)
{
// TODO
currentPoint = event.getPoint();
if (enterTimer.isRunning())
enterTimer.restart();
else if (insideTimer.isRunning())
{
insideTimer.stop();
hideTip();
}
currentComponent.invalidate();
currentComponent.validate();
currentComponent.repaint();
}
/**
* mouseDragged
* @param event TODO
*/
/**
* This method is called when the mouse is dragged in a JComponent
* registered with the ToolTipManager.
*
* @param event The MouseEvent.
*/
public void mouseDragged(MouseEvent event)
{
// TODO
currentPoint = event.getPoint();
if (enterTimer.isRunning())
enterTimer.restart();
}
/**
* mouseMoved
* @param event TODO
*/
/**
* This method is called when the mouse is moved in a JComponent registered
* with the ToolTipManager.
*
* @param event The MouseEvent.
*/
public void mouseMoved(MouseEvent event)
{
// TODO
currentPoint = event.getPoint();
if (currentTip != null)
currentTip.setTipText(((JComponent) currentComponent).getToolTipText(event));
if (enterTimer.isRunning())
enterTimer.restart();
}
/**
* This method displays the ToolTip. It can figure out the method needed to
* show it as well (whether to display it in heavyweight/lightweight panel
* or a window.)
*/
private void showTip()
{
if (! enabled)
return;
if (currentTip == null
|| currentTip.getComponent() != currentComponent
&& currentComponent instanceof JComponent)
currentTip = ((JComponent) currentComponent).createToolTip();
Point p = currentPoint;
Dimension dims = currentTip.getPreferredSize();
if (canToolTipFit(currentTip))
{
JLayeredPane pane = ((JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
currentComponent))
.getLayeredPane();
// This should never happen, but just in case.
if (pane == null)
return;
if (containerPanel != null)
hideTip();
if (isLightWeightPopupEnabled())
{
containerPanel = new Panel();
JRootPane root = new JRootPane();
root.getContentPane().add(currentTip);
containerPanel.add(root);
}
else
{
containerPanel = new JPanel();
containerPanel.add(currentTip);
}
LayoutManager lm = containerPanel.getLayout();
if (lm instanceof FlowLayout)
{
FlowLayout fm = (FlowLayout) lm;
fm.setVgap(0);
fm.setHgap(0);
}
p = getGoodPoint(p, pane, currentTip, dims);
pane.add(containerPanel);
containerPanel.setBounds(p.x, p.y, dims.width, dims.height);
currentTip.setBounds(0, 0, dims.width, dims.height);
pane.revalidate();
pane.repaint();
}
else
{
SwingUtilities.convertPointToScreen(p, currentComponent);
tooltipWindow = new JWindow();
tooltipWindow.getContentPane().add(currentTip);
tooltipWindow.setFocusable(false);
tooltipWindow.pack();
tooltipWindow.setBounds(p.x, p.y, dims.width, dims.height);
tooltipWindow.show();
}
currentTip.setVisible(true);
}
/**
* This method hides the ToolTip.
*/
private void hideTip()
{
if (currentTip == null || ! currentTip.isVisible() || ! enabled)
return;
currentTip.setVisible(false);
if (containerPanel != null)
{
Container parent = containerPanel.getParent();
if (parent == null)
return;
parent.remove(containerPanel);
parent.invalidate();
parent.validate();
parent.repaint();
parent = currentTip.getParent();
if (parent == null)
return;
parent.remove(currentTip);
containerPanel = null;
}
if (tooltipWindow != null)
{
tooltipWindow.hide();
tooltipWindow.dispose();
tooltipWindow = null;
}
}
/**
* This method returns a point in the LayeredPane where the ToolTip can be
* shown. The point returned (if the ToolTip is to be displayed at the
* preferred dimensions) will always place the ToolTip inside the
* currentComponent if possible.
*
* @param p The last known good point for the mouse.
* @param c The JLayeredPane in the first RootPaneContainer up from the
* currentComponent.
* @param tip The ToolTip to display.
* @param dims The ToolTip preferred dimensions (can be null).
*
* @return A good point to place the ToolTip.
*/
private Point getGoodPoint(Point p, JLayeredPane c, JToolTip tip,
Dimension dims)
{
if (dims == null)
dims = tip.getPreferredSize();
Rectangle bounds = currentComponent.getBounds();
if (p.x + dims.width > bounds.width)
p.x = bounds.width - dims.width;
if (p.y + dims.height > bounds.height)
p.y = bounds.height - dims.height;
p = SwingUtilities.convertPoint(currentComponent, p, c);
return p;
}
/**
* This method returns the deepest component in the content pane for the
* first RootPaneContainer up from the currentComponent. This method is
* used in conjunction with one of the mouseXXX methods.
*
* @param e The MouseEvent.
*
* @return The deepest component in the content pane.
*/
private Component getContentPaneDeepestComponent(MouseEvent e)
{
Component source = (Component) e.getSource();
Container parent = (Container) SwingUtilities.getAncestorOfClass(JRootPane.class,
currentComponent);
if (parent == null)
return null;
parent = ((JRootPane) parent).getContentPane();
Point p = e.getPoint();
p = SwingUtilities.convertPoint(source, p, parent);
Component target = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
return target;
}
/**
* This method returns whether the ToolTip can fit in the first
* RootPaneContainer up from the currentComponent.
*
* @param tip The ToolTip.
*
* @return Whether the ToolTip can fit.
*/
private boolean canToolTipFit(JToolTip tip)
{
JRootPane root = (JRootPane) SwingUtilities.getAncestorOfClass(JRootPane.class,
currentComponent);
if (root == null)
return false;
Dimension pref = tip.getPreferredSize();
Dimension rootSize = root.getSize();
if (rootSize.width > pref.width && rootSize.height > pref.height)
return true;
return false;
}
}

View File

@ -278,7 +278,7 @@ public class UIManager implements Serializable
}
/**
* Returns the L&amp;F object that renders the target component.
* Returns the Look and Feel object that renders the target component.
*/
public static ComponentUI getUI(JComponent target)
{

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.colorchooser;
import java.awt.Color;
@ -44,92 +43,119 @@ import javax.swing.Icon;
import javax.swing.JColorChooser;
import javax.swing.JPanel;
/**
* AbstractColorChooserPanel
* @author Andrew Selkirk
* @version 1.0
*
* @author Andrew Selkirk
* @version 1.0
*/
public abstract class AbstractColorChooserPanel extends JPanel
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -977469671210173863L;
/**
* chooser
*/
private JColorChooser chooser;
/** The chooser associated with this panel. */
private JColorChooser chooser;
/**
* Constructor AbstractColorChooserPanel
*/
public AbstractColorChooserPanel() {
// TODO
} // AbstractColorChooserPanel()
/**
* This is the constructor for the AbstractColorChooserPanel.
*/
public AbstractColorChooserPanel()
{
} // AbstractColorChooserPanel()
/**
* getDisplayName
* @returns String
*/
public abstract String getDisplayName();
/**
* This method returns the name displayed in the tab for this chooser panel.
*
* @return The name displayed in the JTabbedPane's tabs.
*/
public abstract String getDisplayName();
/**
* updateChooser
*/
public abstract void updateChooser();
/**
* This method updates the chooser panel when the JColorChooser's color has
* changed.
*/
public abstract void updateChooser();
/**
* buildChooser
*/
protected abstract void buildChooser();
/**
* This method constructs and does any initialization necessary for the
* chooser panel.
*/
protected abstract void buildChooser();
/**
* getSmallDisplayIcon
* @returns Icon
*/
public abstract Icon getSmallDisplayIcon();
/**
* This method sets the small icon used in the JTabbedPane for this chooser
* panel.
*
* @return The small icon used in the JTabbedPane.
*/
public abstract Icon getSmallDisplayIcon();
/**
* getLargeDisplayIcon
* @returns Icon
*/
public abstract Icon getLargeDisplayIcon();
/**
* This method sets the large icon useed in the jTabbedPane for this chooser
* panel.
*
* @return The large icon.
*/
public abstract Icon getLargeDisplayIcon();
/**
* installChooserPanel
* @param chooser TODO
*/
public void installChooserPanel(JColorChooser chooser) {
// TODO
} // installChooserPanel()
/**
* This method installs the chooser panel for the given JColorChooser.
*
* @param chooser The JColorChooser that will have this panel installed.
*/
public void installChooserPanel(JColorChooser chooser)
{
this.chooser = chooser;
buildChooser();
} // installChooserPanel()
/**
* uninstallChooserPanel
* @param chooser TODO
*/
public void uninstallChooserPanel(JColorChooser chooser) {
// TODO
} // uninstallChooserPanel()
/**
* This method removes the chooser panel from the given JColorChooser and
* does any necessary clean up for the chooser panel.
*
* @param chooser The JColorChooser that is having this panel removed.
*/
public void uninstallChooserPanel(JColorChooser chooser)
{
this.chooser = null;
} // uninstallChooserPanel()
/**
* getColorSelectionModel
* @returns ColorSelectionModel
*/
public ColorSelectionModel getColorSelectionModel() {
return null; // TODO
} // getColorSelectionModel()
/**
* This method returns the ColorSelectionModel for the JColorChooser
* associated with this chooser panel.
*
* @return The ColorSelectionModel for the JColorChooser associated with
* this chooser panel.
*/
public ColorSelectionModel getColorSelectionModel()
{
if (chooser != null)
return chooser.getSelectionModel();
return null;
} // getColorSelectionModel()
/**
* getColorFromModel
* @returns Color
*/
protected Color getColorFromModel() {
return null; // TODO
} // getColorFromModel()
/**
* This method returns the current color stored in the model for this
* chooser panel.
*
* @return The current color.
*/
protected Color getColorFromModel()
{
if (chooser != null)
return chooser.getColor();
return null;
} // getColorFromModel()
/**
* paint
* @param graphics TODO
*/
public void paint(Graphics graphics) {
// TODO
} // paint()
/**
* This method paints the chooser panel.
*
* @param graphics The Graphics object to paint with.
*/
public void paint(Graphics graphics)
{
super.paint(graphics);
} // paint()
} // AbstractColorChooserPanel

View File

@ -35,49 +35,51 @@ 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.colorchooser;
import javax.swing.JComponent;
/**
* ColorChooserComponentFactory
* @author Andrew Selkirk
* @version 1.0
*
* @author Andrew Selkirk
* @version 1.0
*/
public class ColorChooserComponentFactory {
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor ColorChooserComponentFactory
*/
private ColorChooserComponentFactory() {
// TODO
} // ColorChooserComponentFactory()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getDefaultChooserPanels
* @returns AbstractColorChooserPanel[]
*/
public static AbstractColorChooserPanel[] getDefaultChooserPanels() {
return null; // TODO
} // getDefaultChooserPanels()
/**
* getPreviewPanel
* @returns JComponent
*/
public static JComponent getPreviewPanel() {
return null; // TODO
} // getPreviewPanel()
public class ColorChooserComponentFactory
{
/**
* Constructor ColorChooserComponentFactory
*/
private ColorChooserComponentFactory()
{
} // ColorChooserComponentFactory()
/**
* This method returns the three default chooser panels to be used in
* JColorChooser.
*
* @return The default chooser panels.
*/
public static AbstractColorChooserPanel[] getDefaultChooserPanels()
{
AbstractColorChooserPanel[] values =
{
new DefaultSwatchChooserPanel(),
new DefaultHSBChooserPanel(),
new DefaultRGBChooserPanel()
};
return values;
}
/**
* This method returns the default preview panel to be used with
* JColorChoosers.
*
* @return The default preview panel.
*/
public static JComponent getPreviewPanel()
{
return new DefaultPreviewPanel();
} // getPreviewPanel()
} // ColorChooserComponentFactory

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.colorchooser;
import java.awt.Color;
@ -44,43 +43,55 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
* DefaultColorSelectionModel
* @author Andrew Selkirk
* @version 1.0
* This is the default implementation of the ColorSelectionModel interface
* that JColorChoosers use.
*
* @author Andrew Selkirk
* @version 1.0
*/
public class DefaultColorSelectionModel
implements ColorSelectionModel, Serializable
public class DefaultColorSelectionModel implements ColorSelectionModel,
Serializable
{
/** DOCUMENT ME! */
private static final long serialVersionUID = -8117143602864778804L;
/** The currently selected color. */
private Color selectedColor;
protected transient ChangeEvent changeEvent = new ChangeEvent (this);
protected EventListenerList listenerList = new EventListenerList ();
/** The ChangeEvent fired to all ChangeListeners. */
protected transient ChangeEvent changeEvent = new ChangeEvent(this);
/** The list of listeners. */
protected EventListenerList listenerList = new EventListenerList();
/**
* Creates a new color selection model.
* Creates a new color selection model with the default white color.
*/
public DefaultColorSelectionModel()
{
this (Color.white);
this(Color.white);
}
/**
* Creates a new color selection model with a given selected color.
*
* @param color The selected color.
*
* @param color The initial color.
*
* @throws Error If the color is null.
*/
public DefaultColorSelectionModel (Color color)
public DefaultColorSelectionModel(Color color)
{
super();
if (color == null)
throw new Error("ColorSelectionModel cannot be set to have null color.");
this.selectedColor = color;
}
/**
* Returns the selected color.
*
*
* @return The selected color.
*/
public Color getSelectedColor()
@ -89,31 +100,41 @@ public class DefaultColorSelectionModel
}
/**
* This method sets the color.
*
* @param color The color to set.
*
* @throws Error If the color is set.
*/
public void setSelectedColor (Color color)
public void setSelectedColor(Color color)
{
this.selectedColor = color;
if (color == null)
throw new Error("ColorSelectionModel cannot be set to have null color.");
if (color != selectedColor)
{
this.selectedColor = color;
fireStateChanged();
}
}
/**
* Adds a listener to this model.
*
*
* @param listener The listener to add.
*/
public void addChangeListener (ChangeListener listener)
public void addChangeListener(ChangeListener listener)
{
listenerList.add (ChangeListener.class, listener);
listenerList.add(ChangeListener.class, listener);
}
/**
* Removes a listener from this model.
*
*
* @param listener The listener to remove.
*/
public void removeChangeListener (ChangeListener listener)
public void removeChangeListener(ChangeListener listener)
{
listenerList.remove (ChangeListener.class, listener);
listenerList.remove(ChangeListener.class, listener);
}
/**
@ -123,19 +144,19 @@ public class DefaultColorSelectionModel
*/
public ChangeListener[] getChangeListeners()
{
return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
}
/**
* Calls all the <code>stateChanged()</code> method of all added
* <code>ChangeListener</code> objects with <code>changeEvent</code>
* as argument.
* <code>ChangeListener</code> objects with <code>changeEvent</code> as
* argument.
*/
protected void fireStateChanged()
{
ChangeListener[] listeners = getChangeListeners();
for (int i = 0; i < listeners.length; i++)
listeners [i].stateChanged (changeEvent);
listeners[i].stateChanged(changeEvent);
}
}

View File

@ -163,7 +163,7 @@ public class BasicArrowButton extends JButton implements SwingConstants
/** The color the arrow is painted in if disabled and the bottom and
* right edges of the button. */
private transient Color shadow = Color.BLACK;
private transient Color shadow = Color.gray;
/** The color the arrow is painted in if enabled and the bottom and
* right edges of the button. */
@ -350,30 +350,30 @@ public class BasicArrowButton extends JButton implements SwingConstants
{
Polygon arrow;
double dsize = (double) size;
int one = (int) (dsize * 1 / 10);
int two = (int) (dsize * 2 / 10);
int three = (int) (dsize * 3 / 10);
int five = (int) (dsize * 5 / 10);
int seven = (int) (dsize * 7 / 10);
int five = (int) (dsize * 5 / 10);
int eight = (int) (dsize * 8 / 10);
switch (direction)
{
case NORTH:
arrow = new Polygon(new int[] { two, five, eight },
new int[] { seven, three, seven }, 3);
arrow = new Polygon(new int[] { eight, five, one },
new int[] { eight, one, eight }, 3);
break;
case SOUTH:
arrow = new Polygon(new int[] { two, five, eight },
new int[] { three, seven, three }, 3);
arrow = new Polygon(new int[] { eight, five, two },
new int[] { two, eight, two }, 3);
break;
case EAST:
case RIGHT:
arrow = new Polygon(new int[] { three, seven, three },
arrow = new Polygon(new int[] { two, eight, two },
new int[] { two, five, eight }, 3);
break;
case WEST:
case LEFT:
arrow = new Polygon(new int[] { seven, three, seven },
arrow = new Polygon(new int[] { eight, two, eight },
new int[] { two, five, eight }, 3);
break;
default:

View File

@ -37,6 +37,7 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
@ -46,6 +47,7 @@ import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JComponent;
@ -64,8 +66,14 @@ public class BasicButtonListener
}
public void focusGained(FocusEvent e)
{
if (e.getSource() instanceof AbstractButton)
{
AbstractButton button = (AbstractButton) e.getSource();
if (button.isFocusPainted())
button.repaint();
}
}
public void focusLost(FocusEvent e)
{
if (e.getSource() instanceof AbstractButton)
@ -73,13 +81,43 @@ public class BasicButtonListener
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
model.setArmed(false);
if (button.isFocusPainted())
button.repaint();
}
}
public void installKeyboardActions(JComponent c)
{
c.getActionMap().put("pressed",
new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
// It is important that these transitions happen in this order.
model.setArmed(true);
model.setPressed(true);
}
});
c.getActionMap().put("released",
new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
// It is important that these transitions happen in this order.
model.setPressed(false);
model.setArmed(false);
}
});
}
public void uninstallKeyboardActions(JComponent c)
{
c.getActionMap().put("pressed", null);
c.getActionMap().put("released", null);
}
public void stateChanged(ChangeEvent e)
{
@ -105,7 +143,7 @@ public class BasicButtonListener
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)
{
// It is important that these transitions happen in this order.
model.setArmed(true);
@ -128,7 +166,7 @@ public class BasicButtonListener
{
AbstractButton button = (AbstractButton) e.getSource();
ButtonModel model = button.getModel();
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
if ((e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)
{
// It is important that these transitions happen in this order.
model.setPressed(false);
@ -156,7 +194,7 @@ public class BasicButtonListener
model.setRollover(true);
if (model.isPressed()
&& (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
&& (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)
model.setArmed(true);
else
model.setArmed(false);

View File

@ -50,6 +50,7 @@ import java.awt.Stroke;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
@ -59,13 +60,21 @@ import javax.swing.plaf.ComponentUI;
public class BasicButtonUI extends ButtonUI
{
/** A constant used to pad out elements in the button's layout and
preferred size calculations. */
int defaultTextIconGap = 4;
/**
* A constant used to pad out elements in the button's layout and
* preferred size calculations.
*/
protected int defaultTextIconGap = 4;
/** A constant added to the defaultTextIconGap to adjust the text
within this particular button. */
int defaultTextShiftOffset = 0;
/**
* A constant added to the defaultTextIconGap to adjust the text
* within this particular button.
*/
protected int defaultTextShiftOffset = 0;
private int textShiftOffset;
private Color focusColor;
/**
* Factory method to create an instance of BasicButtonUI for a given
@ -85,14 +94,32 @@ public class BasicButtonUI extends ButtonUI
return defaultTextIconGap;
}
protected void clearTextShiftOffset()
{
textShiftOffset = 0;
}
protected int getTextShiftOffset()
{
return textShiftOffset;
}
protected void setTextShiftOffset()
{
textShiftOffset = defaultTextShiftOffset;
}
protected void installDefaults(AbstractButton b)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
focusColor = defaults.getColor("Button.focus");
b.setForeground(defaults.getColor("Button.foreground"));
b.setBackground(defaults.getColor("Button.background"));
b.setMargin(defaults.getInsets("Button.margin"));
b.setBorder(defaults.getBorder("Button.border"));
b.setIconTextGap(defaults.getInt("Button.textIconGap"));
b.setInputMap(JComponent.WHEN_FOCUSED,
(InputMap) defaults.get("Button.focusInputMap"));
b.setOpaque(true);
}
@ -133,10 +160,12 @@ public class BasicButtonUI extends ButtonUI
protected void installKeyboardActions(AbstractButton b)
{
listener.installKeyboardActions(b);
}
protected void uninstallKeyboardActions(AbstractButton b)
{
listener.uninstallKeyboardActions(b);
}
/**
@ -271,22 +300,12 @@ public class BasicButtonUI extends ButtonUI
{
if (b.hasFocus() && b.isFocusPainted())
{
Graphics2D g2 = (Graphics2D) g;
Stroke saved_stroke = g2.getStroke();
Color saved_color = g2.getColor();
float dashes[] = new float[] {1.0f, 1.0f};
BasicStroke s = new BasicStroke(1.0f,
BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_MITER,
10, dashes, 0.0f);
g2.setStroke(s);
g2.setColor(Color.BLACK);
g2.drawRect(vr.x + 2,
vr.y + 2,
vr.width - 4,
vr.height - 4);
g2.setStroke(saved_stroke);
g2.setColor(saved_color);
Color saved_color = g.getColor();
g.setColor(focusColor);
Rectangle focusRect = ir.union(tr);
g.drawRect(focusRect.x, focusRect.y,
focusRect.width, focusRect.height);
g.setColor(saved_color);
}
}

View File

@ -765,7 +765,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
lastComponentEntered);
MouseEvent exited = new MouseEvent(lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen(), me.getModifiers(),
me.getWhen(), me.getModifiersEx(),
tp.x, tp.y, me.getClickCount(),
me.isPopupTrigger(),
me.getButton());
@ -787,7 +787,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
MouseEvent entered = new MouseEvent(lastComponentEntered,
MouseEvent.MOUSE_ENTERED,
me.getWhen(),
me.getModifiers(), cp.x,
me.getModifiersEx(), cp.x,
cp.y, me.getClickCount(),
me.isPopupTrigger(),
me.getButton());

View File

@ -41,6 +41,7 @@ package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.Serializable;
import java.util.Enumeration;
@ -131,6 +132,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"SeparatorUI", "javax.swing.plaf.basic.BasicSeparatorUI",
"SliderUI", "javax.swing.plaf.basic.BasicSliderUI",
"SplitPaneUI", "javax.swing.plaf.basic.BasicSplitPaneUI",
"SpinnerUI", "javax.swing.plaf.basic.BasicSpinnerUI",
"StandardDialogUI", "javax.swing.plaf.basic.BasicStandardDialogUI",
"TabbedPaneUI", "javax.swing.plaf.basic.BasicTabbedPaneUI",
"TableHeaderUI", "javax.swing.plaf.basic.BasicTableHeaderUI",
@ -246,6 +248,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"SPACE", "pressed",
"released SPACE", "released"
}),
"Button.focus", midPurple,
"Button.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"Button.foreground", new ColorUIResource(Color.black),
"Button.highlight", new ColorUIResource(Color.white),
@ -820,7 +823,14 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TextField.keyBindings", new JTextComponent.KeyBinding[] {
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
0),
"notify-field-accept")},
"notify-field-accept"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
InputEvent.SHIFT_DOWN_MASK),
"selection-backward"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
InputEvent.SHIFT_DOWN_MASK),
"selection-forward"),
},
"TextField.margin", new InsetsUIResource(0, 0, 0, 0),
"TextField.selectionBackground", new ColorUIResource(lightPurple),
"TextField.selectionForeground", new ColorUIResource(Color.black),
@ -881,7 +891,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ToolBar.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"ToolBar.foreground", new ColorUIResource(Color.black),
"ToolBar.separatorSize", new DimensionUIResource(20, 20),
"ToolTip.background", new ColorUIResource(Color.white),
"ToolTip.background", new ColorUIResource(122, 178, 241),
"ToolTip.border", new BorderUIResource.LineBorderUIResource(Color.lightGray),
"ToolTip.font", new FontUIResource("SansSerif", Font.PLAIN, 12),
"ToolTip.foreground", new ColorUIResource(Color.black),

View File

@ -163,6 +163,7 @@ public class BasicPopupMenuUI extends PopupMenuUI
popupMenu.setBorder(defaults.getBorder("PopupMenu.border"));
popupMenu.setFont(defaults.getFont("PopupMenu.font"));
popupMenu.setForeground(defaults.getColor("PopupMenu.foreground"));
popupMenu.setOpaque(true);
}
/**
@ -228,11 +229,11 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* This method returns the minimum size of the JPopupMenu.
* This method returns the minimum size of the JPopupMenu.
*
* @param c The JComponent to find a size for.
* @param c The JComponent to find a size for.
*
* @return The minimum size.
* @return The minimum size.
*/
public Dimension getMinimumSize(JComponent c)
{
@ -264,13 +265,13 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* Return true if given mouse event is a platform popup trigger,
* and false otherwise
* Return true if given mouse event is a platform popup trigger, and false
* otherwise
*
* @param e MouseEvent that is to be checked for popup trigger event
*
* @return true if given mouse event is a platform popup trigger,
* and false otherwise
* @return true if given mouse event is a platform popup trigger, and false
* otherwise
*/
public boolean isPopupTrigger(MouseEvent e)
{
@ -334,25 +335,25 @@ public class BasicPopupMenuUI extends PopupMenuUI
path[0] = popupMenu;
Component[] comps = popupMenu.getComponents();
if (comps.length != 0 && comps[0] instanceof MenuElement)
path[1] = (MenuElement) comps[0];
manager.setSelectedPath(path);
{
path[1] = (MenuElement) comps[0];
manager.setSelectedPath(path);
}
}
}
}
/**
* ComponentListener that listens to Component Events fired by the
* top - level window to which popup menu belongs. If top-level
* window was resized, moved or hidded then popup menu will
* be hidded and selected path of current menu hierarchy will be set
* to null.
*
* ComponentListener that listens to Component Events fired by the top -
* level window to which popup menu belongs. If top-level window was
* resized, moved or hidded then popup menu will be hidded and selected
* path of current menu hierarchy will be set to null.
*/
private class TopWindowListener implements ComponentListener
{
/**
* This method is invoked when top-level window is resized.
* This method closes current menu hierarchy.
* This method is invoked when top-level window is resized. This method
* closes current menu hierarchy.
*
* @param e The ComponentEvent
*/
@ -363,8 +364,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* This method is invoked when top-level window is moved.
* This method closes current menu hierarchy.
* This method is invoked when top-level window is moved. This method
* closes current menu hierarchy.
*
* @param e The ComponentEvent
*/
@ -375,8 +376,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* This method is invoked when top-level window is shown
* This method does nothing by default.
* This method is invoked when top-level window is shown This method does
* nothing by default.
*
* @param e The ComponentEvent
*/
@ -387,8 +388,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
* This method is invoked when top-level window is hidden
* This method closes current menu hierarchy.
* This method is invoked when top-level window is hidden This method
* closes current menu hierarchy.
*
* @param e The ComponentEvent
*/

View File

@ -1226,6 +1226,7 @@ public class BasicSliderUI extends SliderUI
if (slider.getLabelTable() == null)
return 0;
Dimension pref;
for (Enumeration list = slider.getLabelTable().elements();
list.hasMoreElements();)
{
@ -1233,8 +1234,9 @@ public class BasicSliderUI extends SliderUI
if (! (comp instanceof Component))
continue;
label = (Component) comp;
if (label.getWidth() > widest)
widest = label.getWidth();
pref = label.getPreferredSize();
if (pref != null && pref.width > widest)
widest = pref.width;
}
return widest;
}
@ -1252,7 +1254,7 @@ public class BasicSliderUI extends SliderUI
if (slider.getLabelTable() == null)
return 0;
Dimension pref;
for (Enumeration list = slider.getLabelTable().elements();
list.hasMoreElements();)
{
@ -1260,8 +1262,9 @@ public class BasicSliderUI extends SliderUI
if (! (comp instanceof Component))
continue;
label = (Component) comp;
if (label.getHeight() > tallest)
tallest = label.getHeight();
pref = label.getPreferredSize();
if (pref != null && pref.height > tallest)
tallest = pref.height;
}
return tallest;
}

View File

@ -46,8 +46,16 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TextUI;
import javax.swing.plaf.UIResource;
@ -61,7 +69,9 @@ import javax.swing.text.EditorKit;
import javax.swing.text.Element;
import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent;
import javax.swing.text.Keymap;
import javax.swing.text.PlainDocument;
import javax.swing.text.PlainView;
import javax.swing.text.Position;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
@ -88,14 +98,18 @@ public abstract class BasicTextUI extends TextUI
private class RootView extends View
{
private JTextComponent textComponent;
private View view;
public RootView(JTextComponent parent)
{
super(null);
textComponent = parent;
}
public RootView()
{
super(null);
}
public ViewFactory getViewFactory()
{
// FIXME: Handle EditorKit somehow.
return BasicTextUI.this;
}
public void setView(View v)
{
@ -123,17 +137,34 @@ public abstract class BasicTextUI extends TextUI
public void paint(Graphics g, Shape s)
{
System.out.println("Michael: BasicTextUI.RootView.paint");
if (view != null)
view.paint(g, s);
}
}
protected Rectangle modelToView(int position, Shape a, Position.Bias bias)
throws BadLocationException
{
return ((PlainView) view).modelToView(position, a, bias).getBounds();
}
}
class UpdateHandler implements PropertyChangeListener
{
public void propertyChange(PropertyChangeEvent event)
{
if (event.getPropertyName().equals("document"))
{
// Document changed.
modelChanged();
}
}
}
RootView rootView;
static EditorKit kit = new DefaultEditorKit();
RootView rootView = new RootView();
JTextComponent textComponent;
int gap = 3;
EditorKit kit = new DefaultEditorKit();
UpdateHandler updateHandler = new UpdateHandler();
public BasicTextUI()
{
@ -164,12 +195,12 @@ public abstract class BasicTextUI extends TextUI
Document doc = textComponent.getDocument();
if (doc == null)
{
doc = new PlainDocument();
doc = getEditorKit(textComponent).createDefaultDocument();
textComponent.setDocument(doc);
}
rootView = new RootView(textComponent);
setView(create(doc.getDefaultRootElement()));
}
textComponent.addPropertyChangeListener(updateHandler);
modelChanged();
installDefaults();
installListeners();
@ -178,20 +209,115 @@ public abstract class BasicTextUI extends TextUI
protected void installDefaults()
{
Caret caret = textComponent.getCaret();
if (caret == null)
{
caret = createCaret();
textComponent.setCaret(caret);
}
Highlighter highlighter = textComponent.getHighlighter();
if (highlighter == null)
textComponent.setHighlighter(createHighlighter());
String prefix = getPropertyPrefix();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
textComponent.setBackground(defaults.getColor(prefix + ".background"));
textComponent.setForeground(defaults.getColor(prefix + ".foreground"));
textComponent.setMargin(defaults.getInsets(prefix + ".margin"));
textComponent.setBorder(defaults.getBorder(prefix + ".border"));
textComponent.setFont(defaults.getFont(prefix + ".font"));
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));
}
protected void installListeners()
{
// Do nothing here.
}
protected String getKeymapName()
{
return "BasicTextUI";
}
protected Keymap createKeymap()
{
String prefix = getPropertyPrefix();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
JTextComponent.KeyBinding[] bindings =
(JTextComponent.KeyBinding[]) defaults.get(prefix + ".keyBindings");
Keymap km = JTextComponent.addKeymap(getKeymapName(),
JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP));
JTextComponent.loadKeymap(km, bindings, textComponent.getActions());
return km;
}
protected void installKeyboardActions()
{
// load any bindings for the older Keymap interface
Keymap km = JTextComponent.getKeymap(getKeymapName());
if (km == null)
km = createKeymap();
textComponent.setKeymap(km);
// load any bindings for the newer InputMap / ActionMap interface
SwingUtilities.replaceUIInputMap(textComponent,
JComponent.WHEN_FOCUSED,
getInputMap(JComponent.WHEN_FOCUSED));
SwingUtilities.replaceUIActionMap(textComponent, getActionMap());
}
InputMap getInputMap(int condition)
{
String prefix = getPropertyPrefix();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
switch (condition)
{
case JComponent.WHEN_IN_FOCUSED_WINDOW:
// FIXME: is this the right string? nobody seems to use it.
return (InputMap) defaults.get(prefix + ".windowInputMap");
case JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT:
return (InputMap) defaults.get(prefix + ".ancestorInputMap");
default:
case JComponent.WHEN_FOCUSED:
return (InputMap) defaults.get(prefix + ".focusInputMap");
}
}
ActionMap getActionMap()
{
String prefix = getPropertyPrefix();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
ActionMap am = (ActionMap) defaults.get(prefix + ".actionMap");
if (am == null)
{
am = createActionMap();
defaults.put(prefix + ".actionMap", am);
}
return am;
}
ActionMap createActionMap()
{
Action[] actions = textComponent.getActions();
ActionMap am = new ActionMap();
for (int i = 0; i < actions.length; ++i)
{
String name = (String) actions[i].getValue(Action.NAME);
if (name != null)
am.put(name, actions[i]);
}
return am;
}
public void uninstallUI(final JComponent c)
public void uninstallUI(final JComponent component)
{
super.uninstallUI(c);
rootView = null;
super.uninstallUI(component);
rootView.setView(null);
textComponent.removePropertyChangeListener(updateHandler);
textComponent = null;
uninstallDefaults();
uninstallListeners();
@ -200,14 +326,17 @@ public abstract class BasicTextUI extends TextUI
protected void uninstallDefaults()
{
// Do nothing here.
}
protected void uninstallListeners()
{
// Do nothing here.
}
protected void uninstallKeyboardActions()
{
// Do nothing here.
}
protected abstract String getPropertyPrefix();
@ -235,18 +364,19 @@ public abstract class BasicTextUI extends TextUI
if (textComponent.isOpaque())
paintBackground(g);
rootView.paint(g, getVisibleEditorRect());
if (highlighter != null)
if (highlighter != null
&& textComponent.getSelectionStart() != textComponent.getSelectionEnd())
highlighter.paint(g);
rootView.paint(g, getVisibleEditorRect());
if (caret != null)
caret.paint(g);
}
protected void paintBackground(Graphics g)
{
g.setColor(Color.WHITE); // FIXME: set background color
g.setColor(textComponent.getBackground());
g.fillRect(0, 0, textComponent.getWidth(), textComponent.getHeight());
}
@ -281,13 +411,13 @@ public abstract class BasicTextUI extends TextUI
public Rectangle modelToView(JTextComponent t, int pos)
throws BadLocationException
{
return modelToView(t, pos, null);
return modelToView(t, pos, Position.Bias.Forward);
}
public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias)
throws BadLocationException
{
return null;
return rootView.modelToView(pos, getVisibleEditorRect(), bias).getBounds();
}
public int viewToModel(JTextComponent t, Point pt)
@ -331,4 +461,11 @@ public abstract class BasicTextUI extends TextUI
rootView.setView(view);
view.setParent(rootView);
}
protected void modelChanged()
{
ViewFactory factory = rootView.getViewFactory();
Element elem = textComponent.getDocument().getDefaultRootElement();
setView(factory.create(elem));
}
}

View File

@ -43,12 +43,10 @@ import javax.swing.plaf.ComponentUI;
public class BasicToggleButtonUI extends BasicButtonUI
{
public static ComponentUI createUI(final JComponent c) {
return new BasicToggleButtonUI();
}
public static ComponentUI createUI(final JComponent component)
{
return new BasicToggleButtonUI();
}
}

View File

@ -157,13 +157,11 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
/**
* This method creates a new BasicToolBarUI object for the given JToolBar.
*
* @param b The JToolBar to represent with this UI.
*/
public BasicToolBarUI(JToolBar b)
{
super();
}
public BasicToolBarUI()
{
super();
}
/**
* This method returns whether the JToolBar can dock at the given position.
@ -351,10 +349,10 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
*
* @return A new UI delegate.
*/
public static ComponentUI createUI(JComponent c)
{
return new BasicToolBarUI((JToolBar) c);
}
public static ComponentUI createUI(JComponent c)
{
return new BasicToolBarUI();
}
/**
* This method is called to drag the DragWindow around when the JToolBar is

View File

@ -122,8 +122,22 @@ public class DefaultTableCellRenderer extends JLabel
{
if (value!=null)
super.setText(value.toString());
return this;
setOpaque(true);
if (isSelected)
{
setBackground(table.getSelectionBackground());
setForeground(table.getSelectionForeground());
}
else
{
setBackground(table.getBackground());
setForeground(table.getForeground());
}
setEnabled(table.isEnabled());
setFont(table.getFont());
return this;
}
/**
@ -150,6 +164,11 @@ public class DefaultTableCellRenderer extends JLabel
// Does nothing.
}
public void revalidate()
{
// Does nothing.
}
/**
* Overriden for performance.
*

View File

@ -1,5 +1,5 @@
/* DefaultTableColumnModel.java --
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -44,6 +44,7 @@ import java.util.Enumeration;
import java.util.EventListener;
import java.util.Vector;
import javax.swing.ListSelectionModel;
import javax.swing.DefaultListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
@ -61,86 +62,93 @@ public class DefaultTableColumnModel
implements TableColumnModel, PropertyChangeListener, ListSelectionListener,
Serializable
{
static final long serialVersionUID = 6580012493508960512L;
private static final long serialVersionUID = 6580012493508960512L;
/**
* tableColumns
*/
protected Vector tableColumns;
/**
* tableColumns
*/
protected Vector tableColumns;
/**
* selectionModel
*/
protected ListSelectionModel selectionModel;
/**
* selectionModel
*/
protected ListSelectionModel selectionModel;
/**
* columnMargin
*/
protected int columnMargin;
/**
* columnMargin
*/
protected int columnMargin;
/**
* listenerList
*/
protected EventListenerList listenerList;
/**
* listenerList
*/
protected EventListenerList listenerList = new EventListenerList();
/**
* changeEvent
*/
protected transient ChangeEvent changeEvent;
/**
* changeEvent
*/
protected transient ChangeEvent changeEvent = new ChangeEvent(this);
/**
* columnSelectionAllowed
*/
protected boolean columnSelectionAllowed;
/**
* columnSelectionAllowed
*/
protected boolean columnSelectionAllowed;
/**
* totalColumnWidth
*/
protected int totalColumnWidth;
/**
* totalColumnWidth
*/
protected int totalColumnWidth;
/**
* Constructor DefaultTableColumnModel
*/
/**
* Constructor DefaultTableColumnModel
*/
public DefaultTableColumnModel()
{
// TODO
tableColumns = new Vector();
setSelectionModel(new DefaultListSelectionModel());
columnMargin = 1;
columnSelectionAllowed = false;
}
/**
* addColumn
* @param value0 TODO
*/
public void addColumn(TableColumn value0)
/**
* addColumn
* @param value0 TODO
*/
public void addColumn(TableColumn col)
{
// TODO
tableColumns.add(col);
invalidateWidthCache();
}
/**
* removeColumn
* @param value0 TODO
*/
public void removeColumn(TableColumn value0)
/**
* removeColumn
* @param value0 TODO
*/
public void removeColumn(TableColumn col)
{
// TODO
tableColumns.remove(col);
invalidateWidthCache();
}
/**
* moveColumn
* @param value0 TODO
* @param value1 TODO
*/
public void moveColumn(int value0, int value1)
/**
* moveColumn
* @param value0 TODO
* @param value1 TODO
*/
public void moveColumn(int i, int j)
{
// TODO
Object tmp = tableColumns.get(i);
tableColumns.set(i, tableColumns.get(j));
tableColumns.set(j, tmp);
}
/**
* setColumnMargin
* @param value0 TODO
*/
public void setColumnMargin(int value0)
/**
* setColumnMargin
* @param value0 TODO
*/
public void setColumnMargin(int m)
{
// TODO
columnMargin = m;
}
/**
@ -149,7 +157,7 @@ public class DefaultTableColumnModel
*/
public int getColumnCount()
{
return 0; // TODO
return tableColumns.size();
}
/**
@ -158,27 +166,27 @@ public class DefaultTableColumnModel
*/
public Enumeration getColumns()
{
return null; // TODO
return tableColumns.elements();
}
/**
* getColumnIndex
* @param value0 TODO
* @return int
*/
public int getColumnIndex(Object value0)
*/
public int getColumnIndex(Object obj)
{
return 0; // TODO
return tableColumns.indexOf(obj, 0);
}
/**
* getColumn
* @param value0 TODO
* @return TableColumn
*/
public TableColumn getColumn(int value0)
*/
public TableColumn getColumn(int i)
{
return null; // TODO
return (TableColumn) tableColumns.get(i);
}
/**
@ -187,17 +195,25 @@ public class DefaultTableColumnModel
*/
public int getColumnMargin()
{
return 0; // TODO
return columnMargin;
}
/**
* getColumnIndexAtX
* @param value0 TODO
* @return int
*/
public int getColumnIndexAtX(int value0)
{
return 0; // TODO
*/
public int getColumnIndexAtX(int x)
{
for (int i = 0; i < tableColumns.size(); ++i)
{
int w = ((TableColumn)tableColumns.get(i)).getWidth();
if (0 <= x && x < w)
return i;
else
x -= w;
}
return -1;
}
/**
@ -206,16 +222,23 @@ public class DefaultTableColumnModel
*/
public int getTotalColumnWidth()
{
return 0; // TODO
if (totalColumnWidth == -1)
recalcWidthCache();
return totalColumnWidth;
}
/**
* setSelectionModel
* @param value0 TODO
*/
public void setSelectionModel(ListSelectionModel value0)
/**
* setSelectionModel
* @param model TODO
* @exception IllegalArgumentException if model is null
*/
public void setSelectionModel(ListSelectionModel model)
{
// TODO
if (model == null)
throw new IllegalArgumentException();
selectionModel = model;
selectionModel.addListSelectionListener(this);
}
/**
@ -224,16 +247,16 @@ public class DefaultTableColumnModel
*/
public ListSelectionModel getSelectionModel()
{
return null; // TODO
return selectionModel;
}
/**
* setColumnSelectionAllowed
* @param value0 TODO
*/
public void setColumnSelectionAllowed(boolean value0)
/**
* setColumnSelectionAllowed
* @param value0 TODO
*/
public void setColumnSelectionAllowed(boolean a)
{
// TODO
columnSelectionAllowed = a;
}
/**
@ -242,7 +265,7 @@ public class DefaultTableColumnModel
*/
public boolean getColumnSelectionAllowed()
{
return false; // TODO
return columnSelectionAllowed;
}
/**
@ -263,13 +286,13 @@ public class DefaultTableColumnModel
return 0; // TODO
}
/**
* addColumnModelListener
* @param value0 TODO
*/
public void addColumnModelListener(TableColumnModelListener value0)
/**
* addColumnModelListener
* @param value0 TODO
*/
public void addColumnModelListener(TableColumnModelListener listener)
{
// TODO
listenerList.add(TableColumnModelListener.class, listener);
}
/**
@ -308,13 +331,15 @@ public class DefaultTableColumnModel
// TODO
}
/**
* fireColumnSelectionChanged
* @param value0 TODO
*/
protected void fireColumnSelectionChanged(ListSelectionEvent value0)
/**
* fireColumnSelectionChanged
* @param value0 TODO
*/
protected void fireColumnSelectionChanged(ListSelectionEvent evt)
{
// TODO
EventListener [] listeners = getListeners(TableColumnModelListener.class);
for (int i = 0; i < listeners.length; ++i)
((TableColumnModelListener)listeners[i]).columnSelectionChanged(evt);
}
/**
@ -329,10 +354,10 @@ public class DefaultTableColumnModel
* getListeners
* @param value0 TODO
* @return EventListener[]
*/
public EventListener[] getListeners(Class value0)
*/
public EventListener[] getListeners(Class klass)
{
return null; // TODO
return listenerList.getListeners(klass);
}
/**
@ -350,7 +375,7 @@ public class DefaultTableColumnModel
*/
public void valueChanged(ListSelectionEvent value0)
{
// TODO
fireColumnSelectionChanged(value0);
}
/**
@ -367,7 +392,14 @@ public class DefaultTableColumnModel
*/
protected void recalcWidthCache()
{
// TODO
if (totalColumnWidth == -1)
{
totalColumnWidth = 0;
for (int i = 0; i < tableColumns.size(); ++i)
{
totalColumnWidth += ((TableColumn)tableColumns.get(i)).getWidth();
}
}
}
/**
@ -375,6 +407,6 @@ public class DefaultTableColumnModel
*/
private void invalidateWidthCache()
{
// TODO
totalColumnWidth = -1;
}
}

View File

@ -50,445 +50,387 @@ public class DefaultTableModel extends AbstractTableModel
implements Serializable
{
static final long serialVersionUID = 6680042567037222321L;
//-------------------------------------------------------------
// Variables --------------------------------------------------
//-------------------------------------------------------------
/**
* dataVector
*/
protected Vector dataVector;
/**
* columnIdentifiers
*/
protected Vector columnIdentifiers;
//-------------------------------------------------------------
// Initialization ---------------------------------------------
//-------------------------------------------------------------
/**
* Constructor DefaultTableModel
*/
public DefaultTableModel() {
this(0, 0);
} // DefaultTableModel()
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(int numRows, int numColumns) {
// Variables
int columnIndex;
Vector defaultNames;
// Create Column Names
defaultNames = new Vector();
for (columnIndex = 0; columnIndex < numColumns; columnIndex++) {
defaultNames.addElement(super.getColumnName(columnIndex));
} // for
// Setup Data
// setDataVector(defaultNames, numRows);
} // DefaultTableModel()
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Vector columnNames, int numRows) {
// Variables
Vector data;
Vector rowData;
int rowIndex;
int numColumns;
// Create Data
data = new Vector();
if (columnNames == null) {
numColumns = 0;
} else {
numColumns = columnNames.size();
} // if
for (rowIndex = 0; rowIndex < numRows; rowIndex++) {
rowData = new Vector();
rowData.setSize(numColumns);
data.addElement(rowData);
} // for
// Setup Data
setDataVector(data, columnNames);
} // DefaultTableModel()
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Object[] columnNames, int numRows) {
this(convertToVector(columnNames), numRows);
} // DefaultTableModel()
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Vector data, Vector columnNames) {
setDataVector(data, columnNames);
} // DefaultTableModel()
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Object[][] data, Object[] columnNames) {
this(convertToVector(data), convertToVector(columnNames));
} // DefaultTableModel()
//-------------------------------------------------------------
// Methods ----------------------------------------------------
//-------------------------------------------------------------
/**
* getDataVector
* @returns Vector
*/
public Vector getDataVector() {
return dataVector;
} // getDataVector()
/**
* setDataVector
* @param value0 TODO
* @param value1 TODO
*/
public void setDataVector(Vector data, Vector columnNames) {
// Variables
int rowIndex;
int numRows;
int numColumns;
Vector columnVector;
// Set Data
dataVector = data;
columnIdentifiers = columnNames;
// Check Data
numRows = data.size();
numColumns = columnNames.size();
for (rowIndex = 0; rowIndex < numRows; rowIndex++) {
columnVector = (Vector) dataVector.get(rowIndex);
columnVector.setSize(numColumns);
} // for
} // setDataVector()
/**
* setDataVector
* @param value0 TODO
* @param value1 TODO
*/
public void setDataVector(Object[][] data, Object[] columnNames) {
setDataVector(convertToVector(data), convertToVector(columnNames));
} // setDataVector()
/**
* newDataAvailable
* @param value0 TODO
*/
public void newDataAvailable(TableModelEvent event) {
fireTableChanged(event);
} // newDataAvailable()
/**
* newRowsAdded
* @param value0 TODO
*/
public void newRowsAdded(TableModelEvent event) {
// TODO
} // newRowsAdded()
/**
* rowsRemoved
* @param value0 TODO
*/
public void rowsRemoved(TableModelEvent event) {
fireTableChanged(event);
} // rowsRemoved()
/**
* setColumnIdentifiers
* @param value0 TODO
*/
public void setColumnIdentifiers(Vector columnIdentifiers) {
this.columnIdentifiers = columnIdentifiers;
setColumnCount(columnIdentifiers.size());
} // setColumnIdentifiers()
/**
* setColumnIdentifiers
* @param value0 TODO
*/
public void setColumnIdentifiers(Object[] columnIdentifiers) {
setColumnIdentifiers(convertToVector(columnIdentifiers));
} // setColumnIdentifiers()
/**
* setNumRows
* @param value0 TODO
*/
public void setNumRows(int numRows) {
setRowCount(numRows);
} // setNumRows()
/**
* setRowCount
* @param value0 TODO
*/
public void setRowCount(int rowCount) {
// TODO
} // setRowCount()
/**
* setColumnCount
* @param value0 TODO
*/
public void setColumnCount(int columnCount) {
// TODO
} // setColumnCount()
/**
* addColumn
* @param value0 TODO
*/
public void addColumn(Object columnName) {
addColumn(columnName, new Vector(dataVector.size()));
} // addColumn()
/**
* addColumn
* @param value0 TODO
* @param value1 TODO
*/
public void addColumn(Object columnName, Vector columnData) {
// TODO
} // addColumn()
/**
* addColumn
* @param value0 TODO
* @param value1 TODO
*/
public void addColumn(Object columnName, Object[] columnData) {
// TODO
} // addColumn()
/**
* addRow
* @param value0 TODO
*/
public void addRow(Vector rowData) {
// TODO
} // addRow()
/**
* addRow
* @param value0 TODO
*/
public void addRow(Object[] rowData) {
addRow(convertToVector(rowData));
} // addRow()
/**
* insertRow
* @param value0 TODO
* @param value1 TODO
*/
public void insertRow(int row, Vector rowData) {
dataVector.add(row, rowData);
} // insertRow()
/**
* insertRow
* @param value0 TODO
* @param value1 TODO
*/
public void insertRow(int row, Object[] rowData) {
insertRow(row, convertToVector(rowData));
} // insertRow()
/**
* moveRow
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
public void moveRow(int startIndex, int endIndex, int toIndex) {
// Variables
int index;
Vector vector;
// Move Rows
for (index = 0; index < (endIndex - startIndex); index++) {
vector = (Vector) dataVector.remove(startIndex);
dataVector.add(toIndex, vector);
} // for
} // moveRow()
/**
* removeRow
* @param value0 TODO
*/
public void removeRow(int row) {
dataVector.remove(row);
} // removeRow()
/**
* getRowCount
* @returns int
*/
public int getRowCount() {
return dataVector.size();
} // getRowCount()
/**
* getColumnCount
* @returns int
*/
public int getColumnCount() {
return columnIdentifiers.size();
} // getColumnCount()
/**
* getColumnName
* @param value0 TODO
* @returns String
*/
public String getColumnName(int column) {
// Check for Column
if (columnIdentifiers == null || column >= getColumnCount()) {
return super.getColumnName(column);
} // if
// Return Column name
return (String) columnIdentifiers.get(column);
} // getColumnName()
/**
* isCellEditable
* @param value0 TODO
* @param value1 TODO
* @returns boolean
*/
public boolean isCellEditable(int row, int column) {
return true;
} // isCellEditable()
/**
* getValueAt
* @param value0 TODO
* @param value1 TODO
* @returns Object
*/
public Object getValueAt(int row, int column) {
// Variables
Vector rowVector;
// Get Row Vector
rowVector = (Vector) dataVector.get(row);
// Get Data
return rowVector.get(column);
} // getValueAt()
/**
* setValueAt
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
public void setValueAt(Object value, int row, int column) {
// Variables
Vector rowVector;
// Get Row Vector
rowVector = (Vector) dataVector.get(row);
// Set Data
rowVector.remove(column);
rowVector.add(column, value);
} // setValueAt()
/**
* convertToVector
* @param value0 TODO
* @returns Vector
*/
protected static Vector convertToVector(Object[] data) {
// Variables
int index;
Vector vector;
// Check for null
if (data == null) {
return null;
} // if
// Process
vector = new Vector();
for (index = 0; index < data.length; index++) {
vector.add(data[index]);
} // for: index
// Return new Vector
return vector;
} // convertToVector()
/**
* convertToVector
* @param value0 TODO
* @returns Vector
*/
protected static Vector convertToVector(Object[][] data) {
// Variables
int index;
Vector vector;
// Process
vector = new Vector();
for (index = 0; index < data.length; index++) {
vector.add(convertToVector(data[index]));
} // for: index
// Return new Vector
return vector;
} // convertToVector()
} // DefaultTableModel
/**
* dataVector
*/
protected Vector dataVector;
/**
* columnIdentifiers
*/
protected Vector columnIdentifiers;
/**
* Constructor DefaultTableModel
*/
public DefaultTableModel()
{
this(0, 0);
}
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(int numRows, int numColumns)
{
Vector defaultNames = new Vector(numColumns);
Vector data = new Vector(numRows);
for (int i = 0; i < numColumns; i++)
{
defaultNames.add(super.getColumnName(i));
Vector tmp = new Vector(numColumns);
tmp.setSize(numColumns);
data.add(tmp);
}
setDataVector(defaultNames, data);
}
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Vector columnNames, int numRows)
{
Vector data = new Vector();
int numColumns = 0;
if (columnNames != null)
numColumns = columnNames.size();
while (0 < numRows--)
{
Vector rowData = new Vector();
rowData.setSize(numColumns);
data.add(rowData);
}
setDataVector(data, columnNames);
}
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Object[] columnNames, int numRows)
{
this(convertToVector(columnNames), numRows);
}
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Vector data, Vector columnNames)
{
setDataVector(data, columnNames);
}
/**
* Constructor DefaultTableModel
* @param value0 TODO
* @param value1 TODO
*/
public DefaultTableModel(Object[][] data, Object[] columnNames)
{
this(convertToVector(data), convertToVector(columnNames));
}
/**
* getDataVector
* @returns Vector
*/
public Vector getDataVector()
{
return dataVector;
}
/**
* setDataVector
* @param value0 TODO
* @param value1 TODO
*/
public void setDataVector(Vector data, Vector columnNames)
{
dataVector = data;
columnIdentifiers = columnNames;
for (int r = 0; r < data.size(); r++) {
((Vector) dataVector.get(r)).setSize(columnNames.size());
}
}
/**
* setDataVector
* @param value0 TODO
* @param value1 TODO
*/
public void setDataVector(Object[][] data, Object[] columnNames)
{
setDataVector(convertToVector(data),
convertToVector(columnNames));
}
/**
* newDataAvailable
* @param value0 TODO
*/
public void newDataAvailable(TableModelEvent event)
{
fireTableChanged(event);
}
/**
* newRowsAdded
* @param value0 TODO
*/
public void newRowsAdded(TableModelEvent event)
{
fireTableChanged(event);
}
/**
* rowsRemoved
* @param value0 TODO
*/
public void rowsRemoved(TableModelEvent event)
{
fireTableChanged(event);
}
/**
* setColumnIdentifiers
* @param value0 TODO
*/
public void setColumnIdentifiers(Vector columnIdentifiers)
{
this.columnIdentifiers = columnIdentifiers;
setColumnCount(columnIdentifiers.size());
}
/**
* setColumnIdentifiers
* @param value0 TODO
*/
public void setColumnIdentifiers(Object[] columnIdentifiers)
{
setColumnIdentifiers(convertToVector(columnIdentifiers));
}
/**
* setNumRows
* @param value0 TODO
*/
public void setNumRows(int numRows)
{
setRowCount(numRows);
}
/**
* setRowCount
* @param value0 TODO
*/
public void setRowCount(int rowCount)
{
dataVector.setSize(rowCount);
fireTableDataChanged();
}
/**
* setColumnCount
* @param value0 TODO
*/
public void setColumnCount(int columnCount)
{
for (int i = 0; i < dataVector.size(); ++i)
{
((Vector) dataVector.get(i)).setSize(columnCount);
}
columnIdentifiers.setSize(columnCount);
fireTableDataChanged();
}
/**
* addColumn
* @param value0 TODO
*/
public void addColumn(Object columnName)
{
addColumn(columnName, (Object[]) null);
}
/**
* addColumn
* @param value0 TODO
* @param value1 TODO
*/
public void addColumn(Object columnName, Vector columnData)
{
addColumn(columnName, columnData == null ? null : columnData.toArray());
}
/**
* addColumn
* @param value0 TODO
* @param value1 TODO
*/
public void addColumn(Object columnName, Object[] columnData) {
for (int i = 0; i < dataVector.size(); ++i)
{
((Vector) dataVector.get(i)).add(columnData == null ? null : columnData[i]);
}
columnIdentifiers.add(columnName);
fireTableDataChanged();
}
/**
* addRow
* @param value0 TODO
*/
public void addRow(Vector rowData) {
dataVector.add(rowData);
fireTableDataChanged();
}
/**
* addRow
* @param value0 TODO
*/
public void addRow(Object[] rowData) {
addRow(convertToVector(rowData));
}
/**
* insertRow
* @param value0 TODO
* @param value1 TODO
*/
public void insertRow(int row, Vector rowData) {
dataVector.add(row, rowData);
fireTableDataChanged();
}
/**
* insertRow
* @param value0 TODO
* @param value1 TODO
*/
public void insertRow(int row, Object[] rowData) {
insertRow(row, convertToVector(rowData));
}
/**
* moveRow
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
public void moveRow(int startIndex, int endIndex, int toIndex) {
for (int index = 0; index < (endIndex - startIndex); index++) {
Vector vector = (Vector) dataVector.remove(startIndex);
dataVector.add(toIndex, vector);
}
fireTableDataChanged();
}
/**
* removeRow
* @param value0 TODO
*/
public void removeRow(int row) {
dataVector.remove(row);
fireTableDataChanged();
}
/**
* getRowCount
* @returns int
*/
public int getRowCount() {
return dataVector.size();
}
/**
* getColumnCount
* @returns int
*/
public int getColumnCount() {
return columnIdentifiers.size();
}
/**
* getColumnName
* @param value0 TODO
* @returns String
*/
public String getColumnName(int column) {
// Check for Column
if (columnIdentifiers == null || column >= getColumnCount()) {
return super.getColumnName(column);
}
// Return Column name
return (String) columnIdentifiers.get(column);
}
/**
* isCellEditable
* @param value0 TODO
* @param value1 TODO
* @returns boolean
*/
public boolean isCellEditable(int row, int column) {
return true;
}
/**
* getValueAt
* @param value0 TODO
* @param value1 TODO
* @returns Object
*/
public Object getValueAt(int row, int column) {
return ((Vector) dataVector.get(row)).get(column);
}
/**
* setValueAt
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
public void setValueAt(Object value, int row, int column) {
((Vector) dataVector.get(row)).set(column, value);
fireTableDataChanged();
}
/**
* convertToVector
* @param value0 TODO
* @returns Vector
*/
protected static Vector convertToVector(Object[] data) {
if (data == null)
return null;
Vector vector = new Vector(data.length);
for (int i = 0; i < data.length; i++)
vector.add(data[i]);
return vector;
}
/**
* convertToVector
* @param value0 TODO
* @returns Vector
*/
protected static Vector convertToVector(Object[][] data) {
if (data == null)
return null;
Vector vector = new Vector(data.length);
for (int i = 0; i < data.length; i++)
vector.add(convertToVector(data[i]));
return vector;
}
}

View File

@ -38,26 +38,536 @@ exception statement from your version. */
package javax.swing.table;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Point;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Locale;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleAction;
import javax.accessibility.AccessibleComponent;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleSelection;
import javax.accessibility.AccessibleStateSet;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleText;
import javax.accessibility.AccessibleValue;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.plaf.TableHeaderUI;
public class JTableHeader extends JComponent
{
protected class AccessibleJTableHeader
protected class AccessibleJTableHeader extends AccessibleJComponent
{
protected class AccessibleJTableHeaderEntry
protected class AccessibleJTableHeaderEntry extends AccessibleContext
implements Accessible, AccessibleComponent
{
}
public void addFocusListener(FocusListener l)
{
throw new Error("not implemented");
}
public void addPropertyChangeListener(PropertyChangeListener l)
{
throw new Error("not implemented");
}
public boolean contains(Point p)
{
throw new Error("not implemented");
}
public AccessibleAction getAccessibleAction()
{
throw new Error("not implemented");
}
public Accessible getAccessibleAt(Point p)
{
throw new Error("not implemented");
}
public Accessible getAccessibleChild(int i)
{
throw new Error("not implemented");
}
public int getAccessibleChildrenCount()
{
throw new Error("not implemented");
}
public AccessibleComponent getAccessibleComponent()
{
throw new Error("not implemented");
}
public AccessibleContext getAccessibleContext()
{
throw new Error("not implemented");
}
public String getAccessibleDescription()
{
throw new Error("not implemented");
}
public int getAccessibleIndexInParent()
{
throw new Error("not implemented");
}
public String getAccessibleName()
{
throw new Error("not implemented");
}
public AccessibleRole getAccessibleRole()
{
throw new Error("not implemented");
}
public AccessibleSelection getAccessibleSelection()
{
throw new Error("not implemented");
}
public AccessibleStateSet getAccessibleStateSet()
{
throw new Error("not implemented");
}
public AccessibleText getAccessibleText()
{
throw new Error("not implemented");
}
public AccessibleValue getAccessibleValue()
{
throw new Error("not implemented");
}
public Color getBackground()
{
throw new Error("not implemented");
}
public Rectangle getBounds()
{
throw new Error("not implemented");
}
public Cursor getCursor()
{
throw new Error("not implemented");
}
public Font getFont()
{
throw new Error("not implemented");
}
public FontMetrics getFontMetrics(Font f)
{
throw new Error("not implemented");
}
public Color getForeground()
{
throw new Error("not implemented");
}
public Locale getLocale()
{
throw new Error("not implemented");
}
public Point getLocation()
{
throw new Error("not implemented");
}
public Point getLocationOnScreen()
{
throw new Error("not implemented");
}
public Dimension getSize()
{
throw new Error("not implemented");
}
public boolean isEnabled()
{
throw new Error("not implemented");
}
public boolean isFocusTraversable()
{
throw new Error("not implemented");
}
public boolean isShowing()
{
throw new Error("not implemented");
}
public boolean isVisible()
{
throw new Error("not implemented");
}
public void removeFocusListener(FocusListener l)
{
throw new Error("not implemented");
}
public void removePropertyChangeListener(PropertyChangeListener l)
{
throw new Error("not implemented");
}
public void requestFocus()
{
throw new Error("not implemented");
}
public void setAccessibleDescription(String s)
{
throw new Error("not implemented");
}
public void setAccessibleName(String s)
{
throw new Error("not implemented");
}
public void setBackground(Color c)
{
throw new Error("not implemented");
}
public void setBounds(Rectangle r)
{
throw new Error("not implemented");
}
public void setCursor(Cursor c)
{
throw new Error("not implemented");
}
public void setEnabled(boolean b)
{
throw new Error("not implemented");
}
public void setFont(Font f)
{
throw new Error("not implemented");
}
public void setForeground(Color c)
{
throw new Error("not implemented");
}
public void setLocation(Point p)
{
throw new Error("not implemented");
}
public void setSize(Dimension d)
{
throw new Error("not implemented");
}
public void setVisible(boolean b)
{
throw new Error("not implemented");
}
};
}
private static final long serialVersionUID = 5144633983372967710L;
protected TableColumnModel columnModel;
protected TableColumn draggedColumn;
protected int draggedDistance;
protected boolean reorderingAllowed;
protected boolean resizingAllowed;
protected TableColumn resizingColumn;
protected JTable table;
protected boolean updateTableInRealTime;
/**
* The accessibleContext property.
*/
AccessibleContext accessibleContext;
/**
* The columnModel property.
*/
TableColumnModel columnModel;
/**
* The draggedColumn property.
*/
TableColumn draggedColumn;
/**
* The draggedDistance property.
*/
int draggedDistance;
/**
* The opaque property.
*/
boolean opaque;
/**
* The reorderingAllowed property.
*/
boolean reorderingAllowed;
/**
* The resizingAllowed property.
*/
boolean resizingAllowed;
/**
* The resizingColumn property.
*/
TableColumn resizingColumn;
/**
* The table property.
*/
JTable table;
/**
* The updateTableInRealTime property.
*/
boolean updateTableInRealTime;
TableCellRenderer cellRenderer;
public JTableHeader()
{
this(null);
}
public JTableHeader(TableColumnModel cm)
{
accessibleContext = new AccessibleJTableHeader();
columnModel = cm == null ? createDefaultTableColumnModel() : cm;
draggedColumn = null;
draggedDistance = 0;
opaque = true;
reorderingAllowed = true;
resizingAllowed = true;
resizingColumn = null;
table = null;
updateTableInRealTime = true;
cellRenderer = createDefaultRenderer();
updateUI();
}
protected TableColumnModel createDefaultTableColumnModel()
{
return new DefaultTableColumnModel();
}
/**
* Get the value of the {@link #accessibleContext} property.
*
* @return The current value of the property
*/
public AccessibleContext getAccessibleContext()
{
return accessibleContext;
}
/**
* Get the value of the {@link #columnModel} property.
*
* @return The current value of the property
*/
public TableColumnModel getColumnModel()
{
return columnModel;
}
/**
* Get the value of the {@link #draggedColumn} property.
*
* @return The current value of the property
*/
public TableColumn getDraggedColumn()
{
return draggedColumn;
}
/**
* Get the value of the {@link #draggedDistance} property.
*
* @return The current value of the property
*/
public int getDraggedDistance()
{
return draggedDistance;
}
/**
* Get the value of the {@link #reorderingAllowed} property.
*
* @return The current value of the property
*/
public boolean getReorderingAllowed()
{
return reorderingAllowed;
}
/**
* Get the value of the {@link #resizingAllowed} property.
*
* @return The current value of the property
*/
public boolean getResizingAllowed()
{
return resizingAllowed;
}
/**
* Get the value of the {@link #resizingColumn} property.
*
* @return The current value of the property
*/
public TableColumn getResizingColumn()
{
return resizingColumn;
}
/**
* Get the value of the {@link #table} property.
*
* @return The current value of the property
*/
public JTable getTable()
{
return table;
}
/**
* Get the value of the {@link #updateTableInRealTime} property.
*
* @return The current value of the property
*/
public boolean getUpdateTableInRealTime()
{
return updateTableInRealTime;
}
/**
* Get the value of the {@link #opaque} property.
*
* @return The current value of the property
*/
public boolean isOpaque()
{
return opaque;
}
/**
* Set the value of the {@link #columnModel} property.
*
* @param c The new value of the property
*/
public void setColumnModel(TableColumnModel c)
{
columnModel = c;
}
/**
* Set the value of the {@link #draggedColumn} property.
*
* @param d The new value of the property
*/
public void setDraggedColumn(TableColumn d)
{
draggedColumn = d;
}
/**
* Set the value of the {@link #draggedDistance} property.
*
* @param d The new value of the property
*/
public void setDraggedDistance(int d)
{
draggedDistance = d;
}
/**
* Set the value of the {@link #opaque} property.
*
* @param o The new value of the property
*/
public void setOpaque(boolean o)
{
opaque = o;
}
/**
* Set the value of the {@link #reorderingAllowed} property.
*
* @param r The new value of the property
*/
public void setReorderingAllowed(boolean r)
{
reorderingAllowed = r;
}
/**
* Set the value of the {@link #resizingAllowed} property.
*
* @param r The new value of the property
*/
public void setResizingAllowed(boolean r)
{
resizingAllowed = r;
}
/**
* Set the value of the {@link #resizingColumn} property.
*
* @param r The new value of the property
*/
public void setResizingColumn(TableColumn r)
{
resizingColumn = r;
}
/**
* Set the value of the {@link #table} property.
*
* @param t The new value of the property
*/
public void setTable(JTable t)
{
table = t;
}
/**
* Set the value of the {@link #updateTableInRealTime} property.
*
* @param u The new value of the property
*/
public void setUpdateTableInRealTime(boolean u)
{
updateTableInRealTime = u;
}
protected TableCellRenderer createDefaultRenderer()
{
return new DefaultTableCellRenderer();
}
public TableCellRenderer getDefaultRenderer()
{
return cellRenderer;
}
public Rectangle getHeaderRect(int column)
{
Rectangle r = getTable().getCellRect(-1, column, true);
r.height = getHeight();
return r;
}
protected String paramString()
{
return "JTableHeader";
}
// UI support
public String getUIClassID()
{
return "TableHeaderUI";
}
public TableHeaderUI getUI()
{
return (TableHeaderUI) ui;
}
public void setUI(TableHeaderUI u)
{
super.setUI(u);
}
public void updateUI()
{
setUI((TableHeaderUI) UIManager.getUI(this));
}
}

View File

@ -285,23 +285,19 @@ public class TableColumn
return headerValue;
}
/**
* setHeaderRenderer
* @param headerRenderer TODO
*/
public void setHeaderRenderer(TableCellRenderer headerRenderer)
/**
* setHeaderRenderer
* @param headerRenderer TODO
*/
public void setHeaderRenderer(TableCellRenderer renderer)
{
// Variables
TableCellRenderer oldRenderer;
// Get Old Renderer
oldRenderer = this.headerRenderer;
// Set Property
this.headerRenderer = headerRenderer;
// Notify Listeners of change
firePropertyChange(HEADER_RENDERER_PROPERTY, oldRenderer, headerRenderer);
if (headerRenderer == renderer)
return;
TableCellRenderer oldRenderer = headerRenderer;
headerRenderer = renderer;
firePropertyChange(HEADER_RENDERER_PROPERTY,
oldRenderer, headerRenderer);
}
/**
@ -313,23 +309,19 @@ public class TableColumn
return headerRenderer;
}
/**
* setCellRenderer
* @param cellRenderer TODO
*/
public void setCellRenderer(TableCellRenderer cellRenderer)
/**
* setCellRenderer
* @param cellRenderer TODO
*/
public void setCellRenderer(TableCellRenderer renderer)
{
// Variables
TableCellRenderer oldRenderer;
// Get Old Renderer
oldRenderer = this.cellRenderer;
// Set Property
this.cellRenderer = cellRenderer;
// Notify Listeners of change
firePropertyChange(CELL_RENDERER_PROPERTY, oldRenderer, cellRenderer);
if (cellRenderer == renderer)
return;
TableCellRenderer oldRenderer = cellRenderer;
cellRenderer = renderer;
firePropertyChange(CELL_RENDERER_PROPERTY,
oldRenderer, cellRenderer);
}
/**
@ -359,27 +351,25 @@ public class TableColumn
return cellEditor;
}
/**
* setWidth
* @param width TODO
*/
public void setWidth(int width)
/**
* setWidth
* @param newWidth TODO
*/
public void setWidth(int newWidth)
{
// Variables
int oldWidth;
int oldWidth = width;
// Get Old Width
oldWidth = this.width;
// Adjust Width within Limits
if (width < minWidth)
this.width = minWidth;
else if (width > maxWidth)
this.width = maxWidth;
if (newWidth < minWidth)
width = minWidth;
else if (newWidth > maxWidth)
width = maxWidth;
else
this.width = width;
width = newWidth;
firePropertyChange(COLUMN_WIDTH_PROPERTY, oldWidth, this.width);
if (width == oldWidth)
return;
firePropertyChange(COLUMN_WIDTH_PROPERTY, oldWidth, width);
}
/**

View File

@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing.text;
import java.io.Serializable;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.EventListener;
@ -63,33 +64,37 @@ public abstract class AbstractDocument
public static final String ParagraphElementName = "paragraph";
public static final String SectionElementName = "section";
public static final String ElementNameAttribute = "$ename";
Content content;
AttributeContext context;
protected EventListenerList listenerList = new EventListenerList();
protected AbstractDocument(Content doc)
{
this(doc, null);
this(doc, StyleContext.getDefaultStyleContext());
}
protected AbstractDocument(Content doc, AttributeContext context)
protected AbstractDocument(Content doc, AttributeContext ctx)
{
content = doc;
context = ctx;
}
// these still need to be implemented by a derived class:
// These still need to be implemented by a derived class:
public abstract Element getParagraphElement(int pos);
public abstract Element getDefaultRootElement();
protected Element createBranchElement(Element parent, AttributeSet a)
protected Element createBranchElement(Element parent,
AttributeSet attributes)
{
return new BranchElement(parent, a, 0, 0);
return new BranchElement(parent, attributes);
}
protected Element createLeafElement(Element parent, AttributeSet a, int p0,
int p1)
protected Element createLeafElement(Element parent, AttributeSet attributes,
int start, int end)
{
return new LeafElement(parent, a, p0, p1 - p0);
return new LeafElement(parent, attributes, start, end);
}
public Position createPosition(final int offset) throws BadLocationException
@ -145,7 +150,7 @@ public abstract class AbstractDocument
protected AttributeContext getAttributeContext()
{
return null;
return context;
}
public Element getBidiRootElement()
@ -170,7 +175,13 @@ public abstract class AbstractDocument
public Position getEndPosition()
{
return null;
return new Position()
{
public int getOffset()
{
return getLength();
}
};
}
public int getLength()
@ -190,12 +201,20 @@ public abstract class AbstractDocument
public Element[] getRootElements()
{
return null;
Element[] elements = new Element[1];
elements[0] = getDefaultRootElement();
return elements;
}
public Position getStartPosition()
{
return null;
return new Position()
{
public int getOffset()
{
return 0;
}
};
}
public String getText(int offset, int length) throws BadLocationException
@ -203,34 +222,25 @@ public abstract class AbstractDocument
return content.getString(offset, length);
}
public void getText(int offset, int length, Segment txt)
public void getText(int offset, int length, Segment segment)
throws BadLocationException
{
String a = getText(offset, length);
if (a == null)
{
txt.offset = 0;
txt.count = 0;
txt.array = new char[0];
return;
}
txt.offset = offset;
txt.count = length;
char[] chars = new char[a.length()];
a.getChars(0, a.length(), chars, 0);
txt.array = chars;
content.getChars(offset, length, segment);
}
public void insertString(int offs, String str, AttributeSet a)
public void insertString(int offset, String text, AttributeSet attributes)
throws BadLocationException
{
content.insertString(offs, str);
// Just return when no text to insert was given.
if (text == null || text.length() == 0)
return;
DefaultDocumentEvent event =
new DefaultDocumentEvent(offset, text.length(),
DocumentEvent.EventType.INSERT);
content.insertString(offset, text);
insertUpdate(event, attributes);
fireInsertUpdate(event);
}
protected void insertUpdate(DefaultDocumentEvent chng, AttributeSet attr)
@ -255,6 +265,26 @@ public abstract class AbstractDocument
public void remove(int offset, int length) throws BadLocationException
{
DefaultDocumentEvent event =
new DefaultDocumentEvent(offset, length,
DocumentEvent.EventType.REMOVE);
removeUpdate(event);
content.remove(offset, length);
postRemoveUpdate(event);
fireRemoveUpdate(event);
}
/**
* Replaces some text in the document.
*
* @since 1.4
*/
public void replace(int offset, int length, String text,
AttributeSet attributes)
throws BadLocationException
{
remove(offset, length);
insertString(offset, text, attributes);
}
/**
@ -375,47 +405,51 @@ public abstract class AbstractDocument
}
public abstract class AbstractElement
implements Element, TreeNode, Serializable
implements Element, MutableAttributeSet, TreeNode, Serializable
{
private static final long serialVersionUID = 1265312733007397733L;
int count;
int offset;
AttributeSet attr;
Vector elts = new Vector();
String name;
Element parent;
Vector kids = new Vector();
AttributeSet attributes;
Element element_parent;
Vector element_children;
TreeNode tree_parent;
Vector tree_children;
public AbstractElement(Element p, AttributeSet s)
{
parent = p;
attr = s;
element_parent = p;
attributes = s;
}
// TreeNode implementation
public Enumeration children()
{
return kids.elements();
return Collections.enumeration(tree_children);
}
public boolean getAllowsChildren()
{
return true;
}
public TreeNode getChildAt(int index)
{
return (TreeNode) kids.elementAt(index);
return (TreeNode) tree_children.get(index);
}
public int getChildCount()
{
return kids.size();
return tree_children.size();
}
public int getIndex(TreeNode node)
{
return kids.indexOf(node);
return tree_children.indexOf(node);
}
public TreeNode getParent()
@ -423,55 +457,134 @@ public abstract class AbstractDocument
return tree_parent;
}
public abstract boolean isLeaf();
// MutableAttributeSet support
public void addAttribute(Object name, Object value)
{
attributes = getAttributeContext().addAttribute(attributes, name, value);
}
public void addAttributes(AttributeSet attrs)
{
attributes = getAttributeContext().addAttributes(attributes, attrs);
}
public void removeAttribute(Object name)
{
attributes = getAttributeContext().removeAttribute(attributes, name);
}
public void removeAttributes(AttributeSet attrs)
{
attributes = getAttributeContext().removeAttributes(attributes, attrs);
}
public void removeAttributes(Enumeration names)
{
attributes = getAttributeContext().removeAttributes(attributes, names);
}
public void setResolveParent(AttributeSet parent)
{
attributes = getAttributeContext().addAttribute(attributes, ResolveAttribute, parent);
}
// AttributeSet interface support
public boolean containsAttribute(Object name, Object value)
{
return attributes.containsAttribute(name, value);
}
public boolean containsAttributes(AttributeSet attrs)
{
return attributes.containsAttributes(attrs);
}
public AttributeSet copyAttributes()
{
return attributes.copyAttributes();
}
public Object getAttribute(Object key)
{
return attributes.getAttribute(key);
}
public int getAttributeCount()
{
return attributes.getAttributeCount();
}
public Enumeration getAttributeNames()
{
return attributes.getAttributeNames();
}
public AttributeSet getResolveParent()
{
return attributes.getResolveParent();
}
public boolean isDefined(Object attrName)
{
return attributes.isDefined(attrName);
}
public boolean isEqual(AttributeSet attrs)
{
return attributes.isEqual(attrs);
}
// Element interface support
public AttributeSet getAttributes()
{
return attr;
return attributes;
}
public Document getDocument()
{
return AbstractDocument.this;
}
public Element getElement(int index)
{
return (Element) elts.elementAt(index);
return (Element) element_children.get(index);
}
public String getName()
{
return name;
return (String) getAttribute(NameAttribute);
}
public Element getParentElement()
{
return parent;
return element_parent;
}
public abstract boolean isLeaf();
public abstract int getEndOffset();
public abstract int getElementCount();
public abstract int getElementIndex(int offset);
public abstract int getStartOffset();
}
public class BranchElement extends AbstractElement
{
private static final long serialVersionUID = -8595176318868717313L;
private int start;
private int end;
private Vector children = new Vector();
public BranchElement(Element parent, AttributeSet attributes, int start,
int end)
public BranchElement(Element parent, AttributeSet attributes)
{
super(parent, attributes);
this.start = start;
this.end = end;
}
public Enumeration children()
@ -486,6 +599,9 @@ public abstract class AbstractDocument
public Element getElement(int index)
{
if (index < 0 || index >= children.size())
return null;
return (Element) children.get(index);
}
@ -496,12 +612,20 @@ public abstract class AbstractDocument
public int getElementIndex(int offset)
{
return children.indexOf(positionToElement(offset));
if (children.size() == 0)
return 0;
Element element = positionToElement(offset);
if (element == null)
return 0;
return children.indexOf(element);
}
public int getEndOffset()
{
return end;
return ((Element) children.lastElement()).getEndOffset();
}
public String getName()
@ -511,7 +635,7 @@ public abstract class AbstractDocument
public int getStartOffset()
{
return start;
return ((Element) children.firstElement()).getStartOffset();
}
public boolean isLeaf()
@ -554,8 +678,18 @@ public abstract class AbstractDocument
implements DocumentEvent
{
private static final long serialVersionUID = -7406103236022413522L;
public int len;
public int off;
private int offset;
private int length;
private DocumentEvent.EventType type;
public DefaultDocumentEvent(int offset, int length,
DocumentEvent.EventType type)
{
this.offset = offset;
this.length = length;
this.type = type;
}
public Document getDocument()
{
@ -564,17 +698,17 @@ public abstract class AbstractDocument
public int getLength()
{
return len;
return length;
}
public int getOffset()
{
return off;
return offset;
}
public DocumentEvent.EventType getType()
{
return null;
return type;
}
public DocumentEvent.ElementChange getChange(Element elem)
@ -584,8 +718,43 @@ public abstract class AbstractDocument
}
public static class ElementEdit extends AbstractUndoableEdit
implements DocumentEvent.ElementChange
{
private static final long serialVersionUID = -1216620962142928304L;
private Element elem;
private int index;
private Element[] removed;
private Element[] added;
public ElementEdit(Element elem, int index,
Element[] removed, Element[] added)
{
this.elem = elem;
this.index = index;
this.removed = removed;
this.added = added;
}
public Element[] getChildrenAdded()
{
return added;
}
public Element[] getChildrenRemoved()
{
return removed;
}
public Element getElement()
{
return elem;
}
public int getIndex()
{
return index;
}
}
public class LeafElement extends AbstractElement

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