summaryrefslogtreecommitdiff
path: root/javax/swing
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing')
-rw-r--r--javax/swing/AbstractAction.java64
-rw-r--r--javax/swing/AbstractButton.java329
-rw-r--r--javax/swing/AbstractCellEditor.java17
-rw-r--r--javax/swing/AbstractListModel.java17
-rw-r--r--javax/swing/AbstractSpinnerModel.java11
-rw-r--r--javax/swing/Action.java197
-rw-r--r--javax/swing/ActionMap.java12
-rw-r--r--javax/swing/BorderFactory.java257
-rw-r--r--javax/swing/BoundedRangeModel.java63
-rw-r--r--javax/swing/Box.java17
-rw-r--r--javax/swing/BoxLayout.java592
-rw-r--r--javax/swing/ButtonGroup.java42
-rw-r--r--javax/swing/ButtonModel.java7
-rw-r--r--javax/swing/CellEditor.java11
-rw-r--r--javax/swing/CellRendererPane.java23
-rw-r--r--javax/swing/ComboBoxEditor.java7
-rw-r--r--javax/swing/ComboBoxModel.java9
-rw-r--r--javax/swing/ComponentInputMap.java13
-rw-r--r--javax/swing/DebugGraphics.java58
-rw-r--r--javax/swing/DefaultBoundedRangeModel.java91
-rw-r--r--javax/swing/DefaultButtonModel.java175
-rw-r--r--javax/swing/DefaultCellEditor.java438
-rw-r--r--javax/swing/DefaultComboBoxModel.java13
-rw-r--r--javax/swing/DefaultDesktopManager.java204
-rw-r--r--javax/swing/DefaultFocusManager.java193
-rw-r--r--javax/swing/DefaultListCellRenderer.java28
-rw-r--r--javax/swing/DefaultListModel.java78
-rw-r--r--javax/swing/DefaultListSelectionModel.java170
-rw-r--r--javax/swing/DefaultSingleSelectionModel.java7
-rw-r--r--javax/swing/DesktopManager.java4
-rw-r--r--javax/swing/FocusManager.java54
-rw-r--r--javax/swing/GrayFilter.java29
-rw-r--r--javax/swing/Icon.java31
-rw-r--r--javax/swing/ImageIcon.java25
-rw-r--r--javax/swing/InputMap.java16
-rw-r--r--javax/swing/InputVerifier.java11
-rw-r--r--javax/swing/InternalFrameFocusTraversalPolicy.java11
-rw-r--r--javax/swing/JApplet.java56
-rw-r--r--javax/swing/JButton.java62
-rw-r--r--javax/swing/JCheckBox.java19
-rw-r--r--javax/swing/JCheckBoxMenuItem.java33
-rw-r--r--javax/swing/JColorChooser.java70
-rw-r--r--javax/swing/JComboBox.java240
-rw-r--r--javax/swing/JComponent.java313
-rw-r--r--javax/swing/JDesktopPane.java31
-rw-r--r--javax/swing/JDialog.java75
-rw-r--r--javax/swing/JEditorPane.java10
-rw-r--r--javax/swing/JFileChooser.java10
-rw-r--r--javax/swing/JFormattedTextField.java57
-rw-r--r--javax/swing/JFrame.java84
-rw-r--r--javax/swing/JInternalFrame.java71
-rw-r--r--javax/swing/JLabel.java271
-rw-r--r--javax/swing/JLayeredPane.java70
-rw-r--r--javax/swing/JList.java6
-rw-r--r--javax/swing/JMenu.java83
-rw-r--r--javax/swing/JMenuBar.java6
-rw-r--r--javax/swing/JMenuItem.java18
-rw-r--r--javax/swing/JOptionPane.java64
-rw-r--r--javax/swing/JPanel.java4
-rw-r--r--javax/swing/JPasswordField.java4
-rw-r--r--javax/swing/JPopupMenu.java10
-rw-r--r--javax/swing/JProgressBar.java20
-rw-r--r--javax/swing/JRadioButton.java6
-rw-r--r--javax/swing/JRadioButtonMenuItem.java4
-rw-r--r--javax/swing/JRootPane.java4
-rw-r--r--javax/swing/JScrollBar.java6
-rw-r--r--javax/swing/JScrollPane.java56
-rw-r--r--javax/swing/JSeparator.java6
-rw-r--r--javax/swing/JSlider.java70
-rw-r--r--javax/swing/JSpinner.java185
-rw-r--r--javax/swing/JSplitPane.java6
-rw-r--r--javax/swing/JTabbedPane.java6
-rw-r--r--javax/swing/JTable.java258
-rw-r--r--javax/swing/JTextArea.java44
-rw-r--r--javax/swing/JTextField.java6
-rw-r--r--javax/swing/JTextPane.java595
-rw-r--r--javax/swing/JToggleButton.java51
-rw-r--r--javax/swing/JToolBar.java4
-rw-r--r--javax/swing/JToolTip.java4
-rw-r--r--javax/swing/JTree.java3446
-rw-r--r--javax/swing/JViewport.java49
-rw-r--r--javax/swing/JWindow.java52
-rw-r--r--javax/swing/KeyStroke.java4
-rw-r--r--javax/swing/LayoutFocusTraversalPolicy.java4
-rw-r--r--javax/swing/ListCellRenderer.java7
-rw-r--r--javax/swing/ListModel.java7
-rw-r--r--javax/swing/ListSelectionModel.java8
-rw-r--r--javax/swing/LookAndFeel.java41
-rw-r--r--javax/swing/MenuElement.java11
-rw-r--r--javax/swing/MenuSelectionManager.java21
-rw-r--r--javax/swing/MutableComboBoxModel.java11
-rw-r--r--javax/swing/OverlayLayout.java4
-rw-r--r--javax/swing/Popup.java4
-rw-r--r--javax/swing/PopupFactory.java4
-rw-r--r--javax/swing/ProgressMonitor.java4
-rw-r--r--javax/swing/ProgressMonitorInputStream.java4
-rw-r--r--javax/swing/Renderer.java15
-rw-r--r--javax/swing/RepaintManager.java13
-rw-r--r--javax/swing/RootPaneContainer.java12
-rw-r--r--javax/swing/ScrollPaneConstants.java11
-rw-r--r--javax/swing/ScrollPaneLayout.java4
-rw-r--r--javax/swing/Scrollable.java10
-rw-r--r--javax/swing/SingleSelectionModel.java12
-rw-r--r--javax/swing/SizeRequirements.java5
-rw-r--r--javax/swing/SizeSequence.java4
-rw-r--r--javax/swing/SortingFocusTraversalPolicy.java14
-rw-r--r--javax/swing/SpinnerDateModel.java4
-rw-r--r--javax/swing/SpinnerListModel.java6
-rw-r--r--javax/swing/SpinnerModel.java6
-rw-r--r--javax/swing/SpinnerNumberModel.java4
-rw-r--r--javax/swing/Spring.java10
-rw-r--r--javax/swing/SpringLayout.java14
-rw-r--r--javax/swing/SwingConstants.java7
-rw-r--r--javax/swing/SwingUtilities.java12
-rw-r--r--javax/swing/Timer.java4
-rw-r--r--javax/swing/ToolTipManager.java8
-rw-r--r--javax/swing/TransferHandler.java4
-rw-r--r--javax/swing/UIDefaults.java54
-rw-r--r--javax/swing/UIManager.java4
-rw-r--r--javax/swing/UnsupportedLookAndFeelException.java4
-rw-r--r--javax/swing/ViewportLayout.java4
-rw-r--r--javax/swing/WindowConstants.java11
-rw-r--r--javax/swing/border/AbstractBorder.java6
-rw-r--r--javax/swing/border/BevelBorder.java8
-rw-r--r--javax/swing/border/Border.java4
-rw-r--r--javax/swing/border/CompoundBorder.java4
-rw-r--r--javax/swing/border/EmptyBorder.java4
-rw-r--r--javax/swing/border/EtchedBorder.java6
-rw-r--r--javax/swing/border/LineBorder.java6
-rw-r--r--javax/swing/border/MatteBorder.java4
-rw-r--r--javax/swing/border/SoftBevelBorder.java8
-rw-r--r--javax/swing/border/TitledBorder.java10
-rw-r--r--javax/swing/border/package.html7
-rw-r--r--javax/swing/colorchooser/AbstractColorChooserPanel.java4
-rw-r--r--javax/swing/colorchooser/ColorChooserComponentFactory.java4
-rw-r--r--javax/swing/colorchooser/ColorSelectionModel.java4
-rw-r--r--javax/swing/colorchooser/DefaultColorSelectionModel.java4
-rw-r--r--javax/swing/colorchooser/DefaultHSBChooserPanel.java4
-rw-r--r--javax/swing/colorchooser/DefaultPreviewPanel.java4
-rw-r--r--javax/swing/colorchooser/DefaultRGBChooserPanel.java4
-rw-r--r--javax/swing/colorchooser/DefaultSwatchChooserPanel.java4
-rw-r--r--javax/swing/colorchooser/package.html9
-rw-r--r--javax/swing/event/AncestorEvent.java4
-rw-r--r--javax/swing/event/AncestorListener.java4
-rw-r--r--javax/swing/event/CaretEvent.java4
-rw-r--r--javax/swing/event/CaretListener.java4
-rw-r--r--javax/swing/event/CellEditorListener.java4
-rw-r--r--javax/swing/event/ChangeEvent.java4
-rw-r--r--javax/swing/event/ChangeListener.java4
-rw-r--r--javax/swing/event/DocumentEvent.java4
-rw-r--r--javax/swing/event/DocumentListener.java4
-rw-r--r--javax/swing/event/EventListenerList.java8
-rw-r--r--javax/swing/event/HyperlinkEvent.java4
-rw-r--r--javax/swing/event/HyperlinkListener.java4
-rw-r--r--javax/swing/event/InternalFrameAdapter.java4
-rw-r--r--javax/swing/event/InternalFrameEvent.java4
-rw-r--r--javax/swing/event/InternalFrameListener.java4
-rw-r--r--javax/swing/event/ListDataEvent.java4
-rw-r--r--javax/swing/event/ListDataListener.java4
-rw-r--r--javax/swing/event/ListSelectionEvent.java4
-rw-r--r--javax/swing/event/ListSelectionListener.java4
-rw-r--r--javax/swing/event/MenuDragMouseEvent.java4
-rw-r--r--javax/swing/event/MenuDragMouseListener.java4
-rw-r--r--javax/swing/event/MenuEvent.java4
-rw-r--r--javax/swing/event/MenuKeyEvent.java6
-rw-r--r--javax/swing/event/MenuKeyListener.java4
-rw-r--r--javax/swing/event/MenuListener.java4
-rw-r--r--javax/swing/event/MouseInputAdapter.java4
-rw-r--r--javax/swing/event/MouseInputListener.java4
-rw-r--r--javax/swing/event/PopupMenuEvent.java4
-rw-r--r--javax/swing/event/PopupMenuListener.java4
-rw-r--r--javax/swing/event/SwingPropertyChangeSupport.java4
-rw-r--r--javax/swing/event/TableColumnModelEvent.java4
-rw-r--r--javax/swing/event/TableColumnModelListener.java4
-rw-r--r--javax/swing/event/TableModelEvent.java116
-rw-r--r--javax/swing/event/TableModelListener.java4
-rw-r--r--javax/swing/event/TreeExpansionEvent.java4
-rw-r--r--javax/swing/event/TreeExpansionListener.java4
-rw-r--r--javax/swing/event/TreeModelEvent.java4
-rw-r--r--javax/swing/event/TreeModelListener.java4
-rw-r--r--javax/swing/event/TreeSelectionEvent.java287
-rw-r--r--javax/swing/event/TreeSelectionListener.java4
-rw-r--r--javax/swing/event/TreeWillExpandListener.java4
-rw-r--r--javax/swing/event/UndoableEditEvent.java4
-rw-r--r--javax/swing/event/UndoableEditListener.java4
-rw-r--r--javax/swing/event/package.html9
-rw-r--r--javax/swing/filechooser/FileFilter.java4
-rw-r--r--javax/swing/filechooser/FileSystemView.java6
-rw-r--r--javax/swing/filechooser/FileView.java4
-rw-r--r--javax/swing/filechooser/UnixFileSystemView.java4
-rw-r--r--javax/swing/filechooser/package.html9
-rw-r--r--javax/swing/package.html9
-rw-r--r--javax/swing/plaf/ActionMapUIResource.java4
-rw-r--r--javax/swing/plaf/BorderUIResource.java8
-rw-r--r--javax/swing/plaf/ButtonUI.java4
-rw-r--r--javax/swing/plaf/ColorChooserUI.java4
-rw-r--r--javax/swing/plaf/ColorUIResource.java19
-rw-r--r--javax/swing/plaf/ComboBoxUI.java4
-rw-r--r--javax/swing/plaf/ComponentInputMapUIResource.java4
-rw-r--r--javax/swing/plaf/ComponentUI.java4
-rw-r--r--javax/swing/plaf/DesktopIconUI.java4
-rw-r--r--javax/swing/plaf/DesktopPaneUI.java4
-rw-r--r--javax/swing/plaf/DimensionUIResource.java4
-rw-r--r--javax/swing/plaf/FileChooserUI.java8
-rw-r--r--javax/swing/plaf/FontUIResource.java4
-rw-r--r--javax/swing/plaf/IconUIResource.java4
-rw-r--r--javax/swing/plaf/InputMapUIResource.java4
-rw-r--r--javax/swing/plaf/InsetsUIResource.java4
-rw-r--r--javax/swing/plaf/InternalFrameUI.java4
-rw-r--r--javax/swing/plaf/LabelUI.java4
-rw-r--r--javax/swing/plaf/ListUI.java8
-rw-r--r--javax/swing/plaf/MenuBarUI.java4
-rw-r--r--javax/swing/plaf/MenuItemUI.java4
-rw-r--r--javax/swing/plaf/OptionPaneUI.java4
-rw-r--r--javax/swing/plaf/PanelUI.java4
-rw-r--r--javax/swing/plaf/PopupMenuUI.java4
-rw-r--r--javax/swing/plaf/ProgressBarUI.java4
-rw-r--r--javax/swing/plaf/RootPaneUI.java4
-rw-r--r--javax/swing/plaf/ScrollBarUI.java4
-rw-r--r--javax/swing/plaf/ScrollPaneUI.java4
-rw-r--r--javax/swing/plaf/SeparatorUI.java4
-rw-r--r--javax/swing/plaf/SliderUI.java4
-rw-r--r--javax/swing/plaf/SpinnerUI.java4
-rw-r--r--javax/swing/plaf/SplitPaneUI.java4
-rw-r--r--javax/swing/plaf/TabbedPaneUI.java4
-rw-r--r--javax/swing/plaf/TableHeaderUI.java4
-rw-r--r--javax/swing/plaf/TableUI.java4
-rw-r--r--javax/swing/plaf/TextUI.java19
-rw-r--r--javax/swing/plaf/ToolBarUI.java4
-rw-r--r--javax/swing/plaf/ToolTipUI.java4
-rw-r--r--javax/swing/plaf/TreeUI.java4
-rw-r--r--javax/swing/plaf/UIResource.java8
-rw-r--r--javax/swing/plaf/ViewportUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicArrowButton.java4
-rw-r--r--javax/swing/plaf/basic/BasicBorders.java47
-rw-r--r--javax/swing/plaf/basic/BasicButtonListener.java7
-rw-r--r--javax/swing/plaf/basic/BasicButtonUI.java24
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicColorChooserUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxEditor.java17
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxRenderer.java4
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicComboPopup.java4
-rw-r--r--javax/swing/plaf/basic/BasicDesktopIconUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicDesktopPaneUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicDirectoryModel.java4
-rw-r--r--javax/swing/plaf/basic/BasicEditorPaneUI.java43
-rw-r--r--javax/swing/plaf/basic/BasicFileChooserUI.java69
-rw-r--r--javax/swing/plaf/basic/BasicFormattedTextFieldUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicGraphicsUtils.java10
-rw-r--r--javax/swing/plaf/basic/BasicIconFactory.java219
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameTitlePane.java222
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameUI.java90
-rw-r--r--javax/swing/plaf/basic/BasicLabelUI.java10
-rw-r--r--javax/swing/plaf/basic/BasicListUI.java206
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java142
-rw-r--r--javax/swing/plaf/basic/BasicMenuBarUI.java7
-rw-r--r--javax/swing/plaf/basic/BasicMenuItemUI.java28
-rw-r--r--javax/swing/plaf/basic/BasicMenuUI.java46
-rw-r--r--javax/swing/plaf/basic/BasicOptionPaneUI.java21
-rw-r--r--javax/swing/plaf/basic/BasicPanelUI.java37
-rw-r--r--javax/swing/plaf/basic/BasicPasswordFieldUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicPopupMenuUI.java14
-rw-r--r--javax/swing/plaf/basic/BasicProgressBarUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java109
-rw-r--r--javax/swing/plaf/basic/BasicRootPaneUI.java5
-rw-r--r--javax/swing/plaf/basic/BasicScrollBarUI.java12
-rw-r--r--javax/swing/plaf/basic/BasicScrollPaneUI.java12
-rw-r--r--javax/swing/plaf/basic/BasicSeparatorUI.java6
-rw-r--r--javax/swing/plaf/basic/BasicSliderUI.java274
-rw-r--r--javax/swing/plaf/basic/BasicSpinnerUI.java9
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneDivider.java6
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneUI.java19
-rw-r--r--javax/swing/plaf/basic/BasicTabbedPaneUI.java18
-rw-r--r--javax/swing/plaf/basic/BasicTableHeaderUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java488
-rw-r--r--javax/swing/plaf/basic/BasicTextAreaUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicTextFieldUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicTextPaneUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java425
-rw-r--r--javax/swing/plaf/basic/BasicToggleButtonUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicToolBarSeparatorUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicToolBarUI.java17
-rw-r--r--javax/swing/plaf/basic/BasicToolTipUI.java6
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java2955
-rw-r--r--javax/swing/plaf/basic/BasicViewportUI.java4
-rw-r--r--javax/swing/plaf/basic/ComboPopup.java4
-rw-r--r--javax/swing/plaf/basic/DefaultMenuLayout.java4
-rw-r--r--javax/swing/plaf/basic/package.html8
-rw-r--r--javax/swing/plaf/metal/DefaultMetalTheme.java86
-rw-r--r--javax/swing/plaf/metal/MetalBorders.java177
-rw-r--r--javax/swing/plaf/metal/MetalButtonUI.java54
-rw-r--r--javax/swing/plaf/metal/MetalCheckBoxIcon.java136
-rw-r--r--javax/swing/plaf/metal/MetalCheckBoxUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalComboBoxIcon.java100
-rw-r--r--javax/swing/plaf/metal/MetalComboBoxUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalDesktopIconUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalIconFactory.java786
-rw-r--r--javax/swing/plaf/metal/MetalInternalFrameUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalLabelUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalLookAndFeel.java377
-rw-r--r--javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalProgressBarUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalRadioButtonUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalRootPaneUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalScrollBarUI.java29
-rw-r--r--javax/swing/plaf/metal/MetalScrollPaneUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalSeparatorUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalSliderUI.java267
-rw-r--r--javax/swing/plaf/metal/MetalSplitPaneDivider.java84
-rw-r--r--javax/swing/plaf/metal/MetalSplitPaneUI.java24
-rw-r--r--javax/swing/plaf/metal/MetalTabbedPaneUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalTextFieldUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalTheme.java327
-rw-r--r--javax/swing/plaf/metal/MetalToggleButtonUI.java55
-rw-r--r--javax/swing/plaf/metal/MetalToolBarUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalToolTipUI.java4
-rw-r--r--javax/swing/plaf/metal/MetalTreeUI.java26
-rw-r--r--javax/swing/plaf/metal/MetalUtils.java87
-rw-r--r--javax/swing/plaf/metal/package.html8
-rw-r--r--javax/swing/plaf/package.html9
-rw-r--r--javax/swing/table/AbstractTableModel.java196
-rw-r--r--javax/swing/table/DefaultTableCellRenderer.java4
-rw-r--r--javax/swing/table/DefaultTableColumnModel.java49
-rw-r--r--javax/swing/table/DefaultTableModel.java56
-rw-r--r--javax/swing/table/JTableHeader.java43
-rw-r--r--javax/swing/table/TableCellEditor.java4
-rw-r--r--javax/swing/table/TableCellRenderer.java4
-rw-r--r--javax/swing/table/TableColumn.java113
-rw-r--r--javax/swing/table/TableColumnModel.java53
-rw-r--r--javax/swing/table/TableModel.java8
-rw-r--r--javax/swing/table/package.html9
-rw-r--r--javax/swing/text/AbstractDocument.java40
-rw-r--r--javax/swing/text/AttributeSet.java4
-rw-r--r--javax/swing/text/BadLocationException.java4
-rw-r--r--javax/swing/text/BoxView.java87
-rw-r--r--javax/swing/text/Caret.java4
-rw-r--r--javax/swing/text/ChangedCharSetException.java4
-rw-r--r--javax/swing/text/ComponentView.java4
-rw-r--r--javax/swing/text/CompositeView.java84
-rw-r--r--javax/swing/text/DateFormatter.java85
-rw-r--r--javax/swing/text/DefaultCaret.java4
-rw-r--r--javax/swing/text/DefaultEditorKit.java28
-rw-r--r--javax/swing/text/DefaultFormatter.java429
-rw-r--r--javax/swing/text/DefaultHighlighter.java4
-rw-r--r--javax/swing/text/DefaultStyledDocument.java311
-rw-r--r--javax/swing/text/Document.java4
-rw-r--r--javax/swing/text/DocumentFilter.java4
-rw-r--r--javax/swing/text/EditorKit.java4
-rw-r--r--javax/swing/text/Element.java4
-rw-r--r--javax/swing/text/FieldView.java4
-rw-r--r--javax/swing/text/FlowView.java56
-rw-r--r--javax/swing/text/GapContent.java155
-rw-r--r--javax/swing/text/GlyphView.java111
-rw-r--r--javax/swing/text/Highlighter.java4
-rw-r--r--javax/swing/text/IconView.java110
-rw-r--r--javax/swing/text/InternationalFormatter.java354
-rw-r--r--javax/swing/text/JTextComponent.java107
-rw-r--r--javax/swing/text/Keymap.java4
-rw-r--r--javax/swing/text/LabelView.java54
-rw-r--r--javax/swing/text/LayeredHighlighter.java4
-rw-r--r--javax/swing/text/MutableAttributeSet.java4
-rw-r--r--javax/swing/text/NavigationFilter.java4
-rw-r--r--javax/swing/text/ParagraphView.java56
-rw-r--r--javax/swing/text/PasswordView.java4
-rw-r--r--javax/swing/text/PlainDocument.java20
-rw-r--r--javax/swing/text/PlainView.java4
-rw-r--r--javax/swing/text/Position.java4
-rw-r--r--javax/swing/text/Segment.java4
-rw-r--r--javax/swing/text/SimpleAttributeSet.java4
-rw-r--r--javax/swing/text/StringContent.java4
-rw-r--r--javax/swing/text/Style.java4
-rw-r--r--javax/swing/text/StyleConstants.java4
-rw-r--r--javax/swing/text/StyleContext.java35
-rw-r--r--javax/swing/text/StyledDocument.java4
-rw-r--r--javax/swing/text/StyledEditorKit.java570
-rw-r--r--javax/swing/text/TabExpander.java4
-rw-r--r--javax/swing/text/TabSet.java4
-rw-r--r--javax/swing/text/TabStop.java4
-rw-r--r--javax/swing/text/TabableView.java4
-rw-r--r--javax/swing/text/TextAction.java4
-rw-r--r--javax/swing/text/Utilities.java4
-rw-r--r--javax/swing/text/View.java59
-rw-r--r--javax/swing/text/ViewFactory.java4
-rw-r--r--javax/swing/text/html/HTML.java19
-rw-r--r--javax/swing/text/html/HTMLDocument.java4
-rw-r--r--javax/swing/text/html/HTMLEditorKit.java91
-rw-r--r--javax/swing/text/html/HTMLFrameHyperlinkEvent.java4
-rw-r--r--javax/swing/text/html/package.html4
-rw-r--r--javax/swing/text/html/parser/AttributeList.java4
-rw-r--r--javax/swing/text/html/parser/ContentModel.java4
-rw-r--r--javax/swing/text/html/parser/DTD.java11
-rw-r--r--javax/swing/text/html/parser/DTDConstants.java10
-rw-r--r--javax/swing/text/html/parser/DocumentParser.java16
-rw-r--r--javax/swing/text/html/parser/Element.java6
-rw-r--r--javax/swing/text/html/parser/Entity.java4
-rw-r--r--javax/swing/text/html/parser/Parser.java16
-rw-r--r--javax/swing/text/html/parser/ParserDelegator.java12
-rw-r--r--javax/swing/text/html/parser/TagElement.java4
-rw-r--r--javax/swing/text/html/parser/package.html4
-rw-r--r--javax/swing/text/package.html4
-rw-r--r--javax/swing/text/rtf/ControlWordToken.java4
-rw-r--r--javax/swing/text/rtf/RTFEditorKit.java4
-rw-r--r--javax/swing/text/rtf/RTFParseException.java4
-rw-r--r--javax/swing/text/rtf/RTFParser.java4
-rw-r--r--javax/swing/text/rtf/RTFScanner.java4
-rw-r--r--javax/swing/text/rtf/TextToken.java4
-rw-r--r--javax/swing/text/rtf/Token.java4
-rw-r--r--javax/swing/tree/AbstractLayoutCache.java36
-rw-r--r--javax/swing/tree/DefaultMutableTreeNode.java176
-rw-r--r--javax/swing/tree/DefaultTreeCellEditor.java4
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java401
-rw-r--r--javax/swing/tree/DefaultTreeModel.java796
-rw-r--r--javax/swing/tree/DefaultTreeSelectionModel.java1290
-rw-r--r--javax/swing/tree/ExpandVetoException.java4
-rw-r--r--javax/swing/tree/FixedHeightLayoutCache.java124
-rw-r--r--javax/swing/tree/MutableTreeNode.java12
-rw-r--r--javax/swing/tree/RowMapper.java4
-rw-r--r--javax/swing/tree/TreeCellEditor.java4
-rw-r--r--javax/swing/tree/TreeCellRenderer.java4
-rw-r--r--javax/swing/tree/TreeModel.java4
-rw-r--r--javax/swing/tree/TreeNode.java4
-rw-r--r--javax/swing/tree/TreePath.java224
-rw-r--r--javax/swing/tree/TreeSelectionModel.java4
-rw-r--r--javax/swing/tree/VariableHeightLayoutCache.java12
-rw-r--r--javax/swing/tree/package.html9
-rw-r--r--javax/swing/undo/AbstractUndoableEdit.java4
-rw-r--r--javax/swing/undo/CannotRedoException.java4
-rw-r--r--javax/swing/undo/CannotUndoException.java4
-rw-r--r--javax/swing/undo/CompoundEdit.java4
-rw-r--r--javax/swing/undo/StateEdit.java4
-rw-r--r--javax/swing/undo/StateEditable.java4
-rw-r--r--javax/swing/undo/UndoManager.java8
-rw-r--r--javax/swing/undo/UndoableEdit.java4
-rw-r--r--javax/swing/undo/UndoableEditSupport.java10
-rw-r--r--javax/swing/undo/package.html8
439 files changed, 18661 insertions, 7783 deletions
diff --git a/javax/swing/AbstractAction.java b/javax/swing/AbstractAction.java
index c0ddf44ff..da65bdd1d 100644
--- a/javax/swing/AbstractAction.java
+++ b/javax/swing/AbstractAction.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -48,9 +48,9 @@ import java.util.HashMap;
import javax.swing.event.SwingPropertyChangeSupport;
/**
- * AbstractAction
- * @author Andrew Selkirk
- * @version 1.0
+ * A base class for implementing the {@link Action} interface.
+ *
+ * @author Andrew Selkirk
*/
public abstract class AbstractAction
implements Action, Cloneable, Serializable
@@ -58,12 +58,12 @@ public abstract class AbstractAction
private static final long serialVersionUID = -6803159439231523484L;
/**
- * enabled
+ * A flag that indicates whether or not the action is enabled.
*/
protected boolean enabled = true;
/**
- * changeSupport
+ * Provides support for property change event notification.
*/
protected SwingPropertyChangeSupport changeSupport =
new SwingPropertyChangeSupport(this);
@@ -74,7 +74,8 @@ public abstract class AbstractAction
private transient HashMap store = new HashMap();
/**
- * Constructor AbstractAction
+ * Creates a new action with an empty string for the name. All other
+ * properties are initialised to <code>null</code>
*/
public AbstractAction()
{
@@ -82,9 +83,10 @@ public abstract class AbstractAction
}
/**
- * Constructor AbstractAction
+ * Creates a new action with the specified name. All other properties are
+ * initialised to <code>null</code>.
*
- * @param name TODO
+ * @param name the name (<code>null</code> permitted).
*/
public AbstractAction(String name)
{
@@ -92,10 +94,11 @@ public abstract class AbstractAction
}
/**
- * Constructor AbstractAction
+ * Creates a new action with the specified name and icon. All other
+ * properties are initialised to <code>null</code>.
*
- * @param name TODO
- * @param icon TODO
+ * @param name the name (<code>null</code> permitted).
+ * @param icon the icon (<code>null</code> permitted).
*/
public AbstractAction(String name, Icon icon)
{
@@ -144,11 +147,12 @@ public abstract class AbstractAction
}
/**
- * Returns a value for a given key from the built-in store.
- *
- * @param key the key to get the value for
- *
- * @return Object
+ * Returns the value associated with the specified key.
+ *
+ * @param key the key (not <code>null</code>).
+ *
+ * @return The value associated with the specified key, or
+ * <code>null</code> if the key is not found.
*/
public Object getValue(String key)
{
@@ -156,10 +160,16 @@ public abstract class AbstractAction
}
/**
- * Puts a key/value pair into the built-in store.
- *
- * @param key the key
- * @param value the value
+ * Sets the value associated with the specified key and sends a
+ * {@link java.beans.PropertyChangeEvent} to all registered listeners.
+ * The standard keys are: {@link #NAME}, {@link #SHORT_DESCRIPTION},
+ * {@link #LONG_DESCRIPTION}, {@link #SMALL_ICON},
+ * {@link #ACTION_COMMAND_KEY}, {@link #ACCELERATOR_KEY} and
+ * {@link #MNEMONIC_KEY}. Any existing value associated with the key will be
+ * overwritten.
+ *
+ * @param key the key (not <code>null</code>).
+ * @param value the value (<code>null</code> permitted).
*/
public void putValue(String key, Object value)
{
@@ -172,9 +182,9 @@ public abstract class AbstractAction
}
/**
- * isEnabled
+ * Returns the flag that indicates whether or not the action is enabled.
*
- * @return boolean
+ * @return The flag.
*/
public boolean isEnabled()
{
@@ -182,9 +192,11 @@ public abstract class AbstractAction
}
/**
- * setEnabled
+ * Sets the flag that indicates whether or not the action is enabled and, if
+ * the value of the flag changed from the previous setting, sends a
+ * {@link java.beans.PropertyChangeEvent} to all registered listeners.
*
- * @param enabled TODO
+ * @param enabled the new flag value.
*/
public void setEnabled(boolean enabled)
{
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index 6f465b738..21c4fc0a2 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -47,9 +47,10 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-import java.io.Serializable;
+import java.awt.image.ImageObserver;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.Serializable;
import javax.accessibility.AccessibleAction;
import javax.accessibility.AccessibleIcon;
@@ -64,18 +65,13 @@ import javax.swing.text.AttributeSet;
/**
- * <p>The purpose of this class is to serve as a facade over a number of
- * classes which collectively represent the semantics of a button: the
- * button's model, its listeners, its action, and its look and feel. Some
- * parts of a button's state are stored explicitly in this class, other
- * parts are delegates to the model. Some methods related to buttons are
- * implemented in this class, other methods pass through to the current
- * model or look and feel.</p>
+ * Provides an abstract implementation of common button behaviour,
+ * data model and look &amp; feel.
*
- * <p>Furthermore this class is supposed to serve as a base class for
+ * <p>This class is supposed to serve as a base class for
* several kinds of buttons with similar but non-identical semantics:
- * toggle buttons (radio buttons and checkboxes), simple "push" buttons,
- * menu items.</p>
+ * toggle buttons (radio buttons and checkboxes), simple push buttons,
+ * menu items, etc.</p>
*
* <p>Buttons have many properties, some of which are stored in this class
* while others are delegated to the button's model. The following properties
@@ -199,7 +195,10 @@ public abstract class AbstractButton extends JComponent
/** The text displayed in the button. */
String text;
- /** The gap between icon and text, if both icon and text are non-<code>null</code>. */
+ /**
+ * The gap between icon and text, if both icon and text are
+ * non-<code>null</code>.
+ */
int iconTextGap;
/** The vertical alignment of the button's text and icon. */
@@ -235,8 +234,10 @@ public abstract class AbstractButton extends JComponent
/** 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
- * button's label should be underlined when drawing the label. */
+ /**
+ * 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. */
@@ -248,39 +249,66 @@ public abstract class AbstractButton extends JComponent
/** Listener the button uses to receive ChangeEvents from its model. */
protected ChangeListener changeListener;
- /** The time in miliseconds in which clicks get coalesced into a single
- * <code>ActionEvent</code>. */
+ /**
+ * 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. */
+ /**
+ * Listener the button uses to receive PropertyChangeEvents from its
+ * Action.
+ */
PropertyChangeListener actionPropertyChangeListener;
/** ChangeEvent that is fired to button's ChangeEventListeners */
protected ChangeEvent changeEvent = new ChangeEvent(this);
- /** Fired in a PropertyChangeEvent when the "borderPainted" property changes. */
+ /**
+ * Fired in a PropertyChangeEvent when the "borderPainted" property changes.
+ */
public static final String BORDER_PAINTED_CHANGED_PROPERTY = "borderPainted";
- /** Fired in a PropertyChangeEvent when the "contentAreaFilled" property changes. */
- public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY = "contentAreaFilled";
+ /**
+ * Fired in a PropertyChangeEvent when the "contentAreaFilled" property
+ * changes.
+ */
+ public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY =
+ "contentAreaFilled";
- /** Fired in a PropertyChangeEvent when the "disabledIcon" property changes. */
+ /**
+ * Fired in a PropertyChangeEvent when the "disabledIcon" property changes.
+ */
public static final String DISABLED_ICON_CHANGED_PROPERTY = "disabledIcon";
- /** Fired in a PropertyChangeEvent when the "disabledSelectedIcon" property changes. */
- public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY = "disabledSelectedIcon";
+ /**
+ * Fired in a PropertyChangeEvent when the "disabledSelectedIcon" property
+ * changes.
+ */
+ public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY =
+ "disabledSelectedIcon";
- /** Fired in a PropertyChangeEvent when the "focusPainted" property changes. */
+ /**
+ * Fired in a PropertyChangeEvent when the "focusPainted" property changes.
+ */
public static final String FOCUS_PAINTED_CHANGED_PROPERTY = "focusPainted";
- /** Fired in a PropertyChangeEvent when the "horizontalAlignment" property changes. */
- public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY = "horizontalAlignment";
+ /**
+ * Fired in a PropertyChangeEvent when the "horizontalAlignment" property
+ * changes.
+ */
+ public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY =
+ "horizontalAlignment";
- /** Fired in a PropertyChangeEvent when the "horizontalTextPosition" property changes. */
- public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY = "horizontalTextPosition";
+ /**
+ * Fired in a PropertyChangeEvent when the "horizontalTextPosition" property
+ * changes.
+ */
+ public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY =
+ "horizontalTextPosition";
- /** Fired in a PropertyChangeEvent when the "icon" property changes. */
+ /**
+ * Fired in a PropertyChangeEvent when the "icon" property changes. */
public static final String ICON_CHANGED_PROPERTY = "icon";
/** Fired in a PropertyChangeEvent when the "margin" property changes. */
@@ -295,26 +323,46 @@ public abstract class AbstractButton extends JComponent
/** Fired in a PropertyChangeEvent when the "pressedIcon" property changes. */
public static final String PRESSED_ICON_CHANGED_PROPERTY = "pressedIcon";
- /** Fired in a PropertyChangeEvent when the "rolloverEnabled" property changes. */
- public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY = "rolloverEnabled";
+ /**
+ * Fired in a PropertyChangeEvent when the "rolloverEnabled" property
+ * changes.
+ */
+ public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY =
+ "rolloverEnabled";
- /** Fired in a PropertyChangeEvent when the "rolloverIcon" property changes. */
+ /**
+ * Fired in a PropertyChangeEvent when the "rolloverIcon" property changes.
+ */
public static final String ROLLOVER_ICON_CHANGED_PROPERTY = "rolloverIcon";
- /** Fired in a PropertyChangeEvent when the "rolloverSelectedIcon" property changes. */
- public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY = "rolloverSelectedIcon";
+ /**
+ * Fired in a PropertyChangeEvent when the "rolloverSelectedIcon" property
+ * changes.
+ */
+ public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY =
+ "rolloverSelectedIcon";
- /** Fired in a PropertyChangeEvent when the "selectedIcon" property changes. */
+ /**
+ * Fired in a PropertyChangeEvent when the "selectedIcon" property changes.
+ */
public static final String SELECTED_ICON_CHANGED_PROPERTY = "selectedIcon";
/** Fired in a PropertyChangeEvent when the "text" property changes. */
public static final String TEXT_CHANGED_PROPERTY = "text";
- /** Fired in a PropertyChangeEvent when the "verticalAlignment" property changes. */
- public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY = "verticalAlignment";
+ /**
+ * Fired in a PropertyChangeEvent when the "verticalAlignment" property
+ * changes.
+ */
+ public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY =
+ "verticalAlignment";
- /** Fired in a PropertyChangeEvent when the "verticalTextPosition" property changes. */
- public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY = "verticalTextPosition";
+ /**
+ * 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.
@@ -465,18 +513,7 @@ public abstract class AbstractButton extends JComponent
*/
public AbstractButton()
{
- this("",null);
- }
-
- /**
- * Creates a new AbstractButton object.
- *
- * @param txt Value to use for the button's "text" property
- * @param icon Value to use for the button's "defaultIcon" property
- */
- AbstractButton(String txt, Icon icon)
- {
- init (txt, icon);
+ init("", null);
updateUI();
}
@@ -523,8 +560,16 @@ public abstract class AbstractButton extends JComponent
protected void init(String text, Icon icon)
{
- this.text = text;
- default_icon = icon;
+ // If text is null, we fall back to the empty
+ // string (which is set using AbstractButton's
+ // constructor).
+ // This way the behavior of the JDK is matched.
+ if(text != null)
+ this.text = text;
+
+ if (icon != null)
+ default_icon = icon;
+
actionListener = createActionListener();
changeListener = createChangeListener();
itemListener = createItemListener();
@@ -546,24 +591,31 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Get the action command string for this button's model.
+ * <p>Returns the action command string for this button's model.</p>
+ *
+ * <p>If the action command was set to <code>null</code>, the button's
+ * text (label) is returned instead.</p>
*
* @return The current action command string from the button's model
*/
public String getActionCommand()
{
- return getModel().getActionCommand();
+ String ac = model.getActionCommand();
+ if (ac != null)
+ return ac;
+ else
+ return text;
}
/**
- * Set the action command string for this button's model.
+ * Sets the action command string for this button's model.
*
- * @param aCommand The new action command string to set in the button's
+ * @param actionCommand The new action command string to set in the button's
* model.
*/
- public void setActionCommand(String aCommand)
+ public void setActionCommand(String actionCommand)
{
- getModel().setActionCommand(aCommand);
+ model.setActionCommand(actionCommand);
}
/**
@@ -670,7 +722,7 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Calls {@link ItemListener.itemStateChanged} on each ItemListener in
+ * Calls {@link ItemListener#itemStateChanged} on each ItemListener in
* the button's listener list.
*
* @param e The event signifying that the button's model changed state
@@ -685,22 +737,30 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Calls {@link ActionListener.actionPerformed} on each {@link
+ * Calls {@link ActionListener#actionPerformed} on each {@link
* ActionListener} in the button's listener list.
*
* @param e The event signifying that the button's model was clicked
*/
protected void fireActionPerformed(ActionEvent e)
{
- e.setSource(this);
+ // Dispatch a copy of the given ActionEvent in order to
+ // set the source and action command correctly.
+ ActionEvent ae = new ActionEvent(
+ this,
+ e.getID(),
+ getActionCommand(),
+ e.getWhen(),
+ e.getModifiers());
+
ActionListener[] listeners = getActionListeners();
for (int i = 0; i < listeners.length; i++)
- listeners[i].actionPerformed(e);
+ listeners[i].actionPerformed(ae);
}
/**
- * Calls {@link ChangeEvent.stateChanged} on each {@link ChangeListener}
+ * Calls {@link ChangeListener#stateChanged} on each {@link ChangeListener}
* in the button's listener list.
*/
protected void fireStateChanged()
@@ -754,22 +814,22 @@ public abstract class AbstractButton extends JComponent
if (old != mne)
{
- getModel().setMnemonic(mne);
-
- if (text != null && ! text.equals(""))
- {
- // Since lower case char = upper case char for
- // mnemonic, we will convert both text and mnemonic
- // to upper case before checking if mnemonic character occurs
- // in the menu item text.
- int upperCaseMne = Character.toUpperCase((char) mne);
- String upperCaseText = text.toUpperCase();
- setDisplayedMnemonicIndex(upperCaseText.indexOf(upperCaseMne));
- }
-
- firePropertyChange(MNEMONIC_CHANGED_PROPERTY, old, mne);
- revalidate();
- repaint();
+ getModel().setMnemonic(mne);
+
+ if (text != null && !text.equals(""))
+ {
+ // Since lower case char = upper case char for
+ // mnemonic, we will convert both text and mnemonic
+ // to upper case before checking if mnemonic character occurs
+ // in the menu item text.
+ int upperCaseMne = Character.toUpperCase((char) mne);
+ String upperCaseText = text.toUpperCase();
+ setDisplayedMnemonicIndex(upperCaseText.indexOf(upperCaseMne));
+ }
+
+ firePropertyChange(MNEMONIC_CHANGED_PROPERTY, old, mne);
+ revalidate();
+ repaint();
}
}
@@ -1068,7 +1128,7 @@ public abstract class AbstractButton extends JComponent
* PropertyChangeListener.</p>
*
* <p>This method also configures several of the button's properties from
- * the Action, by calling {@link configurePropertiesFromAction}, and
+ * the Action, by calling {@link #configurePropertiesFromAction}, and
* subscribes the button to the Action as a PropertyChangeListener.
* Subsequent changes to the Action will thus reconfigure the button
* automatically.</p>
@@ -1284,9 +1344,12 @@ public abstract class AbstractButton extends JComponent
*/
public Icon getDisabledIcon()
{
- if (disabeldIcon == null
- && default_icon instanceof ImageIcon)
- disabeldIcon = new ImageIcon(GrayFilter.createDisabledImage(((ImageIcon) default_icon).getImage()));
+ if (disabeldIcon == null && default_icon instanceof ImageIcon)
+ {
+ Image iconImage = ((ImageIcon) default_icon).getImage();
+ Image grayImage = GrayFilter.createDisabledImage(iconImage);
+ disabeldIcon = new ImageIcon(grayImage);
+ }
return disabeldIcon;
}
@@ -1298,7 +1361,7 @@ public abstract class AbstractButton extends JComponent
* <code>null</code>, in which case an icon is constructed, based on the
* default icon.
*
- * @param disabledIcon The new "disabledIcon" property
+ * @param d The new "disabledIcon" property
*/
public void setDisabledIcon(Icon d)
{
@@ -1328,7 +1391,7 @@ public abstract class AbstractButton extends JComponent
* focused, but no special decoration is painted to indicate the presence
* of focus.
*
- * @param b The new "paintFocus" property
+ * @param p The new "paintFocus" property
*/
public void setFocusPainted(boolean p)
{
@@ -1356,8 +1419,8 @@ public abstract class AbstractButton extends JComponent
*
* @throws IllegalArgumentException If key is not one of the valid constants
*
- * @see setHorizontalTextPosition()
- * @see setHorizontalAlignment()
+ * @see #setHorizontalTextPosition(int)
+ * @see #setHorizontalAlignment(int)
*/
protected int checkHorizontalKey(int key, String exception)
{
@@ -1388,8 +1451,8 @@ public abstract class AbstractButton extends JComponent
*
* @throws IllegalArgumentException If key is not one of the valid constants
*
- * @see setVerticalTextPosition()
- * @see setVerticalAlignment()
+ * @see #setVerticalTextPosition(int)
+ * @see #setVerticalAlignment(int)
*/
protected int checkVerticalKey(int key, String exception)
{
@@ -1431,7 +1494,7 @@ public abstract class AbstractButton extends JComponent
*
* @param a An Action to configure the button from
*/
- protected void configurePropertiesFromAction(Action a)
+ protected void configurePropertiesFromAction(Action a)
{
if (a == null)
{
@@ -1442,19 +1505,19 @@ public abstract class AbstractButton extends JComponent
}
else
{
- setText((String)(a.getValue(Action.NAME)));
- setIcon((Icon)(a.getValue(Action.SMALL_ICON)));
+ setText((String) (a.getValue(Action.NAME)));
+ setIcon((Icon) (a.getValue(Action.SMALL_ICON)));
setEnabled(a.isEnabled());
- setToolTipText((String)(a.getValue(Action.SHORT_DESCRIPTION)));
- if (a.getValue(Action.MNEMONIC_KEY) != null)
- setMnemonic(((Integer)(a.getValue(Action.MNEMONIC_KEY))).intValue());
- String actionCommand = (String)(a.getValue(Action.ACTION_COMMAND_KEY));
+ setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION)));
+ if (a.getValue(Action.MNEMONIC_KEY) != null)
+ setMnemonic(((Integer) (a.getValue(Action.MNEMONIC_KEY))).intValue());
+ String actionCommand = (String) (a.getValue(Action.ACTION_COMMAND_KEY));
// Set actionCommand to button's text by default if it is not specified
if (actionCommand != null)
- setActionCommand((String)(a.getValue(Action.ACTION_COMMAND_KEY)));
- else
- setActionCommand(getText());
+ setActionCommand((String) (a.getValue(Action.ACTION_COMMAND_KEY)));
+ else
+ setActionCommand(getText());
}
}
@@ -1462,7 +1525,7 @@ public abstract class AbstractButton extends JComponent
* <p>A factory method which should return an {@link ActionListener} that
* propagates events from the button's {@link ButtonModel} to any of the
* button's ActionListeners. By default, this is an inner class which
- * calls {@link AbstractButton.fireActionPerformed} with a modified copy
+ * calls {@link AbstractButton#fireActionPerformed} with a modified copy
* of the incoming model {@link ActionEvent}.</p>
*
* <p>The button calls this method during construction, stores the
@@ -1488,10 +1551,10 @@ public abstract class AbstractButton extends JComponent
* <p>A factory method which should return a {@link PropertyChangeListener}
* that accepts changes to the specified {@link Action} and reconfigure
* the {@link AbstractButton}, by default using the {@link
- * configurePropertiesFromAction} method.</p>
+ * #configurePropertiesFromAction} method.</p>
*
* <p>The button calls this method whenever a new Action is assigned to
- * the button's "action" property, via {@link setAction}, and stores the
+ * the button's "action" property, via {@link #setAction}, and stores the
* resulting PropertyChangeListener in its
* <code>actionPropertyChangeListener</code> member field. The button
* then subscribes the listener to the button's new action. If the
@@ -1510,21 +1573,22 @@ public abstract class AbstractButton extends JComponent
{
public void propertyChange(PropertyChangeEvent e)
{
- Action act = (Action) (e.getSource());
- if (e.getPropertyName().equals("enabled"))
- setEnabled(act.isEnabled());
- else if (e.getPropertyName().equals(Action.NAME))
- setText((String)(act.getValue(Action.NAME)));
- else if (e.getPropertyName().equals(Action.SMALL_ICON))
- setIcon((Icon)(act.getValue(Action.SMALL_ICON)));
- else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION))
- setToolTipText((String)(act.getValue(Action.SHORT_DESCRIPTION)));
- else if (e.getPropertyName().equals(Action.MNEMONIC_KEY))
+ Action act = (Action) (e.getSource());
+ if (e.getPropertyName().equals("enabled"))
+ setEnabled(act.isEnabled());
+ else if (e.getPropertyName().equals(Action.NAME))
+ setText((String) (act.getValue(Action.NAME)));
+ else if (e.getPropertyName().equals(Action.SMALL_ICON))
+ setIcon((Icon) (act.getValue(Action.SMALL_ICON)));
+ else if (e.getPropertyName().equals(Action.SHORT_DESCRIPTION))
+ setToolTipText((String) (act.getValue(Action.SHORT_DESCRIPTION)));
+ else if (e.getPropertyName().equals(Action.MNEMONIC_KEY))
if (act.getValue(Action.MNEMONIC_KEY) != null)
- setMnemonic(((Integer)(act.getValue(Action.MNEMONIC_KEY))).intValue());
- else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY))
- setActionCommand((String)(act.getValue(Action.ACTION_COMMAND_KEY)));
- }
+ setMnemonic(((Integer) (act.getValue(Action.MNEMONIC_KEY)))
+ .intValue());
+ else if (e.getPropertyName().equals(Action.ACTION_COMMAND_KEY))
+ setActionCommand((String) (act.getValue(Action.ACTION_COMMAND_KEY)));
+ }
};
}
@@ -1534,7 +1598,7 @@ public abstract class AbstractButton extends JComponent
* AbstractButton may wish to override the listener used to subscribe to
* such ChangeEvents. By default, the listener just propagates the
* {@link ChangeEvent} to the button's ChangeListeners, via the {@link
- * AbstractButton.fireStateChanged} method.</p>
+ * AbstractButton#fireStateChanged} method.</p>
*
* <p>The button calls this method during construction, stores the
* resulting ChangeListener in its <code>changeListener</code> member
@@ -1562,7 +1626,7 @@ public abstract class AbstractButton extends JComponent
* AbstractButton may wish to override the listener used to subscribe to
* such ItemEvents. By default, the listener just propagates the
* {@link ItemEvent} to the button's ItemListeners, via the {@link
- * AbstractButton.fireItemStateChanged} method.</p>
+ * AbstractButton#fireItemStateChanged} method.</p>
*
* <p>The button calls this method during construction, stores the
* resulting ItemListener in its <code>changeListener</code> member
@@ -1671,7 +1735,7 @@ public abstract class AbstractButton extends JComponent
* paint this icon when the "rolloverEnabled" property of the button is
* <code>true</code> and the mouse rolls over the button.
*
- * @param rolloverIcon The new rollover icon
+ * @param r The new rollover icon
*/
public void setRolloverIcon(Icon r)
{
@@ -1704,7 +1768,7 @@ public abstract class AbstractButton extends JComponent
* is <code>true</code>, the "selected" property of the button's model is
* <code>true</code>, and the mouse rolls over the button.
*
- * @param rolloverSelectedIcon The new rollover selected icon
+ * @param r The new rollover selected icon
*/
public void setRolloverSelectedIcon(Icon r)
{
@@ -1739,7 +1803,7 @@ public abstract class AbstractButton extends JComponent
* button is <code>false</code> or the mouse is not currently rolled
* over the button.
*
- * @param selectedIcon The new selected icon
+ * @param s The new selected icon
*/
public void setSelectedIcon(Icon s)
{
@@ -1769,7 +1833,7 @@ public abstract class AbstractButton extends JComponent
return objs;
}
else
- {
+ {
return null;
}
}
@@ -1778,15 +1842,15 @@ public abstract class AbstractButton extends JComponent
* Called when image data becomes available for one of the button's icons.
*
* @param img The image being updated
- * @param infoflags One of the constant codes in {@link ImageObserver} used to describe
- * updated portions of an image.
+ * @param infoflags One of the constant codes in {@link ImageObserver} used
+ * to describe updated portions of an image.
* @param x X coordinate of the region being updated
* @param y Y coordinate of the region being updated
* @param w Width of the region beign updated
* @param h Height of the region being updated
*
- * @return <code>true</code> if img is equal to the button's current
- * icon, otherwise <code>false</code>
+ * @return <code>true</code> if img is equal to the button's current icon,
+ * otherwise <code>false</code>
*/
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
int h)
@@ -1825,8 +1889,9 @@ public abstract class AbstractButton extends JComponent
boolean old = contentAreaFilled;
contentAreaFilled = b;
firePropertyChange(CONTENT_AREA_FILLED_CHANGED_PROPERTY, old, b);
- revalidate();
- repaint();
+ // The JDK sets the opaque property to the value of the contentAreaFilled
+ // property, so should we do.
+ setOpaque(b);
}
/**
diff --git a/javax/swing/AbstractCellEditor.java b/javax/swing/AbstractCellEditor.java
index 18f78e319..4ed15809a 100644
--- a/javax/swing/AbstractCellEditor.java
+++ b/javax/swing/AbstractCellEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,11 +46,10 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.EventListenerList;
/**
- * The abstract superclass for table and tree cells. This provides some
+ * An abstract superclass for table and tree cell editors. This provides some
* common shared functionality.
*
- * @author Andrew Selkirk
- * @version 1.0
+ * @author Andrew Selkirk
*/
public abstract class AbstractCellEditor
implements CellEditor, Serializable
@@ -162,8 +161,8 @@ public abstract class AbstractCellEditor
}
/**
- * Notifies all registered listeners that the editing of the cell has
- * has been stopped.
+ * Notifies all registered listeners that the editing of the cell has has been
+ * stopped.
*/
protected void fireEditingStopped()
{
@@ -171,7 +170,7 @@ public abstract class AbstractCellEditor
for (int index = 0; index < listeners.length; index++)
{
- listeners [index].editingStopped (changeEvent);
+ listeners[index].editingStopped(changeEvent);
}
}
@@ -185,7 +184,7 @@ public abstract class AbstractCellEditor
for (int index = 0; index < listeners.length; index++)
{
- listeners [index].editingCanceled (changeEvent);
+ listeners[index].editingCanceled(changeEvent);
}
}
}
diff --git a/javax/swing/AbstractListModel.java b/javax/swing/AbstractListModel.java
index a380b2a2e..8973e5292 100644
--- a/javax/swing/AbstractListModel.java
+++ b/javax/swing/AbstractListModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,11 +46,10 @@ import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
/**
- * AbstractListModel
+ * Provides standard implementations of some methods in {@link ListModel}.
*
* @author Ronald Veldema
* @author Andrew Selkirk
- * @version 1.0
*/
public abstract class AbstractListModel implements ListModel, Serializable
{
@@ -88,7 +87,7 @@ public abstract class AbstractListModel implements ListModel, Serializable
/**
* Call {@link ListDataListener#contentsChanged} on each element of the
- * {@link listenerList} which is a {@link ListDataListener}. The event
+ * {@link #listenerList} which is a {@link ListDataListener}. The event
* fired has type {@ListDataEvent.CONTENTS_CHANGED} and represents a
* change to the data elements in the range [startIndex, endIndex]
* inclusive.
@@ -110,7 +109,7 @@ public abstract class AbstractListModel implements ListModel, Serializable
/**
* Call {@link ListDataListener#intervalAdded} on each element of the
- * {@link listenerList} which is a {@link ListDataListener}. The event
+ * {@link #listenerList} which is a {@link ListDataListener}. The event
* fired has type {@ListDataEvent.INTERVAL_ADDED} and represents an
* addition of the data elements in the range [startIndex, endIndex]
* inclusive.
@@ -132,7 +131,7 @@ public abstract class AbstractListModel implements ListModel, Serializable
/**
* Call {@link ListDataListener#intervalRemoved} on each element of the
- * {@link listenerList} which is a {@link ListDataListener}. The event
+ * {@link #listenerList} which is a {@link ListDataListener}. The event
* fired has type {@ListDataEvent.INTERVAL_REMOVED} and represents a
* removal of the data elements in the range [startIndex, endIndex]
* inclusive.
@@ -155,7 +154,7 @@ public abstract class AbstractListModel implements ListModel, Serializable
/**
* Return the subset of {@link EventListener} objects found in this
- * object's {@link listenerList} which are elements of the specified
+ * object's {@link #listenerList} which are elements of the specified
* type.
*
* @param listenerType The type of listeners to select
@@ -170,7 +169,7 @@ public abstract class AbstractListModel implements ListModel, Serializable
/**
* A synonym for <code>getListeners(ListDataListener.class)</code>.
*
- * @return The set of ListDataListeners found in the {@link listenerList}
+ * @return The set of ListDataListeners found in the {@link #listenerList}
*/
public ListDataListener[] getListDataListeners()
{
diff --git a/javax/swing/AbstractSpinnerModel.java b/javax/swing/AbstractSpinnerModel.java
index 1d3a621e4..d61113b08 100644
--- a/javax/swing/AbstractSpinnerModel.java
+++ b/javax/swing/AbstractSpinnerModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -45,9 +45,10 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
- * AbstractSpinnerModel
- * @author Ka-Hing Cheung
- * @version 1.0
+ * Provides standard implementations for some of the methods in
+ * {@link SpinnerModel}.
+ *
+ * @author Ka-Hing Cheung
*/
public abstract class AbstractSpinnerModel implements SpinnerModel
{
diff --git a/javax/swing/Action.java b/javax/swing/Action.java
index 008ff7f06..3dd63539d 100644
--- a/javax/swing/Action.java
+++ b/javax/swing/Action.java
@@ -1,5 +1,5 @@
/* Action.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,98 +41,113 @@ import java.awt.event.ActionListener;
import java.beans.PropertyChangeListener;
/**
- * Action
+ * Provides a convenient central point of control for some task
+ * that can be triggered by more than one control in a Swing user interface
+ * (for example, a menu item and a toolbar button).
+ *
+ * @see AbstractButton#setAction(Action)
+ *
* @author Ronald Veldema (rveldema@cs.vu.nl)
* @author Andrew Selkirk
*/
public interface Action extends ActionListener {
- //-------------------------------------------------------------
- // Constants --------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * DEFAULT
- */
- String DEFAULT = "Default";
-
- /**
- * LONG_DESCRIPTION
- */
- String LONG_DESCRIPTION = "LongDescription";
-
- /**
- * NAME
- */
- String NAME = "Name";
-
- /**
- * SHORT_DESCRIPTION
- */
- String SHORT_DESCRIPTION = "ShortDescription";
-
- /**
- * SMALL_ICON
- */
- String SMALL_ICON = "SmallIcon";
-
- /**
- * ACCELERATOR_KEY
- */
- String ACCELERATOR_KEY = "AcceleratorKey";
-
- /**
- * ACTION_COMMAND_KEY
- */
- String ACTION_COMMAND_KEY = "ActionCommandKey";
-
- /**
- * MNEMONIC_KEY
- */
- String MNEMONIC_KEY = "MnemonicKey";
-
-
- //-------------------------------------------------------------
- // Interface: Action ------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * getValue
- * @param key TODO
- * @returns TODO
- */
- Object getValue(String key);
-
- /**
- * setValue
- * @param key TODO
- * @param value TODO
- */
- void putValue(String key, Object value);
-
- /**
- * isEnabled
- * @returns TODO
- */
- boolean isEnabled();
-
- /**
- * setEnabled
- * @param b TODO
- */
- void setEnabled(boolean b);
-
- /**
- * addPropertyChangeListener
- * @param listener TODO
- */
- void addPropertyChangeListener(PropertyChangeListener listener);
-
- /**
- * removePropertyChangeListener
- * @param listener TODO
- */
- void removePropertyChangeListener(PropertyChangeListener listener);
-
+ /**
+ * A key to access the default property for the action (this is not used).
+ */
+ String DEFAULT = "Default";
+
+ /**
+ * A key to access the long description for the action.
+ */
+ String LONG_DESCRIPTION = "LongDescription";
+
+ /**
+ * A key to access the name for the action.
+ */
+ String NAME = "Name";
+
+ /**
+ * A key to access the short description for the action (the short
+ * description is typically used as the tool tip text).
+ */
+ String SHORT_DESCRIPTION = "ShortDescription";
+
+ /**
+ * A key to access the icon for the action.
+ */
+ String SMALL_ICON = "SmallIcon";
+
+ /**
+ * A key to access the {@link KeyStroke} used as the accelerator for the
+ * action.
+ */
+ String ACCELERATOR_KEY = "AcceleratorKey";
+
+ /**
+ * A key to access the action command string for the action.
+ */
+ String ACTION_COMMAND_KEY = "ActionCommandKey";
+
+ /**
+ * A key to access the mnemonic for the action.
+ */
+ String MNEMONIC_KEY = "MnemonicKey";
+
+ /**
+ * Returns the value associated with the specified key.
+ *
+ * @param key the key (not <code>null</code>).
+ *
+ * @return The value associated with the specified key, or
+ * <code>null</code> if the key is not found.
+ */
+ Object getValue(String key);
+
+ /**
+ * Sets the value associated with the specified key and sends a
+ * {@link java.beans.PropertyChangeEvent} to all registered listeners.
+ * The standard keys are defined in this interface: {@link #NAME},
+ * {@link #SHORT_DESCRIPTION}, {@link #LONG_DESCRIPTION},
+ * {@link #SMALL_ICON}, {@link #ACTION_COMMAND_KEY},
+ * {@link #ACCELERATOR_KEY} and {@link #MNEMONIC_KEY}. Any existing value
+ * associated with the key will be overwritten.
+ *
+ * @param key the key (not <code>null</code>).
+ * @param value the value (<code>null</code> permitted).
+ */
+ void putValue(String key, Object value);
+
+ /**
+ * Returns the flag that indicates whether or not this action is enabled.
+ *
+ * @return The flag.
+ */
+ boolean isEnabled();
+
+ /**
+ * Sets the flag that indicates whether or not this action is enabled. If
+ * the value changes, a {@link java.beans.PropertyChangeEvent} is sent to
+ * all registered listeners.
+ *
+ * @param b the new value of the flag.
+ */
+ void setEnabled(boolean b);
+
+ /**
+ * Registers a listener to receive notification whenever one of the
+ * action's properties is modified.
+ *
+ * @param listener the listener.
+ */
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ * Deregisters a listener so that it no longer receives notification of
+ * changes to the action's properties.
+ *
+ * @param listener the listener.
+ */
+ void removePropertyChangeListener(PropertyChangeListener listener);
} // Action
diff --git a/javax/swing/ActionMap.java b/javax/swing/ActionMap.java
index 939affe85..c14bafdb4 100644
--- a/javax/swing/ActionMap.java
+++ b/javax/swing/ActionMap.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -49,6 +49,14 @@ import java.util.Set;
/**
+ * Maps arbitrary keys (usually Strings) to {@link Action} instances. This
+ * is used in combination with {@link InputMap}s.
+ *
+ * If a component receives an input event, this is looked up in
+ * the component's <code>InputMap</code>. The result is an object which
+ * serves as a key to the components <code>ActionMap</code>. Finally
+ * the <code>Action</code> that is stored is executed.
+ *
* @author Andrew Selkirk
* @author Michael Koch
*/
diff --git a/javax/swing/BorderFactory.java b/javax/swing/BorderFactory.java
index 4f0a1ee4e..45cf3bbe0 100644
--- a/javax/swing/BorderFactory.java
+++ b/javax/swing/BorderFactory.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -50,20 +50,25 @@ import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import javax.swing.border.TitledBorder;
+/**
+ * A factory for commonly used borders.
+ *
+ * @author original author unknown
+ */
public class BorderFactory
{
private BorderFactory()
{
// Do nothing.
}
-
+
/**
* Creates a line border withe the specified color.
*
* @param color A color to use for the line.
*
* @return The Border object
- */
+ */
public static Border createLineBorder(Color color)
{
return null;
@@ -79,10 +84,10 @@ public class BorderFactory
* @param thickness An int specifying the width in pixels.
*
* @return The Border object
- */
- public static Border createLineBorder (Color color, int thickness)
+ */
+ public static Border createLineBorder(Color color, int thickness)
{
- return new LineBorder (color, thickness);
+ return new LineBorder(color, thickness);
}
/**
@@ -92,10 +97,10 @@ public class BorderFactory
* shadows are underneath.)
*
* @return The Border object
- */
- public static Border createRaisedBevelBorder ()
+ */
+ public static Border createRaisedBevelBorder()
{
- return new BevelBorder (BevelBorder.RAISED);
+ return new BevelBorder(BevelBorder.RAISED);
}
/**
@@ -105,10 +110,10 @@ public class BorderFactory
* highlights are underneath.)
*
* @return The Border object
- */
- public static Border createLoweredBevelBorder ()
+ */
+ public static Border createLoweredBevelBorder()
{
- return new BevelBorder (BevelBorder.LOWERED);
+ return new BevelBorder(BevelBorder.LOWERED);
}
/**
@@ -118,13 +123,13 @@ public class BorderFactory
* highlights are underneath.).
*
* @param type An int specifying either BevelBorder.LOWERED or
- * BevelBorder.RAISED
+ * BevelBorder.RAISED
*
- * @Return The Border object
- */
- public static Border createBevelBorder (int type)
+ * @return The Border object
+ */
+ public static Border createBevelBorder(int type)
{
- return new BevelBorder (type);
+ return new BevelBorder(type);
}
/**
@@ -134,16 +139,15 @@ public class BorderFactory
* area uses a brighter shade of the shadaw color.
*
* @param type An int specifying either BevelBorder.LOWERED or
- * BevelBorder.RAISED
+ * BevelBorder.RAISED
* @param highlight A Color object for highlights
* @param shadow A Color object for shadows
*
* @return The Border object
- */
- public static Border createBevelBorder (int type, Color highlight,
- Color shadow)
+ */
+ public static Border createBevelBorder(int type, Color highlight, Color shadow)
{
- return new BevelBorder (type, highlight, shadow);
+ return new BevelBorder(type, highlight, shadow);
}
/**
@@ -151,22 +155,22 @@ public class BorderFactory
* for the inner and outer highlight and shadow areas.
*
* @param type An int specifying either BevelBorder.LOWERED or
- * BevelBorder.RAISED
+ * BevelBorder.RAISED
* @param highlightOuter A Color object for the outer edge of the
- * highlight area
+ * highlight area
* @param highlightInner A Color object for the inner edge of the
- * highlight area
+ * highlight area
* @param shadowOuter A Color object for the outer edge of the shadow area
* @param shadowInner A Color object for the inner edge of the shadow area
*
* @return The Border object
- */
- public static Border createBevelBorder (int type, Color highlightOuter,
- Color highlightInner,
- Color shadowOuter, Color shadowInner)
+ */
+ public static Border createBevelBorder(int type, Color highlightOuter,
+ Color highlightInner,
+ Color shadowOuter, Color shadowInner)
{
- return new BevelBorder (type, highlightOuter, highlightInner, shadowOuter,
- shadowInner);
+ return new BevelBorder(type, highlightOuter, highlightInner, shadowOuter,
+ shadowInner);
}
/**
@@ -174,10 +178,10 @@ public class BorderFactory
* background color for highlighting and shading.
*
* @return The Border object
- */
- public static Border createEtchedBorder ()
+ */
+ public static Border createEtchedBorder()
{
- return new EtchedBorder ();
+ return new EtchedBorder();
}
/**
@@ -185,10 +189,10 @@ public class BorderFactory
* background color for highlighting and shading.
*
* @return The Border object
- */
- public static Border createEtchedBorder (int etchType)
+ */
+ public static Border createEtchedBorder(int etchType)
{
- return new EtchedBorder (etchType);
+ return new EtchedBorder(etchType);
}
/**
@@ -199,10 +203,10 @@ public class BorderFactory
* @param shadow A Color object for the border shadows
*
* @return The Border object
- */
- public static Border createEtchedBorder (Color highlight, Color shadow)
+ */
+ public static Border createEtchedBorder(Color highlight, Color shadow)
{
- return new EtchedBorder (highlight, shadow);
+ return new EtchedBorder(highlight, shadow);
}
/**
@@ -213,11 +217,11 @@ public class BorderFactory
* @param shadow A Color object for the border shadows
*
* @return The Border object
- */
- public static Border createEtchedBorder (int etchType, Color highlight,
- Color shadow)
+ */
+ public static Border createEtchedBorder(int etchType, Color highlight,
+ Color shadow)
{
- return new EtchedBorder (etchType, highlight, shadow);
+ return new EtchedBorder(etchType, highlight, shadow);
}
/**
@@ -229,10 +233,10 @@ public class BorderFactory
* @param title A String containing the text of the title
*
* @return The TitledBorder object
- */
- public static TitledBorder createTitledBorder (String title)
+ */
+ public static TitledBorder createTitledBorder(String title)
{
- return new TitledBorder (title);
+ return new TitledBorder(title);
}
/**
@@ -246,10 +250,10 @@ public class BorderFactory
* @param border The Border object to add the title to
*
* @return The TitledBorder object
- */
- public static TitledBorder createTitledBorder (Border border)
+ */
+ public static TitledBorder createTitledBorder(Border border)
{
- return new TitledBorder (border);
+ return new TitledBorder(border);
}
/**
@@ -258,14 +262,14 @@ public class BorderFactory
* justification (left) and using the default font and text color determined
* by the current look and feel.
*
- * @param order The Border object to add the title to
+ * @param border The Border object to add the title to
* @param title A String containing the text of the title
*
* @return The TitledBorder object
- */
- public static TitledBorder createTitledBorder (Border border, String title)
+ */
+ public static TitledBorder createTitledBorder(Border border, String title)
{
- return new TitledBorder (border, title);
+ return new TitledBorder(border, title);
}
/**
@@ -276,21 +280,22 @@ public class BorderFactory
* @param border The Border object to add the title to
* @param title A String containing the text of the title
* @param titleJustification An int specifying the left/right position of
- * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
- * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
+ * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
+ * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
* @param titlePosition An int specifying the vertical position of the text
- * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
- * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
- * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
- * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
+ * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
+ * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
+ * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
+ * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION
+ * (top).
*
* @return The TitledBorder object
- */
- public static TitledBorder createTitledBorder (Border border, String title,
+ */
+ public static TitledBorder createTitledBorder(Border border, String title,
int titleJustification,
int titlePosition)
{
- return new TitledBorder (border, title, titleJustification, titlePosition);
+ return new TitledBorder(border, title, titleJustification, titlePosition);
}
/**
@@ -301,24 +306,24 @@ public class BorderFactory
* @param border - the Border object to add the title to
* @param title - a String containing the text of the title
* @param titleJustification - an int specifying the left/right position of
- * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
- * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
+ * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
+ * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
* @param titlePosition - an int specifying the vertical position of the
- * text in relation to the border -- one of: TitledBorder.ABOVE_TOP,
- * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
- * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
- * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
+ * text in relation to the border -- one of: TitledBorder.ABOVE_TOP,
+ * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
+ * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
+ * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
* @param titleFont - a Font object specifying the title font
*
* @return The TitledBorder object
- */
- public static TitledBorder createTitledBorder (Border border, String title,
- int titleJustification,
- int titlePosition,
- Font titleFont)
+ */
+ public static TitledBorder createTitledBorder(Border border, String title,
+ int titleJustification,
+ int titlePosition,
+ Font titleFont)
{
- return new TitledBorder (border, title, titleJustification, titlePosition,
- titleFont);
+ return new TitledBorder(border, title, titleJustification, titlePosition,
+ titleFont);
}
/**
@@ -328,27 +333,25 @@ public class BorderFactory
* @param border - the Border object to add the title to
* @param title - a String containing the text of the title
* @param titleJustification - an int specifying the left/right position of
- * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
- * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
+ * the title -- one of TitledBorder.LEFT, TitledBorder.CENTER, or
+ * TitledBorder.RIGHT, TitledBorder.DEFAULT_JUSTIFICATION (left).
* @param titlePosition - an int specifying the vertical position of the text
- * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
- * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
- * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
- * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
+ * in relation to the border -- one of: TitledBorder.ABOVE_TOP,
+ * TitledBorder.TOP (sitting on the top line), TitledBorder.BELOW_TOP,
+ * TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM (sitting on the bottom
+ * line), TitledBorder.BELOW_BOTTOM, or TitledBorder.DEFAULT_POSITION (top).
* @param titleFont - a Font object specifying the title font
* @param titleColor - a Color object specifying the title color
*
* @return The TitledBorder object
- */
- public static TitledBorder createTitledBorder (Border border,
- String title,
- int titleJustification,
- int titlePosition,
- Font titleFont,
- Color titleColor)
+ */
+ public static TitledBorder createTitledBorder(Border border, String title,
+ int titleJustification,
+ int titlePosition,
+ Font titleFont, Color titleColor)
{
- return new TitledBorder (border, title, titleJustification, titlePosition,
- titleFont, titleColor);
+ return new TitledBorder(border, title, titleJustification, titlePosition,
+ titleFont, titleColor);
}
/**
@@ -356,10 +359,10 @@ public class BorderFactory
* bottom, left, and right sides are all zero.)
*
* @return The Border object
- */
- public static Border createEmptyBorder ()
+ */
+ public static Border createEmptyBorder()
{
- return new EmptyBorder (0, 0, 0, 0);
+ return new EmptyBorder(0, 0, 0, 0);
}
/**
@@ -372,21 +375,21 @@ public class BorderFactory
* @param right An int specifying the width of the bottom in pixels
*
* @return The Border object
- */
- public static Border createEmptyBorder (int top, int left, int bottom,
- int right)
+ */
+ public static Border createEmptyBorder(int top, int left, int bottom,
+ int right)
{
- return new EmptyBorder (top, left, bottom, right);
+ return new EmptyBorder(top, left, bottom, right);
}
/**
* Create a compound border with a null inside edge and a null outside edge.
*
* @return The CompoundBorder object
- */
- public static CompoundBorder createCompoundBorder ()
+ */
+ public static CompoundBorder createCompoundBorder()
{
- return new CompoundBorder ();
+ return new CompoundBorder();
}
/**
@@ -394,35 +397,39 @@ public class BorderFactory
* outside and inside edges.
*
* @param outsideBorder A Border object for the outer edge of the
- * compound border
+ * compound border
* @param insideBorder A Border object for the inner edge of the
- * compound border
+ * compound border
*
* @return The CompoundBorder object
- */
- public static CompoundBorder createCompoundBorder (Border outsideBorder,
- Border insideBorder)
+ */
+ public static CompoundBorder createCompoundBorder(Border outsideBorder,
+ Border insideBorder)
{
- return new CompoundBorder (outsideBorder, insideBorder);
+ return new CompoundBorder(outsideBorder, insideBorder);
}
/**
* Create a matte-look border using a solid color. (The difference between
- * this border and a line border is that you can specify the individual
- * border dimensions.)
- *
- * @param top An int specifying the width of the top in pixels
- * @param left An int specifying the width of the left side in pixels
- * @param bottom An int specifying the width of the right side in pixels
- * @param right An int specifying the width of the bottom in pixels
- * @param color A Color to use for the border
- *
+ * this border and a line border is that you can specify the individual border
+ * dimensions.)
+ *
+ * @param top
+ * An int specifying the width of the top in pixels
+ * @param left
+ * An int specifying the width of the left side in pixels
+ * @param bottom
+ * An int specifying the width of the right side in pixels
+ * @param right
+ * An int specifying the width of the bottom in pixels
+ * @param color
+ * A Color to use for the border
* @return The MatteBorder object
- */
- public static MatteBorder createMatteBorder (int top, int left, int bottom,
- int right, Color color)
+ */
+ public static MatteBorder createMatteBorder(int top, int left, int bottom,
+ int right, Color color)
{
- return new MatteBorder (top, left, bottom, right, color);
+ return new MatteBorder(top, left, bottom, right, color);
}
/**
@@ -440,10 +447,10 @@ public class BorderFactory
* @param tileIcon The Icon object used for the border tiles
*
* @return The MatteBorder object
- */
- public static MatteBorder createMatteBorder (int top, int left, int bottom,
- int right, Icon tileIcon)
+ */
+ public static MatteBorder createMatteBorder(int top, int left, int bottom,
+ int right, Icon tileIcon)
{
- return new MatteBorder (top, left, bottom, right, tileIcon);
+ return new MatteBorder(top, left, bottom, right, tileIcon);
}
}
diff --git a/javax/swing/BoundedRangeModel.java b/javax/swing/BoundedRangeModel.java
index 92cf69df8..5ca5a7e04 100644
--- a/javax/swing/BoundedRangeModel.java
+++ b/javax/swing/BoundedRangeModel.java
@@ -1,5 +1,5 @@
/* BoundedRangeModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,24 +38,36 @@ exception statement from your version. */
package javax.swing;
+import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
+ * The data model that represents a <i>range</i> that is constrained to fit
+ * within specified <i>bounds</i>. The range is defined as <code>value</code>
+ * to <code>value + extent</code>, where both <code>value</code> and
+ * <code>extent</code> are integers, and <code>extent >= 0</code>. The bounds
+ * are defined by integers <code>minimum</code> and <code>maximum</code>.
+ * <p>
+ * This type of model is used in components that display a range of values,
+ * like {@link JProgressBar} and {@link JSlider}.
+ *
* @author Andrew Selkirk
*/
public interface BoundedRangeModel
{
/**
- * getValue
+ * Returns the current value for the model.
*
- * @return int
+ * @return The current value for the model.
*
* @see #setValue(int)
*/
int getValue();
/**
- * setValue
+ * Sets the value for the model and sends a {@link ChangeEvent} to
+ * all registered listeners. The new value must satisfy the constraint
+ * <code>min <= value <= value + extent <= max</code>.
*
* @param value the value
*
@@ -64,16 +76,20 @@ public interface BoundedRangeModel
void setValue(int value);
/**
- * getMinimum
+ * Returns the lower bound for the model. The start of the model's range
+ * (see {@link #getValue()}) cannot be less than this lower bound.
*
- * @return int
+ * @return The lower bound for the model.
*
* @see #setMinimum(int)
+ * @see #getMaximum()
*/
int getMinimum();
/**
- * setMinimum
+ * Sets the lower bound for the model and sends a {@link ChangeEvent} to all
+ * registered listeners. The new minimum must be less than or equal to the
+ * start value of the model's range (as returned by {@link #getValue()}).
*
* @param minimum the minimum value
*
@@ -82,16 +98,22 @@ public interface BoundedRangeModel
void setMinimum(int minimum);
/**
- * getMaximum
+ * Returns the upper bound for the model. This sets an upper limit for the
+ * end value of the model's range ({@link #getValue()} +
+ * {@link #getExtent()}).
*
- * @return int
+ * @return The upper bound for the model.
*
* @see #setMaximum(int)
+ * @see #getMinimum()
*/
int getMaximum();
/**
- * setMaximum
+ * Sets the upper bound for the model and sends a {@link ChangeEvent} to all
+ * registered listeners. The new maximum must be greater than or equal to the
+ * end value of the model's range (as returned by {@link #getValue()} +
+ * {@link #getExtent()}).
*
* @param maximum the maximum value
*
@@ -105,12 +127,12 @@ public interface BoundedRangeModel
* @return <code>true</code> if value is adjusting,
* otherwise <code>false</code>
*
- * @see setValueIsAdjusting(boolean)
+ * @see #setValueIsAdjusting(boolean)
*/
boolean getValueIsAdjusting();
/**
- * setValueIsAdjusting
+ * Sets the <code>valueIsAdjusting</code> property.
*
* @param adjusting <code>true</code> if adjusting,
* <code>false</code> otherwise
@@ -129,7 +151,8 @@ public interface BoundedRangeModel
int getExtent();
/**
- * setExtent
+ * Sets the extent, which is the length of the model's range, and sends a
+ * {@link ChangeEvent} to all registered listeners.
*
* @param extent the extent
*
@@ -138,12 +161,14 @@ public interface BoundedRangeModel
void setExtent(int extent);
/**
- * setRangeProperties
+ * Sets all the properties for the model in a single call.
+ *
* @param value the value
* @param extent the extent
* @param minnimum the minimum value
* @param maximum the maximum value
- * @param adjusting TODO
+ * @param adjusting a flag that indicates the model is being adjusted
+ * continuously.
*/
void setRangeProperties(int value, int extent, int minimum, int maximum,
boolean adjusting);
@@ -153,7 +178,7 @@ public interface BoundedRangeModel
*
* @param listener the listener to add
*
- * @see #removeChangeListener(javax.swing.event.ChangeListener)
+ * @see #removeChangeListener(ChangeListener)
*/
void addChangeListener(ChangeListener listener);
@@ -162,7 +187,7 @@ public interface BoundedRangeModel
*
* @param listener the listener to remove
*
- * @see #addChangeListener(javax.swing.event.ChangeListener)
+ * @see #addChangeListener(ChangeListener)
*/
void removeChangeListener(ChangeListener listener);
}
diff --git a/javax/swing/Box.java b/javax/swing/Box.java
index 7532d3087..b2cb44ace 100644
--- a/javax/swing/Box.java
+++ b/javax/swing/Box.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -60,6 +60,9 @@ public class Box extends JComponent implements Accessible
{
private static final long serialVersionUID = 1525417495883046342L;
+ /**
+ * Provides accessibility support for <code>Box</code>es.
+ */
// FIXME: disable to make libjava compile; visibility rules are broken
protected class AccessibleBox // extends Container.AccessibleAWTContainer
{
@@ -82,6 +85,9 @@ public class Box extends JComponent implements Accessible
{
private static final long serialVersionUID = -1204263191910183998L;
+ /**
+ * Provides accessibility support for <code>Box.Filler</code>.
+ */
// FIXME: disable to make libjava compile; visibility rules are broken
protected class AccessibleBoxFiller // extends Component.AccessibleAWTComponent
{
@@ -192,7 +198,7 @@ public class Box extends JComponent implements Accessible
public static Component createGlue()
{
Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0),
- new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)
+ new Dimension(Short.MAX_VALUE,Short.MAX_VALUE)
);
return glue;
}
@@ -211,7 +217,10 @@ public class Box extends JComponent implements Accessible
*/
public static Component createHorizontalGlue()
{
- return createGlue();
+ Filler glue = new Filler(new Dimension(0,0), new Dimension(0,0),
+ new Dimension(Short.MAX_VALUE, 0)
+ );
+ return glue;
}
/**
diff --git a/javax/swing/BoxLayout.java b/javax/swing/BoxLayout.java
index 2d4abf944..28bb53928 100644
--- a/javax/swing/BoxLayout.java
+++ b/javax/swing/BoxLayout.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -45,14 +45,265 @@ import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.io.Serializable;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import gnu.java.awt.AWTUtilities;
/**
- * A layout for swing components.
+ * A layout that stacks the children of a container in a Box, either
+ * horizontally or vertically.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
+ * @author Roman Kennke (roman@kennke.org)
*/
public class BoxLayout implements LayoutManager2, Serializable
{
+
+ /**
+ * This is an abstraction that allows the BoxLayout algorithm to
+ * be applied to both direction (X and Y) without duplicating the
+ * algorithm. It defines several methods that access properties of
+ * a component for a specific direction.
+ */
+ static interface Direction
+ {
+ /**
+ * Returns the correct part of <code>d</code> for this direction. This will
+ * be <code>d.width</code> for horizontal and <code>d.height</code> for
+ * vertical direction.
+ *
+ * @param d the size as Dimension object
+ *
+ * @return the correct part of <code>d</code> for this direction
+ */
+ int size(Dimension d);
+
+ /**
+ * Returns the lower bounds of the {@link Insets} object according to this
+ * direction. This will be <code>insets.top</code> for vertical direction
+ * and <code>insets.left</code> for horizontal direction.
+ *
+ * @param the {@link Insets} object from which to return the lower bounds
+ *
+ * @return the lower bounds of the {@link Insets} object according to this
+ * direction
+ */
+ int lower(Insets insets);
+
+ /**
+ * Returns the alignment property according to this direction.
+ *
+ * @param comp the Component for which to return the alignment property
+ *
+ * @return the alignment property according to this direction
+ */
+ float alignment(Component comp);
+
+ /**
+ * Sets the location for Component <code>c</code>. <code>coord1</code>
+ * specifies the coordinate of the location in this direction,
+ * <code>coord2</code> the coordinate of the location in the opposite
+ * direction.
+ *
+ * @param c the Component for which to set the location
+ * @param coord1 the coordinate in this direction
+ * @param coord2 the coordinate in the opposite direction
+ */
+ void setLocation(Component c, int coord1, int coord2);
+
+ /**
+ * Sets the size for Component <code>c</code>. <code>coord1</code>
+ * specifies the size in this direction,
+ * <code>coord2</code> the size in the opposite
+ * direction.
+ *
+ * @param c the Component for which to set the size
+ * @param size1 the size in this direction
+ * @param size2 the size in the opposite direction
+ */
+ void setSize(Component c, int size1, int size2);
+ }
+
+ /**
+ * The horizontal direction.
+ */
+ static class Horizontal implements Direction
+ {
+ /**
+ * Returns the correct part of <code>d</code> for this direction. This will
+ * be <code>d.width</code> for horizontal and <code>d.height</code> for
+ * vertical direction.
+ *
+ * @param d the size as Dimension object
+ *
+ * @return the correct part of <code>d</code> for this direction
+ */
+ public int size(Dimension d)
+ {
+ return d.width;
+ }
+
+ /**
+ * Returns the lower bounds of the {@link Insets} object according to this
+ * direction. This will be <code>insets.top</code> for vertical direction
+ * and <code>insets.left</code> for horizontal direction.
+ *
+ * @param insets the {@link Insets} object from which to return the lower
+ * bounds
+ *
+ * @return the lower bounds of the {@link Insets} object according to this
+ * direction
+ */
+ public int lower(Insets insets)
+ {
+ return insets.left;
+ }
+
+ /**
+ * Returns the alignment property according to this direction.
+ *
+ * @param comp the Component for which to return the alignment property
+ *
+ * @return the alignment property according to this direction
+ */
+ public float alignment(Component comp)
+ {
+ return comp.getAlignmentX();
+ }
+
+ /**
+ * Sets the location for Component <code>c</code>. <code>coord1</code>
+ * specifies the coordinate of the location in this direction,
+ * <code>coord2</code> the coordinate of the location in the opposite
+ * direction.
+ *
+ * @param c the Component for which to set the location
+ * @param coord1 the coordinate in this direction
+ * @param coord2 the coordinate in the opposite direction
+ */
+ public void setLocation(Component c, int coord1, int coord2)
+ {
+ c.setLocation(coord1, coord2);
+ }
+
+ /**
+ * Sets the size for Component <code>c</code>. <code>coord1</code>
+ * specifies the size in this direction,
+ * <code>coord2</code> the size in the opposite
+ * direction.
+ *
+ * @param c the Component for which to set the size
+ * @param size1 the size in this direction
+ * @param size2 the size in the opposite direction
+ */
+ public void setSize(Component c, int size1, int size2)
+ {
+ c.setSize(size1, size2);
+ }
+ }
+ /**
+ * The vertical direction.
+ */
+ static class Vertical implements Direction
+ {
+ /**
+ * Returns the correct part of <code>d</code> for this direction. This will
+ * be <code>d.width</code> for horizontal and <code>d.height</code> for
+ * vertical direction.
+ *
+ * @param d the size as Dimension object
+ *
+ * @return the correct part of <code>d</code> for this direction
+ */
+ public int size(Dimension d)
+ {
+ return d.height;
+ }
+
+ /**
+ * Returns the lower bounds of the {@link Insets} object according to this
+ * direction. This will be <code>insets.top</code> for vertical direction
+ * and <code>insets.left</code> for horizontal direction.
+ *
+ * @param insets the {@link Insets} object from which to return the lower
+ * bounds
+ *
+ * @return the lower bounds of the {@link Insets} object according to this
+ * direction
+ */
+ public int lower(Insets insets)
+ {
+ return insets.top;
+ }
+
+ /**
+ * Returns the alignment property according to this direction.
+ *
+ * @param comp the Component for which to return the alignment property
+ *
+ * @return the alignment property according to this direction
+ */
+ public float alignment(Component comp)
+ {
+ return comp.getAlignmentY();
+ }
+
+ /**
+ * Sets the location for Component <code>c</code>. <code>coord1</code>
+ * specifies the coordinate of the location in this direction,
+ * <code>coord2</code> the coordinate of the location in the opposite
+ * direction.
+ *
+ * @param c the Component for which to set the location
+ * @param coord1 the coordinate in this direction
+ * @param coord2 the coordinate in the opposite direction
+ */
+ public void setLocation(Component c, int coord1, int coord2)
+ {
+ c.setLocation(coord2, coord1);
+ }
+
+ /**
+ * Sets the size for Component <code>c</code>. <code>coord1</code>
+ * specifies the size in this direction,
+ * <code>coord2</code> the size in the opposite
+ * direction.
+ *
+ * @param c the Component for which to set the size
+ * @param size1 the size in this direction
+ * @param size2 the size in the opposite direction
+ */
+ public void setSize(Component c, int size1, int size2)
+ {
+ c.setSize(size2, size1);
+ }
+ }
+
+ /**
+ * A helper class that temporarily stores the size specs of a component.
+ */
+ static class SizeReq
+ {
+ int size;
+ int min;
+ int pref;
+ int max;
+ float align;
+ Component comp;
+ SizeReq(Component comp, Direction dir)
+ {
+ this.min = dir.size(comp.getMinimumSize());
+ this.pref = dir.size(comp.getPreferredSize());
+ this.max = dir.size(comp.getMaximumSize());
+ this.size = dir.size(comp.getSize());
+ this.align = dir.alignment(comp);
+ this.comp = comp;
+ }
+ }
+
/**
* Specifies that components are laid out left to right.
*/
@@ -88,6 +339,12 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
private int way = X_AXIS;
+ /** Constant for the horizontal direction. */
+ private static final Direction HORIZONTAL = new Horizontal();
+
+ /** Constant for the vertical direction. */
+ private static final Direction VERTICAL = new Vertical();
+
/**
* Constructs a <code>BoxLayout</code> object.
*
@@ -151,16 +408,16 @@ public class BoxLayout implements LayoutManager2, Serializable
int x = 0;
int y = 0;
- Component[] children = parent.getComponents();
+ List children = AWTUtilities.getVisibleChildren(parent);
if (isHorizontalIn(parent))
{
x = insets.left + insets.right;
// sum up preferred widths of components, find maximum of preferred
// heights
- for (int index = 0; index < children.length; index++)
+ for (Iterator i = children.iterator(); i.hasNext();)
{
- Component comp = children[index];
+ Component comp = (Component) i.next();
Dimension sz = comp.getPreferredSize();
x += sz.width;
y = Math.max(y, sz.height);
@@ -172,9 +429,9 @@ public class BoxLayout implements LayoutManager2, Serializable
y = insets.top + insets.bottom;
// sum up preferred heights of components, find maximum of
// preferred widths
- for (int index = 0; index < children.length; index++)
+ for (Iterator i = children.iterator(); i.hasNext();)
{
- Component comp = children[index];
+ Component comp = (Component) i.next();
Dimension sz = comp.getPreferredSize();
y += sz.height;
x = Math.max(x, sz.width);
@@ -201,15 +458,15 @@ public class BoxLayout implements LayoutManager2, Serializable
int x = insets.left + insets.right;
int y = insets.bottom + insets.top;
- Component[] children = parent.getComponents();
+ List children = AWTUtilities.getVisibleChildren(parent);
if (isHorizontalIn(parent))
{
// sum up preferred widths of components, find maximum of preferred
// heights
- for (int index = 0; index < children.length; index++)
+ for (Iterator i = children.iterator(); i.hasNext();)
{
- Component comp = children[index];
+ Component comp = (Component) i.next();
Dimension sz = comp.getMinimumSize();
x += sz.width;
y = Math.max(y, sz.height);
@@ -219,9 +476,9 @@ public class BoxLayout implements LayoutManager2, Serializable
{
// sum up preferred heights of components, find maximum of
// preferred widths
- for (int index = 0; index < children.length; index++)
+ for (Iterator i = children.iterator(); i.hasNext();)
{
- Component comp = children[index];
+ Component comp = (Component) i.next();
Dimension sz = comp.getMinimumSize();
y += sz.height;
x = Math.max(x, sz.width);
@@ -238,163 +495,10 @@ public class BoxLayout implements LayoutManager2, Serializable
*/
public void layoutContainer(Container parent)
{
- if (parent != container)
- throw new AWTError("invalid parent");
-
- Dimension size = parent.getSize();
- Insets insets = parent.getInsets();
- Dimension innerSize = new Dimension(size.width - insets.left
- - insets.right, size.height
- - insets.bottom - insets.top);
- Component[] children = parent.getComponents();
- boolean[] laidOut = new boolean[children.length];
- for (int index = 0; index < laidOut.length; index++)
- laidOut[index] = false;
-
if (isHorizontalIn(parent))
- {
- // compute overall preferred width
- int preferredWidthAll = 0;
- for (int index = 0; index < children.length; index++)
- {
- preferredWidthAll += children[index].getPreferredSize().width;
- }
- double widthFactor = (double) innerSize.width /
- (double) preferredWidthAll;
-
- // sort out components that are constrained by minimum or maximum size
- int widthRemain = innerSize.width;
- for (int index = 0; index < children.length; index++)
- {
- Component comp = children[index];
- Dimension sz = comp.getPreferredSize();
- Dimension minSize = comp.getMinimumSize();
- Dimension maxSize = comp.getMaximumSize();
- int width = (int) (sz.width * widthFactor);
- int height = Math.min(innerSize.height, maxSize.height);
- // check min size
- if (width < minSize.width)
- {
- width = minSize.width;
- comp.setSize(width, height);
- laidOut[index] = true;
- preferredWidthAll -= sz.width;
- widthRemain -= width;
- continue;
- }
- // check max size
- if (width > maxSize.width)
- {
- width = maxSize.width;
- comp.setSize(width, height);
- laidOut[index] = true;
- preferredWidthAll -= sz.width;
- widthRemain -= width;
- continue;
- }
-
- }
-
- // recompute widthFactor for remaining components
- widthFactor = (double) widthRemain / (double) preferredWidthAll;
-
- int x = insets.left;
-
- // lay out remaining comonents
- for (int index = 0; index < children.length; index++)
- {
- Component comp = children[index];
- int width = 0;
-
- if (!laidOut[index])
- {
- Dimension sz = comp.getPreferredSize();
- Dimension maxSize = comp.getMaximumSize();
- width = (int) (sz.width * widthFactor);
- int height = Math.min(innerSize.height, maxSize.height);
- comp.setSize(width, height);
- }
- else
- width = comp.getWidth();
-
- int cy = (int) ((innerSize.height - comp.getHeight())
- * comp.getAlignmentY() + insets.top);
- comp.setLocation(x, cy);
- x = x + width;
- }
- }
+ layoutAlgorithm(parent, HORIZONTAL, VERTICAL);
else
- {
- // compute overall preferred height
- int preferredHeightAll = 0;
- for (int index = 0; index < children.length; index++)
- {
- preferredHeightAll += children[index].getPreferredSize().height;
- }
- double heightFactor = (double) innerSize.height /
- (double) preferredHeightAll;
-
- // sort out components that are constrained by minimum or maximum size
- int heightRemain = innerSize.height;
- for (int index = 0; index < children.length; index++)
- {
- Component comp = children[index];
- Dimension sz = comp.getPreferredSize();
- Dimension minSize = comp.getMinimumSize();
- Dimension maxSize = comp.getMaximumSize();
- int height = (int) (sz.height * heightFactor);
- int width = Math.min(innerSize.width, maxSize.width);
- // check min size
- if (height < minSize.height)
- {
- height = minSize.height;
- comp.setSize(width, height);
- laidOut[index] = true;
- preferredHeightAll -= sz.height;
- heightRemain -= height;
- continue;
- }
- // check max size
- if (height > maxSize.height)
- {
- height = maxSize.height;
- comp.setSize(width, height);
- laidOut[index] = true;
- preferredHeightAll -= sz.height;
- heightRemain -= height;
- continue;
- }
-
- }
-
- // recompute heightFactor for remaining components
- heightFactor = (double) heightRemain / (double) preferredHeightAll;
-
- int y = insets.top;
-
- // lay out remaining comonents
- for (int index = 0; index < children.length; index++)
- {
- Component comp = children[index];
- int height = 0;
-
- if (!laidOut[index])
- {
- Dimension sz = comp.getPreferredSize();
- Dimension maxSize = comp.getMaximumSize();
- height = (int) (sz.height * heightFactor);
- int width = Math.min(innerSize.width, maxSize.width);
- comp.setSize(width, height);
- }
- else
- height = comp.getHeight();
-
- int cx = (int) ((innerSize.width - comp.getWidth())
- * comp.getAlignmentX() + insets.left);
- comp.setLocation(cx, y);
- y = y + height;
- }
- }
+ layoutAlgorithm(parent, VERTICAL, HORIZONTAL);
}
/**
@@ -465,16 +569,16 @@ public class BoxLayout implements LayoutManager2, Serializable
int x = insets.left + insets.right;
int y = insets.top + insets.bottom;
- Component[] children = parent.getComponents();
+ List children = AWTUtilities.getVisibleChildren(parent);
if (isHorizontalIn(parent))
{
// sum up preferred widths of components, find maximum of preferred
// heights
- for (int index = 0; index < children.length; index++)
+ for (Iterator i = children.iterator(); i.hasNext();)
{
- Component comp = children[index];
+ Component comp = (Component) i.next();
Dimension sz = comp.getMaximumSize();
x += sz.width;
// Check for overflow.
@@ -487,9 +591,9 @@ public class BoxLayout implements LayoutManager2, Serializable
{
// sum up preferred heights of components, find maximum of
// preferred widths
- for (int index = 0; index < children.length; index++)
+ for (Iterator i = children.iterator(); i.hasNext();)
{
- Component comp = children[index];
+ Component comp = (Component) i.next();
Dimension sz = comp.getMaximumSize();
y += sz.height;
// Check for overflow
@@ -500,4 +604,146 @@ public class BoxLayout implements LayoutManager2, Serializable
}
return new Dimension(x, y);
}
+
+ /**
+ * Lays out the Container <code>c</code> in the layout direction
+ * <code>layoutDir</code>. The direction that is crossing the layout
+ * direction is specified in <code>crossDir</code>.
+ *
+ * @param parent
+ * @param layoutDir
+ * @param crossDir
+ */
+ void layoutAlgorithm(Container parent, Direction layoutDir, Direction crossDir)
+ {
+ if (parent != container)
+ throw new AWTError("invalid parent");
+
+ Dimension parentSize = parent.getSize();
+ Insets insets = parent.getInsets();
+ Dimension innerSize = new Dimension(parentSize.width - insets.left
+ - insets.right, parentSize.height
+ - insets.bottom - insets.top);
+
+ // Set all components to their preferredSizes and sum up the allocated
+ // space. Create SizeReqs for each component and store them in
+ // sizeReqs. Find the maximum size in the crossing direction.
+ List children = AWTUtilities.getVisibleChildren(parent);
+ Vector sizeReqs = new Vector();
+ int allocated = 0;
+ for (Iterator i = children.iterator(); i.hasNext();)
+ {
+ Component c = (Component) i.next();
+ SizeReq sizeReq = new SizeReq(c, layoutDir);
+ int preferred = layoutDir.size(c.getPreferredSize());
+ sizeReq.size = preferred;
+ allocated += preferred;
+ sizeReqs.add(sizeReq);
+ }
+
+ // Distribute remaining space (may be positive or negative) over components
+ int remainder = layoutDir.size(innerSize) - allocated;
+ distributeSpace(sizeReqs, remainder, layoutDir);
+
+ // Resize and relocate components. If the component can be sized to
+ // take the full space in the crossing direction, then do so, otherwise
+ // align according to its alingnmentX or alignmentY property.
+ int loc = 0;
+ int offset1 = layoutDir.lower(insets);
+ int offset2 = crossDir.lower(insets);
+ for (Iterator i = sizeReqs.iterator(); i.hasNext();)
+ {
+ SizeReq sizeReq = (SizeReq) i.next();
+ Component c = sizeReq.comp;
+ int availCrossSize = crossDir.size(innerSize);
+ int maxCross = crossDir.size(c.getMaximumSize());
+ int crossSize = Math.min(availCrossSize, maxCross);
+ int crossRemainder = availCrossSize - crossSize;
+ int crossLoc = (int) (crossDir.alignment(c) * crossRemainder);
+ layoutDir.setSize(c, sizeReq.size, crossSize);
+ layoutDir.setLocation(c, offset1 + loc, offset2 + crossLoc);
+ loc += sizeReq.size;
+ }
+ }
+
+ /**
+ * Distributes some space over a set of components. This implementation
+ * tries to set the components as close as possible to their
+ * <code>preferredSize</code>s, and respects the components
+ * <code>minimumSize</code> and <code>maximumSize</code>.
+ *
+ * The algorithm is implemented as follows:
+ *
+ * <ul>
+ * <li>The <code>remainder</code> is divided by the number of components
+ * in <code>freeComponents</code>.</li>
+ * <li>The result is added to (or substracted from) the size of each
+ * component.</li>
+ * <li>If the <code>minimumSize</code> or <code>maximumSize</code> of a
+ * component is exceeded, then this component is set to its
+ * <code>minimumSize</code> or <code>maximumSize</code>, it is removed from
+ * <code>freeComponents</code> and the difference is added to a new
+ * remainder.</li>
+ * <li>Finally, if there is a new remainer != 0 and the
+ * <code>freeComponents.size() != 0</code>, then this method is called
+ * recursivly to distribute the newly allocated remaining space.</li>
+ * </ul>
+ *
+ * @param freeComponents a SizeReq collection for components that have space
+ * left so that they can be moved freely
+ * @param remainder the space that should be distributed between the
+ * components
+ * @param dir the direction in which we operate
+ */
+ void distributeSpace(Collection freeComponents, int remainder, Direction dir)
+ {
+ // Sum up total available space in components. If the remainder is negative
+ // then we sum up the difference between minSize and size. If remainder
+ // is positive we sum up the difference between maxSize and size.
+ double totalAvailable = 0;
+ for (Iterator i = freeComponents.iterator(); i.hasNext();)
+ {
+ SizeReq sizeReq = (SizeReq) i.next();
+ if (remainder >= 0)
+ totalAvailable += sizeReq.max - sizeReq.size;
+ else
+ totalAvailable += sizeReq.min - sizeReq.size;
+ }
+ if (totalAvailable == 0)
+ if (remainder >= 0)
+ totalAvailable = 1;
+ else
+ totalAvailable = -1;
+
+ int newRemainder = 0;
+ Vector stillFree = new Vector();
+ for (Iterator i = freeComponents.iterator(); i.hasNext();)
+ {
+ // Add/substract share to component.
+ SizeReq sizeReq = (SizeReq) i.next();
+ double available = 0;
+ if (remainder >= 0)
+ available = sizeReq.max - sizeReq.size;
+ else
+ available = sizeReq.min - sizeReq.size;
+ int share = (int) ((available / totalAvailable) * remainder);
+ sizeReq.size += share;
+ // check for min/maximumSize
+ if (sizeReq.size < sizeReq.min)
+ {
+ newRemainder += sizeReq.size - sizeReq.min;
+ sizeReq.size = sizeReq.min;
+ }
+ else if (sizeReq.size > sizeReq.max)
+ {
+ newRemainder += sizeReq.size - sizeReq.max;
+ sizeReq.size = sizeReq.max;
+ }
+ else
+ stillFree.add(sizeReq);
+ }
+ // recursivly call this method if necessary
+ if (newRemainder != 0 && stillFree.size() > 0)
+ distributeSpace(stillFree, newRemainder, dir);
+ }
}
diff --git a/javax/swing/ButtonGroup.java b/javax/swing/ButtonGroup.java
index 5f6a28d86..3de1d4b9f 100644
--- a/javax/swing/ButtonGroup.java
+++ b/javax/swing/ButtonGroup.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,7 +43,25 @@ import java.util.Vector;
/**
- * DOCUMENT ME!
+ * Logically groups a set of buttons, so that only one of the buttons in
+ * a <code>ButtonGroup</code> can be selected at the same time. If one
+ * button in a <code>ButtonGroup</code> is selected, all other buttons
+ * are automatically deselected.
+ *
+ * While <code>ButtonGroup</code> can be used for all buttons that are derived
+ * from {@link AbstractButton}, it is normally only used for
+ * {@link JRadioButton}s, {@link JRadioButtonMenuItem}s and
+ * {@link JToggleButton}s.
+ *
+ * You could use it for {@link JCheckBox}es, but for the sake of usability
+ * this is strongly discouraged because the common expectation of checkboxes
+ * is that the user is allowed to make multiple selections.
+ *
+ * It makes no sense to put {@link JButton}s or {@link JMenuItem}s in
+ * a <code>ButtonGroup</code> because they don't implement the
+ * <code>selected</code> semantics.
+ *
+ * @author original author unknown
*/
public class ButtonGroup implements Serializable
{
@@ -138,16 +156,16 @@ public class ButtonGroup implements Serializable
if (b && sel != m)
{
- ButtonModel old = sel;
- sel = m;
-
- if (old != null)
- old.setSelected(false);
- AbstractButton button = FindButton(old);
- if (button != null)
- button.repaint();
+ ButtonModel old = sel;
+ sel = m;
+
+ if (old != null)
+ old.setSelected(false);
+ AbstractButton button = FindButton(old);
+ if (button != null)
+ button.repaint();
}
- else if (! b && sel == m)
+ else if (!b && sel == m)
m.setSelected(true);
}
diff --git a/javax/swing/ButtonModel.java b/javax/swing/ButtonModel.java
index 0c704bed2..1bdc5d185 100644
--- a/javax/swing/ButtonModel.java
+++ b/javax/swing/ButtonModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -44,6 +44,9 @@ import java.awt.event.ItemListener;
import javax.swing.event.ChangeListener;
+/**
+ * The data model that is used in all kinds of buttons.
+ */
public interface ButtonModel extends ItemSelectable
{
boolean isArmed();
diff --git a/javax/swing/CellEditor.java b/javax/swing/CellEditor.java
index 5c298dbca..bdb166575 100644
--- a/javax/swing/CellEditor.java
+++ b/javax/swing/CellEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,9 +43,10 @@ import java.util.EventObject;
import javax.swing.event.CellEditorListener;
/**
- * CellEditor
- * @author Andrew Selkirk
- * @version 1.0
+ * Provides edit capabilities for components that display cells like
+ * {@link JTable}, {@link JList} and {@link JTree}.
+ *
+ * @author Andrew Selkirk
*/
public interface CellEditor
{
diff --git a/javax/swing/CellRendererPane.java b/javax/swing/CellRendererPane.java
index 0ef270bf8..886d5c5f2 100644
--- a/javax/swing/CellRendererPane.java
+++ b/javax/swing/CellRendererPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,20 +42,17 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
- * The CellRendererPane's purpose is to paint the cells of JList, JTable and
- * JTree. It intercepts the usual paint tree, so that we don't walk up and
+ * Paints the cells of JList, JTable and JTree.
+ * It intercepts the usual paint tree, so that we don't walk up and
* repaint everything.
*
- * @author Andrew Selkirk
- * @version 1.0
+ * @author Andrew Selkirk
*/
public class CellRendererPane
extends Container
@@ -64,7 +61,7 @@ public class CellRendererPane
private static final long serialVersionUID = -7642183829532984273L;
/**
- * AccessibleCellRendererPane
+ * Provides accessibility support for CellRendererPanes.
*/
protected class AccessibleCellRendererPane extends AccessibleAWTContainer
{
@@ -72,7 +69,6 @@ public class CellRendererPane
/**
* Constructor AccessibleCellRendererPane
- * @param component TODO
*/
protected AccessibleCellRendererPane()
{
@@ -216,10 +212,9 @@ public class CellRendererPane
* @param h the height of the components drawing area
*/
public void paintComponent(Graphics graphics, Component c,
- Container p, int x, int y, int w, int h) {
-
+ Container p, int x, int y, int w, int h)
+ {
paintComponent(graphics, c, p, x, y, w, h, false);
-
} // paintComponent()
/**
@@ -237,9 +232,7 @@ public class CellRendererPane
public void paintComponent(Graphics graphics, Component c,
Container p, Rectangle r)
{
-
paintComponent(graphics, c, p, r.x, r.y, r.width, r.height);
-
} // paintComponent()
/**
diff --git a/javax/swing/ComboBoxEditor.java b/javax/swing/ComboBoxEditor.java
index 30813175a..4eb5fc562 100644
--- a/javax/swing/ComboBoxEditor.java
+++ b/javax/swing/ComboBoxEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,11 +41,10 @@ import java.awt.Component;
import java.awt.event.ActionListener;
/**
- * ComboBoxEditor
+ * Provides edit capabilities for {@link JComboBox}es.
*
* @author Andrew Selkirk
* @author Olga Rodimina
- * @version 1.0
*/
public interface ComboBoxEditor
{
diff --git a/javax/swing/ComboBoxModel.java b/javax/swing/ComboBoxModel.java
index c3b59bda6..6968db490 100644
--- a/javax/swing/ComboBoxModel.java
+++ b/javax/swing/ComboBoxModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,13 +39,12 @@ package javax.swing;
/**
- * ComboBoxModel is a data model for JComboBox. This model keeps
+ * The data model for {@link 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
+ * @author Andrew Selkirk
*/
public interface ComboBoxModel extends ListModel
{
diff --git a/javax/swing/ComponentInputMap.java b/javax/swing/ComponentInputMap.java
index 1c85892f5..f95c31045 100644
--- a/javax/swing/ComponentInputMap.java
+++ b/javax/swing/ComponentInputMap.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,6 +39,9 @@ package javax.swing;
/**
+ * An {@link InputMap} that is associated with a particular {@link JComponent}.
+ * The component is notified when its <code>ComponentInputMap</code> changes.
+ *
* @author Andrew Selkirk
* @author Michael Koch
*/
@@ -70,7 +73,7 @@ public class ComponentInputMap extends InputMap
* If actionMapKey is null an existing entry will be removed.
*
* @param keystroke the keystroke for the entry
- * @param actionMapKey the action.
+ * @param value the action.
*/
public void put(KeyStroke keystroke, Object value)
{
@@ -90,7 +93,7 @@ public class ComponentInputMap extends InputMap
/**
* Remove an entry from the <code>InputMap</code>.
*
- * @param key the key of the entry to remove
+ * @param keystroke the key of the entry to remove
*/
public void remove(KeyStroke keystroke)
{
@@ -103,7 +106,7 @@ public class ComponentInputMap extends InputMap
*
* @param parentMap the new parent
*
- * @exception IllegalArgument if parentMap is not a
+ * @exception IllegalArgumentException if parentMap is not a
* <code>ComponentInputMap</code> or not associated with the same component
*/
public void setParent(InputMap parentMap)
diff --git a/javax/swing/DebugGraphics.java b/javax/swing/DebugGraphics.java
index 074d45114..137b82337 100644
--- a/javax/swing/DebugGraphics.java
+++ b/javax/swing/DebugGraphics.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -50,9 +50,11 @@ import java.text.AttributedCharacterIterator;
/**
- * DebugGraphics
- * @author Andrew Selkirk
- * @version 1.0
+ * An extension of {@link Graphics} that can be used for debugging
+ * custom Swing widgets. <code>DebugGraphics</code> has the ability to
+ * draw slowly and can log drawing actions.
+ *
+ * @author Andrew Selkirk
*/
public class DebugGraphics extends Graphics
{
@@ -404,11 +406,11 @@ public class DebugGraphics extends Graphics
{
try
{
- Thread.sleep(milliseconds);
+ Thread.sleep(milliseconds);
}
catch (InterruptedException e)
{
- // Ignore this.
+ // Ignore this.
}
}
@@ -424,13 +426,13 @@ public class DebugGraphics extends Graphics
{
for (int index = 0; index < (debugFlashCount - 1); ++index)
{
- graphics.setColor(color);
- graphics.drawRect(x, y, width, height);
- sleep(debugFlashTime);
-
- graphics.setColor(debugFlashColor);
- graphics.drawRect(x, y, width, height);
- sleep(debugFlashTime);
+ graphics.setColor(color);
+ graphics.drawRect(x, y, width, height);
+ sleep(debugFlashTime);
+
+ graphics.setColor(debugFlashColor);
+ graphics.drawRect(x, y, width, height);
+ sleep(debugFlashTime);
}
graphics.setColor(color);
@@ -449,13 +451,13 @@ public class DebugGraphics extends Graphics
{
for (int index = 0; index < (debugFlashCount - 1); ++index)
{
- graphics.setColor(color);
- graphics.fillRect(x, y, width, height);
- sleep(debugFlashTime);
-
- graphics.setColor(debugFlashColor);
- graphics.fillRect(x, y, width, height);
- sleep(debugFlashTime);
+ graphics.setColor(color);
+ graphics.fillRect(x, y, width, height);
+ sleep(debugFlashTime);
+
+ graphics.setColor(debugFlashColor);
+ graphics.fillRect(x, y, width, height);
+ sleep(debugFlashTime);
}
graphics.setColor(color);
@@ -696,13 +698,13 @@ public class DebugGraphics extends Graphics
{
for (int index = 0; index < (debugFlashCount - 1); ++index)
{
- graphics.setColor(color);
- graphics.drawChars(data, offset, length, x, y);
- sleep(debugFlashTime);
-
- graphics.setColor(debugFlashColor);
- graphics.drawChars(data, offset, length, x, y);
- sleep(debugFlashTime);
+ graphics.setColor(color);
+ graphics.drawChars(data, offset, length, x, y);
+ sleep(debugFlashTime);
+
+ graphics.setColor(debugFlashColor);
+ graphics.drawChars(data, offset, length, x, y);
+ sleep(debugFlashTime);
}
graphics.setColor(color);
diff --git a/javax/swing/DefaultBoundedRangeModel.java b/javax/swing/DefaultBoundedRangeModel.java
index 9c1962379..10de4b948 100644
--- a/javax/swing/DefaultBoundedRangeModel.java
+++ b/javax/swing/DefaultBoundedRangeModel.java
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -47,7 +47,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
- * A default implementation of <code>BoundedRangeModel</code>.
+ * The default implementation of <code>BoundedRangeModel</code>.
*
* @author Andrew Selkirk (aselkirk@sympatico.ca)
* @author Sascha Brawer (brawer@dandelis.ch)
@@ -61,7 +61,6 @@ public class DefaultBoundedRangeModel
*/
private static final long serialVersionUID = 5034068491295259790L;
-
/**
* An event that is sent to all registered {@link ChangeListener}s
* when the state of this range model has changed.
@@ -73,13 +72,11 @@ public class DefaultBoundedRangeModel
*/
protected transient ChangeEvent changeEvent;
-
/**
* The list of the currently registered EventListeners.
*/
protected EventListenerList listenerList = new EventListenerList();
-
/**
* The current value of the range model, which is always between
* {@link #minimum} and ({@link #maximum} - {@link #extent}). In a
@@ -88,7 +85,6 @@ public class DefaultBoundedRangeModel
*/
private int value;
-
/**
* The current extent of the range model, which is a number greater
* than or equal to zero. In a scroll bar visualization of a {@link
@@ -97,28 +93,24 @@ public class DefaultBoundedRangeModel
*/
private int extent;
-
/**
* The current minimum value of the range model, which is always
* less than or equal to {@link #maximum}.
*/
private int minimum;
-
/**
* The current maximum value of the range model, which is always
* greater than or equal to {@link #minimum}.
*/
private int maximum;
-
/**
* A property that indicates whether the value of this {@link
* BoundedRangeModel} is going to change in the immediate future.
*/
private boolean isAdjusting;
-
/**
* Constructs a <code>DefaultBoundedRangeModel</code> with default
* values for the properties. The properties <code>value</code>,
@@ -134,29 +126,25 @@ public class DefaultBoundedRangeModel
maximum = 100;
}
-
/**
* Constructs a <code>DefaultBoundedRangeModel</code> with the
* specified values for some properties.
*
* @param value the initial value of the range model, which must be
- * a number between <code>minimum</code> and <code>(maximum -
- * extent)</code>. In a scroll bar visualization of a {@link
- * BoundedRangeModel}, the <code>value</code> is displayed as the
- * position of the thumb.
- *
+ * a number between <code>minimum</code> and <code>(maximum -
+ * extent)</code>. In a scroll bar visualization of a {@link
+ * BoundedRangeModel}, the <code>value</code> is displayed as the
+ * position of the thumb.
* @param extent the initial extent of the range model, which is a
- * number greater than or equal to zero. In a scroll bar
- * visualization of a {@link BoundedRangeModel}, the
- * <code>extent</code> is displayed as the size of the thumb.
- *
+ * number greater than or equal to zero. In a scroll bar
+ * visualization of a {@link BoundedRangeModel}, the
+ * <code>extent</code> is displayed as the size of the thumb.
* @param minimum the initial minimal value of the range model.
- *
* @param maximum the initial maximal value of the range model.
*
* @throws IllegalArgumentException if the following condition is
- * not satisfied: <code>minimum &lt;= value &lt;= value + extent &lt;=
- * maximum</code>.
+ * not satisfied: <code>minimum &lt;= value &lt;= value + extent &lt;=
+ * maximum</code>.
*/
public DefaultBoundedRangeModel(int value, int extent, int minimum,
int maximum)
@@ -172,7 +160,6 @@ public class DefaultBoundedRangeModel
// The isAdjusting field already has a false value by default.
}
-
/**
* Returns a string with all relevant properties of this range
* model.
@@ -190,7 +177,6 @@ public class DefaultBoundedRangeModel
+ ']';
}
-
/**
* Returns the current value of this bounded range model. In a
* scroll bar visualization of a {@link BoundedRangeModel}, the
@@ -203,7 +189,6 @@ public class DefaultBoundedRangeModel
return value;
}
-
/**
* Changes the current value of this bounded range model. In a
* scroll bar visualization of a {@link BoundedRangeModel}, the
@@ -226,7 +211,6 @@ public class DefaultBoundedRangeModel
}
}
-
/**
* Returns the current extent of this bounded range model, which is
* a number greater than or equal to zero. In a scroll bar
@@ -240,14 +224,13 @@ public class DefaultBoundedRangeModel
return extent;
}
-
/**
* Changes the current extent of this bounded range model. In a
* scroll bar visualization of a {@link BoundedRangeModel}, the
* <code>extent</code> is displayed as the size of the thumb.
*
* @param extent the new extent of the range model, which is a
- * number greater than or equal to zero.
+ * number greater than or equal to zero.
*/
public void setExtent(int extent)
{
@@ -262,7 +245,6 @@ public class DefaultBoundedRangeModel
}
}
-
/**
* Returns the current minimal value of this bounded range model.
*/
@@ -271,7 +253,6 @@ public class DefaultBoundedRangeModel
return minimum;
}
-
/**
* Changes the current minimal value of this bounded range model.
*
@@ -287,7 +268,6 @@ public class DefaultBoundedRangeModel
setRangeProperties(value, extent, minimum, maximum, isAdjusting);
}
-
/**
* Returns the current maximal value of this bounded range model.
*
@@ -298,7 +278,6 @@ public class DefaultBoundedRangeModel
return maximum;
}
-
/**
* Changes the current maximal value of this bounded range model.
*
@@ -315,7 +294,6 @@ public class DefaultBoundedRangeModel
setRangeProperties(value, extent, minimum, maximum, isAdjusting);
}
-
/**
* Returns whether or not the value of this bounded range model is
* going to change in the immediate future. Scroll bars set this
@@ -324,14 +302,13 @@ public class DefaultBoundedRangeModel
* <code>false</code> and post a final {@link ChangeEvent}.
*
* @return <code>true</code> if the value will change soon again;
- * <code>false</code> if the value will probably not change soon.
+ * <code>false</code> if the value will probably not change soon.
*/
public boolean getValueIsAdjusting()
{
return isAdjusting;
}
-
/**
* Specifies whether or not the value of this bounded range model is
* going to change in the immediate future. Scroll bars set this
@@ -340,8 +317,8 @@ public class DefaultBoundedRangeModel
* <code>false</code>.
*
* @param isAdjusting <code>true</code> if the value will change
- * soon again; <code>false</code> if the value will probably not
- * change soon.
+ * soon again; <code>false</code> if the value will probably not
+ * change soon.
*/
public void setValueIsAdjusting(boolean isAdjusting)
{
@@ -352,28 +329,23 @@ public class DefaultBoundedRangeModel
fireStateChanged();
}
-
/**
* Sets all properties.
*
* @param value the new value of the range model. In a scroll bar
- * visualization of a {@link BoundedRangeModel}, the
- * <code>value</code> is displayed as the position of the thumb.
- *
+ * visualization of a {@link BoundedRangeModel}, the
+ * <code>value</code> is displayed as the position of the thumb.
* @param extent the new extent of the range model, which is a
- * number greater than or equal to zero. In a scroll bar
- * visualization of a {@link BoundedRangeModel}, the
- * <code>extent</code> is displayed as the size of the thumb.
- *
+ * number greater than or equal to zero. In a scroll bar
+ * visualization of a {@link BoundedRangeModel}, the
+ * <code>extent</code> is displayed as the size of the thumb.
* @param minimum the new minimal value of the range model.
- *
* @param maximum the new maximal value of the range model.
-
* @param isAdjusting whether or not the value of this bounded range
- * model is going to change in the immediate future. Scroll bars set
- * this property to <code>true</code> while the thumb is being
- * dragged around; when the mouse is relased, they set the property
- * to <code>false</code>.
+ * model is going to change in the immediate future. Scroll bars set
+ * this property to <code>true</code> while the thumb is being
+ * dragged around; when the mouse is relased, they set the property
+ * to <code>false</code>.
*/
public void setRangeProperties(int value, int extent, int minimum,
int maximum, boolean isAdjusting)
@@ -400,7 +372,6 @@ public class DefaultBoundedRangeModel
fireStateChanged();
}
-
/**
* Subscribes a ChangeListener to state changes.
*
@@ -411,7 +382,6 @@ public class DefaultBoundedRangeModel
listenerList.add(ChangeListener.class, listener);
}
-
/**
* Cancels the subscription of a ChangeListener.
*
@@ -422,7 +392,6 @@ public class DefaultBoundedRangeModel
listenerList.remove(ChangeListener.class, listener);
}
-
/**
* Sends a {@link ChangeEvent} to any registered {@link
* ChangeListener}s.
@@ -441,15 +410,14 @@ public class DefaultBoundedRangeModel
listeners[i].stateChanged(changeEvent);
}
-
/**
* Retrieves the current listeners of the specified class.
*
- * @param c the class of listeners; usually {@link
- * ChangeListener}<code>.class</code>.
+ * @param listenerType the class of listeners; usually {@link
+ * ChangeListener}<code>.class</code>.
*
* @return an array with the currently subscribed listeners, or
- * an empty array if there are currently no listeners.
+ * an empty array if there are currently no listeners.
*
* @since 1.3
*/
@@ -458,14 +426,13 @@ public class DefaultBoundedRangeModel
return listenerList.getListeners(listenerType);
}
-
/**
* Returns all <code>ChangeListeners</code> that are currently
* subscribed for changes to this
* <code>DefaultBoundedRangeModel</code>.
*
* @return an array with the currently subscribed listeners, or
- * an empty array if there are currently no listeners.
+ * an empty array if there are currently no listeners.
*
* @since 1.4
*/
diff --git a/javax/swing/DefaultButtonModel.java b/javax/swing/DefaultButtonModel.java
index 021f02ced..f7d09d578 100644
--- a/javax/swing/DefaultButtonModel.java
+++ b/javax/swing/DefaultButtonModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing;
+import java.awt.ItemSelectable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@@ -51,6 +52,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
+ * The default implementation of {@link ButtonModel}.
* 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).
@@ -265,9 +267,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
- * Inform each ItemListener in the {@link listenerList} that an ItemEvent
+ * Inform each ItemListener in the {@link #listenerList} that an ItemEvent
* has occurred. This happens in response to any change to the {@link
- * stateMask} field.
+ * #stateMask} field.
*
* @param e The ItemEvent to fire
*/
@@ -280,9 +282,9 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
- * Inform each ActionListener in the {@link listenerList} that an
+ * 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
+ * the {@link #stateMask} field which makes the enabled, armed and pressed
* properties all simultaneously <code>true</code>.
*
* @param e The ActionEvent to fire
@@ -296,7 +298,7 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
- * Inform each ChangeListener in the {@link listenerList} that a ChangeEvent
+ * 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.
*/
@@ -309,55 +311,6 @@ public class DefaultButtonModel implements ButtonModel, Serializable
}
/**
- * Helper method to fire a ChangeEvent with the model as the event's source.
- *
- * @param stateflag DOCUMENT ME!
- * @param b DOCUMENT ME!
- */
- private void changeState(int stateflag, boolean b)
- {
- int oldstate = stateMask;
- int newstate;
-
- if (b)
- newstate = oldstate | stateflag;
- else
- newstate = oldstate & ~ stateflag;
-
- if (oldstate == newstate)
- return;
-
- if ((stateflag != SELECTED) && (stateflag != ENABLED)
- && (stateMask & ENABLED) == 0)
- return;
-
- stateMask = newstate;
-
- fireStateChanged();
-
- if ((oldstate & SELECTED) == 0 && (newstate & SELECTED) == SELECTED)
- {
- 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
@@ -374,7 +327,22 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void setArmed(boolean a)
{
- changeState(ARMED, a);
+ // if this call does not represent a CHANGE in state, then return
+ if ((a && isArmed()) || (!a && !isArmed()))
+ return;
+
+ // cannot change ARMED state unless button is enabled
+ if (!isEnabled())
+ return;
+
+ // make the change
+ if (a)
+ stateMask = stateMask | ARMED;
+ else
+ stateMask = stateMask & (~ARMED);
+
+ // notify interested ChangeListeners
+ fireStateChanged();
}
/**
@@ -394,7 +362,18 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void setEnabled(boolean e)
{
- changeState(ENABLED, e);
+ // if this call does not represent a CHANGE in state, then return
+ if ((e && isEnabled()) || (!e && !isEnabled()))
+ return;
+
+ // make the change
+ if (e)
+ stateMask = stateMask | ENABLED;
+ else
+ stateMask = stateMask & (~ENABLED);
+
+ // notify interested ChangeListeners
+ fireStateChanged();
}
/**
@@ -404,7 +383,27 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void setPressed(boolean p)
{
- changeState(PRESSED, p);
+ // if this call does not represent a CHANGE in state, then return
+ if ((p && isPressed()) || (!p && !isPressed()))
+ return;
+
+ // cannot changed PRESSED state unless button is enabled
+ if (!isEnabled())
+ return;
+
+ // make the change
+ if (p)
+ stateMask = stateMask | PRESSED;
+ else
+ stateMask = stateMask & (~PRESSED);
+
+ // if button is armed and was released, fire action event
+ if (!p && isArmed())
+ fireActionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
+ actionCommand));
+
+ // notify interested ChangeListeners
+ fireStateChanged();
}
/**
@@ -424,7 +423,22 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void setRollover(boolean r)
{
- changeState(ROLLOVER, r);
+ // if this call does not represent a CHANGE in state, then return
+ if ((r && isRollover()) || (!r && !isRollover()))
+ return;
+
+ // cannot set ROLLOVER property unless button is enabled
+ if (!isEnabled())
+ return;
+
+ // make the change
+ if (r)
+ stateMask = stateMask | ROLLOVER;
+ else
+ stateMask = stateMask & (~ROLLOVER);
+
+ // notify interested ChangeListeners
+ fireStateChanged();
}
/**
@@ -434,7 +448,34 @@ public class DefaultButtonModel implements ButtonModel, Serializable
*/
public void setSelected(boolean s)
{
- changeState(SELECTED, s);
+ // if this call does not represent a CHANGE in state, then return
+ if ((s && isSelected()) || (!s && !isSelected()))
+ return;
+
+ // make the change
+ if (s)
+ stateMask = stateMask | SELECTED;
+ else
+ stateMask = stateMask & (~SELECTED);
+
+ // notify interested ChangeListeners
+ fireStateChanged();
+
+ // fire ItemStateChanged events
+ if (s)
+ {
+ fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
+ null, ItemEvent.SELECTED));
+ if (group != null)
+ group.setSelected(this, true);
+ }
+ else
+ {
+ fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,
+ null, ItemEvent.DESELECTED));
+ if (group != null)
+ group.setSelected(this, false);
+ }
}
/**
@@ -476,8 +517,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
if (mnemonic != key)
{
- mnemonic = key;
- fireStateChanged();
+ mnemonic = key;
+ fireStateChanged();
}
}
@@ -492,8 +533,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
if (actionCommand != s)
{
- actionCommand = s;
- fireStateChanged();
+ actionCommand = s;
+ fireStateChanged();
}
}
@@ -519,8 +560,8 @@ public class DefaultButtonModel implements ButtonModel, Serializable
{
if (group != g)
{
- group = g;
- fireStateChanged();
+ group = g;
+ fireStateChanged();
}
}
diff --git a/javax/swing/DefaultCellEditor.java b/javax/swing/DefaultCellEditor.java
index 26bf708be..52d2e5254 100644
--- a/javax/swing/DefaultCellEditor.java
+++ b/javax/swing/DefaultCellEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -50,9 +50,13 @@ import javax.swing.table.TableCellEditor;
import javax.swing.tree.TreeCellEditor;
/**
- * DefaultCellEditor
- * @author Andrew Selkirk
- * @version 1.0
+ * The default implementation of {@link TableCellEditor} and
+ * {@link TreeCellEditor}. It provides editor components for
+ * some standard object types.
+ *
+ * @author Andrew Selkirk
+ *
+ * @status mostly unimplemented
*/
public class DefaultCellEditor
extends AbstractCellEditor
@@ -61,7 +65,9 @@ public class DefaultCellEditor
private static final long serialVersionUID = 3564035141373880027L;
/**
- * EditorDelegate
+ * Delegates a couple of method calls (such as {@link #isCellEditable)
+ * to the component it contains and listens for events that indicate
+ * that editing has stopped.
*/
protected class EditorDelegate
implements ActionListener, ItemListener, Serializable
@@ -75,7 +81,6 @@ public class DefaultCellEditor
/**
* Constructor EditorDelegate
- * @param value0 TODO
*/
protected EditorDelegate()
{
@@ -83,212 +88,261 @@ public class DefaultCellEditor
/**
* setValue
+ *
* @param event TODO
*/
public void setValue(Object event)
{
}
- /**
- * getCellEditorValue
- * @returns Object
- */
- public Object getCellEditorValue() {
- return null; // TODO
- } // getCellEditorValue()
-
- /**
- * isCellEditable
- * @param event TODO
- * @returns boolean
- */
- public boolean isCellEditable(EventObject event) {
- return false; // TODO
- } // isCellEditable()
-
- /**
- * shouldSelectCell
- * @param event TODO
- * @returns boolean
- */
- public boolean shouldSelectCell(EventObject event) {
- return false; // TODO
- } // shouldSelectCell()
-
- /**
- * stopCellEditing
- * @returns boolean
- */
- public boolean stopCellEditing() {
- return false; // TODO
- } // stopCellEditing()
-
- /**
- * cancelCellEditing
- */
- public void cancelCellEditing() {
- // TODO
- } // cancelCellEditing()
-
- /**
- * startCellEditing
- * @param event TODO
- * @returns boolean
- */
- public boolean startCellEditing(EventObject event) {
- return false; // TODO
- } // startCellEditing()
-
- /**
- * actionPerformed
- * @param event TODO
- */
- public void actionPerformed(ActionEvent event) {
- // TODO
- } // actionPerformed()
-
- /**
- * itemStateChanged
- * @param event TODO
- */
- public void itemStateChanged(ItemEvent event) {
- // TODO
- } // itemStateChanged()
-
-
- } // EditorDelegate
+ /**
+ * getCellEditorValue
+ *
+ * @returns Object
+ */
+ public Object getCellEditorValue()
+ {
+ return null; // TODO
+ } // getCellEditorValue()
- /**
- * editorComponent
- */
- protected JComponent editorComponent;
+ /**
+ * isCellEditable
+ *
+ * @param event TODO
+ *
+ * @returns boolean
+ */
+ public boolean isCellEditable(EventObject event)
+ {
+ return false; // TODO
+ } // isCellEditable()
- /**
- * delegate
- */
- protected EditorDelegate delegate;
+ /**
+ * shouldSelectCell
+ *
+ * @param event TODO
+ *
+ * @returns boolean
+ */
+ public boolean shouldSelectCell(EventObject event)
+ {
+ return false; // TODO
+ } // shouldSelectCell()
- /**
- * clickCountToStart
- */
- protected int clickCountToStart;
+ /**
+ * stopCellEditing
+ *
+ * @returns boolean
+ */
+ public boolean stopCellEditing()
+ {
+ return false; // TODO
+ } // stopCellEditing()
- /**
- * Constructor DefaultCellEditor
- * @param textfield TODO
- */
- public DefaultCellEditor(JTextField textfield) {
- // TODO
- } // DefaultCellEditor()
+ /**
+ * cancelCellEditing
+ */
+ public void cancelCellEditing()
+ {
+ // TODO
+ } // cancelCellEditing()
- /**
- * Constructor DefaultCellEditor
- * @param checkbox TODO
- */
- public DefaultCellEditor(JCheckBox checkbox) {
- // TODO
- } // DefaultCellEditor()
+ /**
+ * startCellEditing
+ *
+ * @param event TODO
+ *
+ * @returns boolean
+ */
+ public boolean startCellEditing(EventObject event)
+ {
+ return false; // TODO
+ } // startCellEditing()
- /**
- * Constructor DefaultCellEditor
- * @param combobox TODO
- */
- public DefaultCellEditor(JComboBox combobox) {
- // TODO
- } // DefaultCellEditor()
+ /**
+ * actionPerformed
+ *
+ * @param event TODO
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ // TODO
+ } // actionPerformed()
- /**
- * getComponent
- * @returns Component
- */
- public Component getComponent() {
- return null; // TODO
- } // getComponent()
+ /**
+ * itemStateChanged
+ *
+ * @param event TODO
+ */
+ public void itemStateChanged(ItemEvent event)
+ {
+ // TODO
+ } // itemStateChanged()
- /**
- * getClickCountToStart
- * @returns int
- */
- public int getClickCountToStart() {
- return 0; // TODO
- } // getClickCountToStart()
+ } // EditorDelegate
/**
- * setClickCountToStart
- * @param count TODO
- */
- public void setClickCountToStart(int count) {
- // TODO
- } // setClickCountToStart()
+ * editorComponent
+ */
+ protected JComponent editorComponent;
- /**
- * getCellEditorValue
- * @returns Object
- */
- public Object getCellEditorValue() {
- return null; // TODO
- } // getCellEditorValue()
+ /**
+ * delegate
+ */
+ protected EditorDelegate delegate;
- /**
- * isCellEditable
- * @param event TODO
- * @returns boolean
- */
- public boolean isCellEditable(EventObject event) {
- return false; // TODO
- } // isCellEditable()
+ /**
+ * clickCountToStart
+ */
+ protected int clickCountToStart;
- /**
- * shouldSelectCell
- * @param event TODO
- * @returns boolean
- */
- public boolean shouldSelectCell(EventObject event) {
- return false; // TODO
- } // shouldSelectCell()
+ /**
+ * Constructor DefaultCellEditor
+ *
+ * @param textfield TODO
+ */
+ public DefaultCellEditor(JTextField textfield)
+ {
+ // TODO
+ } // DefaultCellEditor()
- /**
- * stopCellEditing
- * @returns boolean
- */
- public boolean stopCellEditing() {
- return false; // TODO
- } // stopCellEditing()
+ /**
+ * Constructor DefaultCellEditor
+ *
+ * @param checkbox TODO
+ */
+ public DefaultCellEditor(JCheckBox checkbox)
+ {
+ // TODO
+ } // DefaultCellEditor()
- /**
- * cancelCellEditing
- */
- public void cancelCellEditing() {
- // TODO
- } // cancelCellEditing()
+ /**
+ * Constructor DefaultCellEditor
+ *
+ * @param combobox TODO
+ */
+ public DefaultCellEditor(JComboBox combobox)
+ {
+ // TODO
+ } // DefaultCellEditor()
- /**
- * getTreeCellEditorComponent
- * @param tree TODO
- * @param value TODO
- * @param isSelected TODO
- * @param expanded TODO
- * @param leaf TODO
- * @param row TODO
- * @returns Component
- */
- public Component getTreeCellEditorComponent(JTree tree,
- Object value, boolean isSelected, boolean expanded,
- boolean leaf, int row) {
- return null; // TODO
- } // getTreeCellEditorComponent()
+ /**
+ * getComponent
+ *
+ * @returns Component
+ */
+ public Component getComponent()
+ {
+ return null; // TODO
+ } // getComponent()
- /**
- * getTableCellEditorComponent
- * @param tree TODO
- * @param value TODO
- * @param isSelected TODO
- * @param row TODO
- * @param column TODO
- * @returns Component
- */
- public Component getTableCellEditorComponent(JTable tree,
- Object value, boolean isSelected, int row, int column) {
- return null; // TODO
- } // getTableCellEditorComponent()
+ /**
+ * getClickCountToStart
+ *
+ * @returns int
+ */
+ public int getClickCountToStart()
+ {
+ return 0; // TODO
+ } // getClickCountToStart()
+
+ /**
+ * setClickCountToStart
+ *
+ * @param count TODO
+ */
+ public void setClickCountToStart(int count)
+ {
+ // TODO
+ } // setClickCountToStart()
+
+ /**
+ * getCellEditorValue
+ *
+ * @returns Object
+ */
+ public Object getCellEditorValue()
+ {
+ return null; // TODO
+ } // getCellEditorValue()
+
+ /**
+ * isCellEditable
+ *
+ * @param event TODO
+ *
+ * @returns boolean
+ */
+ public boolean isCellEditable(EventObject event)
+ {
+ return false; // TODO
+ } // isCellEditable()
+
+ /**
+ * shouldSelectCell
+ *
+ * @param event TODO
+ *
+ * @returns boolean
+ */
+ public boolean shouldSelectCell(EventObject event)
+ {
+ return false; // TODO
+ } // shouldSelectCell()
+
+ /**
+ * stopCellEditing
+ *
+ * @returns boolean
+ */
+ public boolean stopCellEditing()
+ {
+ return false; // TODO
+ } // stopCellEditing()
+
+ /**
+ * cancelCellEditing
+ */
+ public void cancelCellEditing()
+ {
+ // TODO
+ } // cancelCellEditing()
+
+ /**
+ * getTreeCellEditorComponent
+ *
+ * @param tree TODO
+ * @param value TODO
+ * @param isSelected TODO
+ * @param expanded TODO
+ * @param leaf TODO
+ * @param row TODO
+ *
+ * @returns Component
+ */
+ public Component getTreeCellEditorComponent(JTree tree, Object value,
+ boolean isSelected,
+ boolean expanded, boolean leaf,
+ int row)
+ {
+ return null; // TODO
+ } // getTreeCellEditorComponent()
+
+ /**
+ * getTableCellEditorComponent
+ *
+ * @param tree TODO
+ * @param value TODO
+ * @param isSelected TODO
+ * @param row TODO
+ * @param column TODO
+ *
+ * @returns Component
+ */
+ public Component getTableCellEditorComponent(JTable tree, Object value,
+ boolean isSelected, int row,
+ int column)
+ {
+ return null; // TODO
+ } // getTableCellEditorComponent()
}
diff --git a/javax/swing/DefaultComboBoxModel.java b/javax/swing/DefaultComboBoxModel.java
index 496551e00..b48b968d6 100644
--- a/javax/swing/DefaultComboBoxModel.java
+++ b/javax/swing/DefaultComboBoxModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,7 +43,8 @@ import java.util.Vector;
/**
- * DefaultComboBoxModel is a data model for JComboBox. This model keeps track
+ * The default implementation of {@link MutableComboBoxModel}.
+ * 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.
@@ -51,7 +52,6 @@ import java.util.Vector;
* @author Andrew Selkirk
* @author Olga Rodimina
* @author Robert Schuster
- * @version 1.0
*/
public class DefaultComboBoxModel extends AbstractListModel
implements MutableComboBoxModel, Serializable
@@ -192,9 +192,8 @@ public class DefaultComboBoxModel extends AbstractListModel
public void setSelectedItem(Object object)
{
- /* Updates the selected item only if the given object
- * is null or in the list (this is how the JDK behaves).
- */
+ // Updates the selected item only if the given object
+ // is null or in the list (this is how the JDK behaves).
if(object == null || list.contains(object)) {
selectedItem = object;
fireContentsChanged(this, -1, -1);
diff --git a/javax/swing/DefaultDesktopManager.java b/javax/swing/DefaultDesktopManager.java
index a0dd5e2d1..2b8977e9d 100644
--- a/javax/swing/DefaultDesktopManager.java
+++ b/javax/swing/DefaultDesktopManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -49,8 +49,8 @@ import java.io.Serializable;
import javax.swing.JInternalFrame.JDesktopIcon;
/**
- * DefaultDesktopManager is the default implementation of DesktopManager for
- * swing. It implements the basic beaviours for JInternalFrames in arbitrary
+ * The default implementation of DesktopManager for
+ * Swing. It implements the basic beaviours for JInternalFrames in arbitrary
* parents. The methods provided by the class are not meant to be called by
* the user, instead, the JInternalFrame methods will call these methods.
*/
@@ -189,14 +189,14 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
p.setSelectedFrame(frame);
else
{
- try
- {
- frame.setSelected(true);
- }
- catch (PropertyVetoException e)
- {
- // Do nothing.
- }
+ try
+ {
+ frame.setSelected(true);
+ }
+ catch (PropertyVetoException e)
+ {
+ // Do nothing.
+ }
}
setBoundsForFrame(frame, normalBounds.x, normalBounds.y,
@@ -217,32 +217,32 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
p.setSelectedFrame(null);
else
{
- try
- {
- frame.setSelected(false);
- }
- catch (PropertyVetoException e)
- {
- }
+ try
+ {
+ frame.setSelected(false);
+ }
+ catch (PropertyVetoException e)
+ {
+ }
}
Container c = frame.getParent();
- if (! wasIcon(frame))
+ if (!wasIcon(frame))
{
- Rectangle r = getBoundsForIconOf(frame);
- icon.setBounds(r);
- setWasIcon(frame, Boolean.TRUE);
+ Rectangle r = getBoundsForIconOf(frame);
+ icon.setBounds(r);
+ setWasIcon(frame, Boolean.TRUE);
}
if (c != null)
{
- if (icon != null)
- {
- c.add(icon);
- icon.setVisible(true);
- }
- c.remove(frame);
+ if (icon != null)
+ {
+ c.add(icon);
+ icon.setVisible(true);
+ }
+ c.remove(frame);
}
}
@@ -261,22 +261,22 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
c.add(frame);
frame.setVisible(true);
- if (! frame.isSelected())
+ if (!frame.isSelected())
{
- JDesktopPane p = frame.getDesktopPane();
- if (p != null)
- p.setSelectedFrame(frame);
- else
- {
- try
- {
- frame.setSelected(true);
- }
- catch (PropertyVetoException e)
- {
- // Do nothing.
- }
- }
+ JDesktopPane p = frame.getDesktopPane();
+ if (p != null)
+ p.setSelectedFrame(frame);
+ else
+ {
+ try
+ {
+ frame.setSelected(true);
+ }
+ catch (PropertyVetoException e)
+ {
+ // Do nothing.
+ }
+ }
}
c.invalidate();
@@ -296,13 +296,13 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
p.setSelectedFrame(frame);
else
{
- try
- {
- frame.setSelected(true);
- }
- catch (PropertyVetoException e)
- {
- }
+ try
+ {
+ frame.setSelected(true);
+ }
+ catch (PropertyVetoException e)
+ {
+ }
}
frame.toFront();
@@ -318,18 +318,18 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
JDesktopPane p = frame.getDesktopPane();
if (p != null)
{
- if (p.getSelectedFrame() == frame)
- p.setSelectedFrame(null);
+ if (p.getSelectedFrame() == frame)
+ p.setSelectedFrame(null);
}
else
{
- try
- {
- frame.setSelected(false);
- }
- catch (PropertyVetoException e)
- {
- }
+ try
+ {
+ frame.setSelected(false);
+ }
+ catch (PropertyVetoException e)
+ {
+ }
}
}
@@ -361,6 +361,7 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
* This method is called to drag the JInternalFrame to a new location.
*
* @param component The JComponent to drag, usually a JInternalFrame.
+ *
* @param newX The new x coordinate.
* @param newY The new y coordinate.
*/
@@ -368,16 +369,16 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
{
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
- // FIXME: Do outline drag mode painting.
+ // FIXME: Do outline drag mode painting.
}
else
{
- Rectangle b = component.getBounds();
- if (component instanceof JDesktopIcon)
- component.setBounds(newX, newY, b.width, b.height);
- else
- setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
- b.height);
+ Rectangle b = component.getBounds();
+ if (component instanceof JDesktopIcon)
+ component.setBounds(newX, newY, b.width, b.height);
+ else
+ setBoundsForFrame((JInternalFrame) component, newX, newY, b.width,
+ b.height);
}
}
@@ -391,10 +392,10 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
{
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
- setBoundsForFrame((JInternalFrame) component, dragCache.x,
- dragCache.y, dragCache.width, dragCache.height);
- pane = null;
- dragCache = null;
+ setBoundsForFrame((JInternalFrame) component, dragCache.x, dragCache.y,
+ dragCache.width, dragCache.height);
+ pane = null;
+ dragCache = null;
}
component.repaint();
}
@@ -436,7 +437,7 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
- // FIXME: Do outline drag painting.
+ // FIXME: Do outline drag painting.
}
else
setBoundsForFrame(component, dragCache.x, dragCache.y, dragCache.width,
@@ -454,10 +455,10 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
{
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE)
{
- setBoundsForFrame((JInternalFrame) component, dragCache.x,
- dragCache.y, dragCache.width, dragCache.height);
- pane = null;
- dragCache = null;
+ setBoundsForFrame((JInternalFrame) component, dragCache.x, dragCache.y,
+ dragCache.width, dragCache.height);
+ pane = null;
+ dragCache = null;
}
component.repaint();
}
@@ -516,13 +517,14 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
// The icon also must not be placed where another icon is placed
// (regardless whether that frame is an icon currently or not)
JDesktopPane desktopPane = frame.getDesktopPane();
- Rectangle paneBounds = desktopPane.getBounds();
- Insets insets = desktopPane.getInsets();
- Dimension pref = frame.getDesktopIcon().getPreferredSize();
if (desktopPane == null)
return frame.getDesktopIcon().getBounds();
+ Rectangle paneBounds = desktopPane.getBounds();
+ Insets insets = desktopPane.getInsets();
+ Dimension pref = frame.getDesktopIcon().getPreferredSize();
+
Component[] frames = desktopPane.getComponents();
int count = 0;
@@ -534,12 +536,12 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
iconRects = new Rectangle[count];
for (int i = 0, j = 0; i < frames.length; i++)
if (frames[i] instanceof JDesktopIcon)
- iconRects[--count] = frames[i].getBounds();
+ iconRects[--count] = frames[i].getBounds();
else if (frames[i] instanceof JInternalFrame
&& ((JInternalFrame) frames[i]).getWasIcon()
&& frames[i] != frame)
- iconRects[--count] = ((JInternalFrame) frames[i]).getDesktopIcon()
- .getBounds();
+ iconRects[--count] = ((JInternalFrame) frames[i])
+ .getDesktopIcon().getBounds();
int startingX = insets.left;
int startingY = paneBounds.height - insets.bottom - pref.height;
@@ -549,25 +551,25 @@ public class DefaultDesktopManager implements DesktopManager, Serializable
while (iconRects.length > 0)
{
- clear = true;
- for (int i = 0; i < iconRects.length; i++)
- {
- if (iconRects[i] != null && iconRects[i].intersects(ideal))
- {
- clear = false;
- break;
- }
- }
- if (clear)
- return ideal;
-
- startingX += pref.width;
- if (startingX + pref.width > paneBounds.width - insets.right)
- {
- startingX = insets.left;
- startingY -= pref.height;
- }
- ideal.setBounds(startingX, startingY, pref.width, pref.height);
+ clear = true;
+ for (int i = 0; i < iconRects.length; i++)
+ {
+ if (iconRects[i] != null && iconRects[i].intersects(ideal))
+ {
+ clear = false;
+ break;
+ }
+ }
+ if (clear)
+ return ideal;
+
+ startingX += pref.width;
+ if (startingX + pref.width > paneBounds.width - insets.right)
+ {
+ startingX = insets.left;
+ startingY -= pref.height;
+ }
+ ideal.setBounds(startingX, startingY, pref.width, pref.height);
}
return ideal;
diff --git a/javax/swing/DefaultFocusManager.java b/javax/swing/DefaultFocusManager.java
index b2c8c6e99..08db65168 100644
--- a/javax/swing/DefaultFocusManager.java
+++ b/javax/swing/DefaultFocusManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,113 +43,126 @@ import java.awt.event.KeyEvent;
import java.util.Stack;
/**
- * DefaultFocusManager
- * @author Andrew Selkirk
- * @version 1.0
+ * This class has been obsoleted by the new
+ * {@link java.awt.KeyboardFocusManager} and
+ * {@link java.awt.DefaultKeyboardFocusManager} API.
+ *
+ * @author Andrew Selkirk
*/
public class DefaultFocusManager extends FocusManager {
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * historyStack
- */
- private Stack historyStack;
-
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
/**
- * Constructor DefaultFocusManager
- */
- public DefaultFocusManager() {
- // TODO
- } // DefaultFocusManager()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
+ * historyStack
+ */
+ private Stack historyStack;
+
+ /**
+ * Constructor DefaultFocusManager
+ */
+ public DefaultFocusManager()
+ {
+ // TODO
+ } // DefaultFocusManager()
/**
- * processKeyEvent
- * @param component TODO
- * @param event TODO
- */
- public void processKeyEvent(Component component, KeyEvent event) {
- // TODO
- } // processKeyEvent()
+ * processKeyEvent
+ *
+ * @param component
+ * TODO
+ * @param event
+ * TODO
+ */
+ public void processKeyEvent(Component component, KeyEvent event)
+ {
+ // TODO
+ } // processKeyEvent()
/**
- * focusNextComponent
- * @param component TODO
- */
- public void focusNextComponent(Component component) {
- // TODO
- } // focusNextComponent()
+ * focusNextComponent
+ *
+ * @param component
+ * TODO
+ */
+ public void focusNextComponent(Component component)
+ {
+ // TODO
+ } // focusNextComponent()
/**
- * focusPreviousComponent
- * @param component TODO
- */
- public void focusPreviousComponent(Component component) {
- // TODO
- } // focusPreviousComponent()
+ * focusPreviousComponent
+ *
+ * @param component
+ * TODO
+ */
+ public void focusPreviousComponent(Component component)
+ {
+ // TODO
+ } // focusPreviousComponent()
/**
- * getFirstComponent
- * @param container TODO
- * @returns Component
- */
- public Component getFirstComponent(Container container) {
- return null; // TODO
- } // getFirstComponent()
+ * getFirstComponent
+ *
+ * @param container
+ * TODO
+ * @returns Component
+ */
+ public Component getFirstComponent(Container container)
+ {
+ return null; // TODO
+ } // getFirstComponent()
/**
- * getLastComponent
- * @param container TODO
- * @returns Component
- */
- public Component getLastComponent(Container container) {
- return null; // TODO
- } // getLastComponent()
+ * getLastComponent
+ *
+ * @param container
+ * TODO
+ * @returns Component
+ */
+ public Component getLastComponent(Container container)
+ {
+ return null; // TODO
+ } // getLastComponent()
/**
- * getComponentBefore
- * @param container TODO
- * @param component TODO
- * @returns Component
- */
- public Component getComponentBefore(Container container,
- Component component) {
- return null; // TODO
- } // getComponentBefore()
+ * getComponentBefore
+ *
+ * @param container
+ * TODO
+ * @param component
+ * TODO
+ * @returns Component
+ */
+ public Component getComponentBefore(Container container, Component component)
+ {
+ return null; // TODO
+ } // getComponentBefore()
/**
- * getComponentAfter
- * @param container TODO
- * @param component TODO
- * @returns Component
- */
- public Component getComponentAfter(Container container,
- Component component) {
- return null; // TODO
- } // getComponentAfter()
+ * getComponentAfter
+ *
+ * @param container
+ * TODO
+ * @param component
+ * TODO
+ * @returns Component
+ */
+ public Component getComponentAfter(Container container, Component component)
+ {
+ return null; // TODO
+ } // getComponentAfter()
/**
- * compareTabOrder
- * @param component1 TODO
- * @param component2 TODO
- * @returns boolean
- */
- public boolean compareTabOrder(Component component1,
- Component component2) {
- return false; // TODO
- } // compareTabOrder()
-
+ * compareTabOrder
+ *
+ * @param component1
+ * TODO
+ * @param component2
+ * TODO
+ * @returns boolean
+ */
+ public boolean compareTabOrder(Component component1, Component component2)
+ {
+ return false; // TODO
+ } // compareTabOrder()
} // DefaultFocusManager
diff --git a/javax/swing/DefaultListCellRenderer.java b/javax/swing/DefaultListCellRenderer.java
index 91b8a8a2e..5a34ba7aa 100644
--- a/javax/swing/DefaultListCellRenderer.java
+++ b/javax/swing/DefaultListCellRenderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,17 +46,23 @@ import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
/**
- * DefaultListCellRenderer. This class is responsible for rendering list
- * cells.
+ * The default implementation {@link ListCellRenderer}. It provides a standard
+ * renderer for data objects of all types via {@link Object#toString()}.
*
* @author Andrew Selkirk
- * @version 1.0
*/
public class DefaultListCellRenderer extends JLabel
implements ListCellRenderer, Serializable
{
private static final long serialVersionUID = 7708947179685189462L;
+ /**
+ * Subclasses <code>DefaultListCellRenderers</code> and implements
+ * {@link javax.swing.plaf.UIResource}. This is used by
+ * {@link javax.swing.plaf.ListUI} subclasses to provide a default for
+ * the <code>List.cellRenderer</code> property. If you want to override
+ * this property, use <code>DefaultListCellRenderer</code> or a subclass.
+ */
public static class UIResource extends DefaultListCellRenderer
implements javax.swing.plaf.UIResource
{
@@ -93,21 +99,21 @@ public class DefaultListCellRenderer extends JLabel
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
+ // Use focusCellHighlightBorder when renderer has focus and
// noFocusBorder otherwise
-
+
if (cellHasFocus)
setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
else
diff --git a/javax/swing/DefaultListModel.java b/javax/swing/DefaultListModel.java
index c3704dbea..fdbbb562c 100644
--- a/javax/swing/DefaultListModel.java
+++ b/javax/swing/DefaultListModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,7 +41,7 @@ import java.util.Enumeration;
import java.util.Vector;
/**
- * This is a default subclass of the {@link AbstractListModel}, used by
+ * The default implementation of {@link AbstractListModel}, used by
* {@link javax.swing.JList} and similar objects as the model of a list of
* values. The implementation is based on an underlying {@link
* java.util.Vector}.
@@ -67,7 +67,7 @@ public class DefaultListModel extends AbstractListModel
* @return The object at the given index
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public Object elementAt(int index)
{
@@ -90,9 +90,9 @@ public class DefaultListModel extends AbstractListModel
* @param element The element to search for
*
* @return The first index in the list at which an object
- * <code>obj</code> exists such that <code>obj.equals(element)</code> is
- * <code>true</code>; if no such object exists, the method returns
- * <code>-1</code>
+ * <code>obj</code> exists such that <code>obj.equals(element)</code> is
+ * <code>true</code>; if no such object exists, the method returns
+ * <code>-1</code>
*/
public int indexOf(Object element)
{
@@ -107,9 +107,9 @@ public class DefaultListModel extends AbstractListModel
* @param startIndex The index to begin searching at
*
* @return The first index in the list, greater than or equal to
- * <code>startIndex</code>, at which an object <code>obj</code> exists
- * such that <code>obj.equals(element)</code> is <code>true</code>; if no
- * such object exists, the method returns <code>-1</code>
+ * <code>startIndex</code>, at which an object <code>obj</code> exists
+ * such that <code>obj.equals(element)</code> is <code>true</code>; if no
+ * such object exists, the method returns <code>-1</code>
*/
public int indexOf(Object element, int startIndex)
{
@@ -122,9 +122,9 @@ public class DefaultListModel extends AbstractListModel
* @param element The element to search for
*
* @return The last index in the list at which an object
- * <code>obj</code> exists such that <code>obj.equals(element)</code> is
- * <code>true</code>; if no such object exists, the method returns
- * <code>-1</code>
+ * <code>obj</code> exists such that <code>obj.equals(element)</code> is
+ * <code>true</code>; if no such object exists, the method returns
+ * <code>-1</code>
*/
public int lastIndexOf(Object element)
{
@@ -139,9 +139,9 @@ public class DefaultListModel extends AbstractListModel
* @param endIndex The index to finish searching at
*
* @return The last index in the list, less than to or equal to
- * <code>endIndexIndex</code>, at which an object <code>obj</code> exists
- * such that <code>obj.equals(element)</code> is <code>true</code>; if no
- * such object exists, the method returns <code>-1</code>
+ * <code>endIndexIndex</code>, at which an object <code>obj</code> exists
+ * such that <code>obj.equals(element)</code> is <code>true</code>; if no
+ * such object exists, the method returns <code>-1</code>
*/
public int lastIndexOf(Object element, int endIndex)
{
@@ -156,7 +156,7 @@ public class DefaultListModel extends AbstractListModel
* @return The list value at the provided index
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public Object get(int index)
{
@@ -172,7 +172,7 @@ public class DefaultListModel extends AbstractListModel
* @return The value previously held at the specified index
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public Object set(int index, Object element)
{
@@ -193,7 +193,7 @@ public class DefaultListModel extends AbstractListModel
* @param element The element to insert at the index
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds <code>[0, size()]</code>
+ * outside the bounds <code>[0, size()]</code>
*/
public void add(int index, Object element)
{
@@ -228,7 +228,7 @@ public class DefaultListModel extends AbstractListModel
* Gets an array containing the elements of the list.
*
* @return An array of the objects in the list, in the order they occur
- * in the list
+ * in the list
*/
public Object[] toArray()
{
@@ -241,7 +241,7 @@ public class DefaultListModel extends AbstractListModel
* @param element The element to search for
*
* @return <code>true</code> if <code>element</code> is a member of the
- * list, otherwise <code>false</code>
+ * list, otherwise <code>false</code>
*/
public boolean contains(Object element)
{
@@ -255,7 +255,7 @@ public class DefaultListModel extends AbstractListModel
* @param array The array to copy the list into
*
* @throws IndexOutOfBoundsException if the array is too small to hold the
- * elements of the list
+ * elements of the list
*/
public void copyInto(Object[] array)
{
@@ -283,7 +283,7 @@ public class DefaultListModel extends AbstractListModel
* @return The value at the index, which has been removed from the list
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public Object remove(int index)
{
@@ -297,7 +297,7 @@ public class DefaultListModel extends AbstractListModel
* Determines whether the list is empty.
*
* @return <code>true</code> if the list is empty, otherwise
- * <code>false</code>
+ * <code>false</code>
*/
public boolean isEmpty()
{
@@ -348,14 +348,14 @@ public class DefaultListModel extends AbstractListModel
{
int oldSize = elements.size();
elements.setSize(size);
- if (oldSize < size)
- {
- fireIntervalAdded(this, oldSize, size - 1);
- }
- else if (oldSize > size)
- {
- this.fireIntervalRemoved(this, size, oldSize - 1);
- }
+ if (oldSize < size)
+ {
+ fireIntervalAdded(this, oldSize, size - 1);
+ }
+ else if (oldSize > size)
+ {
+ this.fireIntervalRemoved(this, size, oldSize - 1);
+ }
}
/**
@@ -396,7 +396,7 @@ public class DefaultListModel extends AbstractListModel
* @param index The list index at which to set a value
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public void setElementAt(Object element, int index)
{
@@ -410,7 +410,7 @@ public class DefaultListModel extends AbstractListModel
* @param index The index of the element to remove
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public void removeElementAt(int index)
{
@@ -429,7 +429,7 @@ public class DefaultListModel extends AbstractListModel
* @param index The index to insert the element at
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds <code>[0, size()]</code>
+ * outside the bounds <code>[0, size()]</code>
*/
public void insertElementAt(Object element, int index)
{
@@ -444,7 +444,7 @@ public class DefaultListModel extends AbstractListModel
* @param element The element to remove
*
* @return <code>true</code> if the element existed in the list (and was
- * removed), <code>false</code> otherwise
+ * removed), <code>false</code> otherwise
*/
public boolean removeElement(Object element)
{
@@ -481,8 +481,8 @@ public class DefaultListModel extends AbstractListModel
* @param endIndex The last index in the range to remove
*
* @throws ArrayIndexOutOfBoundsException if either index is outside the
- * valid range of indices for this list <code>[0, size())</code>
- * @throws IllegalArgumentException if <code>startIndex > endIndex</code>
+ * valid range of indices for this list <code>[0, size())</code>
+ * @throws IllegalArgumentException if <code>startIndex &gt; endIndex</code>
*/
public void removeRange(int startIndex, int endIndex)
{
@@ -512,7 +512,7 @@ public class DefaultListModel extends AbstractListModel
* @return The list value at the provided index
*
* @throws ArrayIndexOutOfBoundsException If the provided index is
- * outside the bounds of the list <code>[0, size())</code>
+ * outside the bounds of the list <code>[0, size())</code>
*/
public Object getElementAt(int index)
{
diff --git a/javax/swing/DefaultListSelectionModel.java b/javax/swing/DefaultListSelectionModel.java
index 46ff27859..f8d544d9b 100644
--- a/javax/swing/DefaultListSelectionModel.java
+++ b/javax/swing/DefaultListSelectionModel.java
@@ -1,5 +1,5 @@
/* DefaultListSelectionModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -47,10 +47,10 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
/**
- * <p>This class provides a default implementation of {@link
- * ListSelectioModel}, which is used by {@link javax.swing.JList} and
+ * The default implementation of {@link ListSelectionModel},
+ * which is used by {@link javax.swing.JList} and
* similar classes to manage the selection status of a number of data
- * elements. </p>
+ * elements.
*
* <p>The class is organized <em>abstractly</em> as a set of intervals of
* integers. Each interval indicates an inclusive range of indices in a
@@ -78,7 +78,6 @@ public class DefaultListSelectionModel implements Cloneable,
*/
int selectionMode = MULTIPLE_INTERVAL_SELECTION;
-
/**
* The index of the "lead" of the most recent selection. The lead is the
* second argument in any call to {@link #setSelectionInterval}, {@link
@@ -88,7 +87,6 @@ public class DefaultListSelectionModel implements Cloneable,
*/
int leadSelectionIndex = -1;
-
/**
* The index of the "anchor" of the most recent selection. The anchor is
* the first argument in any call to {@link #setSelectionInterval},
@@ -102,12 +100,11 @@ public class DefaultListSelectionModel implements Cloneable,
*/
int anchorSelectionIndex = -1;
-
/**
* controls the range of indices provided in any {@link
* ListSelectionEvent} fired by the selectionModel. Let
* <code>[A,L]</code> be the range of indices between {@link
- * anchorSelectionIndex} and {@link leadSelectionIndex} inclusive, and
+ * #anchorSelectionIndex} and {@link #leadSelectionIndex} inclusive, and
* let <code>[i0,i1]</code> be the range of indices changed in a given
* call which generates a {@link ListSelectionEvent}. Then when this
* property is <code>true</code>, the {@link ListSelectionEvent} contains
@@ -120,7 +117,6 @@ public class DefaultListSelectionModel implements Cloneable,
*/
protected boolean leadAnchorNotificationEnabled = true;
-
/**
* Whether the selection is currently "adjusting". Any {@link
* ListSelectionEvent} events constructed in response to changes in this
@@ -140,6 +136,18 @@ public class DefaultListSelectionModel implements Cloneable,
*/
BitSet sel = new BitSet();
+ /**
+ * A variable to store the previous value of sel.
+ * Used to make sure we only fireValueChanged when the BitSet
+ * actually does change.
+ */
+ Object oldSel;
+
+ /**
+ * Whether this call of setLeadSelectionInterval was called locally
+ * from addSelectionInterval
+ */
+ boolean setLeadCalledFromAdd = false;
/**
* Gets the value of the {@link #selectionMode} property.
@@ -224,13 +232,15 @@ public class DefaultListSelectionModel implements Cloneable,
* which changed selection status between the beginning and end of the
* method.</p>
*
- * @param anchorIndex The new property value
+ * @param leadIndex The new property value
*
* @see #getAnchorSelectionIndex
*/
public void setLeadSelectionIndex(int leadIndex)
{
int oldLeadIndex = leadSelectionIndex;
+ if (setLeadCalledFromAdd == false)
+ oldSel = sel.clone();
leadSelectionIndex = leadIndex;
if (anchorSelectionIndex == -1)
@@ -240,7 +250,7 @@ public class DefaultListSelectionModel implements Cloneable,
int R2 = Math.max(anchorSelectionIndex, oldLeadIndex);
int S1 = Math.min(anchorSelectionIndex, leadIndex);
int S2 = Math.max(anchorSelectionIndex, leadIndex);
-
+
int lo = Math.min(R1, S1);
int hi = Math.max(R2, S2);
@@ -262,10 +272,9 @@ public class DefaultListSelectionModel implements Cloneable,
int beg = sel.nextSetBit(0), end = -1;
for(int i=beg; i >= 0; i=sel.nextSetBit(i+1))
- {
- end = i;
- }
- fireValueChanged(beg, end, valueIsAdjusting);
+ end = i;
+ if (sel.equals(oldSel) == false)
+ fireValueChanged(beg, end, valueIsAdjusting);
}
/**
@@ -283,16 +292,15 @@ public class DefaultListSelectionModel implements Cloneable,
/**
* Sets the value of the {@link #leadAnchorNotificationEnabled} property.
*
- * @param flag The new property value
+ * @param l The new property value
*
- * @see #getLeadAnchorNotificationEnabled
+ * @see #isLeadAnchorNotificationEnabled
*/
public void setLeadAnchorNotificationEnabled(boolean l)
{
leadAnchorNotificationEnabled = l;
}
-
/**
* Gets the value of the {@link #valueIsAdjusting} property.
*
@@ -328,14 +336,13 @@ public class DefaultListSelectionModel implements Cloneable,
return sel.isEmpty();
}
-
/**
* Gets the smallest index which is currently a member of a selection
* interval.
*
* @return The least integer <code>i</code> such that <code>i >=
- * 0</code> and <code>i</code> is a member of a selected interval, or
- * <code>-1</code> if there are no selected intervals
+ * 0</code> and <code>i</code> is a member of a selected interval, or
+ * <code>-1</code> if there are no selected intervals
*
* @see #getMaxSelectionIndex
*/
@@ -352,8 +359,8 @@ public class DefaultListSelectionModel implements Cloneable,
* interval.
*
* @return The greatest integer <code>i</code> such that <code>i >=
- * 0</code> and <code>i</code> is a member of a selected interval, or
- * <code>-1</code> if there are no selected intervals
+ * 0</code> and <code>i</code> is a member of a selected interval, or
+ * <code>-1</code> if there are no selected intervals
*
* @see #getMinSelectionIndex
*/
@@ -377,7 +384,7 @@ public class DefaultListSelectionModel implements Cloneable,
* @param a The index to search for
*
* @return <code>true</code> if the index is a member of a selection interval,
- * otherwise <code>false</code>
+ * otherwise <code>false</code>
*/
public boolean isSelectedIndex(int a)
{
@@ -386,10 +393,14 @@ public class DefaultListSelectionModel implements Cloneable,
/**
* If the {@link #selectionMode} property is equal to
- * <code>SINGLE_SELECTION</code> or
- * <code>SINGLE_INTERVAL_SELECTION</code>, equivalent to calling
- * <code>setSelectionInterval(index1, index2)</code>; otherwise adds the
- * range <code>[index0, index1]</code> to the selection interval set.
+ * <code>SINGLE_SELECTION</code> equivalent to calling
+ * <code>setSelectionInterval(index1, index2)</code>;
+ * If the {@link #selectionMode} property is equal to
+ * <code>SINGLE_INTERVAL_SELECTION</code> and the interval being
+ * added is not adjacent to an already selected interval,
+ * equivalent to <code>setSelectionInterval(index1, index2)</code>.
+ * Otherwise adds the range <code>[index0, index1]</code>
+ * to the selection interval set.
*
* @param index0 The beginning of the range of indices to select
* @param index1 The end of the range of indices to select
@@ -399,18 +410,54 @@ public class DefaultListSelectionModel implements Cloneable,
*/
public void addSelectionInterval(int index0, int index1)
{
- if (selectionMode == SINGLE_SELECTION
- || selectionMode == SINGLE_INTERVAL_SELECTION)
+ int lo = Math.min(index0, index1);
+ int hi = Math.max(index0, index1);
+ oldSel = sel.clone();
+
+ if (selectionMode == SINGLE_SELECTION)
sel.clear();
+
+ // COMPAT: Like Sun (but not like IBM), we allow calls to
+ // addSelectionInterval when selectionMode is
+ // SINGLE_SELECTION_INTERVAL iff the interval being added
+ // is adjacent to an already selected interval
+ if (selectionMode == SINGLE_INTERVAL_SELECTION)
+ if (!(isSelectedIndex(index0) ||
+ isSelectedIndex(index1) ||
+ isSelectedIndex(Math.max(lo-1,0)) ||
+ isSelectedIndex(Math.min(hi+1,sel.size()))))
+ sel.clear();
if (selectionMode == SINGLE_SELECTION)
index0 = index1;
- int lo = Math.min(index0, index1);
- int hi = Math.max(index0, index1);
-
- sel.set(lo, hi+1);
- fireValueChanged(lo, hi, valueIsAdjusting);
+ // We have to update the anchorSelectionIndex and leadSelectionIndex
+ // variables
+
+ // The next if statements breaks down to "if this selection is adjacent
+ // to the previous selection and going in the same direction"
+ if ((isSelectedIndex(leadSelectionIndex))
+ && ((index0 - 1 == leadSelectionIndex
+ && (index1 >= index0)
+ && (leadSelectionIndex >= anchorSelectionIndex))
+ || (index0 + 1 == leadSelectionIndex && (index1 <= index0)
+ && (leadSelectionIndex <= anchorSelectionIndex)))
+ && (anchorSelectionIndex != -1 || leadSelectionIndex != -1))
+ {
+ // setting setLeadCalledFromAdd to true tells setLeadSelectionIndex
+ // not to update oldSel
+ setLeadCalledFromAdd = true;
+ setLeadSelectionIndex(index1);
+ setLeadCalledFromAdd = false;
+ }
+ else
+ {
+ leadSelectionIndex = index1;
+ anchorSelectionIndex = index0;
+ sel.set(lo, hi+1);
+ if (sel.equals(oldSel) == false)
+ fireValueChanged(lo, hi, valueIsAdjusting);
+ }
}
@@ -427,10 +474,24 @@ public class DefaultListSelectionModel implements Cloneable,
public void removeSelectionInterval(int index0,
int index1)
{
+ oldSel = sel.clone();
int lo = Math.min(index0, index1);
int hi = Math.max(index0, index1);
+
+ // if selectionMode is SINGLE_INTERVAL_SELECTION and removing the interval
+ // (index0,index1) would leave two disjoint selection intervals, remove all
+ // selected indices from lo to the last selected index
+ if (getMinSelectionIndex() > 0 && getMinSelectionIndex() < lo &&
+ selectionMode == SINGLE_INTERVAL_SELECTION)
+ hi = sel.size() - 1;
+
sel.clear(lo, hi+1);
- fireValueChanged(lo, hi, valueIsAdjusting);
+ //update anchorSelectionIndex and leadSelectionIndex variables
+ //TODO: will probably need MouseDragged to test properly and know if this works
+ setAnchorSelectionIndex(index0);
+ leadSelectionIndex = index1;
+ if (sel.equals(oldSel) == false)
+ fireValueChanged(lo, hi, valueIsAdjusting);
}
/**
@@ -438,9 +499,11 @@ public class DefaultListSelectionModel implements Cloneable,
*/
public void clearSelection()
{
+ oldSel = sel.clone();
int sz = sel.size();
sel.clear();
- fireValueChanged(0, sz, valueIsAdjusting);
+ if (sel.equals(oldSel) == false)
+ fireValueChanged(0, sz, valueIsAdjusting);
}
/**
@@ -454,6 +517,7 @@ public class DefaultListSelectionModel implements Cloneable,
*/
public void setSelectionInterval(int index0, int index1)
{
+ oldSel = sel.clone();
sel.clear();
if (selectionMode == SINGLE_SELECTION)
index0 = index1;
@@ -461,7 +525,11 @@ public class DefaultListSelectionModel implements Cloneable,
int lo = Math.min(index0, index1);
int hi = Math.max(index0, index1);
sel.set(lo, hi+1);
- fireValueChanged(lo, hi, valueIsAdjusting);
+ // update the anchorSelectionIndex and leadSelectionIndex variables
+ setAnchorSelectionIndex(index0);
+ leadSelectionIndex=index1;
+ if (sel.equals(oldSel) == false)
+ fireValueChanged(lo, hi, valueIsAdjusting);
}
/**
@@ -474,7 +542,7 @@ public class DefaultListSelectionModel implements Cloneable,
* @param index The position to insert indices at
* @param length The number of indices to insert
* @param before Indicates whether to insert the indices before the index
- * or after it
+ * or after it
*/
public void insertIndexInterval(int index,
int length,
@@ -520,7 +588,7 @@ public class DefaultListSelectionModel implements Cloneable,
* indicate that a series of adjustment has just ended.
*
* The values of {@link #getMinSelectionIndex} and
- * {@link getMaxSelectionIndex} are used in the {@link ListSelectionEvent}
+ * {@link #getMaxSelectionIndex} are used in the {@link ListSelectionEvent}
* that gets fired.
*
* @param isAdjusting <code>true</code> if this is the final change
@@ -551,7 +619,7 @@ public class DefaultListSelectionModel implements Cloneable,
* @param firstIndex The low index of the changed range
* @param lastIndex The high index of the changed range
* @param isAdjusting Whether this change is part of a seqence of adjustments
- * made to the selection, such as during interactive scrolling
+ * made to the selection, such as during interactive scrolling
*/
protected void fireValueChanged(int firstIndex, int lastIndex,
boolean isAdjusting)
@@ -568,8 +636,8 @@ public class DefaultListSelectionModel implements Cloneable,
*
* @param listener The listener to add
*
- * @see removeListSelectionListener
- * @see getListSelectionListeners
+ * @see #removeListSelectionListener
+ * @see #getListSelectionListeners
*/
public void addListSelectionListener(ListSelectionListener listener)
{
@@ -581,8 +649,8 @@ public class DefaultListSelectionModel implements Cloneable,
*
* @param listener The listener to remove
*
- * @see addListSelectionListener
- * @see getListSelectionListeners
+ * @see #addListSelectionListener
+ * @see #getListSelectionListeners
*/
public void removeListSelectionListener(ListSelectionListener listener)
{
@@ -596,7 +664,7 @@ public class DefaultListSelectionModel implements Cloneable,
*
* @return The array
*
- * @see getListSelectionListener
+ * @see #getListSelectionListeners
* @since 1.3
*/
public EventListener[] getListeners(Class listenerType)
@@ -609,9 +677,9 @@ public class DefaultListSelectionModel implements Cloneable,
*
* @return the array
*
- * @see addListSelectionListener
- * @see removeListSelectionListener
- * @see getListeners
+ * @see #addListSelectionListener
+ * @see #removeListSelectionListener
+ * @see #getListeners
* @since 1.4
*/
public ListSelectionListener[] getListSelectionListeners()
diff --git a/javax/swing/DefaultSingleSelectionModel.java b/javax/swing/DefaultSingleSelectionModel.java
index 63611f4a0..8f4d405f9 100644
--- a/javax/swing/DefaultSingleSelectionModel.java
+++ b/javax/swing/DefaultSingleSelectionModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,7 +46,8 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
/**
- * DefaultSingleSelectionModel
+ * The default implementation of {@link SingleSelectionModel}, used in
+ * {@link JTabbedPane}, {@link JMenuBar} and {@link JPopupMenu}.
*
* @author Andrew Selkirk
*/
diff --git a/javax/swing/DesktopManager.java b/javax/swing/DesktopManager.java
index 7fbc972c3..300d66517 100644
--- a/javax/swing/DesktopManager.java
+++ b/javax/swing/DesktopManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/FocusManager.java b/javax/swing/FocusManager.java
index 419c4d4e0..179fa6f82 100644
--- a/javax/swing/FocusManager.java
+++ b/javax/swing/FocusManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,17 +40,19 @@ package javax.swing;
import java.awt.Component;
import java.awt.DefaultKeyboardFocusManager;
+import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
/**
- * FocusManager
- * @author Andrew Selkirk
- * @version 1.0
+ * This class has been obsoleted by the new
+ * {@link java.awt.KeyboardFocusManager} and
+ * {@link java.awt.DefaultKeyboardFocusManager} API.
+ *
+ * @author Andrew Selkirk
*/
public abstract class FocusManager
extends DefaultKeyboardFocusManager
{
-
/**
* DisabledFocusManager
*/
@@ -95,7 +97,6 @@ public abstract class FocusManager
}
}
-
/**
* FOCUS_MANAGER_CLASS_PROPERTY
*/
@@ -107,7 +108,7 @@ public abstract class FocusManager
*/
public FocusManager()
{
- // TODO
+ super();
}
/**
@@ -116,7 +117,20 @@ public abstract class FocusManager
*/
public static FocusManager getCurrentManager()
{
- return null; // TODO
+ KeyboardFocusManager fm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ if (fm instanceof FocusManager)
+ return (FocusManager) fm;
+ else
+ {
+ System.err.println("The Swing FocusManager API has been obsoleted by");
+ System.err.println("the new KeyboardFocusManager system.");
+ System.err.println("You should either not use the Swing FocusManager");
+ System.err.println("API or set the system property");
+ System.err.println
+ ("gnu.java.awt.FocusManager=javax.swing.FocusManager");
+ }
+ return null;
}
/**
@@ -125,7 +139,7 @@ public abstract class FocusManager
*/
public static void setCurrentManager(FocusManager manager)
{
- // TODO
+ KeyboardFocusManager.setCurrentKeyboardFocusManager(manager);
}
/**
@@ -146,24 +160,4 @@ public abstract class FocusManager
{
return false; // TODO
}
-
- /**
- * processKeyEvent
- * @param component TODO
- * @param event TODO
- */
- public abstract void processKeyEvent(Component component, KeyEvent event);
-
- /**
- * focusNextComponent
- * @param component TODO
- */
- public abstract void focusNextComponent(Component component);
-
- /**
- * focusPreviousComponent
- * @param component TODO
- */
- public abstract void focusPreviousComponent(Component component);
-
}
diff --git a/javax/swing/GrayFilter.java b/javax/swing/GrayFilter.java
index 73302ad19..b920b088a 100644
--- a/javax/swing/GrayFilter.java
+++ b/javax/swing/GrayFilter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,13 +43,20 @@ import java.awt.Toolkit;
import java.awt.image.FilteredImageSource;
import java.awt.image.RGBImageFilter;
+/**
+ * Produces grayscale images out of colored images. This is used to provide
+ * default disabled icons for buttons.
+ *
+ * @author original author unknown
+ */
public class GrayFilter extends RGBImageFilter
{
private boolean b;
- private int p;
+ private double p;
/**
- * Create a GrayFilter. If b is true then brighten. Also, indicate how much gray.
+ * Create a GrayFilter. If b is true then brighten. Also, indicate how much
+ * gray.
*
* @param b if brighten
* @param p percent of gray, 0 - 100
@@ -57,7 +64,7 @@ public class GrayFilter extends RGBImageFilter
public GrayFilter(boolean b, int p)
{
this.b = b; //FIXME - HANDLE THIS
- this.p = p;
+ this.p = (1. - (p / 100.)) / 3.;
}
/**
@@ -71,7 +78,7 @@ public class GrayFilter extends RGBImageFilter
{
return (Toolkit.getDefaultToolkit().
createImage(new FilteredImageSource(src.getSource(),
- new GrayFilter(false, 100))));
+ new GrayFilter(true, 0))));
}
/**
@@ -79,7 +86,13 @@ public class GrayFilter extends RGBImageFilter
*/
public int filterRGB(int x, int y, int rgb)
{
- return (int) (p * (0.299 * ((0xff0000 & rgb) >> 16)
- + 0.587 * ((0xff00 & rgb) >> 8) + 0.114 * (0xff & rgb)));
+ int alpha = 0xff000000 & rgb;
+ int red = (0xff0000 & rgb) >> 16;
+ int green = (0xff00 & rgb) >> 8;
+ int blue = (0xff & rgb);
+ int gray = (int) ((0.299 * red + 0.587 * green + 0.114 * blue) * p);
+ if (b)
+ gray = Math.min(gray + 128, 255);
+ return gray | gray << 8 | gray << 16 | alpha ;
}
}
diff --git a/javax/swing/Icon.java b/javax/swing/Icon.java
index da2ba74ef..c73ad2d40 100644
--- a/javax/swing/Icon.java
+++ b/javax/swing/Icon.java
@@ -1,5 +1,5 @@
/* Icon.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,9 +40,34 @@ package javax.swing;
import java.awt.Component;
import java.awt.Graphics;
+/**
+ * Defines the methods that an object must implement if it should be used
+ * as an icon in Swing.
+ */
public interface Icon
{
+ /**
+ * Returns the height of the icon.
+ *
+ * @return The height of the icon.
+ */
int getIconHeight();
+
+ /**
+ * Returns the width of the icon.
+ *
+ * @return The width of the icon.
+ */
int getIconWidth();
+
+ /**
+ * Draws the icon at the location (x, y) on the specified graphics device.
+ *
+ * @param c a component related to the icon in some way (can be ignored by
+ some implementing classes).
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
void paintIcon(Component c, Graphics g, int x, int y);
}
diff --git a/javax/swing/ImageIcon.java b/javax/swing/ImageIcon.java
index 062c5d8a0..4cedd276b 100644
--- a/javax/swing/ImageIcon.java
+++ b/javax/swing/ImageIcon.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -53,6 +53,11 @@ import javax.accessibility.AccessibleIcon;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
+/**
+ * An {@link Icon} implementation that is backed by an {@link Image}.
+ *
+ * @author original author unknown
+ */
public class ImageIcon
implements Icon, Serializable, Accessible
{
@@ -319,17 +324,17 @@ public class ImageIcon
{
try
{
- tracker.addImage(image, id);
- id++;
- tracker.waitForID(id - 1);
+ tracker.addImage(image, id);
+ id++;
+ tracker.waitForID(id - 1);
}
catch (InterruptedException ex)
{
- ; // ignore this for now
+ ; // ignore this for now
}
finally
{
- loadStatus = tracker.statusID(id - 1, false);
+ loadStatus = tracker.statusID(id - 1, false);
}
}
@@ -338,9 +343,9 @@ public class ImageIcon
*
* @return the load status of the icon image
*
- * @see {@link MediaTracker.COMPLETE}
- * @see {@link MediaTracker.ABORTED}
- * @see {@link MediaTracker.ERRORED}
+ * @see MediaTracker#COMPLETE
+ * @see MediaTracker#ABORTED
+ * @see MediaTracker#ERRORED
*/
public int getImageLoadStatus()
{
diff --git a/javax/swing/InputMap.java b/javax/swing/InputMap.java
index 53be5b1b1..a7ec38c41 100644
--- a/javax/swing/InputMap.java
+++ b/javax/swing/InputMap.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -49,6 +49,14 @@ import java.util.Set;
/**
+ * Maps {@link KeyStroke}s to arbitrary objects, usually Strings. This
+ * is used in combination with {@link ActionMap}s.
+ *
+ * If a component receives an input event, this is looked up in
+ * the component's <code>InputMap</code>. The result is an object which
+ * serves as a key to the components <code>ActionMap</code>. Finally
+ * the <code>Action</code> that is stored is executed.
+ *
* @author Andrew Selkirk
* @author Michael Koch
*
@@ -80,7 +88,7 @@ public class InputMap
/**
* Returns the binding for keystroke.
*
- * @param key the key of the enty
+ * @param keystroke the key of the enty
*
* @return the binding associated with keystroke may be null
*/
@@ -111,7 +119,7 @@ public class InputMap
/**
* Remove an entry from the <code>InputMap</code>.
*
- * @param key the key of the entry to remove
+ * @param keystroke the key of the entry to remove
*/
public void remove(KeyStroke keystroke)
{
diff --git a/javax/swing/InputVerifier.java b/javax/swing/InputVerifier.java
index ccd13d285..8e02ab813 100644
--- a/javax/swing/InputVerifier.java
+++ b/javax/swing/InputVerifier.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,9 +39,12 @@ package javax.swing;
/**
- * InputVerifier
+ * Verifies the user input on a component before the focus is shifted.
+ * It is sometimes necessary that input components have a valid state before
+ * they loose focus. Such components can have a <code>InputVerifier</code>
+ * subclass registered, that permits or vetos a focus change request.
+ *
* @author Andrew Selkirk
- * @version 1.0
*/
public abstract class InputVerifier
{
diff --git a/javax/swing/InternalFrameFocusTraversalPolicy.java b/javax/swing/InternalFrameFocusTraversalPolicy.java
index 0ac701446..4780a67c5 100644
--- a/javax/swing/InternalFrameFocusTraversalPolicy.java
+++ b/javax/swing/InternalFrameFocusTraversalPolicy.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,11 +42,16 @@ import java.awt.Component;
import java.awt.FocusTraversalPolicy;
/**
+ * A {@link FocusTraversalPolicy} that provides the additional capability
+ * to determine a {@link JInternalFrame}'s initially focused component
+ * when it is selected.
+ *
* @author Michael Koch
*
* @since 1.4
*/
-public abstract class InternalFrameFocusTraversalPolicy extends FocusTraversalPolicy
+public abstract class InternalFrameFocusTraversalPolicy
+ extends FocusTraversalPolicy
{
public Component getInitialComponent(JInternalFrame frame)
{
diff --git a/javax/swing/JApplet.java b/javax/swing/JApplet.java
index 8446e27b1..cafb2dabb 100644
--- a/javax/swing/JApplet.java
+++ b/javax/swing/JApplet.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -49,18 +49,35 @@ import java.awt.event.KeyEvent;
import javax.accessibility.AccessibleContext;
+/**
+ * A top-level container that is usually used in web browsers.
+ *
+ * @author original author unknown
+ */
public class JApplet extends Applet
implements RootPaneContainer
{
private static final long serialVersionUID = 7269359214497372587L;
protected JRootPane rootPane;
- protected boolean rootPaneCheckingEnabled;
+
+ /**
+ * @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0
+ */
+ protected boolean rootPaneCheckingEnabled=false;
+
+ /**
+ * Tells us if we're in the initialization stage.
+ * If so, adds go to top-level Container, otherwise they go
+ * to the content pane for this container
+ */
+ private boolean initStageDone = false;
public JApplet()
{
super.setLayout(new BorderLayout(1, 1));
- getRootPane(); // will do set/create
+ getRootPane(); // Will do set/create.
+ initStageDone = true; // Init stage is now over.
}
public Dimension getPreferredSize()
@@ -70,7 +87,17 @@ public class JApplet extends Applet
public void setLayout(LayoutManager manager)
{
- super.setLayout(manager);
+ // Check if we're in initialization stage. If so, call super.setLayout
+ // otherwise, valid calls go to the content pane
+ if (initStageDone)
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Cannot set layout. Use getContentPane().setLayout()"
+ + "instead.");
+ getContentPane().setLayout(manager);
+ }
+ else
+ super.setLayout(manager);
}
public void setLayeredPane(JLayeredPane layeredPane)
@@ -126,7 +153,17 @@ public class JApplet extends Applet
protected void addImpl(Component comp, Object constraints, int index)
{
- super.addImpl(comp, constraints, index);
+ // If we're adding in the initialization stage use super.add.
+ // Otherwise pass the add onto the content pane.
+ if (!initStageDone)
+ super.addImpl(comp, constraints, index);
+ else
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Do not use add() on JApplet directly. Use "
+ + "getContentPane().add() instead");
+ getContentPane().add(comp, constraints, index);
+ }
}
public AccessibleContext getAccessibleContext()
@@ -156,7 +193,12 @@ public class JApplet extends Applet
public void remove(Component comp)
{
- getContentPane().remove(comp);
+ // If we're removing the root pane, use super.remove. Otherwise
+ // pass it on to the content pane instead
+ if (comp == rootPane)
+ super.remove(rootPane);
+ else
+ getContentPane().remove(comp);
}
protected boolean isRootPaneCheckingEnabled()
diff --git a/javax/swing/JButton.java b/javax/swing/JButton.java
index eca53750e..5653fbf42 100644
--- a/javax/swing/JButton.java
+++ b/javax/swing/JButton.java
@@ -1,5 +1,5 @@
/* JButton.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,21 +39,45 @@ package javax.swing;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
import javax.swing.plaf.ButtonUI;
/**
- * An instance of JButton can be added to a panel, frame etc
+ * A general purpose push button. <code>JButton</code>s can display a label,
+ * an {@link Icon} or both.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
public class JButton extends AbstractButton
implements Accessible
{
+
+ /**
+ * Accessibility support for JButtons.
+ */
+ protected class AccessibleJButton
+ extends AbstractButton.AccessibleAbstractButton
+ {
+ /**
+ * Returns the accessible role that this component represents.
+ * This is {@link AccessibleRole#PUSH_BUTTON} for <code>JButton</code>s.
+ *
+ * @return the accessible role that this component represents
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.PUSH_BUTTON;
+ }
+ }
+
private static final long serialVersionUID = -1907255238954382202L;
boolean def;
boolean is_def;
+ /** The AccessibleContext for this JButton. */
+ AccessibleJButton accessibleContext;
+
public JButton()
{
this(null, null);
@@ -77,9 +101,9 @@ public class JButton extends AbstractButton
public JButton(String text, Icon icon)
{
- super(text, icon);
+ super();
+ init(text, icon);
setModel(new DefaultButtonModel());
- setActionCommand(text);
}
public Object[] getSelectedObjects()
@@ -89,37 +113,49 @@ public class JButton extends AbstractButton
protected void configurePropertiesFromAction(Action a)
{
- //Factory method which sets the AbstractButton's properties according to values from the Action instance.
+ // Factory method which sets the AbstractButton's properties according to
+ // values from the Action instance.
super.configurePropertiesFromAction(a);
}
public AccessibleContext getAccessibleContext()
{
- //Gets the AccessibleContext associated with this JButton.
- return null;
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJButton();
+ return accessibleContext;
}
public String getUIClassID()
{
- //Returns a string that specifies the name of the L&F class that renders this component.
+ // Returns a string that specifies the name of the L&F class that renders
+ // this component.
return "ButtonUI";
}
public boolean isDefaultButton()
{
- //Returns whether or not this button is the default button on the RootPane.
+ // Returns whether or not this button is the default button on the
+ // RootPane.
return is_def;
}
public boolean isDefaultCapable()
{
- //Returns whether or not this button is capable of being the default button on the RootPane.
+ // Returns whether or not this button is capable of being the default
+ // button on the RootPane.
return def;
}
protected String paramString()
{
- return "JButton";
+ String superParam = super.paramString();
+
+ // 41 is the maximum number of chars which may be needed.
+ StringBuffer sb = new StringBuffer(41);
+ sb.append(",defaultButton=").append(is_def);
+ sb.append(",defaultCapable=").append(def);
+
+ return superParam + sb.toString();
}
/**
diff --git a/javax/swing/JCheckBox.java b/javax/swing/JCheckBox.java
index a8506e5f8..a743308dc 100644
--- a/javax/swing/JCheckBox.java
+++ b/javax/swing/JCheckBox.java
@@ -1,5 +1,5 @@
/* JCheckBox.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,7 +41,16 @@ package javax.swing;
import javax.accessibility.AccessibleContext;
/**
- * An instance of JCheckbox can be added to a panel, frame etc
+ * A small box that displays a check or not, depending on it's
+ * <code>selected</code> state. This works very similar to
+ * {@link JToggleButton} and {@link JRadioButton}, but in UI design it
+ * has different semantics. <code>JCheckBox</code>es are usually
+ * used in multiple-choice scenarios, where a user can select 0..n
+ * of n different options. (This is in contrast to the general RadioButton
+ * semantics where the user can select exactly one of n options).
+ *
+ * Note however that this semantics is in no way enforced by the
+ * <code>JCheckBox</code>.
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
@@ -127,7 +136,7 @@ public class JCheckBox extends JToggleButton
protected String paramString()
{
- return "JCheckBox";
+ return super.paramString() + ",borderPaintedFlat=" + borderPaintedFlat;
}
public boolean isBorderPaintedFlat()
diff --git a/javax/swing/JCheckBoxMenuItem.java b/javax/swing/JCheckBoxMenuItem.java
index 090c3c204..39fbc191c 100644
--- a/javax/swing/JCheckBoxMenuItem.java
+++ b/javax/swing/JCheckBoxMenuItem.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,11 +46,14 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
/**
- * This class represents JCheckBoxMenuItem. Its behaviour is very similar
- * to JCheckBoxButton. Just like the JCheckBoxButton, user can check and
- * uncheck this menu item by clicking on it. Also setSelected()/setState()
- * can be use used for the same purpose. JCheckBoxMenuItem uses
- * ToggleButtonModel to keep track of its selection.
+ * A menu item that displays a checkbox. Its behaviour is very similar
+ * to {@link JCheckBox}. Just like the <code>JCheckBox</code>, user can check
+ * and uncheck this menu item by clicking on it. Also {@link #setSelected()}
+ * and {@link #setState()} can be use used for the same purpose.
+ * <code>JCheckBoxMenuItem</code> uses
+ * <code>ToggleButtonModel</code> to keep track of its selection.
+ *
+ * @author original author unknown
*/
public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
Accessible
@@ -121,10 +124,11 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Creates a new JCheckBoxMenuItem object using specified label and
- * marked as checked if given 'state' is true
+ * marked as checked if given 'state' is true.
*
* @param text Label for this menu item
- * @param state True if this item should be in checked state and false otherwise
+ * @param state <code>true</code> if this item should be in checked state and
+ * <code>false</code> otherwise
*/
public JCheckBoxMenuItem(String text, boolean state)
{
@@ -133,11 +137,12 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
/**
* Creates a new JCheckBoxMenuItem object with given label, icon,
- * and marked as checked if given 'state' is true
+ * and marked as checked if given 'state' is true.
*
* @param text Label for this menu item
* @param icon icon for this menu item
- * @param state True if this item should be in checked state and false otherwise
+ * @param state <code>true</code> if this item should be in checked state and
+ * false otherwise
*/
public JCheckBoxMenuItem(String text, Icon icon, boolean state)
{
@@ -178,7 +183,6 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
* and uncheck this menu item otherwise.
*
* @param state new state for this menu item
- *
*/
public synchronized void setState(boolean state)
{
@@ -190,7 +194,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
* menu item if it is selected and null otherwise.
*
* @return Array containing label of this
- * menu item if this menu item is selected or null otherwise.
+ * menu item if this menu item is selected or null otherwise.
*/
public Object[] getSelectedObjects()
{
@@ -231,6 +235,9 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
return accessibleContext;
}
+ /**
+ * Accessibility support for <code>JCheckBoxMenuItem</code>.
+ */
protected class AccessibleJCheckBoxMenuItem extends AccessibleJMenuItem
{
private static final long serialVersionUID = 1079958073579370777L;
diff --git a/javax/swing/JColorChooser.java b/javax/swing/JColorChooser.java
index 1ae4ed195..4016b82f3 100644
--- a/javax/swing/JColorChooser.java
+++ b/javax/swing/JColorChooser.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -58,13 +58,15 @@ import javax.swing.plaf.ColorChooserUI;
/**
- * The JColorChooser is a Swing widget that offers users different ways to
+ * 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.
+ *
+ * @author original author unknown
*/
public class JColorChooser extends JComponent implements Accessible
{
@@ -72,7 +74,7 @@ public class JColorChooser extends JComponent implements Accessible
private static final long serialVersionUID = 9168066781620640889L;
/**
- * AccessibleJColorChooser
+ * Accessibility support for <code>JColorChooser</code>.
*/
protected class AccessibleJColorChooser
extends JComponent.AccessibleJComponent
@@ -237,11 +239,11 @@ public class JColorChooser extends JComponent implements Accessible
{
try
{
- synchronized (dialog)
- {
- while (dialog.isVisible())
- dialog.wait();
- }
+ synchronized (dialog)
+ {
+ while (dialog.isVisible())
+ dialog.wait();
+ }
}
catch (InterruptedException e)
{
@@ -393,9 +395,9 @@ public class JColorChooser extends JComponent implements Accessible
{
if (component != previewPanel)
{
- JComponent old = previewPanel;
- previewPanel = component;
- firePropertyChange(PREVIEW_PANEL_PROPERTY, old, previewPanel);
+ JComponent old = previewPanel;
+ previewPanel = component;
+ firePropertyChange(PREVIEW_PANEL_PROPERTY, old, previewPanel);
}
} // setPreviewPanel()
@@ -421,10 +423,8 @@ public class JColorChooser extends JComponent implements Accessible
if (panel == null)
return;
AbstractColorChooserPanel[] old = chooserPanels;
- AbstractColorChooserPanel[] newPanels = new AbstractColorChooserPanel[(old == null)
- ? 1
- : old.length
- + 1];
+ 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;
@@ -447,8 +447,8 @@ public class JColorChooser extends JComponent implements Accessible
for (int i = 0; i < chooserPanels.length; i++)
if (panel == chooserPanels[i])
{
- index = i;
- break;
+ index = i;
+ break;
}
if (index == -1)
@@ -459,12 +459,12 @@ public class JColorChooser extends JComponent implements Accessible
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;
+ 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);
@@ -480,20 +480,20 @@ public class JColorChooser extends JComponent implements Accessible
{
if (panels != chooserPanels)
{
- if (chooserPanels != null)
- for (int i = 0; i < chooserPanels.length; i++)
- if (chooserPanels[i] != null)
- chooserPanels[i].uninstallChooserPanel(this);
+ if (chooserPanels != null)
+ for (int i = 0; i < chooserPanels.length; i++)
+ if (chooserPanels[i] != null)
+ chooserPanels[i].uninstallChooserPanel(this);
- AbstractColorChooserPanel[] old = chooserPanels;
- chooserPanels = panels;
+ AbstractColorChooserPanel[] old = chooserPanels;
+ chooserPanels = panels;
- if (panels != null)
- for (int i = 0; i < panels.length; i++)
- if (panels[i] != null)
- panels[i].installChooserPanel(this);
+ if (panels != null)
+ for (int i = 0; i < panels.length; i++)
+ if (panels[i] != null)
+ panels[i].installChooserPanel(this);
- firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels);
+ firePropertyChange(CHOOSER_PANELS_PROPERTY, old, chooserPanels);
}
} // setChooserPanels()
diff --git a/javax/swing/JComboBox.java b/javax/swing/JComboBox.java
index 078c77df4..47d18323a 100644
--- a/javax/swing/JComboBox.java
+++ b/javax/swing/JComboBox.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -61,10 +61,10 @@ import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComboBoxUI;
/**
- * JComboBox. JComboBox is a container, that keeps track of elements added to
- * it by the user. JComboBox allows user to select any item in its list and
- * displays the selected item to the user. JComboBox also can show/hide popup
- * menu containing its list of item whenever the mouse is pressed over it.
+ * A component that allows a user to select any item in its list and
+ * displays the selected item to the user. JComboBox also can show/hide a
+ * popup menu containing its list of item whenever the mouse is pressed
+ * over it.
*
* @author Andrew Selkirk
* @author Olga Rodimina
@@ -79,7 +79,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
private static final long serialVersionUID = 5654585963292734470L;
/**
- * KeySelectionManager interface. Class implementing this interface are
+ * Classes implementing this interface are
* responsible for matching key characters typed by the user with combo
* box's items.
*/
@@ -95,7 +95,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
private static final int DEFAULT_MAXIMUM_ROW_COUNT = 8;
/**
- * dataModel used by JComboBox to keep track of its list data and currently
+ * Data model used by JComboBox to keep track of its list data and currently
* selected element in the list.
*/
protected ComboBoxModel dataModel;
@@ -290,16 +290,16 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void setModel(ComboBoxModel newDataModel)
{
-
// dataModel is null if it this method is called from inside the constructors.
- if(dataModel != null) {
- // Prevents unneccessary updates.
- if (dataModel == newDataModel)
- return;
+ if (dataModel != null)
+ {
+ // Prevents unneccessary updates.
+ if (dataModel == newDataModel)
+ return;
- // Removes itself (as DataListener) from the to-be-replaced model.
- dataModel.removeListDataListener(this);
- }
+ // Removes itself (as DataListener) from the to-be-replaced model.
+ dataModel.removeListDataListener(this);
+ }
/* Adds itself as a DataListener to the new model.
* It is intentioned that this operation will fail with a NullPointerException if the
@@ -366,8 +366,8 @@ public class JComboBox extends JComponent implements ItemSelectable,
{
if (isEditable != editable)
{
- isEditable = editable;
- firePropertyChange("editable", ! isEditable, isEditable);
+ isEditable = editable;
+ firePropertyChange("editable", !isEditable, isEditable);
}
}
@@ -383,10 +383,10 @@ public class JComboBox extends JComponent implements ItemSelectable,
{
if (maximumRowCount != rowCount)
{
- int oldMaximumRowCount = maximumRowCount;
- maximumRowCount = rowCount;
- firePropertyChange("maximumRowCount",
- oldMaximumRowCount, maximumRowCount);
+ int oldMaximumRowCount = maximumRowCount;
+ maximumRowCount = rowCount;
+ firePropertyChange("maximumRowCount", oldMaximumRowCount,
+ maximumRowCount);
}
}
@@ -415,10 +415,9 @@ public class JComboBox extends JComponent implements ItemSelectable,
{
if (renderer != aRenderer)
{
- ListCellRenderer oldRenderer = renderer;
- renderer = aRenderer;
- firePropertyChange("renderer", oldRenderer,
- renderer);
+ ListCellRenderer oldRenderer = renderer;
+ renderer = aRenderer;
+ firePropertyChange("renderer", oldRenderer, renderer);
}
}
@@ -501,52 +500,52 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void setSelectedIndex(int index)
{
- if(index < -1 || index >= dataModel.getSize()) {
- // Fails because index is out of bounds.
- throw new IllegalArgumentException("illegal index: " + index);
- } else {
- /* Selects the item at the given index or clears the selection if the
- * index value is -1.
- */
- setSelectedItem((index == -1) ? null : dataModel.getElementAt(index));
- }
+ if (index < -1 || index >= dataModel.getSize())
+ // Fails because index is out of bounds.
+ throw new IllegalArgumentException("illegal index: " + index);
+ else
+ // Selects the item at the given index or clears the selection if the
+ // index value is -1.
+ setSelectedItem((index == -1) ? null : dataModel.getElementAt(index));
}
/**
- * Returns index of the item that is currently selected in the combo box.
- * If no item is currently selected, then -1 is returned.
- *
- * <p>Note: For performance reasons you should minimize invocation of this
+ * Returns index of the item that is currently selected in the combo box. If
+ * no item is currently selected, then -1 is returned.
+ * <p>
+ * Note: For performance reasons you should minimize invocation of this
* method. If the data model is not an instance of
- * <code>DefaultComboBoxModel</code> the complexity is O(n) where
- * n is the number of elements in the combo box.</p>
- *
- * @return int Index specifying location of the currently selected item in
- * the combo box or -1 if nothing is selected in the combo box.
+ * <code>DefaultComboBoxModel</code> the complexity is O(n) where n is the
+ * number of elements in the combo box.
+ * </p>
+ *
+ * @return int Index specifying location of the currently selected item in the
+ * combo box or -1 if nothing is selected in the combo box.
*/
public int getSelectedIndex()
{
Object selectedItem = getSelectedItem();
-
- if (selectedItem != null) {
-
- if(dataModel instanceof DefaultComboBoxModel) {
- // Uses special method of DefaultComboBoxModel to retrieve the index.
- return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem);
- } else {
- // Iterates over all items to retrieve the index.
- int size = dataModel.getSize();
-
- for(int i=0; i < size; i++) {
- Object o = dataModel.getElementAt(i);
-
- // XXX: Is special handling of ComparableS neccessary?
- if((selectedItem != null) ? selectedItem.equals(o) : o == null) {
- return i;
- }
- }
- }
- }
+
+ if (selectedItem != null)
+ {
+ if (dataModel instanceof DefaultComboBoxModel)
+ // Uses special method of DefaultComboBoxModel to retrieve the index.
+ return ((DefaultComboBoxModel) dataModel).getIndexOf(selectedItem);
+ else
+ {
+ // Iterates over all items to retrieve the index.
+ int size = dataModel.getSize();
+
+ for (int i = 0; i < size; i++)
+ {
+ Object o = dataModel.getElementAt(i);
+
+ // XXX: Is special handling of ComparableS neccessary?
+ if ((selectedItem != null) ? selectedItem.equals(o) : o == null)
+ return i;
+ }
+ }
+ }
// returns that no item is currently selected
return -1;
@@ -571,11 +570,12 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void addItem(Object element)
{
- if(dataModel instanceof MutableComboBoxModel) {
- ((MutableComboBoxModel) dataModel).addElement(element);
- } else {
- throw new RuntimeException("Unable to add the item because the data model it is not an instance of MutableComboBoxModel.");
- }
+ if (dataModel instanceof MutableComboBoxModel)
+ ((MutableComboBoxModel) dataModel).addElement(element);
+ else
+ throw new RuntimeException("Unable to add the item because the data "
+ + "model it is not an instance of "
+ + "MutableComboBoxModel.");
}
/**
@@ -588,11 +588,12 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void insertItemAt(Object element, int index)
{
- if(dataModel instanceof MutableComboBoxModel) {
- ((MutableComboBoxModel) dataModel).insertElementAt(element, index);
- } else {
- throw new RuntimeException("Unable to insert the item because the data model it is not an instance of MutableComboBoxModel.");
- }
+ if (dataModel instanceof MutableComboBoxModel)
+ ((MutableComboBoxModel) dataModel).insertElementAt(element, index);
+ else
+ throw new RuntimeException("Unable to insert the item because the data "
+ + "model it is not an instance of "
+ + "MutableComboBoxModel.");
}
/**
@@ -604,11 +605,12 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void removeItem(Object element)
{
- if(dataModel instanceof MutableComboBoxModel) {
- ((MutableComboBoxModel) dataModel).removeElement(element);
- } else {
- throw new RuntimeException("Unable to remove the item because the data model it is not an instance of MutableComboBoxModel.");
- }
+ if (dataModel instanceof MutableComboBoxModel)
+ ((MutableComboBoxModel) dataModel).removeElement(element);
+ else
+ throw new RuntimeException("Unable to remove the item because the data "
+ + "model it is not an instance of "
+ + "MutableComboBoxModel.");
}
/**
@@ -621,40 +623,40 @@ public class JComboBox extends JComponent implements ItemSelectable,
*/
public void removeItemAt(int index)
{
- if(dataModel instanceof MutableComboBoxModel) {
- ((MutableComboBoxModel) dataModel).removeElementAt(index);
- } else {
- throw new RuntimeException("Unable to remove the item because the data model it is not an instance of MutableComboBoxModel.");
- }
+ if (dataModel instanceof MutableComboBoxModel)
+ ((MutableComboBoxModel) dataModel).removeElementAt(index);
+ else
+ throw new RuntimeException("Unable to remove the item because the data "
+ + "model it is not an instance of "
+ + "MutableComboBoxModel.");
}
/**
* This method removes all elements from this JComboBox.
- * <p>A <code>RuntimeException</code> is thrown if the data model is not
- * an instance of {@link MutableComboBoxModel}.</p>
- *
+ * <p>
+ * A <code>RuntimeException</code> is thrown if the data model is not an
+ * instance of {@link MutableComboBoxModel}.
+ * </p>
*/
public void removeAllItems()
{
- if (dataModel instanceof DefaultComboBoxModel) {
- // Uses special method if we have a DefaultComboBoxModel.
- ((DefaultComboBoxModel) dataModel).removeAllElements();
- } else if(dataModel instanceof MutableComboBoxModel){
- // Iterates over all items and removes each.
- MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel;
-
- /* We intentionally remove the items backwards to support
- * models which shift their content to the beginning (e.g.
- * linked lists)
- */
- for(int i=mcbm.getSize()-1; i >= 0; i--) {
- mcbm.removeElementAt(i);
- }
-
- } else {
- throw new RuntimeException("Unable to remove the items because the data model it is not an instance of MutableComboBoxModel.");
- }
-
+ if (dataModel instanceof DefaultComboBoxModel)
+ // Uses special method if we have a DefaultComboBoxModel.
+ ((DefaultComboBoxModel) dataModel).removeAllElements();
+ else if (dataModel instanceof MutableComboBoxModel)
+ {
+ // Iterates over all items and removes each.
+ MutableComboBoxModel mcbm = (MutableComboBoxModel) dataModel;
+
+ // We intentionally remove the items backwards to support models which
+ // shift their content to the beginning (e.g. linked lists)
+ for (int i = mcbm.getSize() - 1; i >= 0; i--)
+ mcbm.removeElementAt(i);
+ }
+ else
+ throw new RuntimeException("Unable to remove the items because the data "
+ +"model it is not an instance of "
+ + "MutableComboBoxModel.");
}
/**
@@ -755,13 +757,13 @@ public class JComboBox extends JComponent implements ItemSelectable,
{
if (a == null)
{
- setEnabled(true);
- setToolTipText(null);
+ setEnabled(true);
+ setToolTipText(null);
}
else
{
- setEnabled(a.isEnabled());
- setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION)));
+ setEnabled(a.isEnabled());
+ setToolTipText((String) (a.getValue(Action.SHORT_DESCRIPTION)));
}
}
@@ -771,18 +773,18 @@ public class JComboBox extends JComponent implements ItemSelectable,
*
* @param action action to listen to for property changes
*
- * @return $PropertyChangeListener$ Listener that listens to changes in
+ * @return a PropertyChangeListener that listens to changes in
* action properties.
*/
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
{
return new PropertyChangeListener()
{
- public void propertyChange(PropertyChangeEvent e)
- {
- Action act = (Action) (e.getSource());
- configurePropertiesFromAction(act);
- }
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ Action act = (Action) (e.getSource());
+ configurePropertiesFromAction(act);
+ }
};
}
@@ -936,8 +938,8 @@ public class JComboBox extends JComponent implements ItemSelectable,
boolean oldEnabled = super.isEnabled();
if (enabled != oldEnabled)
{
- super.setEnabled(enabled);
- firePropertyChange("enabled", oldEnabled, enabled);
+ super.setEnabled(enabled);
+ firePropertyChange("enabled", oldEnabled, enabled);
}
}
@@ -1136,7 +1138,7 @@ public class JComboBox extends JComponent implements ItemSelectable,
}
/**
- * AccessibleJComboBox
+ * Accessibility support for <code>JComboBox</code>.
*/
protected class AccessibleJComboBox extends AccessibleJComponent
implements AccessibleAction, AccessibleSelection
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 08f13ed0f..ed81443fa 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -44,8 +44,10 @@ import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
+import java.awt.FocusTraversalPolicy;
import java.awt.Font;
import java.awt.Graphics;
+import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
@@ -70,6 +72,7 @@ import java.io.Serializable;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Locale;
+import java.util.Set;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
@@ -85,7 +88,7 @@ import javax.swing.event.SwingPropertyChangeSupport;
import javax.swing.plaf.ComponentUI;
/**
- * Every component in swing inherits from this class (JLabel, JButton, etc).
+ * The base class of all Swing components.
* It contains generic methods to manage events, properties and sizes. Actual
* drawing of the component is channeled to a look-and-feel class that is
* implemented elsewhere.
@@ -100,13 +103,19 @@ public abstract class JComponent extends Container implements Serializable
/**
* Accessibility support is currently missing.
*/
-
protected AccessibleContext accessibleContext;
+ /**
+ * Basic accessibility support for <code>JComponent</code> derived
+ * widgets.
+ */
public abstract class AccessibleJComponent
extends AccessibleAWTContainer
implements AccessibleExtendedComponent
{
+ /**
+ * Accessibility support for <code>JComponent</code>'s focus handler.
+ */
protected class AccessibleFocusHandler
implements FocusListener
{
@@ -115,6 +124,9 @@ public abstract class JComponent extends Container implements Serializable
public void focusLost(FocusEvent valevent){}
}
+ /**
+ * Accessibility support for <code>JComponent</code>'s container handler.
+ */
protected class AccessibleContainerHandler
implements ContainerListener
{
@@ -164,7 +176,6 @@ public abstract class JComponent extends Container implements Serializable
*/
Dimension maximumSize;
-
/**
* A value between 0.0 and 1.0 indicating the preferred horizontal
* alignment of the component, relative to its siblings. The values
@@ -274,7 +285,7 @@ public abstract class JComponent extends Container implements Serializable
* repainting of the component are usually delegated to this object.
*
* @see #setUI
- * @see #getUI
+ * @see #getUIClassID
* @see #updateUI
*/
protected ComponentUI ui;
@@ -348,7 +359,6 @@ public abstract class JComponent extends Container implements Serializable
*/
private static final Object paintLock = new Object();
-
/**
* The default locale of the component.
*
@@ -363,7 +373,7 @@ public abstract class JComponent extends Container implements Serializable
* Constant used to indicate that no condition has been assigned to a
* particular action.
*
- * @see #registerKeyboardAction
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
*/
public static final int UNDEFINED_CONDITION = -1;
@@ -371,7 +381,7 @@ public abstract class JComponent extends Container implements Serializable
* Constant used to indicate that an action should be performed only when
* the component has focus.
*
- * @see #registerKeyboardAction
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
*/
public static final int WHEN_FOCUSED = 0;
@@ -379,7 +389,7 @@ public abstract class JComponent extends Container implements Serializable
* Constant used to indicate that an action should be performed only when
* the component is an ancestor of the component which has focus.
*
- * @see #registerKeyboardAction
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
*/
public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT = 1;
@@ -387,11 +397,10 @@ public abstract class JComponent extends Container implements Serializable
* Constant used to indicate that an action should be performed only when
* the component is in the window which has focus.
*
- * @see #registerKeyboardAction
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
*/
public static final int WHEN_IN_FOCUSED_WINDOW = 2;
-
/**
* Creates a new <code>JComponent</code> instance.
*/
@@ -452,7 +461,10 @@ public abstract class JComponent extends Container implements Serializable
*/
public final void putClientProperty(Object key, Object value)
{
- getClientProperties().put(key, value);
+ if (value != null)
+ getClientProperties().put(key, value);
+ else
+ getClientProperties().remove(key);
}
/**
@@ -460,7 +472,7 @@ public abstract class JComponent extends Container implements Serializable
*
* @param listener The listener to unregister
*
- * @see addAncestorListener
+ * @see #addAncestorListener
*/
public void removeAncestorListener(AncestorListener listener)
{
@@ -472,7 +484,7 @@ public abstract class JComponent extends Container implements Serializable
*
* @param listener The listener to register
*
- * @see #addPropertyChangeListener
+ * @see #addPropertyChangeListener(PropertyChangeListener)
* @see #changeSupport
*/
public void removePropertyChangeListener(PropertyChangeListener listener)
@@ -487,7 +499,7 @@ public abstract class JComponent extends Container implements Serializable
* @param propertyName The property name to unregister the listener from
* @param listener The listener to unregister
*
- * @see #addPropertyChangeListener
+ * @see #addPropertyChangeListener(String, PropertyChangeListener)
* @see #changeSupport
*/
public void removePropertyChangeListener(String propertyName,
@@ -529,7 +541,7 @@ public abstract class JComponent extends Container implements Serializable
*
* @param listener The listener to register
*
- * @see #removePropertyChangeListener
+ * @see #removePropertyChangeListener(PropertyChangeListener)
* @see #changeSupport
*/
public void addPropertyChangeListener(PropertyChangeListener listener)
@@ -547,7 +559,7 @@ public abstract class JComponent extends Container implements Serializable
* @param propertyName The property name to listen to
* @param listener The listener to register
*
- * @see #removePropertyChangeListener
+ * @see #removePropertyChangeListener(String, PropertyChangeListener)
* @see #changeSupport
*/
public void addPropertyChangeListener(String propertyName,
@@ -613,12 +625,12 @@ public abstract class JComponent extends Container implements Serializable
* @param property The property to return the listeners of
*
* @return The set of <code>PropertyChangeListener</code> objects in
- * {@link #changeSupport} registered to listen on the specified propert
+ * {@link #changeSupport} registered to listen on the specified property
*/
public PropertyChangeListener[] getPropertyChangeListeners(String property)
{
return changeSupport == null ? new PropertyChangeListener[0]
- : changeSupport.getPropertyChangeListeners(property);
+ : changeSupport.getPropertyChangeListeners(property);
}
/**
@@ -715,8 +727,8 @@ public abstract class JComponent extends Container implements Serializable
* @param newValue The new value of the property
*
* @see #changeSupport
- * @see #addPropertyChangeListener
- * @see #removePropertyChangeListener
+ * @see #addPropertyChangeListener(PropertyChangeListener)
+ * @see #removePropertyChangeListener(PropertyChangeListener)
*/
protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue)
@@ -748,17 +760,17 @@ public abstract class JComponent extends Container implements Serializable
*
* @throws PropertyVetoException if the change was vetoed by a listener
*
- * @see addVetoableChangeListener
- * @see removeVetoableChangeListener
+ * @see #addVetoableChangeListener
+ * @see #removeVetoableChangeListener
*/
protected void fireVetoableChange(String propertyName, Object oldValue,
Object newValue)
throws PropertyVetoException
{
VetoableChangeListener[] listeners = getVetoableChangeListeners();
-
+
PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, oldValue, newValue);
-
+
for (int i = 0; i < listeners.length; i++)
listeners[i].vetoableChange(evt);
}
@@ -773,7 +785,6 @@ public abstract class JComponent extends Container implements Serializable
return null;
}
-
/**
* Get the value of the {@link #alignmentX} property.
*
@@ -811,8 +822,7 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Set the value of the {@link #border} property, revalidate
- * and repaint this component.
+ * Set the value of the {@link #border} property.
*
* @param newBorder The new value of the property
*
@@ -823,8 +833,6 @@ public abstract class JComponent extends Container implements Serializable
Border oldBorder = border;
border = newBorder;
firePropertyChange("border", oldBorder, newBorder);
- revalidate();
- repaint();
}
/**
@@ -876,13 +884,11 @@ public abstract class JComponent extends Container implements Serializable
*/
protected Graphics getComponentGraphics(Graphics g)
{
- Graphics g2 = g.create();
- g2.setFont(this.getFont());
- g2.setColor(this.getForeground());
- return g2;
+ g.setFont (this.getFont());
+ g.setColor (this.getForeground());
+ return g;
}
-
/**
* Get the value of the {@link #debugGraphicsOptions} property.
*
@@ -954,7 +960,7 @@ public abstract class JComponent extends Container implements Serializable
/**
* Get the component's maximum size. If the {@link #maximumSize} property
* has been explicitly set, it is returned. If the {@link #maximumSize}
- * property has not been set but the {@link ui} property has been, the
+ * property has not been set but the {@link #ui} property has been, the
* result of {@link ComponentUI#getMaximumSize} is returned. If neither
* property has been set, the result of {@link Container#getMaximumSize}
* is returned.
@@ -983,7 +989,7 @@ public abstract class JComponent extends Container implements Serializable
/**
* Get the component's minimum size. If the {@link #minimumSize} property
* has been explicitly set, it is returned. If the {@link #minimumSize}
- * property has not been set but the {@link ui} property has been, the
+ * property has not been set but the {@link #ui} property has been, the
* result of {@link ComponentUI#getMinimumSize} is returned. If neither
* property has been set, the result of {@link Container#getMinimumSize}
* is returned.
@@ -1012,7 +1018,7 @@ public abstract class JComponent extends Container implements Serializable
/**
* Get the component's preferred size. If the {@link #preferredSize}
* property has been explicitly set, it is returned. If the {@link
- * #preferredSize} property has not been set but the {@link ui} property
+ * #preferredSize} property has not been set but the {@link #ui} property
* has been, the result of {@link ComponentUI#getPreferredSize} is
* returned. If neither property has been set, the result of {@link
* Container#getPreferredSize} is returned.
@@ -1024,17 +1030,26 @@ public abstract class JComponent extends Container implements Serializable
*/
public Dimension getPreferredSize()
{
+ Dimension prefSize = null;
if (preferredSize != null)
- return preferredSize;
+ prefSize = preferredSize;
- if (ui != null)
+ else if (ui != null)
{
Dimension s = ui.getPreferredSize(this);
if (s != null)
- return s;
+ prefSize = s;
}
- Dimension p = super.getPreferredSize();
- return p;
+
+ if (prefSize == null)
+ prefSize = super.getPreferredSize();
+ // make sure that prefSize is not smaller than minSize
+ if (minimumSize != null && prefSize != null
+ && (minimumSize.width > prefSize.width
+ || minimumSize.height > prefSize.height))
+ prefSize = new Dimension(Math.max(minimumSize.width, prefSize.width),
+ Math.max(minimumSize.height, prefSize.height));
+ return prefSize;
}
/**
@@ -1077,7 +1092,7 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Return the value of the {@link #nextFocusableComponent} property.
+ * Return the value of the <code>nextFocusableComponent</code> property.
*
* @return The current value of the property, or <code>null</code>
* if none has been set.
@@ -1132,7 +1147,7 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Return the {@link #toolTip} property of this component, creating it and
+ * Return the <code>toolTip</code> property of this component, creating it and
* setting it if it is currently <code>null</code>. This method can be
* overridden in subclasses which wish to control the exact form of
* tooltip created.
@@ -1141,21 +1156,21 @@ public abstract class JComponent extends Container implements Serializable
*/
public JToolTip createToolTip()
{
- JToolTip toolTip = new JToolTip();
- toolTip.setComponent(this);
- toolTip.setTipText(toolTipText);
-
+ JToolTip toolTip = new JToolTip();
+ toolTip.setComponent(this);
+ toolTip.setTipText(toolTipText);
+
return toolTip;
}
/**
- * Return the location at which the {@link #toolTip} property should be
+ * Return the location at which the {@link #toolTipText} property should be
* displayed, when triggered by a particular mouse event.
*
* @param event The event the tooltip is being presented in response to
*
* @return The point at which to display a tooltip, or <code>null</code>
- * if swing is to choose a default location.
+ * if swing is to choose a default location.
*/
public Point getToolTipLocation(MouseEvent event)
{
@@ -1167,7 +1182,7 @@ public abstract class JComponent extends Container implements Serializable
*
* @param text The new property value
*
- * @see #getToolTipText
+ * @see #getToolTipText()
*/
public void setToolTipText(String text)
{
@@ -1177,14 +1192,14 @@ public abstract class JComponent extends Container implements Serializable
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);
}
@@ -1218,7 +1233,7 @@ public abstract class JComponent extends Container implements Serializable
/**
* Return the top level ancestral container (usually a {@link
- * java.awt.Window} or {@link java.awt.Applet}) which this component is
+ * java.awt.Window} or {@link java.applet.Applet}) which this component is
* contained within, or <code>null</code> if no ancestors exist.
*
* @return The top level container, if it exists
@@ -1275,9 +1290,9 @@ public abstract class JComponent extends Container implements Serializable
* displayable, focusable, visible components.</p>
*
* <p>This method should not be called by clients; it is intended for
- * focus implementations. Use {@link Component#requestFocus} instead.</p>
+ * focus implementations. Use {@link Component#requestFocus()} instead.</p>
*
- * @see {@link Component#requestFocus}
+ * @see Component#requestFocus()
*/
public void grabFocus()
{
@@ -1315,10 +1330,10 @@ public abstract class JComponent extends Container implements Serializable
* <code>CTRL+TAB</code> and <code>CTRL+SHIFT+TAB</code>.
*
* @return <code>true</code> if you want this component to manage its own
- * focus, otherwise (by default) <code>false</code>
+ * focus, otherwise (by default) <code>false</code>
*
- * @deprecated 1.4 Use {@link Component.setFocusTraversalKeys(int,Set)} and
- * {@link Container.setFocusCycleRoot(boolean)} instead
+ * @deprecated 1.4 Use {@link Component#setFocusTraversalKeys(int, Set)} and
+ * {@link Container#setFocusCycleRoot(boolean)} instead
*/
public boolean isManagingFocus()
{
@@ -1326,7 +1341,7 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Return the current value of the {@link opaque} property.
+ * Return the current value of the {@link #opaque} property.
*
* @return The current property value
*/
@@ -1370,10 +1385,10 @@ public abstract class JComponent extends Container implements Serializable
/**
* Return <code>true</code> if this component is a validation root; this
- * will cause calls to {@link #invalidate} in this component's children
+ * will cause calls to {@link #invalidate()} in this component's children
* to be "captured" at this component, and not propagate to its parents.
* For most components this should return <code>false</code>, but some
- * components such as {@link JViewPort} will want to return
+ * components such as {@link JViewport} will want to return
* <code>true</code>.
*
* @return Whether this component is a validation root
@@ -1386,7 +1401,7 @@ public abstract class JComponent extends Container implements Serializable
/**
* <p>Paint the component. This is a delicate process, and should only be
* called from the repaint thread, under control of the {@link
- * RepaintManager}. Client code should usually call {@link #repaint} to
+ * RepaintManager}. Client code should usually call {@link #repaint()} to
* trigger painting.</p>
*
* <p>This method will acquire a double buffer from the {@link
@@ -1405,12 +1420,12 @@ public abstract class JComponent extends Container implements Serializable
* one of these methods rather than <code>paint</code>.</p>
*
* <p>For more details on the painting sequence, see <a
- * href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">this
- * article</a>.</p>
+ * href="http://java.sun.com/products/jfc/tsc/articles/painting/index.html">
+ * this article</a>.</p>
*
* @param g The graphics context to paint with
*
- * @see #paintImmediately
+ * @see #paintImmediately(Rectangle)
*/
public void paint(Graphics g)
{
@@ -1497,7 +1512,14 @@ public abstract class JComponent extends Container implements Serializable
protected void paintComponent(Graphics g)
{
if (ui != null)
- ui.update(g, this);
+ {
+ Graphics g2 = g;
+ if (!(g instanceof Graphics2D))
+ g2 = g.create();
+ ui.update(getComponentGraphics(g2), this);
+ if (!(g instanceof Graphics2D))
+ g2.dispose();
+ }
}
/**
@@ -1596,7 +1618,6 @@ public abstract class JComponent extends Container implements Serializable
* sun-private solution so I will only immitate it as much as it matters
* to external observers.
*/
-
private static class ActionListenerProxy
extends AbstractAction
{
@@ -1627,18 +1648,18 @@ public abstract class JComponent extends Container implements Serializable
* to fetch mapping tables from keystrokes to commands, and commands to
* actions, respectively, and modify those mappings directly.
*
- * @param anAction The action to be registered
- * @param aCommand The command to deliver in the delivered {@link
- * java.awt.ActionEvent}
- * @param aKeyStroke The keystroke to register on
- * @param aCondition One of the values {@link #UNDEFINED_CONDITION},
- * {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or
- * {@link #WHEN_IN_FOCUSED_WINDOW}, indicating the condition which must
- * be met for the action to be fired
+ * @param act The action to be registered
+ * @param cmd The command to deliver in the delivered {@link
+ * java.awt.event.ActionEvent}
+ * @param stroke The keystroke to register on
+ * @param cond One of the values {@link #UNDEFINED_CONDITION},
+ * {@link #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or
+ * {@link #WHEN_IN_FOCUSED_WINDOW}, indicating the condition which must
+ * be met for the action to be fired
*
* @see #unregisterKeyboardAction
- * @see #getConditionForKeystroke
- * @see #resetKeyboardActiond
+ * @see #getConditionForKeyStroke
+ * @see #resetKeyboardActions
*/
public void registerKeyboardAction(ActionListener act,
String cmd,
@@ -1648,8 +1669,6 @@ public abstract class JComponent extends Container implements Serializable
getInputMap(cond).put(stroke, new ActionListenerProxy(act, cmd));
}
-
-
public final void setInputMap(int condition, InputMap map)
{
enableEvents(AWTEvent.KEY_EVENT_MASK);
@@ -1720,18 +1739,18 @@ public abstract class JComponent extends Container implements Serializable
* 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
+ * @param ks 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}
+ * #WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}, {@link #WHEN_FOCUSED}, or {@link
+ * #WHEN_IN_FOCUSED_WINDOW}
*
* @deprecated As of 1.3 KeyStrokes can be registered with multiple
- * simultaneous conditions.
+ * simultaneous conditions.
*
- * @see #registerKeyboardAction
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
* @see #unregisterKeyboardAction
- * @see #resetKeyboardActiond
+ * @see #resetKeyboardActions
*/
public int getConditionForKeyStroke(KeyStroke ks)
{
@@ -1752,7 +1771,7 @@ public abstract class JComponent extends Container implements Serializable
* Get the ActionListener (typically an {@link Action} object) which is
* associated with a particular keystroke.
*
- * @param aKeyStroke The keystroke to retrieve the action of
+ * @param ks The keystroke to retrieve the action of
*
* @return The action associated with the specified keystroke
*
@@ -1783,8 +1802,8 @@ public abstract class JComponent extends Container implements Serializable
* 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.
+ * 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)
{
@@ -1829,23 +1848,24 @@ public abstract class JComponent extends Container implements Serializable
/**
* Remove a keyboard action registry.
*
- * @param stroke The keystroke to unregister
+ * @param aKeyStroke The keystroke to unregister
*
- * @see #registerKeyboardAction
- * @see #getConditionForKeystroke
- * @see #resetKeyboardActiond
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
+ * @see #getConditionForKeyStroke
+ * @see #resetKeyboardActions
*/
public void unregisterKeyboardAction(KeyStroke aKeyStroke)
{
+ // FIXME: Must be implemented.
}
/**
* Reset all keyboard action registries.
*
- * @see #registerKeyboardAction
+ * @see #registerKeyboardAction(ActionListener, KeyStroke, int)
* @see #unregisterKeyboardAction
- * @see #getConditionForKeystroke
+ * @see #getConditionForKeyStroke
*/
public void resetKeyboardActions()
{
@@ -1859,7 +1879,6 @@ public abstract class JComponent extends Container implements Serializable
actionMap.clear();
}
-
/**
* Mark the described region of this component as dirty in the current
* {@link RepaintManager}. This will queue an asynchronous repaint using
@@ -1898,10 +1917,10 @@ public abstract class JComponent extends Container implements Serializable
* Request focus on the default component of this component's {@link
* FocusTraversalPolicy}.
*
- * @return The result of {@link #requestFocus}
+ * @return The result of {@link #requestFocus()}
*
- * @deprecated Use {@link #requestFocus()} on the default component provided from
- * the {@link FocusTraversalPolicy} instead.
+ * @deprecated Use {@link #requestFocus()} on the default component provided
+ * from the {@link FocusTraversalPolicy} instead.
*/
public boolean requestDefaultFocus()
{
@@ -1982,8 +2001,7 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Set the value of the {@link #enabled} property, revalidate
- * and repaint this component.
+ * Set the value of the <code>enabled</code> property.
*
* @param enable The new value of the property
*/
@@ -1991,53 +2009,41 @@ public abstract class JComponent extends Container implements Serializable
{
boolean oldEnabled = isEnabled();
super.setEnabled(enable);
- firePropertyChange("enabeld", oldEnabled, enable);
- revalidate();
- repaint();
+ firePropertyChange("enabled", oldEnabled, enable);
}
/**
- * Set the value of the {@link #font} property, revalidate
- * and repaint this component.
+ * Set the value of the <code>font</code> property.
*
* @param f The new value of the property
*/
public void setFont(Font f)
{
super.setFont(f);
- revalidate();
- repaint();
}
/**
- * Set the value of the {@link #background} property, revalidate
- * and repaint this component.
+ * Set the value of the <code>background</code> property.
*
* @param bg The new value of the property
*/
public void setBackground(Color bg)
{
super.setBackground(bg);
- revalidate();
- repaint();
}
/**
- * Set the value of the {@link #foreground} property, revalidate
- * and repaint this component.
+ * Set the value of the <code>foreground</code> property.
*
* @param fg The new value of the property
*/
public void setForeground(Color fg)
{
super.setForeground(fg);
- revalidate();
- repaint();
}
/**
- * Set the value of the {@link #maximumSize} property, revalidate
- * and repaint this component.
+ * Set the value of the {@link #maximumSize} property.
*
* @param max The new value of the property
*/
@@ -2046,13 +2052,10 @@ public abstract class JComponent extends Container implements Serializable
Dimension oldMaximumSize = maximumSize;
maximumSize = max;
firePropertyChange("maximumSize", oldMaximumSize, maximumSize);
- revalidate();
- repaint();
}
/**
- * Set the value of the {@link #minimumSize} property, revalidate
- * and repaint this component.
+ * Set the value of the {@link #minimumSize} property.
*
* @param min The new value of the property
*/
@@ -2061,13 +2064,10 @@ public abstract class JComponent extends Container implements Serializable
Dimension oldMinimumSize = minimumSize;
minimumSize = min;
firePropertyChange("minimumSize", oldMinimumSize, minimumSize);
- revalidate();
- repaint();
}
/**
- * Set the value of the {@link #preferredSize} property, revalidate
- * and repaint this component.
+ * Set the value of the {@link #preferredSize} property.
*
* @param pref The new value of the property
*/
@@ -2106,7 +2106,7 @@ public abstract class JComponent extends Container implements Serializable
*
* @return The current value of the property
*
- * @see ComponentUI#setTransferHandler
+ * @see #setTransferHandler
*/
public TransferHandler getTransferHandler()
@@ -2119,7 +2119,7 @@ public abstract class JComponent extends Container implements Serializable
*
* @param newHandler The new value of the property
*
- * @see ComponentUI#getTransferHandler
+ * @see #getTransferHandler
*/
public void setTransferHandler(TransferHandler newHandler)
@@ -2133,8 +2133,7 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Set the value of the {@link #opaque} property, revalidate and repaint
- * this component.
+ * Set the value of the {@link #opaque} property.
*
* @param isOpaque The new value of the property
*
@@ -2145,25 +2144,20 @@ public abstract class JComponent extends Container implements Serializable
boolean oldOpaque = opaque;
opaque = isOpaque;
firePropertyChange("opaque", oldOpaque, opaque);
- revalidate();
- repaint();
}
/**
- * Set the value of the visible property, and revalidate / repaint the
- * component.
+ * Set the value of the visible property.
*
* @param v The new value of the property
*/
public void setVisible(boolean v)
{
super.setVisible(v);
- revalidate();
- repaint();
}
/**
- * Call {@link paint}.
+ * Call {@link #paint}.
*
* @param g The graphics context to paint into
*/
@@ -2176,7 +2170,7 @@ public abstract class JComponent extends Container implements Serializable
* Get the value of the UIClassID property. This property should be a key
* in the {@link UIDefaults} table managed by {@link UIManager}, the
* value of which is the name of a class to load for the component's
- * {@link ui} property.
+ * {@link #ui} property.
*
* @return A "symbolic" name which will map to a class to use for the
* component's UI, such as <code>"ComponentUI"</code>
@@ -2190,10 +2184,10 @@ public abstract class JComponent extends Container implements Serializable
}
/**
- * Install a new UI delegate as the component's {@link ui} property. In
- * the process, this will call {@link ComponentUI.uninstallUI} on any
- * existing value for the {@link ui} property, and {@link
- * ComponentUI.installUI} on the new UI delegate.
+ * Install a new UI delegate as the component's {@link #ui} property. In
+ * the process, this will call {@link ComponentUI#uninstallUI} on any
+ * existing value for the {@link #ui} property, and {@link
+ * ComponentUI#installUI} on the new UI delegate.
*
* @param newUI The new UI delegate to install
*
@@ -2213,15 +2207,13 @@ public abstract class JComponent extends Container implements Serializable
firePropertyChange("UI", oldUI, newUI);
- revalidate();
- repaint();
}
/**
* This method should be overridden in subclasses. In JComponent, the
* method does nothing. In subclasses, it should a UI delegate
* (corresponding to the symbolic name returned from {@link
- * getUIClassID}) from the {@link UIManager}, and calls {@link setUI}
+ * #getUIClassID}) from the {@link UIManager}, and calls {@link #setUI}
* with the new delegate.
*/
public void updateUI()
@@ -2296,9 +2288,9 @@ public abstract class JComponent extends Container implements Serializable
* situations in which it is not possible to get the focus. So developers
* should not assume that the component has the focus until it receives
* a {@link java.awt.event.FocusEvent} with a value of
- * {@link java.awt.event.FocusEvent.FOCUS_GAINED}.
+ * {@link java.awt.event.FocusEvent#FOCUS_GAINED}.
*
- * @see {@link Component#requestFocus()}
+ * @see Component#requestFocus()
*/
public void requestFocus()
{
@@ -2311,15 +2303,15 @@ public abstract class JComponent extends Container implements Serializable
* by look and feel implementations.
*
* You should not use this method directly. Instead you are strongly
- * encouraged to call {@link #requestFocus} or {@link #requestFocusInWindow}
- * instead.
+ * encouraged to call {@link #requestFocus()} or
+ * {@link #requestFocusInWindow()} instead.
*
* @param temporary if the focus change is temporary
*
* @return <code>false</code> if the focus change request will definitly
* fail, <code>true</code> if it will likely succeed
*
- * @see {@link Component#requestFocus(boolean)}
+ * @see Component#requestFocus(boolean)
*
* @since 1.4
*/
@@ -2340,12 +2332,12 @@ public abstract class JComponent extends Container implements Serializable
* situations in which it is not possible to get the focus. So developers
* should not assume that the component has the focus until it receives
* a {@link java.awt.event.FocusEvent} with a value of
- * {@link java.awt.event.FocusEvent.FOCUS_GAINED}.
+ * {@link java.awt.event.FocusEvent#FOCUS_GAINED}.
*
* @return <code>false</code> if the focus change request will definitly
* fail, <code>true</code> if it will likely succeed
*
- * @see {@link Component#requestFocusInWindow()}
+ * @see Component#requestFocusInWindow()
*/
public boolean requestFocusInWindow()
{
@@ -2360,15 +2352,15 @@ public abstract class JComponent extends Container implements Serializable
* by look and feel implementations.
*
* You should not use this method directly. Instead you are strongly
- * encouraged to call {@link #requestFocus} or {@link #requestFocusInWindow}
- * instead.
+ * encouraged to call {@link #requestFocus()} or
+ * {@link #requestFocusInWindow()} instead.
*
* @param temporary if the focus change is temporary
*
* @return <code>false</code> if the focus change request will definitly
* fail, <code>true</code> if it will likely succeed
*
- * @see {@link Component#requestFocus(boolean)}
+ * @see Component#requestFocus(boolean)
*
* @since 1.4
*/
@@ -2449,7 +2441,8 @@ public abstract class JComponent extends Container implements Serializable
* has changed.
*
* This method is called before the component is actually removed from
- * its parent, so the parent is still visible through {@link #getParent}.
+ * its parent, so the parent is still visible through
+ * {@link Component#getParent}.
*/
public void removeNotify()
{
@@ -2608,7 +2601,7 @@ public abstract class JComponent extends Container implements Serializable
/**
* Prints this component to the given Graphics context. A call to this
* method results in calls to the methods {@link #printComponent},
- * {@link #printBorder} and {@link printChildren} in this order.
+ * {@link #printBorder} and {@link #printChildren} in this order.
*
* Double buffering is temporarily turned off so the painting goes directly
* to the supplied Graphics context.
diff --git a/javax/swing/JDesktopPane.java b/javax/swing/JDesktopPane.java
index 996aaf191..ff512114e 100644
--- a/javax/swing/JDesktopPane.java
+++ b/javax/swing/JDesktopPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -154,10 +154,9 @@ public class JDesktopPane extends JLayeredPane implements Accessible
// FIXME: Unsupported mode.
if (mode == OUTLINE_DRAG_MODE)
- {
- // throw new IllegalArgumentException("Outline drag modes are unsupported.");
- mode = LIVE_DRAG_MODE;
- }
+ // throw new IllegalArgumentException("Outline drag modes are
+ // unsupported.");
+ mode = LIVE_DRAG_MODE;
dragMode = mode;
}
@@ -241,22 +240,22 @@ public class JDesktopPane extends JLayeredPane implements Accessible
{
if (selectedFrame != null)
{
- try
- {
- selectedFrame.setSelected(false);
- }
- catch (PropertyVetoException e)
- {
- }
+ try
+ {
+ selectedFrame.setSelected(false);
+ }
+ catch (PropertyVetoException e)
+ {
+ }
}
selectedFrame = null;
try
{
- if (frame != null)
- frame.setSelected(true);
+ if (frame != null)
+ frame.setSelected(true);
- selectedFrame = frame;
+ selectedFrame = frame;
}
catch (PropertyVetoException e)
{
diff --git a/javax/swing/JDialog.java b/javax/swing/JDialog.java
index db9976ed3..83865f836 100644
--- a/javax/swing/JDialog.java
+++ b/javax/swing/JDialog.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -69,8 +69,12 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
/** The single RootPane in the Dialog. */
protected JRootPane rootPane;
- /** Whether checking is enabled on the RootPane */
- protected boolean rootPaneCheckingEnabled = true;
+ /**
+ * Whether checking is enabled on the RootPane.
+ *
+ * @specnote Should be false to comply with J2SE 5.0
+ */
+ protected boolean rootPaneCheckingEnabled = false;
/** The default action taken when closed. */
private int close_action = HIDE_ON_CLOSE;
@@ -79,7 +83,13 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
private static boolean decorated;
/**
- * Creates a new non-modal JDialog with no title
+ * Whether we're in the init stage or not.
+ * If so, adds and layouts are for top-level, otherwise they're for the
+ * content pane
+ */
+ private boolean initStageDone = false;
+
+ /* Creates a new non-modal JDialog with no title
* using a shared Frame as the owner.
*/
public JDialog()
@@ -224,12 +234,12 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
protected void dialogInit()
{
// FIXME: Do a check on GraphicsEnvironment.isHeadless()
- setRootPaneCheckingEnabled(false);
- setLocale(JComponent.getDefaultLocale());
- getRootPane(); // will do set/create
- setRootPaneCheckingEnabled(true);
+ setLocale(JComponent.getDefaultLocale());
+ getRootPane(); // Will do set/create.
invalidate();
-
+ // Now that initStageDone is true, adds and layouts apply to contentPane,
+ // not top-level.
+ initStageDone = true;
}
/**
@@ -298,9 +308,17 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
public void setLayout(LayoutManager manager)
{
- if (isRootPaneCheckingEnabled())
- throw new Error("rootPaneChecking is enabled - cannot set layout.");
- super.setLayout(manager);
+ // Check if we're in initialization stage. If so, call super.setLayout
+ // otherwise, valid calls go to the content pane.
+ if (initStageDone)
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Cannot set top-level layout. Use"
+ + " getConentPane().setLayout instead.");
+ getContentPane().setLayout(manager);
+ }
+ else
+ super.setLayout(manager);
}
/**
@@ -420,9 +438,17 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
protected void addImpl(Component comp, Object constraints, int index)
{
- if (isRootPaneCheckingEnabled())
- throw new Error("rootPaneChecking is enabled - adding components disallowed.");
- super.addImpl(comp, constraints, index);
+ // If we're adding in the initialization stage use super.add.
+ // Otherwise pass the add onto the content pane.
+ if (!initStageDone)
+ super.addImpl(comp, constraints, index);
+ else
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Do not add directly to JDialog."
+ + " Use getContentPane().add instead.");
+ getContentPane().add(comp, constraints, index);
+ }
}
/**
@@ -432,7 +458,8 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
public void remove(Component comp)
{
- // The path changes if the component == root.
+ // If we're removing the root pane, use super.remove. Otherwise
+ // pass it on to the content pane instead.
if (comp == rootPane)
super.remove(rootPane);
else
@@ -520,14 +547,12 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
*/
public void setDefaultCloseOperation(int operation)
{
- if (operation == DO_NOTHING_ON_CLOSE ||
- operation == HIDE_ON_CLOSE ||
- operation == DISPOSE_ON_CLOSE)
- close_action = operation;
- else
- // accept illegal value and set the property to the default value,
- // that's what the reference implementation does
- close_action = DO_NOTHING_ON_CLOSE;
+ /* Reference implementation allows invalid operations
+ to be specified. If so, getDefaultCloseOperation
+ must return the invalid code, and the behaviour
+ defaults to DO_NOTHING_ON_CLOSE. processWindowEvent
+ above handles this */
+ close_action = operation;
}
/**
diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java
index 2b5d9e0a4..63c79ffdf 100644
--- a/javax/swing/JEditorPane.java
+++ b/javax/swing/JEditorPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -117,8 +117,14 @@ public class JEditorPane extends JTextComponent
return getEditorKit().getContentType();
}
+ /**
+ * Returns the EditorKit. If there is no EditorKit set this method
+ * calls createDefaultEditorKit() and setEditorKit() first.
+ */
public EditorKit getEditorKit()
{
+ if (editorKit == null)
+ setEditorKit(createDefaultEditorKit());
return editorKit;
}
diff --git a/javax/swing/JFileChooser.java b/javax/swing/JFileChooser.java
index 07a67a041..17292fa4f 100644
--- a/javax/swing/JFileChooser.java
+++ b/javax/swing/JFileChooser.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -357,7 +357,11 @@ public class JFileChooser extends JComponent implements Accessible
*/
public File[] getSelectedFiles()
{
- return selectedFiles;
+ if (selectedFiles != null)
+ return selectedFiles;
+ if (selectedFile != null)
+ return new File[] { selectedFile };
+ return null;
}
/**
diff --git a/javax/swing/JFormattedTextField.java b/javax/swing/JFormattedTextField.java
index 863ed204a..f8230f69f 100644
--- a/javax/swing/JFormattedTextField.java
+++ b/javax/swing/JFormattedTextField.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,7 +42,10 @@ import java.awt.event.FocusEvent;
import java.io.Serializable;
import java.text.Format;
import java.text.ParseException;
+import java.util.Date;
+import javax.swing.text.DateFormatter;
+import javax.swing.text.DefaultFormatter;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
import javax.swing.text.NavigationFilter;
@@ -197,7 +200,8 @@ public class JFormattedTextField extends JTextField
public Action[] getActions ()
{
- throw new InternalError ("not implemented");
+ // FIXME: Add JFormattedTextField specific actions
+ return super.getActions();
}
public int getFocusLostBehavior()
@@ -240,7 +244,10 @@ public class JFormattedTextField extends JTextField
protected void processFocusEvent (FocusEvent evt)
{
- throw new InternalError ("not implemented");
+ // it's safe to simply call super for now, until it gets clear
+ // what this method is supposed to do
+ // throw new InternalError ("not implemented");
+ super.processFocusEvent(evt);
}
public void setDocument(Document newDocument)
@@ -292,9 +299,49 @@ public class JFormattedTextField extends JTextField
{
if (value == newValue)
return;
-
+
+ // format value
+ AbstractFormatter formatter = createFormatter(newValue);
+ try
+ {
+ setText(formatter.valueToString(newValue));
+ }
+ catch (ParseException ex)
+ {
+ // TODO: what should we do with this?
+ }
+
Object oldValue = value;
value = newValue;
firePropertyChange("value", oldValue, newValue);
}
+
+ /**
+ * A helper method that attempts to create a formatter that is suitable
+ * to format objects of the type like <code>value</code>.
+ *
+ * If <code>formatterFactory</code> is not null and the returned formatter
+ * is also not <code>null</code> then this formatter is used. Otherwise we
+ * try to create one based on the type of <code>value</code>.
+ *
+ * @param value an object which should be formatted by the formatter
+ *
+ * @return a formatter able to format objects of the class of
+ * <code>value</code>
+ */
+ AbstractFormatter createFormatter(Object value)
+ {
+ AbstractFormatter formatter = null;
+ if (formatterFactory != null
+ && formatterFactory.getFormatter(this) != null)
+ formatter = formatterFactory.getFormatter(this);
+ else
+ {
+ if (value instanceof Date)
+ formatter = new DateFormatter();
+ else
+ formatter = new DefaultFormatter();
+ }
+ return formatter;
+ }
}
diff --git a/javax/swing/JFrame.java b/javax/swing/JFrame.java
index c450d0f50..bcefce22f 100644
--- a/javax/swing/JFrame.java
+++ b/javax/swing/JFrame.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -45,6 +45,7 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
import java.awt.LayoutManager;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
@@ -65,7 +66,18 @@ public class JFrame extends Frame
private int close_action = HIDE_ON_CLOSE;
protected AccessibleContext accessibleContext;
protected JRootPane rootPane;
- protected boolean rootPaneCheckingEnabled;
+
+ /**
+ * @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0
+ */
+ protected boolean rootPaneCheckingEnabled = false;
+
+ /**
+ * Tells us if we're in the initialization stage.
+ * If so, adds go to top-level Container, otherwise they go
+ * to the content pane for this container.
+ */
+ private boolean initStageDone = false;
public JFrame()
{
@@ -79,11 +91,44 @@ public class JFrame extends Frame
frameInit();
}
+ /**
+ * Creates a new JFrame in the specified {@link GraphicsConfiguration}
+ * and with an empty title.
+ *
+ * @param gc the <code>GraphicsConfiguration</code> that is used for
+ * the new <code>JFrame</code>
+ *
+ * @see Frame#Frame(GraphicsConfiguration)
+ */
+ public JFrame(GraphicsConfiguration gc)
+ {
+ super(gc);
+ frameInit();
+ }
+
+ /**
+ * Creates a new JFrame in the specified {@link GraphicsConfiguration}
+ * and with the specified title.
+ *
+ * @param title the title for the new <code>JFrame</code>
+ * @param gc the <code>GraphicsConfiguration</code> that is used for
+ * the new <code>JFrame</code>
+ *
+ * @see Frame#Frame(String, GraphicsConfiguration)
+ */
+ public JFrame(String title, GraphicsConfiguration gc)
+ {
+ super(title, gc);
+ frameInit();
+ }
+
protected void frameInit()
{
super.setLayout(new BorderLayout(1, 1));
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
getRootPane(); // will do set/create
+ // We're now done the init stage.
+ initStageDone = true;
}
public Dimension getPreferredSize()
@@ -103,7 +148,17 @@ public class JFrame extends Frame
public void setLayout(LayoutManager manager)
{
- super.setLayout(manager);
+ // Check if we're in initialization stage. If so, call super.setLayout
+ // otherwise, valid calls go to the content pane.
+ if (initStageDone)
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Cannot set layout. Use getContentPane().setLayout()"
+ + " instead.");
+ getContentPane().setLayout(manager);
+ }
+ else
+ super.setLayout(manager);
}
public void setLayeredPane(JLayeredPane layeredPane)
@@ -159,12 +214,27 @@ public class JFrame extends Frame
protected void addImpl(Component comp, Object constraints, int index)
{
- super.addImpl(comp, constraints, index);
+ // If we're adding in the initialization stage use super.add.
+ // Otherwise pass the add onto the content pane.
+ if (!initStageDone)
+ super.addImpl(comp, constraints, index);
+ else
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("rootPaneChecking is enabled - adding components "
+ + "disallowed.");
+ getContentPane().add(comp,constraints,index);
+ }
}
public void remove(Component comp)
{
- getContentPane().remove(comp);
+ // If we're removing the root pane, use super.remove. Otherwise
+ // pass it on to the content pane instead.
+ if (comp==rootPane)
+ super.remove(rootPane);
+ else
+ getContentPane().remove(comp);
}
protected boolean isRootPaneCheckingEnabled()
@@ -272,7 +342,7 @@ public class JFrame extends Frame
if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE
&& operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE)
- throw new IllegalArgumentException("operation = " + operation);
+ throw new IllegalArgumentException("defaultCloseOperation must be EXIT_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or DO_NOTHING_ON_CLOSE");
close_action = operation;
}
diff --git a/javax/swing/JInternalFrame.java b/javax/swing/JInternalFrame.java
index 8a29d2fff..b504aaaa5 100644
--- a/javax/swing/JInternalFrame.java
+++ b/javax/swing/JInternalFrame.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -430,8 +430,19 @@ public class JInternalFrame extends JComponent implements Accessible,
/** Whether the JInternalFrame can be maximized. */
protected boolean maximizable;
- /** Whether the JInternalFrame has rootPaneChecking enabled. */
- protected boolean rootPaneCheckingEnabled = true;
+ /**
+ * Whether the JInternalFrame has rootPaneChecking enabled.
+ *
+ * @specnote Should be false to comply with J2SE 5.0
+ */
+ protected boolean rootPaneCheckingEnabled = false;
+
+ /**
+ * Tells us if we're in the initialization stage.
+ * If so, adds go to top-level Container, otherwise they go
+ * to the content pane for this container.
+ */
+ private boolean initStageDone = false;
/** Whether the JInternalFrame is resizable. */
protected boolean resizable;
@@ -554,12 +565,9 @@ public class JInternalFrame extends JComponent implements Accessible,
this.maximizable = maximizable;
this.iconable = iconifiable;
storedBounds = new Rectangle();
-
- setRootPaneCheckingEnabled(false);
setRootPane(createRootPane());
-
updateUI();
- setRootPaneCheckingEnabled(true);
+ initStageDone = true; // Done the init stage, now adds go to content pane.
}
/**
@@ -576,10 +584,18 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
protected void addImpl(Component comp, Object constraints, int index)
{
- if (isRootPaneCheckingEnabled())
- throw new Error("Do not use add() on JInternalPane directly. Use getContentPane().add() instead");
-
- super.addImpl(comp, constraints, index);
+ // If we're in the initialization stage use super.add. Here we add the
+ // rootPane as well as the title bar and other stuff.
+ // Otherwise pass the add onto the content pane.
+ if (!initStageDone)
+ super.addImpl(comp,constraints, index);
+ else
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Do not use add() on JInternalFrame directly. Use "
+ + "getContentPane().add() instead");
+ getContentPane().add(comp, constraints, index);
+ }
}
/**
@@ -1150,7 +1166,7 @@ public class JInternalFrame extends JComponent implements Accessible,
{
// Do nothing if they don't want to be restored first.
}
- doLayout();
+ setSize(getPreferredSize());
}
/**
@@ -1181,7 +1197,12 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void remove(Component comp)
{
- super.remove(comp);
+ // If we're removing the root pane, use super.remove. Otherwise
+ // pass it on to the content pane instead.
+ if (comp==rootPane)
+ super.remove(comp);
+ else
+ getContentPane().remove(comp);
}
/**
@@ -1285,10 +1306,10 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setDefaultCloseOperation(int operation)
{
- if (operation != DO_NOTHING_ON_CLOSE
- && operation != HIDE_ON_CLOSE
- && operation != DISPOSE_ON_CLOSE)
- throw new Error("Close operation must be one of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
+ /* Reference implementation allows invalid operations to be specified.
+ In that case, behaviour defaults to DO_NOTHING_ON_CLOSE.
+ processWindowEvent handles the behaviour. getDefaultCloseOperation
+ must return the invalid operator code. */
defaultCloseOperation = operation;
}
@@ -1466,9 +1487,17 @@ public class JInternalFrame extends JComponent implements Accessible,
*/
public void setLayout(LayoutManager manager)
{
- if (isRootPaneCheckingEnabled())
- throw new Error("Cannot set layout. Use getContentPane().setLayout() instead.");
- super.setLayout(manager);
+ // Check if we're in initialization stage. If so, call super.setLayout
+ // otherwise, valid calls go to the content pane.
+ if (initStageDone)
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Cannot set layout. Use getContentPane().setLayout()"
+ + " instead.");
+ getContentPane().setLayout(manager);
+ }
+ else
+ super.setLayout(manager);
}
/**
diff --git a/javax/swing/JLabel.java b/javax/swing/JLabel.java
index c01d8110d..2e7ad98dd 100644
--- a/javax/swing/JLabel.java
+++ b/javax/swing/JLabel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,17 +41,257 @@ package javax.swing;
import java.awt.Component;
import java.awt.Font;
import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleExtendedComponent;
+import javax.accessibility.AccessibleText;
import javax.swing.plaf.LabelUI;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.SimpleAttributeSet;
/**
* A swing widget that displays a text message and/or an icon.
*/
public class JLabel extends JComponent implements Accessible, SwingConstants
{
+
+ /**
+ * Accessibility support for JLabel.
+ */
+ protected class AccessibleJLabel
+ extends JComponent.AccessibleJComponent
+ implements AccessibleText, AccessibleExtendedComponent
+ {
+ /**
+ * Returns the selected text. This is an empty string since JLabels
+ * are not selectable.
+ *
+ * @return the selected text
+ */
+ public String getSelectedText()
+ {
+ // We return "" here since JLabel's text is not selectable.
+ return "";
+ }
+
+ /**
+ * Returns the start index of the selected text.
+ *
+ * @return the start index of the selected text
+ */
+ public int getSelectionStart()
+ {
+ // TODO: Figure out what should be returned here, because JLabels don't
+ // allow selection. I guess -1 for now.
+ return -1;
+ }
+
+ /**
+ * Returns the end index of the selected text.
+ *
+ * @return the end index of the selected text
+ */
+ public int getSelectionEnd()
+ {
+ // TODO: Figure out what should be returned here, because JLabels don't
+ // allow selection. I guess -1 for now.
+ return -1;
+ }
+
+ /**
+ * Returns an {@link AttributeSet} that reflects the text attributes of
+ * the specified character. We return an empty
+ * <code>AttributeSet</code> here, because JLabels don't support text
+ * attributes (at least not yet).
+ *
+ * @param index the index of the character
+ *
+ * @return an {@link AttributeSet} that reflects the text attributes of
+ * the specified character
+ */
+ public AttributeSet getCharacterAttribute(int index)
+ {
+ return new SimpleAttributeSet();
+ }
+
+ /**
+ * Returns the character, word or sentence at the specified index. The
+ * <code>part</code> parameter determines what is returned, the character,
+ * word or sentence after the index.
+ *
+ * @param part one of {@link AccessibleText#CHARACTER},
+ * {@link AccessibleText#WORD} or
+ * {@link AccessibleText#SENTENCE}, specifying what is returned
+ * @param index the index
+ *
+ * @return the character, word or sentence after <code>index</code>
+ */
+ public String getAtIndex(int part, int index)
+ {
+ String result = "";
+ int startIndex = -1;
+ int endIndex = -1;
+ switch(part)
+ {
+ case AccessibleText.CHARACTER:
+ result = String.valueOf(text.charAt(index));
+ break;
+ case AccessibleText.WORD:
+ startIndex = text.lastIndexOf(' ', index);
+ endIndex = text.indexOf(' ', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ case AccessibleText.SENTENCE:
+ default:
+ startIndex = text.lastIndexOf('.', index);
+ endIndex = text.indexOf('.', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the character, word or sentence after the specified index. The
+ * <code>part</code> parameter determines what is returned, the character,
+ * word or sentence after the index.
+ *
+ * @param part one of {@link AccessibleText#CHARACTER},
+ * {@link AccessibleText#WORD} or
+ * {@link AccessibleText#SENTENCE}, specifying what is returned
+ * @param index the index
+ *
+ * @return the character, word or sentence after <code>index</code>
+ */
+ public String getAfterIndex(int part, int index)
+ {
+ String result = "";
+ int startIndex = -1;
+ int endIndex = -1;
+ switch(part)
+ {
+ case AccessibleText.CHARACTER:
+ result = String.valueOf(text.charAt(index + 1));
+ break;
+ case AccessibleText.WORD:
+ startIndex = text.indexOf(' ', index);
+ endIndex = text.indexOf(' ', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ case AccessibleText.SENTENCE:
+ default:
+ startIndex = text.indexOf('.', index);
+ endIndex = text.indexOf('.', startIndex + 1);
+ if (endIndex == -1)
+ endIndex = startIndex + 1;
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the character, word or sentence before the specified index. The
+ * <code>part</code> parameter determines what is returned, the character,
+ * word or sentence before the index.
+ *
+ * @param part one of {@link AccessibleText#CHARACTER},
+ * {@link AccessibleText#WORD} or
+ * {@link AccessibleText#SENTENCE}, specifying what is returned
+ * @param index the index
+ *
+ * @return the character, word or sentence before <code>index</code>
+ */
+ public String getBeforeIndex(int part, int index)
+ {
+ String result = "";
+ int startIndex = -1;
+ int endIndex = -1;
+ switch(part)
+ {
+ case AccessibleText.CHARACTER:
+ result = String.valueOf(text.charAt(index - 1));
+ break;
+ case AccessibleText.WORD:
+ endIndex = text.lastIndexOf(' ', index);
+ if (endIndex == -1)
+ endIndex = 0;
+ startIndex = text.lastIndexOf(' ', endIndex - 1);
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ case AccessibleText.SENTENCE:
+ default:
+ endIndex = text.lastIndexOf('.', index);
+ if (endIndex == -1)
+ endIndex = 0;
+ startIndex = text.lastIndexOf('.', endIndex - 1);
+ result = text.substring(startIndex + 1, endIndex);
+ break;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the caret position. This method returns -1 because JLabel don't
+ * have a caret.
+ *
+ * @return the caret position
+ */
+ public int getCaretPosition()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the number of characters that are displayed by the JLabel.
+ *
+ * @return the number of characters that are displayed by the JLabel
+ */
+ public int getCharCount()
+ {
+ return text.length();
+ }
+
+ /**
+ * Returns the bounding box of the character at the specified index.
+ *
+ * @param index the index of the character that we return the
+ * bounds for
+ *
+ * @return the bounding box of the character at the specified index
+ */
+ public Rectangle getCharacterBounds(int index)
+ {
+ // FIXME: Implement this correctly.
+ return new Rectangle();
+ }
+
+ /**
+ * Returns the index of the character that is located at the specified
+ * point.
+ *
+ * @param point the location that we lookup the character for
+ *
+ * @return the index of the character that is located at the specified
+ * point
+ */
+ public int getIndexAtPoint(Point point)
+ {
+ // FIXME: Implement this correctly.
+ return 0;
+ }
+ }
+
/** DOCUMENT ME! */
private static final long serialVersionUID = 5496508283662221534L;
@@ -62,7 +302,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
protected Component labelFor;
/** The label's text. */
- private transient String text;
+ transient String text;
/** Where the label will be positioned horizontally. */
private transient int horizontalAlignment = LEADING;
@@ -91,18 +331,21 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
/** The gap between the icon and the text. */
private transient int iconTextGap = 4;
+ /** The accessible context for this JLabel. */
+ private AccessibleJLabel accessibleContext;
+
/**
- * Creates a new horizontally and vertically centered JLabel object with no
- * text and no icon.
+ * Creates a new vertically centered, horizontally on the leading edge
+ * JLabel object with text and no icon.
*/
public JLabel()
{
- this(null, null, CENTER);
+ this(null, null, LEADING);
}
/**
- * Creates a new horizontally and vertically centered JLabel object with no
- * text and the given icon.
+ * Creates a new vertically and horizontally centered
+ * JLabel object with no text and the given icon.
*
* @param image The icon to use with the label.
*/
@@ -125,14 +368,14 @@ 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 leading and vertically centered JLabel
+ * object with no icon and the given text.
*
* @param text The text to use with the label.
*/
public JLabel(String text)
{
- this(text, null, CENTER);
+ this(text, null, LEADING);
}
/**
@@ -638,10 +881,12 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
/**
* DOCUMENT ME!
*
- * @return
+ * @return The accessible context.
*/
public AccessibleContext getAccessibleContext()
{
- return null;
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleJLabel();
+ return accessibleContext;
}
}
diff --git a/javax/swing/JLayeredPane.java b/javax/swing/JLayeredPane.java
index f07d36e99..1ea39dc50 100644
--- a/javax/swing/JLayeredPane.java
+++ b/javax/swing/JLayeredPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,6 +39,7 @@ exception statement from your version. */
package javax.swing;
import java.awt.Component;
+import java.awt.Container;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -47,21 +48,43 @@ import java.util.TreeMap;
import javax.accessibility.Accessible;
/**
- * <p>The "Layered Pane" is a container which divides its children into 6 (or
- * more) disjoint sets. the pre-defined sets are:</p>
+ * A container that adds depth to the usual <code>Container</code> semantics.
+ * Each child component of a <code>Layered Pane</code> is placed within one
+ * of several layers. <code>JLayeredPane</code> defines a set of standard
+ * layers. The pre-defined sets are (in the order from button to top):
*
- * <ul>
- * <li>"Frame Content"</li>
- * <li>"Default"</li>
- * <li>"Palette"</li>
- * <li>"Modal"</li>
- * <li>"Popup"</li>
- * <li>"Drag"</li>
- * </ul>
+ * <dl>
+ * <dt>{@link #DEFAULT_LAYER}</dt>
+ * <dd>The layer where most of the normal components are placed. This
+ * is the bottommost layer.</dd>
+ *
+ * <dt>{@link #PALETTE_LAYER}</dt>
+ * <dd>Palette windows are placed in this layer.</dd>
+ *
+ * <dt>{@link #MODAL_LAYER}</dt>
+ * <dd>The layer where internal modal dialog windows are placed.</dd>
+ *
+ * <dt>{@link #POPUP_LAYER}</dt>
+ * <dd>The layer for popup menus</dd>
+ *
+ * <dt>{@link #DRAG_LAYER}</dt>
+ * <dd>Components that are beeing dragged are temporarily placed in
+ * this layer.</dd>
+ * </dl>
*
* <p>A child is in exactly one of these layers at any time, though there may
* be other layers if someone creates them.</p>
*
+ * <p>You can add a component to a specific layer using the
+ * {@link Container#add(Component, Object)} method. I.e.
+ * <code>layeredPane.add(comp, JLayeredPane.MODAL_LAYER)</code> will add the
+ * component <code>comp</code> to the modal layer of <code>layeredPane</code>.
+ * </p>
+ *
+ * <p>To change the layer of a component that is already a child of
+ * a <code>JLayeredPane</code>, use the {@link #setLayer(Component, int)}
+ * method.</p>
+ *
* <p>The purpose of this class is to translate this view of "layers" into a
* contiguous array of components: the one held in our ancestor,
* {@link java.awt.Container}.</p>
@@ -124,9 +147,18 @@ public class JLayeredPane extends JComponent implements Accessible
*/
public int getLayer(Component c)
{
- if (! componentToLayer.containsKey (c))
- throw new IllegalArgumentException ();
- return ((Integer) componentToLayer.get(c)).intValue();
+ Component myComp = c;
+ while(! componentToLayer.containsKey(myComp))
+ {
+ myComp = myComp.getParent();
+ if (myComp == null)
+ break;
+ }
+ if (myComp == null)
+ throw new IllegalArgumentException
+ ("component is not in this JLayeredPane");
+ Integer layerObj = (Integer) componentToLayer.get(myComp);
+ return layerObj.intValue();
}
/**
@@ -274,7 +306,7 @@ public class JLayeredPane extends JComponent implements Accessible
* @param c the component to move to the front of its layer.
* @throws IllegalArgumentException if the component is not a child of
* this container.
- * @see #moveToBack()
+ * @see #moveToBack
*/
public void moveToFront(Component c)
{
@@ -293,7 +325,7 @@ public class JLayeredPane extends JComponent implements Accessible
* @param c the component to move to the back of its layer.
* @throws IllegalArgumentException if the component is not a child of
* this container.
- * @see #moveToFront()
+ * @see #moveToFront
*/
public void moveToBack(Component c)
{
@@ -308,7 +340,7 @@ public class JLayeredPane extends JComponent implements Accessible
* @param c the component to get the position of.
* @throws IllegalArgumentException if the component is not a child of
* this container.
- * @see #setPosition()
+ * @see #setPosition
*/
public int getPosition(Component c)
{
@@ -335,7 +367,7 @@ public class JLayeredPane extends JComponent implements Accessible
* @param position the position to assign the component to.
* @throws IllegalArgumentException if the component is not a child of
* this container.
- * @see #getPosition()
+ * @see #getPosition
*/
public void setPosition(Component c, int position)
{
diff --git a/javax/swing/JList.java b/javax/swing/JList.java
index e5ca14a2a..fb8d18b85 100644
--- a/javax/swing/JList.java
+++ b/javax/swing/JList.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -633,7 +633,7 @@ public class JList extends JComponent implements Accessible, Scrollable
lo = selectionModel.getMinSelectionIndex();
hi = selectionModel.getMaxSelectionIndex();
n = 0;
- for (i = lo; i < hi; ++i)
+ for (i = lo; i <= hi; ++i)
if (selectionModel.isSelectedIndex(i))
n++;
int [] v = new int[n];
diff --git a/javax/swing/JMenu.java b/javax/swing/JMenu.java
index e93ec0533..8dcad8b77 100644
--- a/javax/swing/JMenu.java
+++ b/javax/swing/JMenu.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -328,50 +328,57 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
*/
public boolean isSelected()
{
- return super.isArmed();
+ return super.isSelected();
}
/**
- * Changes this menu selected state if selected is true and false otherwise
- * This method fires menuEvents to menu's registered listeners.
- *
- * @param selected true if the menu should be selected and false otherwise
+ * A helper method to handle setSelected calls from both mouse events and
+ * direct calls to setSelected. Direct calls shouldn't expand the popup
+ * menu and should select the JMenu even if it is disabled. Mouse events
+ * only select the JMenu if it is enabled and should expand the popup menu
+ * associated with this JMenu.
+ * @param selected whether or not the JMenu was selected
+ * @param menuEnabled whether or not selecting the menu is "enabled". This
+ * is always true for direct calls, and is set to isEnabled() for mouse
+ * based calls.
+ * @param showMenu whether or not to show the popup menu
*/
- public void setSelected(boolean selected)
+ private void setSelectedHelper(boolean selected, boolean menuEnabled, boolean showMenu)
{
- // if this menu selection is true, then activate this menu and
- // display popup associated with this menu
- if (selected)
+ // If menu is selected and enabled, activates the menu and
+ // displays associated popup.
+ if (selected && menuEnabled)
{
super.setArmed(true);
super.setSelected(true);
- // FIXME: The popup menu should be shown on the screen after certain
- // number of seconds pass. The 'delay' property of this menu indicates
- // this amount of seconds. 'delay' property is 0 by default.
- if (this.isShowing())
+ // FIXME: The popup menu should be shown on the screen after certain
+ // number of seconds pass. The 'delay' property of this menu indicates
+ // this amount of seconds. 'delay' property is 0 by default.
+ if (isShowing())
{
fireMenuSelected();
-
+
int x = 0;
int y = 0;
-
- if (menuLocation == null)
- {
- // Calculate correct position of the popup. Note that location of the popup
- // passed to show() should be relative to the popup's invoker
- if (isTopLevelMenu())
- y = this.getHeight();
- else
- x = this.getWidth();
-
- getPopupMenu().show(this, x, y);
- }
- else
- getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+ if (showMenu)
+ if (menuLocation == null)
+ {
+ // Calculate correct position of the popup. Note that location of the popup
+ // passed to show() should be relative to the popup's invoker
+ if (isTopLevelMenu())
+ y = this.getHeight();
+ else
+ x = this.getWidth();
+ getPopupMenu().show(this, x, y);
+ }
+ else
+ {
+ getPopupMenu().show(this, menuLocation.x, menuLocation.y);
+ }
}
}
-
+
else
{
super.setSelected(false);
@@ -382,6 +389,17 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
}
/**
+ * Changes this menu selected state if selected is true and false otherwise
+ * This method fires menuEvents to menu's registered listeners.
+ *
+ * @param selected true if the menu should be selected and false otherwise
+ */
+ public void setSelected(boolean selected)
+ {
+ setSelectedHelper(selected, true, false);
+ }
+
+ /**
* Checks if PopupMenu associated with this menu is visible
*
* @return true if the popup associated with this menu is currently visible
@@ -709,7 +727,7 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
{
// if this menu selection is true, then activate this menu and
// display popup associated with this menu
- setSelected(changed);
+ setSelectedHelper(changed, isEnabled(), true);
}
/**
@@ -893,4 +911,5 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
// FIXME: Need to implement
}
}
+
}
diff --git a/javax/swing/JMenuBar.java b/javax/swing/JMenuBar.java
index e14c26270..eebb1a050 100644
--- a/javax/swing/JMenuBar.java
+++ b/javax/swing/JMenuBar.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -326,7 +326,7 @@ public class JMenuBar extends JComponent implements Accessible, MenuElement
* Process key events forwarded from MenuSelectionManager. This method
* doesn't do anything. It is here to conform to the MenuElement interface.
*
- * @param event event forwarded from MenuSelectionManager
+ * @param e event forwarded from MenuSelectionManager
* @param path path to the menu element from which event was generated
* @param manager MenuSelectionManager for the current menu hierarchy
*
diff --git a/javax/swing/JMenuItem.java b/javax/swing/JMenuItem.java
index c8a2931d4..069b7bc86 100644
--- a/javax/swing/JMenuItem.java
+++ b/javax/swing/JMenuItem.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -83,7 +83,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem()
{
- super(null, null);
+ super();
}
/**
@@ -95,7 +95,8 @@ public class JMenuItem extends AbstractButton implements Accessible,
{
// FIXME: The requestedFocusEnabled property should
// be set to false, when only icon is set for menu item.
- super(null, icon);
+ super();
+ init(null, icon);
}
/**
@@ -105,7 +106,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(String text)
{
- super(text, null);
+ this(text, null);
}
/**
@@ -115,7 +116,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(Action action)
{
- super(null, null);
+ super();
super.setAction(action);
}
@@ -128,7 +129,8 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(String text, Icon icon)
{
- super(text, icon);
+ super();
+ init(text, icon);
}
/**
@@ -141,7 +143,7 @@ public class JMenuItem extends AbstractButton implements Accessible,
*/
public JMenuItem(String text, int mnemonic)
{
- super(text, null);
+ this(text, null);
setMnemonic(mnemonic);
}
diff --git a/javax/swing/JOptionPane.java b/javax/swing/JOptionPane.java
index 0a00729b5..ad0772ab8 100644
--- a/javax/swing/JOptionPane.java
+++ b/javax/swing/JOptionPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -384,8 +384,8 @@ public class JOptionPane extends JComponent implements Accessible
}
/**
- * This method creates a new JInternalFrame that is in the JDesktopPane
- * which contains the parentComponent given. If no suitable JDesktopPane
+ * This method creates a new JInternalFrame that is in the JLayeredPane
+ * which contains the parentComponent given. If no suitable JLayeredPane
* can be found from the parentComponent given, a RuntimeException will be
* thrown.
*
@@ -395,25 +395,42 @@ public class JOptionPane extends JComponent implements Accessible
* @return A new JInternalFrame based on the JOptionPane configuration.
*
* @throws RuntimeException If no suitable JDesktopPane is found.
+ *
+ * @specnote The specification says that the internal frame is placed
+ * in the nearest <code>JDesktopPane</code> that is found in
+ * <code>parent</code>'s ancestors. The behaviour of the JDK
+ * is that it actually looks up the nearest
+ * <code>JLayeredPane</code> in <code>parent</code>'s ancestors.
+ * So do we.
*/
public JInternalFrame createInternalFrame(Component parentComponent,
String title)
throws RuntimeException
{
- JDesktopPane toUse = getDesktopPaneForComponent(parentComponent);
+ // Try to find a JDesktopPane.
+ JLayeredPane toUse = getDesktopPaneForComponent(parentComponent);
+ // If we don't have a JDesktopPane, we try to find a JLayeredPane.
+ if (toUse == null)
+ toUse = JLayeredPane.getLayeredPaneAbove(parentComponent);
+ // If this still fails, we throw a RuntimeException.
if (toUse == null)
- throw new RuntimeException("parentComponent does not have a valid parent");
+ throw new RuntimeException
+ ("parentComponent does not have a valid parent");
JInternalFrame frame = new JInternalFrame(title);
inputValue = UNINITIALIZED_VALUE;
value = UNINITIALIZED_VALUE;
+ frame.setContentPane(this);
frame.setClosable(true);
+
toUse.add(frame);
+ frame.setLayer(JLayeredPane.MODAL_LAYER);
+
+ frame.pack();
+ frame.setVisible(true);
- // FIXME: JLayeredPane broken? See bug # 16576
- // frame.setLayer(JLayeredPane.MODAL_LAYER);
return frame;
}
@@ -1102,7 +1119,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message);
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
- startModal(frame, pane);
+ startModal(frame);
return ((Integer) pane.getValue()).intValue();
}
@@ -1127,7 +1144,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, optionType);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
return ((Integer) pane.getValue()).intValue();
}
@@ -1153,7 +1170,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message, messageType, optionType);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
return ((Integer) pane.getValue()).intValue();
}
@@ -1181,7 +1198,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message, messageType, optionType, icon);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
return ((Integer) pane.getValue()).intValue();
}
@@ -1204,7 +1221,7 @@ public class JOptionPane extends JComponent implements Accessible
pane.setWantsInput(true);
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
- startModal(frame, pane);
+ startModal(frame);
return (String) pane.getInputValue();
}
@@ -1230,7 +1247,7 @@ public class JOptionPane extends JComponent implements Accessible
pane.setWantsInput(true);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
return (String) pane.getInputValue();
}
@@ -1265,7 +1282,7 @@ public class JOptionPane extends JComponent implements Accessible
pane.setInitialSelectionValue(initialSelectionValue);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
return (String) pane.getInputValue();
}
@@ -1284,7 +1301,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message);
JInternalFrame frame = pane.createInternalFrame(parentComponent, null);
- startModal(frame, pane);
+ startModal(frame);
}
/**
@@ -1304,7 +1321,7 @@ public class JOptionPane extends JComponent implements Accessible
JOptionPane pane = new JOptionPane(message, messageType);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
}
/**
@@ -1326,7 +1343,7 @@ public class JOptionPane extends JComponent implements Accessible
pane.setIcon(icon);
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
}
/**
@@ -1358,7 +1375,7 @@ public class JOptionPane extends JComponent implements Accessible
JInternalFrame frame = pane.createInternalFrame(parentComponent, title);
- startModal(frame, pane);
+ startModal(frame);
return ((Integer) pane.getValue()).intValue();
}
@@ -1509,15 +1526,8 @@ public class JOptionPane extends JComponent implements Accessible
* @param f The JInternalFrame to make modal.
* @param pane The JOptionPane to add to the JInternalFrame.
*/
- private static void startModal(JInternalFrame f, JOptionPane pane)
+ private static void startModal(JInternalFrame f)
{
- f.getContentPane().add(pane);
- f.pack();
- f.show();
-
- Dimension pref = f.getPreferredSize();
- f.setBounds(0, 0, pref.width, pref.height);
-
synchronized (f)
{
final JInternalFrame tmp = f;
diff --git a/javax/swing/JPanel.java b/javax/swing/JPanel.java
index 34a7c9fdc..c7f7c4483 100644
--- a/javax/swing/JPanel.java
+++ b/javax/swing/JPanel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/JPasswordField.java b/javax/swing/JPasswordField.java
index 449aa82cd..f9df10217 100644
--- a/javax/swing/JPasswordField.java
+++ b/javax/swing/JPasswordField.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/JPopupMenu.java b/javax/swing/JPopupMenu.java
index f1ec51156..c4ee5fe73 100644
--- a/javax/swing/JPopupMenu.java
+++ b/javax/swing/JPopupMenu.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -232,6 +232,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
constraints.gridy = i;
super.add(items[i], constraints, i);
}
+ this.setSize(this.getPreferredSize());
}
/**
@@ -276,6 +277,7 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
super.add(items[i], constraints, i);
}
}
+ this.setSize(this.getPreferredSize());
}
/**
@@ -908,13 +910,13 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
*/
private class LightWeightPopup extends Container implements Popup
{
+ private Component c;
+
/**
* Creates a new LightWeightPopup menu
*
* @param c Container containing menu items
*/
- private Component c;
-
public LightWeightPopup(Container c)
{
this.c = c;
diff --git a/javax/swing/JProgressBar.java b/javax/swing/JProgressBar.java
index 3f8a45ad6..1b8fcea46 100644
--- a/javax/swing/JProgressBar.java
+++ b/javax/swing/JProgressBar.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -88,8 +88,6 @@ public class JProgressBar extends JComponent implements SwingConstants,
/**
* Constructor AccessibleJProgressBar
- *
- * @param component TODO
*/
protected AccessibleJProgressBar()
{
@@ -200,7 +198,7 @@ public class JProgressBar extends JComponent implements SwingConstants,
*/
public JProgressBar()
{
- this(0, 100, HORIZONTAL);
+ this(HORIZONTAL, 0, 100);
}
/**
@@ -208,10 +206,13 @@ public class JProgressBar extends JComponent implements SwingConstants,
* a maximum of 100, and the given orientation.
*
* @param orientation The orientation of the JProgressBar.
+ *
+ * @throws IllegalArgumentException if <code>orientation</code> is not either
+ * {@link #HORIZONTAL} or {@link #VERTICAL}.
*/
public JProgressBar(int orientation)
{
- this(0, 100, orientation);
+ this(orientation, 0, 100);
}
/**
@@ -223,7 +224,7 @@ public class JProgressBar extends JComponent implements SwingConstants,
*/
public JProgressBar(int minimum, int maximum)
{
- this(minimum, maximum, HORIZONTAL);
+ this(HORIZONTAL, minimum, maximum);
}
/**
@@ -233,8 +234,11 @@ public class JProgressBar extends JComponent implements SwingConstants,
* @param minimum The minimum of the JProgressBar.
* @param maximum The maximum of the JProgressBar.
* @param orientation The orientation of the JProgressBar.
+ *
+ * @throws IllegalArgumentException if <code>orientation</code> is not either
+ * {@link #HORIZONTAL} or {@link #VERTICAL}.
*/
- public JProgressBar(int minimum, int maximum, int orientation)
+ public JProgressBar(int orientation, int minimum, int maximum)
{
model = new DefaultBoundedRangeModel(minimum, 0, minimum, maximum);
if (orientation != HORIZONTAL && orientation != VERTICAL)
diff --git a/javax/swing/JRadioButton.java b/javax/swing/JRadioButton.java
index 10f7e81fd..66f5902e8 100644
--- a/javax/swing/JRadioButton.java
+++ b/javax/swing/JRadioButton.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -236,7 +236,7 @@ public class JRadioButton extends JToggleButton
*/
protected String paramString()
{
- return "JRadioButton";
+ return super.paramString();
}
/**
diff --git a/javax/swing/JRadioButtonMenuItem.java b/javax/swing/JRadioButtonMenuItem.java
index 2aefb3395..76a8fef64 100644
--- a/javax/swing/JRadioButtonMenuItem.java
+++ b/javax/swing/JRadioButtonMenuItem.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/JRootPane.java b/javax/swing/JRootPane.java
index ee05d27f9..cb0bafd84 100644
--- a/javax/swing/JRootPane.java
+++ b/javax/swing/JRootPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/JScrollBar.java b/javax/swing/JScrollBar.java
index 0ed7679e7..a2cc76c65 100644
--- a/javax/swing/JScrollBar.java
+++ b/javax/swing/JScrollBar.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -69,8 +69,6 @@ public class JScrollBar extends JComponent implements Adjustable, Accessible
/**
* Creates a new AccessibleJSlider object.
- *
- * @param value0 DOCUMENT ME!
*/
protected AccessibleJScrollBar()
{
diff --git a/javax/swing/JScrollPane.java b/javax/swing/JScrollPane.java
index baa0a6a85..e83513f07 100644
--- a/javax/swing/JScrollPane.java
+++ b/javax/swing/JScrollPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -54,6 +54,9 @@ import javax.swing.plaf.ScrollPaneUI;
import javax.swing.plaf.UIResource;
/**
+ * A component that embeds another component and enables it to be scrolled
+ * both in horizontal and vertical direction.
+ *
* <table>
* <tr><th>Property </th><th>Stored in </th><th>Bound?</th></tr>
* <tr><td>columnHeader </td><td>scrollPane </td><td>yes </td></tr>
@@ -564,11 +567,23 @@ public class JScrollPane
}
+ /**
+ * Creates a new <code>JScrollPane</code> without a view. The scrollbar
+ * policy is set to {@link #VERTICAL_SCROLLBAR_AS_NEEDED} and
+ * {@link #HORIZONTAL_SCROLLBAR_AS_NEEDED}.
+ */
public JScrollPane()
{
this(null);
}
-
+
+ /**
+ * Creates a new <code>JScrollPane</code> that embeds the specified
+ * <code>view</code> component, displaying vertical and horizontal scrollbars
+ * as needed.
+ *
+ * @param view the component that is embedded inside the JScrollPane
+ */
public JScrollPane(Component view)
{
this(view,
@@ -576,11 +591,40 @@ public class JScrollPane
HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
+ /**
+ * Creates a new <code>JScrollPane</code> without a view; The scrollbar
+ * policies are set to <code>vsbPolicy</code> and <code>hsbPolicy</code>.
+ *
+ * @param vsbPolicy the vertical scrollbar policy to set
+ * @param hsbPolicy the vertical scrollbar policy to set
+ *
+ * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_ALWAYS
+ * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_AS_NEEDED
+ * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_NEVER
+ * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_ALWAYS
+ * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_AS_NEEDED
+ * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_NEVER
+ */
public JScrollPane(int vsbPolicy, int hsbPolicy)
{
this(null, vsbPolicy, hsbPolicy);
}
+ /**
+ * Creates a new <code>JScrollPane</code> that embeds the specified
+ * <code>view</code> component; The scrollbar
+ * policies are set to <code>vsbPolicy</code> and <code>hsbPolicy</code>.
+ *
+ * @param vsbPolicy the vertical scrollbar policy to set
+ * @param hsbPolicy the vertical scrollbar policy to set
+ *
+ * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_ALWAYS
+ * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_AS_NEEDED
+ * @see ScrollPaneConstants#HORIZONTAL_SCROLLBAR_NEVER
+ * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_ALWAYS
+ * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_AS_NEEDED
+ * @see ScrollPaneConstants#VERTICAL_SCROLLBAR_NEVER
+ */
public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
{
scrollListener = createScrollListener();
@@ -588,7 +632,11 @@ public class JScrollPane
setVerticalScrollBar(createVerticalScrollBar());
setHorizontalScrollBarPolicy(hsbPolicy);
setHorizontalScrollBar(createHorizontalScrollBar());
- setViewportView(view);
+ viewport = createViewport();
+ if (view != null)
+ getViewport().setView(view);
+ viewport.addChangeListener(scrollListener);
+ add(viewport,0);
setLayout(new ScrollPaneLayout());
setOpaque(false);
updateUI();
diff --git a/javax/swing/JSeparator.java b/javax/swing/JSeparator.java
index d3edb737d..6a3b97d35 100644
--- a/javax/swing/JSeparator.java
+++ b/javax/swing/JSeparator.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -59,8 +59,6 @@ public class JSeparator extends JComponent implements SwingConstants,
/**
* Constructor AccessibleJSeparator
- *
- * @param component TODO
*/
protected AccessibleJSeparator()
{
diff --git a/javax/swing/JSlider.java b/javax/swing/JSlider.java
index cfe7880df..2caf509a1 100644
--- a/javax/swing/JSlider.java
+++ b/javax/swing/JSlider.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,6 +41,7 @@ package javax.swing;
import java.awt.Dimension;
import java.awt.MenuContainer;
import java.awt.image.ImageObserver;
+import java.beans.PropertyChangeEvent;
import java.io.Serializable;
import java.util.Dictionary;
import java.util.Enumeration;
@@ -124,8 +125,6 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
/**
* Creates a new AccessibleJSlider object.
- *
- * @param value0 DOCUMENT ME!
*/
protected AccessibleJSlider()
{
@@ -229,7 +228,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
protected int minorTickSpacing;
/** Whether the slider snaps its values to ticks. */
- protected boolean snapToTicks = true;
+ protected boolean snapToTicks = false;
/** The orientation of the slider. */
protected int orientation = HORIZONTAL;
@@ -256,7 +255,11 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
* Creates a new JSlider object with the given orientation and a minimum of
* 0, a maximum of 100, and a value of 50.
*
- * @param orientation The orientation of the slider.
+ * @param orientation The orientation of the slider ({@link #HORIZONTAL} or
+ * {@link #VERTICAL}).
+ *
+ * @throws IllegalArgumentException if <code>orientation</code> is not one of
+ * the specified values.
*/
public JSlider(int orientation)
{
@@ -293,10 +296,14 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
* Creates a new JSlider object with the given orientation, minimum,
* maximum, and value.
*
- * @param orientation The orientation of the JSlider.
+ * @param orientation The orientation of the slider ({@link #HORIZONTAL} or
+ * {@link #VERTICAL}).
* @param minimum The minimum value of the JSlider.
* @param maximum The maximum value of the JSlider.
* @param value The initial value of the JSlider.
+ *
+ * @throws IllegalArgumentException if <code>orientation</code> is not one of
+ * the specified values.
*/
public JSlider(int orientation, int minimum, int maximum, int value)
{
@@ -312,14 +319,13 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
/**
* Creates a new horizontal JSlider object with the given model.
*
- * @param model The model the slider will be created with.
+ * @param model The model (<code>null</code> not permitted).
+ *
+ * @throws NullPointerException if <code>model</code> is <code>null</code>.
*/
public JSlider(BoundedRangeModel model)
{
- if (model == null)
- sliderModel = new DefaultBoundedRangeModel(50, 0, 0, 100);
- else
- sliderModel = model;
+ sliderModel = model;
changeListener = createChangeListener();
sliderModel.addChangeListener(changeListener);
updateUI();
@@ -504,7 +510,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
public void setMinimum(int minimum)
{
+ int old = sliderModel.getMinimum();
sliderModel.setMinimum(minimum);
+ if (minimum != old)
+ firePropertyChange("minimum", old, minimum);
}
/**
@@ -524,7 +533,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
*/
public void setMaximum(int maximum)
{
+ int old = sliderModel.getMaximum();
sliderModel.setMaximum(maximum);
+ if (maximum != old)
+ firePropertyChange("maximum", old, maximum);
}
/**
@@ -643,9 +655,12 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
* minimum and increase by the increment. Each label will have a text
* string indicating their integer value.
*
- * @param increment The increment to between labels.
+ * @param increment The increment between labels (must be > 0).
*
* @return A hashtable with the labels and their keys.
+ *
+ * @throws IllegalArgumentException if <code>increment</code> is not greater
+ * than zero.
*/
public Hashtable createStandardLabels(int increment)
{
@@ -656,15 +671,23 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
* Creates a hashtable of (Integer, JLabel) pairs that can be used as a
* label table for this slider. The labels will start from the given start
* value and increase by the increment. Each label will have a text string
- * indicating their integer value.
+ * indicating its integer value.
*
- * @param increment The increment to between labels.
+ * @param increment The increment between labels (must be > 0).
* @param start The value to start from.
*
* @return A hashtable with the labels and their keys.
+ *
+ * @throws IllegalArgumentException if <code>increment</code> is not greater
+ * than zero, or <code>start</code> is not within the range of the
+ * model.
*/
public Hashtable createStandardLabels(int increment, int start)
{
+ if (increment <= 0)
+ throw new IllegalArgumentException("Requires 'increment' > 0.");
+ if (start < getMinimum() || start > getMaximum())
+ throw new IllegalArgumentException("The 'start' value is out of range.");
Hashtable table = new Hashtable();
JLabel label;
Dimension dim;
@@ -801,7 +824,7 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
if (snap != snapToTicks)
{
snapToTicks = snap;
- fireStateChanged();
+ firePropertyChange("snapToTicks", !snap, snap);
}
}
@@ -847,13 +870,19 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
}
/**
- * This method sets whether the track will be painted.
+ * Sets the flag that controls whether or not the track is painted, and
+ * sends a {@link PropertyChangeEvent} (for the "paintTrack" property) to all
+ * registered listeners.
*
* @param paint Whether the track will be painted.
*/
public void setPaintTrack(boolean paint)
{
- paintTrack = paint;
+ if (paintTrack != paint)
+ {
+ paintTrack = paint;
+ firePropertyChange("paintTrack", !paint, paint);
+ }
}
/**
@@ -875,9 +904,10 @@ public class JSlider extends JComponent implements SwingConstants, Accessible,
{
if (paint != paintLabels)
{
- boolean oldPaintLabels = paintLabels;
paintLabels = paint;
- firePropertyChange("paintLabels", oldPaintLabels, paintLabels);
+ if (paint && majorTickSpacing > 0)
+ labelTable = createStandardLabels(majorTickSpacing);
+ firePropertyChange("paintLabels", !paint, paint);
}
}
diff --git a/javax/swing/JSpinner.java b/javax/swing/JSpinner.java
index 4efb1c27e..fc2b13e81 100644
--- a/javax/swing/JSpinner.java
+++ b/javax/swing/JSpinner.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,17 +41,18 @@ package javax.swing;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Insets;
import java.awt.LayoutManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DecimalFormat;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
-import javax.swing.border.EtchedBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.SpinnerUI;
-
+import javax.swing.text.DateFormatter;
/**
* A JSpinner is a component which typically contains a numeric value and a
@@ -66,53 +67,15 @@ public class JSpinner extends JComponent
/**
* DOCUMENT ME!
*/
- public static class StubEditor extends JLabel implements ChangeListener
- {
- /** DOCUMENT ME! */
- private JLabel label;
-
- /** DOCUMENT ME! */
- private JButton up;
-
- /** DOCUMENT ME! */
- private JButton down;
-
- /** DOCUMENT ME! */
- private JSpinner spinner;
-
- /**
- * Creates a new StubEditor object.
- *
- * @param spinner DOCUMENT ME!
- */
- public StubEditor(JSpinner spinner)
- {
- this.spinner = spinner;
- setBorder(new EtchedBorder());
- setHorizontalAlignment(SwingConstants.TRAILING);
- stateChanged(null); /* fill in the label */
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param evt DOCUMENT ME!
- */
- public void stateChanged(ChangeEvent evt)
- {
- setText(String.valueOf(spinner.getValue()));
- }
- }
-
- /**
- * DOCUMENT ME!
- */
public static class DefaultEditor extends JPanel implements ChangeListener,
PropertyChangeListener,
LayoutManager
{
private JSpinner spinner;
-
+
+ /** The JFormattedTextField that backs the editor. */
+ JFormattedTextField ftf;
+
/**
* For compatability with Sun's JDK 1.4.2 rev. 5
*/
@@ -125,8 +88,12 @@ public class JSpinner extends JComponent
*/
public DefaultEditor(JSpinner spinner)
{
+ super();
+ setLayout(this);
this.spinner = spinner;
-
+ ftf = new JFormattedTextField();
+ add(ftf);
+ ftf.setValue(spinner.getValue());
spinner.addChangeListener(this);
}
@@ -163,8 +130,8 @@ public class JSpinner extends JComponent
*/
public JFormattedTextField getTextField()
{
- return null;
- } /* TODO */
+ return ftf;
+ }
/**
* DOCUMENT ME!
@@ -173,7 +140,12 @@ public class JSpinner extends JComponent
*/
public void layoutContainer(Container parent)
{
- } /* TODO */
+ Insets insets = getInsets();
+ Dimension size = getSize();
+ ftf.setBounds(insets.left, insets.top,
+ size.width - insets.left - insets.right,
+ size.height - insets.top - insets.bottom);
+ }
/**
* DOCUMENT ME!
@@ -184,8 +156,11 @@ public class JSpinner extends JComponent
*/
public Dimension minimumLayoutSize(Container parent)
{
- return null;
- } /* TODO */
+ Insets insets = getInsets();
+ Dimension minSize = ftf.getMinimumSize();
+ return new Dimension(minSize.width + insets.left + insets.right,
+ minSize.height + insets.top + insets.bottom);
+ }
/**
* DOCUMENT ME!
@@ -196,8 +171,11 @@ public class JSpinner extends JComponent
*/
public Dimension preferredLayoutSize(Container parent)
{
- return null;
- } /* TODO */
+ Insets insets = getInsets();
+ Dimension prefSize = ftf.getPreferredSize();
+ return new Dimension(prefSize.width + insets.left + insets.right,
+ prefSize.height + insets.top + insets.bottom);
+ }
/**
* DOCUMENT ME!
@@ -279,6 +257,95 @@ public class JSpinner extends JComponent
}
}
+ /**
+ * An editor class for a <code>JSpinner</code> that is used
+ * for displaying and editing dates (e.g. that uses
+ * <code>SpinnerDateModel</code> as model).
+ *
+ * The editor uses a {@link JTextField} with the value
+ * displayed by a {@link DateFormatter} instance.
+ */
+ public static class DateEditor extends DefaultEditor
+ {
+
+ /** The serialVersionUID. */
+ private static final long serialVersionUID = -4279356973770397815L;
+
+ /** The DateFormat instance used to format the date. */
+ SimpleDateFormat dateFormat;
+
+ /**
+ * Creates a new instance of DateEditor for the specified
+ * <code>JSpinner</code>.
+ *
+ * @param spinner the <code>JSpinner</code> for which to
+ * create a <code>DateEditor</code> instance
+ */
+ public DateEditor(JSpinner spinner)
+ {
+ super(spinner);
+ init(new SimpleDateFormat());
+ }
+
+ /**
+ * Creates a new instance of DateEditor for the specified
+ * <code>JSpinner</code> using the specified date format
+ * pattern.
+ *
+ * @param spinner the <code>JSpinner</code> for which to
+ * create a <code>DateEditor</code> instance
+ * @param dateFormatPattern the date format to use
+ *
+ * @see SimpleDateFormat#SimpleDateFormat(String)
+ */
+ public DateEditor(JSpinner spinner, String dateFormatPattern)
+ {
+ super(spinner);
+ init(new SimpleDateFormat(dateFormatPattern));
+ }
+
+ /**
+ * Initializes the JFormattedTextField for this editor.
+ *
+ * @param the date format to use in the formatted text field
+ */
+ private void init(SimpleDateFormat format)
+ {
+ dateFormat = format;
+ getTextField().setFormatterFactory(
+ new JFormattedTextField.AbstractFormatterFactory()
+ {
+ public JFormattedTextField.AbstractFormatter
+ getFormatter(JFormattedTextField ftf)
+ {
+ return new DateFormatter(dateFormat);
+ }
+ });
+ }
+
+ /**
+ * Returns the <code>SimpleDateFormat</code> instance that is used to
+ * format the date value.
+ *
+ * @return the <code>SimpleDateFormat</code> instance that is used to
+ * format the date value
+ */
+ public SimpleDateFormat getFormat()
+ {
+ return dateFormat;
+ }
+
+ /**
+ * Returns the {@link SpinnerDateModel} that is edited by this editor.
+ *
+ * @return the <code>SpinnerDateModel</code> that is edited by this editor
+ */
+ public SpinnerDateModel getModel()
+ {
+ return (SpinnerDateModel) getSpinner().getModel();
+ }
+ }
+
private static final long serialVersionUID = 3412663575706551720L;
/** DOCUMENT ME! */
@@ -544,5 +611,11 @@ public class JSpinner extends JComponent
*/
protected JComponent createEditor(SpinnerModel model)
{
- return new StubEditor(this);
- } /* TODO */}
+ if (model instanceof SpinnerDateModel)
+ return new DateEditor(this);
+ else if (model instanceof SpinnerNumberModel)
+ return new NumberEditor(this);
+ else
+ return new DefaultEditor(this);
+ }
+}
diff --git a/javax/swing/JSplitPane.java b/javax/swing/JSplitPane.java
index 9cdad16a7..cea5afef2 100644
--- a/javax/swing/JSplitPane.java
+++ b/javax/swing/JSplitPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -66,8 +66,6 @@ public class JSplitPane extends JComponent implements Accessible
/**
* Creates a new AccessibleJSplitPane object.
- *
- * @param value0 DOCUMENT ME!
*/
protected AccessibleJSplitPane()
{
diff --git a/javax/swing/JTabbedPane.java b/javax/swing/JTabbedPane.java
index 5a37d1b9b..828a69a24 100644
--- a/javax/swing/JTabbedPane.java
+++ b/javax/swing/JTabbedPane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -523,7 +523,7 @@ public class JTabbedPane extends JComponent implements Serializable,
if (index < -1 || title != null && index >= title.length())
throw new IllegalArgumentException();
- if (title == null || mnemonicKey == 0 || title.charAt(index) != mnemonicKey)
+ if (title == null || mnemonicKey == 0 || (index > -1 && title.charAt(index) != mnemonicKey))
index = -1;
underlinedChar = index;
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index e609e61ed..04ea714f2 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -356,10 +356,10 @@ public class JTable extends JComponent
* {@link TableColumnModel} and assign it to the {@link #columnModel}
* property when the {@link #dataModel} property is changed.
*
- * @see #setModel()
+ * @see #setModel(TableModel)
* @see #createColumnsFromModel()
- * @see #setColumnModel()
- * @see #setAutoCreateColumnsFromModel()
+ * @see #setColumnModel(TableColumnModel)
+ * @see #setAutoCreateColumnsFromModel(boolean)
* @see #getAutoCreateColumnsFromModel()
*/
protected boolean autoCreateColumnsFromModel;
@@ -371,7 +371,7 @@ public class JTable extends JComponent
* #AUTO_RESIZE_SUBSEQUENT_COLUMNS}, or {@link #AUTO_RESIZE_OFF}.
*
* @see #doLayout()
- * @see #setAutoResizeMode()
+ * @see #setAutoResizeMode(int)
* @see #getAutoResizeMode()
*/
protected int autoResizeMode;
@@ -383,21 +383,21 @@ public class JTable extends JComponent
* {@link #columnModel}.
*
* @see #getRowHeight()
- * @see #setRowHeight()
+ * @see #setRowHeight(int)
* @see TableColumn#getWidth()
- * @see TableColumn#setWidth()
+ * @see TableColumn#setWidth(int)
*/
protected int rowHeight;
/**
* The height in pixels of the gap left between any two rows of the table.
*
- * @see #setRowMargin()
+ * @see #setRowMargin(int)
* @see #getRowHeight()
* @see #getIntercellSpacing()
- * @see #setIntercellSpacing()
+ * @see #setIntercellSpacing(Dimension)
* @see TableColumnModel#getColumnMargin()
- * @see TableColumnModel#setColumnMargin()
+ * @see TableColumnModel#setColumnMargin(int)
*/
protected int rowMargin;
@@ -408,18 +408,18 @@ public class JTable extends JComponent
* selection as an independent concept, but it is now represented solely
* in terms of simultaneous row and column selection.
*
- * @see TableColumnModel#columnSelectionAllowed()
- * @see #setRowSelectionAllowed()
+ * @see TableColumnModel#getColumnSelectionAllowed()
+ * @see #setRowSelectionAllowed(boolean)
* @see #getRowSelectionAllowed()
* @see #getCellSelectionEnabled()
- * @see #setCellSelectionEnabled()
+ * @see #setCellSelectionEnabled(boolean)
*/
protected boolean rowSelectionAllowed;
/**
- * @deprecated Use {@link #rowSelectionAllowed}, {@link
- * #columnSelectionAllowed}, or the combined methods {@link
- * getCellSelectionEnabled} and {@link setCellSelectionEnabled}.
+ * @deprecated Use {@link #rowSelectionAllowed}, {@link
+ * #getColumnSelectionAllowed}, or the combined methods {@link
+ * #getCellSelectionEnabled} and {@link #setCellSelectionEnabled(boolean)}.
*/
protected boolean cellSelectionEnabled;
@@ -429,8 +429,8 @@ public class JTable extends JComponent
* property name. The table listens to its model as a {@link
* TableModelListener}.
*
- * @see #tableChanged()
- * @see TableModel#addTableModelListener()
+ * @see #tableChanged(TableModelEvent)
+ * @see TableModel#addTableModelListener(TableModelListener)
*/
protected TableModel dataModel;
@@ -444,7 +444,7 @@ public class JTable extends JComponent
*
* <p>The TableColumnModel also contains a {@link ListSelectionModel} which
* indicates which columns are currently selected. This selection model
- * works in combination with the {@link selectionModel} of the table
+ * works in combination with the {@link #selectionModel} of the table
* itself to specify a <em>table selection</em>: a combination of row and
* column selections.</p>
*
@@ -453,7 +453,7 @@ public class JTable extends JComponent
* columnModel automatically, and the table acts as a facade for most of
* the interesting properties of the columnModel anyways.</p>
*
- * @see #setColumnModel()
+ * @see #setColumnModel(TableColumnModel)
* @see #getColumnModel()
*/
protected TableColumnModel columnModel;
@@ -461,14 +461,14 @@ public class JTable extends JComponent
/**
* A model of the rows of this table which are currently selected. This
* model is used in combination with the column selection model held as a
- * member of the {@link columnModel} property, to represent the rows and
+ * member of the {@link #columnModel} property, to represent the rows and
* columns (or both: cells) of the table which are currently selected.
*
* @see #rowSelectionAllowed
- * @see #setSelectionModel()
+ * @see #setSelectionModel(ListSelectionModel)
* @see #getSelectionModel()
* @see TableColumnModel#getSelectionModel()
- * @see ListSelectionModel#addListSelectionListener()
+ * @see ListSelectionModel#addListSelectionListener(ListSelectionListener)
*/
protected ListSelectionModel selectionModel;
@@ -494,7 +494,7 @@ public class JTable extends JComponent
* The color to paint the grid lines of the table, when either {@link
* #showHorizontalLines} or {@link #showVerticalLines} is set.
*
- * @see #setGridColor()
+ * @see #setGridColor(Color)
* @see #getGridColor()
*/
protected Color gridColor;
@@ -503,7 +503,7 @@ public class JTable extends JComponent
* The size this table would prefer its viewport assume, if it is
* contained in a {@link JScrollPane}.
*
- * @see #setPreferredScrollableViewportSize()
+ * @see #setPreferredScrollableViewportSize(Dimension)
* @see #getPreferredScrollableViewportSize()
*/
protected Dimension preferredViewportSize;
@@ -513,7 +513,7 @@ public class JTable extends JComponent
* change event with name {@link #SELECTION_BACKGROUND_CHANGED_PROPERTY}
* when its value changes.
*
- * @see #setSelectionBackground()
+ * @see #setSelectionBackground(Color)
* @see #getSelectionBackground()
*/
protected Color selectionBackground;
@@ -529,7 +529,7 @@ public class JTable extends JComponent
* change event with name {@link #SELECTION_FOREGROUND_CHANGED_PROPERTY}
* when its value changes.
*
- * @see #setSelectionForeground()
+ * @see #setSelectionForeground(Color)
* @see #getSelectionForeground()
*/
protected Color selectionForeground;
@@ -616,16 +616,22 @@ public class JTable extends JComponent
*/
public JTable (TableModel dm, TableColumnModel cm, ListSelectionModel sm)
{
- this.dataModel = dm == null ? createDefaultDataModel() : dm;
+ setModel(dm == null ? createDefaultDataModel() : dm);
setSelectionModel(sm == null ? createDefaultSelectionModel() : sm);
-
+
this.columnModel = cm;
initializeLocalVars();
+ // The next two lines are for compliance with the JDK which starts
+ // the JLists associated with a JTable with both lead selection
+ // indices at 0, rather than -1 as in regular JLists
+ selectionModel.setLeadSelectionIndex(0);
+ columnModel.getSelectionModel().setLeadSelectionIndex(0);
updateUI();
}
protected void initializeLocalVars()
{
+ setTableHeader(createDefaultTableHeader());
this.autoCreateColumnsFromModel = false;
if (columnModel == null)
{
@@ -646,14 +652,14 @@ public class JTable extends JComponent
this.rowSelectionAllowed = true;
// this.accessibleContext = new AccessibleJTable();
this.cellEditor = null;
- this.dragEnabled = false;
+ // COMPAT: Both Sun and IBM have drag enabled
+ this.dragEnabled = true;
this.preferredViewportSize = new Dimension(450,400);
this.showHorizontalLines = true;
this.showVerticalLines = true;
this.editingColumn = -1;
this.editingRow = -1;
setIntercellSpacing(new Dimension(1,1));
- setTableHeader(createDefaultTableHeader());
}
/**
@@ -671,8 +677,8 @@ public class JTable extends JComponent
{
if (column.getHeaderValue() == null)
{
- String name = getColumnName(column.getModelIndex());
- column.setHeaderValue(name);
+ String name = dataModel.getColumnName(column.getModelIndex());
+ column.setHeaderValue(name);
}
columnModel.addColumn(column);
@@ -778,6 +784,13 @@ public class JTable extends JComponent
public void tableChanged (TableModelEvent event)
{
+ // update the column model from the table model if the structure has
+ // changed and the flag autoCreateColumnsFromModel is set
+ if ((event.getFirstRow() ==TableModelEvent.HEADER_ROW)
+ && autoCreateColumnsFromModel)
+
+ createColumnsFromModel();
+
repaint();
}
@@ -885,10 +898,11 @@ public class JTable extends JComponent
public void clearSelection()
{
selectionModel.clearSelection();
+ getColumnModel().getSelectionModel().clearSelection();
}
/**
- * Get the value of the {@link #selectedRow} property by delegation to
+ * Get the value of the selectedRow property by delegation to
* the {@link ListSelectionModel#getMinSelectionIndex} method of the
* {@link #selectionModel} field.
*
@@ -906,9 +920,7 @@ public class JTable extends JComponent
*/
public ListSelectionModel getSelectionModel()
{
- if (! rowSelectionAllowed)
- return null;
-
+ //Neither Sun nor IBM returns null if rowSelection not allowed
return selectionModel;
}
@@ -921,23 +933,21 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #scrollableTracksViewportHeight} property.
+ * Get the value of the <code>scrollableTracksViewportHeight</code> property.
*
* @return The constant value <code>false</code>
*/
-
public boolean getScrollableTracksViewportHeight()
{
return false;
}
/**
- * Get the value of the {@link #scrollableTracksViewportWidth} property.
+ * Get the value of the <code>scrollableTracksViewportWidth</code> property.
*
- * @return <code>true</code> unless the {@link autoResizeMode} prperty is
+ * @return <code>true</code> unless the {@link #autoResizeMode} property is
* <code>AUTO_RESIZE_OFF</code>
*/
-
public boolean getScrollableTracksViewportWidth()
{
if (autoResizeMode == AUTO_RESIZE_OFF)
@@ -1021,8 +1031,6 @@ public class JTable extends JComponent
{
if (vc < 0)
return vc;
- else if (vc > getColumnCount())
- return -1;
else
return columnModel.getColumn(vc).getModelIndex();
}
@@ -1132,7 +1140,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #columnCount} property by
+ * Get the value of the <code>columnCount</code> property by
* delegation to the @{link #columnModel} field.
*
* @return The current value of the columnCount property
@@ -1143,7 +1151,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #rowCount} property by
+ * Get the value of the <code>rowCount</code> property by
* delegation to the @{link #dataModel} field.
*
* @return The current value of the rowCount property
@@ -1164,7 +1172,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #selectedColumn} property by
+ * Get the value of the <code>selectedColumn</code> property by
* delegation to the @{link #columnModel} field.
*
* @return The current value of the selectedColumn property
@@ -1234,7 +1242,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #selectedColumnCount} property by
+ * Get the value of the <code>selectedColumnCount</code> property by
* delegation to the @{link #columnModel} field.
*
* @return The current value of the selectedColumnCount property
@@ -1245,7 +1253,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #selectedColumns} property by
+ * Get the value of the <code>selectedColumns</code> property by
* delegation to the @{link #columnModel} field.
*
* @return The current value of the selectedColumns property
@@ -1256,7 +1264,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #columnSelectionAllowed} property.
+ * Get the value of the <code>columnSelectionAllowed</code> property.
*
* @return The current value of the columnSelectionAllowed property
*/
@@ -1266,7 +1274,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #selectedRowCount} property by
+ * Get the value of the <code>selectedRowCount</code> property by
* delegation to the @{link #selectionModel} field.
*
* @return The current value of the selectedRowCount property
@@ -1277,7 +1285,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #selectedRows} property by
+ * Get the value of the <code>selectedRows</code> property by
* delegation to the @{link #selectionModel} field.
*
* @return The current value of the selectedRows property
@@ -1328,7 +1336,7 @@ public class JTable extends JComponent
}
/**
- * Get the value of the {@link #intercellSpacing} property.
+ * Get the value of the <code>intercellSpacing</code> property.
*
* @return The current value of the property
*/
@@ -1419,13 +1427,20 @@ public class JTable extends JComponent
}
/**
- * Set the value of the {@link #autoCreateColumnsFromModel} property.
+ * Set the value of the {@link #autoCreateColumnsFromModel} flag. If the
+ * flag changes from <code>false</code> to <code>true</code>, the
+ * {@link #createDefaultColumnsFromModel()} method is called.
*
- * @param a The new value of the autoCreateColumnsFromModel property
+ * @param autoCreate the new value of the flag.
*/
- public void setAutoCreateColumnsFromModel(boolean a)
+ public void setAutoCreateColumnsFromModel(boolean autoCreate)
{
- autoCreateColumnsFromModel = a;
+ if (autoCreateColumnsFromModel != autoCreate)
+ {
+ autoCreateColumnsFromModel = autoCreate;
+ if (autoCreate)
+ createDefaultColumnsFromModel();
+ }
}
/**
@@ -1454,7 +1469,20 @@ public class JTable extends JComponent
revalidate();
repaint();
}
-
+
+ /**
+ * Sets the value of the rowHeight property for the specified
+ * row.
+ *
+ * @param rh is the new rowHeight
+ * @param row is the row to change the rowHeight of
+ */
+ public void setRowHeight(int rh, int row)
+ {
+ setRowHeight(rh);
+ // FIXME: not implemented
+ }
+
/**
* Set the value of the {@link #rowMargin} property.
*
@@ -1557,12 +1585,18 @@ public class JTable extends JComponent
for (int i = 0; i < ncols; ++i)
columnModel.getColumn(i).setHeaderValue(dataModel.getColumnName(i));
}
+
+ // according to Sun's spec we also have to set the tableHeader's
+ // column model here
+ if (tableHeader != null)
+ tableHeader.setColumnModel(c);
+
revalidate();
repaint();
}
/**
- * Set the value of the {@link #columnSelectionAllowed} property.
+ * Set the value of the <code>columnSelectionAllowed</code> property.
*
* @param c The new value of the property
*/
@@ -1594,7 +1628,7 @@ public class JTable extends JComponent
}
/**
- * Set the value of the {@link #selectionMode} property by
+ * Set the value of the <code>selectionMode</code> property by
* delegation to the {@link #selectionModel} field. The same selection
* mode is set for row and column selection models.
*
@@ -1649,7 +1683,7 @@ public class JTable extends JComponent
}
/**
- * Set the value of the {@link #intercellSpacing} property.
+ * Set the value of the <code>intercellSpacing</code> property.
*
* @param i The new value of the intercellSpacing property
*/
@@ -1696,7 +1730,7 @@ public class JTable extends JComponent
* <p>Set the value of the {@link #selectionForeground} property.</p>
*
* <p>Fire a PropertyChangeEvent with name {@link
- * SELECTION_FOREGROUND_CHANGED_PROPERTY} to registered listeners, if
+ * #SELECTION_FOREGROUND_CHANGED_PROPERTY} to registered listeners, if
* selectionForeground changed.</p>
*
* @param s The new value of the selectionForeground property
@@ -1713,7 +1747,7 @@ public class JTable extends JComponent
}
/**
- * Set the value of the {@link #showGrid} property.
+ * Set the value of the <code>showGrid</code> property.
*
* @param s The new value of the showGrid property
*/
@@ -1936,7 +1970,8 @@ public class JTable extends JComponent
public String getColumnName(int column)
{
- return dataModel.getColumnName(column);
+ int modelColumn = columnModel.getColumn(column).getModelIndex();
+ return dataModel.getColumnName(modelColumn);
}
public int getEditingColumn()
@@ -2048,8 +2083,17 @@ public class JTable extends JComponent
public void selectAll()
{
+ // rowLead and colLead store the current lead selection indices
+ int rowLead = selectionModel.getLeadSelectionIndex();
+ int colLead = getColumnModel().getSelectionModel().getLeadSelectionIndex();
+ // the following calls to setSelectionInterval change the lead selection
+ // indices
setColumnSelectionInterval(0, getColumnCount() - 1);
setRowSelectionInterval(0, getRowCount() - 1);
+ // the following addSelectionInterval calls restore the lead selection
+ // indices to their previous values
+ addColumnSelectionInterval(colLead,colLead);
+ addRowSelectionInterval(rowLead, rowLead);
}
public Object getValueAt(int row, int column)
@@ -2066,4 +2110,88 @@ public class JTable extends JComponent
{
return columnModel.getColumn(columnModel.getColumnIndex(identifier));
}
+
+ /**
+ * Returns <code>true</code> if the specified cell is editable, and
+ * <code>false</code> otherwise.
+ *
+ * @param row the row index.
+ * @param column the column index.
+ *
+ * @return A boolean.
+ */
+ public boolean isCellEditable(int row, int column)
+ {
+ return dataModel.isCellEditable(row, convertColumnIndexToModel(column));
+ }
+
+ /**
+ * Clears any existing columns from the <code>JTable</code>'s
+ * {@link TableColumnModel} and creates new columns to match the values in
+ * the data ({@link TableModel}) used by the table.
+ *
+ * @see #setAutoCreateColumnsFromModel(boolean)
+ */
+ public void createDefaultColumnsFromModel()
+ {
+ // remove existing columns
+ int columnIndex = columnModel.getColumnCount() - 1;
+ while (columnIndex >= 0)
+ {
+ columnModel.removeColumn(columnModel.getColumn(columnIndex));
+ columnIndex--;
+ }
+
+ // add new columns to match the TableModel
+ int columnCount = dataModel.getColumnCount();
+ for (int c = 0; c < columnCount; c++)
+ {
+ TableColumn column = new TableColumn(c);
+ column.setIdentifier(dataModel.getColumnName(c));
+ columnModel.addColumn(column);
+ }
+ }
+
+ public void changeSelection (int rowIndex, int columnIndex, boolean toggle, boolean extend)
+ {
+ if (toggle && extend)
+ {
+ // Leave the selection state as is, but move the anchor
+ // index to the specified location
+ selectionModel.setAnchorSelectionIndex(rowIndex);
+ getColumnModel().getSelectionModel().setAnchorSelectionIndex(columnIndex);
+ }
+ else if (toggle)
+ {
+ // Toggle the state of the specified cell
+ if (isCellSelected(rowIndex,columnIndex))
+ {
+ selectionModel.removeSelectionInterval(rowIndex,rowIndex);
+ getColumnModel().getSelectionModel().removeSelectionInterval(columnIndex,columnIndex);
+ }
+ else
+ {
+ selectionModel.addSelectionInterval(rowIndex,rowIndex);
+ getColumnModel().getSelectionModel().addSelectionInterval(columnIndex,columnIndex);
+ }
+ }
+ else if (extend)
+ {
+ // Extend the previous selection from the anchor to the
+ // specified cell, clearing all other selections
+ selectionModel.setLeadSelectionIndex(rowIndex);
+ getColumnModel().getSelectionModel().setLeadSelectionIndex(columnIndex);
+ }
+ else
+ {
+ // Clear the previous selection and ensure the new cell
+ // is selected
+ selectionModel.clearSelection();
+ selectionModel.setSelectionInterval(rowIndex,rowIndex);
+ getColumnModel().getSelectionModel().clearSelection();
+ getColumnModel().getSelectionModel().setSelectionInterval(columnIndex, columnIndex);
+
+
+ }
+ }
}
diff --git a/javax/swing/JTextArea.java b/javax/swing/JTextArea.java
index 12e5a4e50..53591ffcc 100644
--- a/javax/swing/JTextArea.java
+++ b/javax/swing/JTextArea.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -47,6 +47,7 @@ import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;
+import javax.swing.text.View;
/**
* The <code>JTextArea</code> component provides a multi-line area for displaying
@@ -79,13 +80,13 @@ import javax.swing.text.PlainDocument;
* @author Michael Koch (konqueror@gmx.de)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see java.awt.TextArea
- * @see javax.swing.JTextComponent
+ * @see javax.swing.text.JTextComponent
* @see javax.swing.JTextField
* @see javax.swing.JTextPane
* @see javax.swing.JEditorPane
* @see javax.swing.text.Document
- * @see javax.swing.text.DocumentEvent
- * @see javax.swing.text.DocumentListener
+ * @see javax.swing.event.DocumentEvent
+ * @see javax.swing.event.DocumentListener
*/
public class JTextArea extends JTextComponent
@@ -165,7 +166,7 @@ public class JTextArea extends JTextComponent
/**
* Creates a new <code>JTextArea</code> object.
*
- * @param the document model to use
+ * @param doc the document model to use
*/
public JTextArea(Document doc)
{
@@ -175,7 +176,7 @@ public class JTextArea extends JTextComponent
/**
* Creates a new <code>JTextArea</code> object.
*
- * @param the document model to use
+ * @param doc the document model to use
* @param text the initial text
* @param rows the number of rows
* @param columns the number of cols
@@ -188,7 +189,6 @@ public class JTextArea extends JTextComponent
setText(text);
setRows(rows);
setColumns(columns);
- setPreferredSize(new Dimension(440, 150));
}
/**
@@ -235,12 +235,12 @@ public class JTextArea extends JTextComponent
/**
* Returns the increment that is needed to expose exactly one new line
* of text. This is implemented here to return the values of
- * {@link #getRowHeight} and {@link getColumnWidth}, depending on
+ * {@link #getRowHeight} and {@link #getColumnWidth}, depending on
* the value of the argument <code>direction</code>.
*
* @param visibleRect the view area that is visible in the viewport
- * @param orientation either {@link SwingConstants.VERTICAL} or
- * {@link SwingConstants.HORIZONTAL}
+ * @param orientation either {@link SwingConstants#VERTICAL} or
+ * {@link SwingConstants#HORIZONTAL}
* @param direction less than zero for up/left scrolling, greater
* than zero for down/right scrolling
*
@@ -329,7 +329,7 @@ public class JTextArea extends JTextComponent
/**
* Sets the number of rows.
*
- * @param columns number of columns
+ * @param rows number of rows
*
* @exception IllegalArgumentException if rows is negative
*/
@@ -355,7 +355,7 @@ public class JTextArea extends JTextComponent
/**
* Enables/disables line wrapping.
*
- * @param wrapping <code>true</code> to enable line wrapping,
+ * @param flag <code>true</code> to enable line wrapping,
* <code>false</code> otherwise
*/
public void setLineWrap(boolean flag)
@@ -529,4 +529,22 @@ public class JTextArea extends JTextComponent
// This cannot happen as we check offset above.
}
}
+
+ /**
+ * Returns the preferred size for the JTextArea. This is the maximum of
+ * the size that is needed to display the content and the requested size
+ * as per {@link #getColumns} and {@link #getRows}.
+ *
+ * @return the preferred size of the JTextArea
+ */
+ public Dimension getPreferredSize()
+ {
+ int reqWidth = getColumns() * getColumnWidth();
+ int reqHeight = getRows() * getRowHeight();
+ View view = getUI().getRootView(this);
+ int neededWidth = (int) view.getPreferredSpan(View.HORIZONTAL);
+ int neededHeight = (int) view.getPreferredSpan(View.VERTICAL);
+ return new Dimension(Math.max(reqWidth, neededWidth),
+ Math.max(reqHeight, neededHeight));
+ }
}
diff --git a/javax/swing/JTextField.java b/javax/swing/JTextField.java
index 4f284d8d5..5ae9c9f1a 100644
--- a/javax/swing/JTextField.java
+++ b/javax/swing/JTextField.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -197,7 +197,7 @@ public class JTextField extends JTextComponent
public void insertString(int offset, String str, AttributeSet a)
throws BadLocationException
{
- if (str.indexOf('\n') == -1)
+ if (str != null && str.indexOf('\n') == -1)
super.insertString(offset, str, a);
}
};
diff --git a/javax/swing/JTextPane.java b/javax/swing/JTextPane.java
index 95d2d5001..a845ba581 100644
--- a/javax/swing/JTextPane.java
+++ b/javax/swing/JTextPane.java
@@ -1,5 +1,5 @@
-/* JTextPane.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+/* JTextPane.java -- A powerful text widget supporting styled text
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,237 +43,374 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Caret;
import javax.swing.text.Document;
import javax.swing.text.EditorKit;
+import javax.swing.text.Element;
import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.Style;
import javax.swing.text.StyledDocument;
import javax.swing.text.StyledEditorKit;
/**
- * JTextPane
- * @author Andrew Selkirk
- * @version 1.0
+ * A powerful text component that supports styled content as well as
+ * embedding images and components. It is entirely based on a
+ * {@link StyledDocument} content model and a {@link StyledEditorKit}.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ * @author Andrew Selkirk
*/
-public class JTextPane extends JEditorPane {
-
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * uiClassID
- */
- private static final String uiClassID = "TextPaneUI";
-
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor JTextPane
- */
- public JTextPane() {
- // TODO
- } // JTextPane()
-
- /**
- * Constructor JTextPane
- * @param document TODO
- */
- public JTextPane(StyledDocument document) {
- // TODO
- } // JTextPane()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * writeObject
- * @param stream TODO
- * @exception IOException TODO
- */
- private void writeObject(ObjectOutputStream stream) throws IOException {
- // TODO
- } // writeObject()
-
- /**
- * getUIClassID
- * @returns String
- */
- public String getUIClassID() {
- return uiClassID;
- } // getUIClassID()
-
- /**
- * setDocument
- * @param document TODO
- */
- public void setDocument(Document document) {
- // TODO
- } // setDocument()
-
- /**
- * getStyledDocument
- * @returns StyledDocument
- */
- public StyledDocument getStyledDocument() {
- return null; // TODO
- } // getStyledDocument()
-
- /**
- * setStyledDocument
- * @param document TODO
- */
- public void setStyledDocument(StyledDocument document) {
- // TODO
- } // setStyledDocument()
-
- /**
- * replaceSelection
- * @param content TODO
- */
- public void replaceSelection(String content) {
- // TODO
- } // replaceSelection()
-
- /**
- * insertComponent
- * @param component TODO
- */
- public void insertComponent(Component component) {
- // TODO
- } // insertComponent()
-
- /**
- * insertIcon
- * @param icon TODO
- */
- public void insertIcon(Icon icon) {
- // TODO
- } // insertIcon()
-
- /**
- * addStyle
- * @param nm TODO
- * @param parent TODO
- * @returns Style
- */
- public Style addStyle(String nm, Style parent) {
- return null; // TODO
- } // addStyle()
-
- /**
- * removeStyle
- * @param nm TODO
- */
- public void removeStyle(String nm) {
- // TODO
- } // removeStyle()
-
- /**
- * getStyle
- * @param nm TODO
- * @returns Style
- */
- public Style getStyle(String nm) {
- return null; // TODO
- } // getStyle()
-
- /**
- * getLogicalStyle
- * @returns Style
- */
- public Style getLogicalStyle() {
- return null; // TODO
- } // getLogicalStyle()
-
- /**
- * setLogicalStyle
- * @param style TODO
- */
- public void setLogicalStyle(Style style) {
- // TODO
- } // setLogicalStyle()
-
- /**
- * getCharacterAttributes
- * @returns AttributeSet
- */
- public AttributeSet getCharacterAttributes() {
- return null; // TODO
- } // getCharacterAttributes()
-
- /**
- * setCharacterAttributes
- * @param attribute TODO
- * @param replace TODO
- */
- public void setCharacterAttributes(AttributeSet attribute,
- boolean replace) {
- // TODO
- } // setCharacterAttributes()
-
- /**
- * getParagraphAttributes
- * @returns AttributeSet
- */
- public AttributeSet getParagraphAttributes() {
- return null; // TODO
- } // getParagraphAttributes()
-
- /**
- * setParagraphAttributes
- * @param attribute TODO
- * @param replace TODO
- */
- public void setParagraphAttributes(AttributeSet attribute,
- boolean replace) {
- // TODO
- } // setParagraphAttributes()
-
- /**
- * getInputAttributes
- * @returns MutableAttributeSet
- */
- public MutableAttributeSet getInputAttributes() {
- return null; // TODO
- } // getInputAttributes()
-
- /**
- * getStyledEditorKit
- * @returns StyledEditorKit
- */
- protected final StyledEditorKit getStyledEditorKit() {
- return null; // TODO
- } // getStyledEditorKit()
-
- /**
- * createDefaultEditorKit
- * @returns EditorKit
- */
- protected EditorKit createDefaultEditorKit() {
- return null; // TODO
- } // createDefaultEditorKit()
-
- /**
- * setEditorKit
- * @param editor TODO
- */
- public final void setEditorKit(EditorKit editor) {
- // TODO
- } // setEditorKit()
-
- /**
- * paramString
- * @returns String
- */
- protected String paramString() {
- return null; // TODO
- } // paramString()
-
-
-} // JTextPane
+public class JTextPane
+ extends JEditorPane
+{
+ /**
+ * Creates a new <code>JTextPane</code> with a <code>null</code> document.
+ */
+ public JTextPane()
+ {
+ setEditorKit(createDefaultEditorKit());
+ setDocument(null);
+ }
+
+ /**
+ * Creates a new <code>JTextPane</code> and sets the specified
+ * <code>document</code>.
+ *
+ * @param document the content model to use
+ */
+ public JTextPane(StyledDocument document)
+ {
+ this();
+ setStyledDocument(document);
+ }
+
+ /**
+ * Returns the UI class ID. This is <code>TextPaneUI</code>.
+ *
+ * @return <code>TextPaneUI</code>
+ */
+ public String getUIClassID()
+ {
+ return "TextPaneUI";
+ }
+
+ /**
+ * Sets the content model for this <code>JTextPane</code>.
+ * <code>JTextPane</code> can only be used with {@link StyledDocument}s,
+ * if you try to set a different type of <code>Document</code>, an
+ * <code>IllegalArgumentException</code> is thrown.
+ *
+ * @param document the content model to set
+ *
+ * @throws IllegalArgumentException if <code>document</code> is not an
+ * instance of <code>StyledDocument</code>
+ *
+ * @see {@link #setStyledDocument}
+ */
+ public void setDocument(Document document)
+ {
+ if (document != null && !(document instanceof StyledDocument))
+ throw new IllegalArgumentException
+ ("JTextPane can only handle StyledDocuments");
+
+ setStyledDocument((StyledDocument) document);
+ }
+
+ /**
+ * Returns the {@link StyledDocument} that is the content model for
+ * this <code>JTextPane</code>. This is a typed wrapper for
+ * {@link #getDocument}.
+ *
+ * @return the content model of this <code>JTextPane</code>
+ */
+ public StyledDocument getStyledDocument()
+ {
+ return (StyledDocument) super.getDocument();
+ }
+
+ /**
+ * Sets the content model for this <code>JTextPane</code>.
+ *
+ * @param document the content model to set
+ */
+ public void setStyledDocument(StyledDocument document)
+ {
+ super.setDocument(document);
+ }
+
+ /**
+ * Replaces the currently selected text with the specified
+ * <code>content</code>. If there is no selected text, this results
+ * in a simple insertion at the current caret position. If there is
+ * no <code>content</code> specified, this results in the selection
+ * beeing deleted.
+ *
+ * @param content the text with which the selection is replaced
+ */
+ public void replaceSelection(String content)
+ {
+ Caret caret = getCaret();
+ StyledDocument doc = getStyledDocument();
+
+ int dot = caret.getDot();
+ int mark = caret.getMark();
+
+ // If content is empty delete selection.
+ if (content == null)
+ {
+ caret.setDot(dot);
+ return;
+ }
+
+ try
+ {
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+ int contentLength = content.length();
+
+ // Remove selected text.
+ if (dot != mark)
+ doc.remove(start, end - start);
+
+ // Insert new text.
+ doc.insertString(start, content, null);
+ // Set attributes for inserted text
+ doc.setCharacterAttributes(start, contentLength, getInputAttributes(),
+ true);
+
+ // Set dot to new position.
+ setCaretPosition(start + contentLength);
+ }
+ catch (BadLocationException e)
+ {
+ throw new AssertionError
+ ("No BadLocationException should be thrown here");
+ }
+ }
+
+ /**
+ * Inserts an AWT or Swing component into the text at the current caret
+ * position.
+ *
+ * @param component the component to be inserted
+ */
+ public void insertComponent(Component component)
+ {
+ // TODO: One space must be inserted here with attributes set to indicate
+ // that the component must be displayed here. Have to figure out the
+ // attributes.
+ }
+
+ /**
+ * Inserts an <code>Icon</code> into the text at the current caret position.
+ *
+ * @param icon the <code>Icon</code> to be inserted
+ */
+ public void insertIcon(Icon icon)
+ {
+ // TODO: One space must be inserted here with attributes set to indicate
+ // that the icon must be displayed here. Have to figure out the
+ // attributes.
+ }
+
+ /**
+ * Adds a style into the style hierarchy. Unspecified style attributes
+ * can be resolved in the <code>parent</code> style, if one is specified.
+ *
+ * While it is legal to add nameless styles (<code>nm == null</code),
+ * you must be aware that the client application is then responsible
+ * for managing the style hierarchy, since unnamed styles cannot be
+ * looked up by their name.
+ *
+ * @param nm the name of the style or <code>null</code> if the style should
+ * be unnamed
+ * @param parent the parent in which unspecified style attributes are
+ * resolved, or <code>null</code> if that is not necessary
+ *
+ * @return the newly created <code>Style</code>
+ */
+ public Style addStyle(String nm, Style parent)
+ {
+ return getStyledDocument().addStyle(nm, parent);
+ }
+
+ /**
+ * Removes a named <code>Style</code> from the style hierarchy.
+ *
+ * @param nm the name of the <code>Style</code> to be removed
+ */
+ public void removeStyle(String nm)
+ {
+ getStyledDocument().removeStyle(nm);
+ }
+
+ /**
+ * Looks up and returns a named <code>Style</code>.
+ *
+ * @param nm the name of the <code>Style</code>
+ *
+ * @return the found <code>Style</code> of <code>null</code> if no such
+ * <code>Style</code> exists
+ */
+ public Style getStyle(String nm)
+ {
+ return getStyledDocument().getStyle(nm);
+ }
+
+ /**
+ * Returns the logical style of the paragraph at the current caret position.
+ *
+ * @return the logical style of the paragraph at the current caret position
+ */
+ public Style getLogicalStyle()
+ {
+ return getStyledDocument().getLogicalStyle(getCaretPosition());
+ }
+
+ /**
+ * Sets the logical style for the paragraph at the current caret position.
+ *
+ * @param style the style to set for the current paragraph
+ */
+ public void setLogicalStyle(Style style)
+ {
+ getStyledDocument().setLogicalStyle(getCaretPosition(), style);
+ }
+
+ /**
+ * Returns the text attributes for the character at the current caret
+ * position.
+ *
+ * @return the text attributes for the character at the current caret
+ * position
+ */
+ public AttributeSet getCharacterAttributes()
+ {
+ StyledDocument doc = getStyledDocument();
+ Element el = doc.getCharacterElement(getCaretPosition());
+ return el.getAttributes();
+ }
+
+ /**
+ * Sets text attributes for the current selection. If there is no selection
+ * the text attributes are applied to newly inserted text
+ *
+ * @param attribute the text attributes to set
+ * @param replace if <code>true</code>, the attributes of the current
+ * selection are overridden, otherwise they are merged
+ *
+ * @see {@link #getInputAttributes}
+ */
+ public void setCharacterAttributes(AttributeSet attribute,
+ boolean replace)
+ {
+ int dot = getCaret().getDot();
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+ if (start == dot && end == dot)
+ // There is no selection, update insertAttributes instead
+ {
+ MutableAttributeSet inputAttributes =
+ getStyledEditorKit().getInputAttributes();
+ inputAttributes.addAttributes(attribute);
+ }
+ else
+ getStyledDocument().setCharacterAttributes(start, end - start, attribute,
+ replace);
+ }
+
+ /**
+ * Returns the text attributes of the paragraph at the current caret
+ * position.
+ *
+ * @return the attributes of the paragraph at the current caret position
+ */
+ public AttributeSet getParagraphAttributes()
+ {
+ StyledDocument doc = getStyledDocument();
+ Element el = doc.getParagraphElement(getCaretPosition());
+ return el.getAttributes();
+ }
+
+ /**
+ * Sets text attributes for the paragraph at the current selection.
+ * If there is no selection the text attributes are applied to
+ * the paragraph at the current caret position.
+ *
+ * @param attribute the text attributes to set
+ * @param replace if <code>true</code>, the attributes of the current
+ * selection are overridden, otherwise they are merged
+ */
+ public void setParagraphAttributes(AttributeSet attribute,
+ boolean replace)
+ {
+ // TODO
+ }
+
+ /**
+ * Returns the attributes that are applied to newly inserted text.
+ * This is a {@link MutableAttributeSet}, so you can easily modify these
+ * attributes.
+ *
+ * @return the attributes that are applied to newly inserted text
+ */
+ public MutableAttributeSet getInputAttributes()
+ {
+ return getStyledEditorKit().getInputAttributes();
+ }
+
+ /**
+ * Returns the {@link StyledEditorKit} that is currently used by this
+ * <code>JTextPane</code>.
+ *
+ * @return the current <code>StyledEditorKit</code> of this
+ * <code>JTextPane</code>
+ */
+ protected final StyledEditorKit getStyledEditorKit()
+ {
+ return (StyledEditorKit) getEditorKit();
+ }
+
+ /**
+ * Creates the default {@link EditorKit} that is used in
+ * <code>JTextPane</code>s. This is an instance of {@link StyledEditorKit}.
+ *
+ * @return the default {@link EditorKit} that is used in
+ * <code>JTextPane</code>s
+ */
+ protected EditorKit createDefaultEditorKit()
+ {
+ return new StyledEditorKit();
+ }
+
+ /**
+ * Sets the {@link EditorKit} to use for this <code>JTextPane</code>.
+ * <code>JTextPane</code>s can only handle {@link StyledEditorKit}s,
+ * if client programs try to set a different type of <code>EditorKit</code>
+ * then an IllegalArgumentException is thrown
+ *
+ * @param editor the <code>EditorKit</code> to set
+ *
+ * @throws IllegalArgumentException if <code>editor</code> is no
+ * <code>StyledEditorKit</code>
+ */
+ public final void setEditorKit(EditorKit editor)
+ {
+ if (!(editor instanceof StyledEditorKit))
+ throw new IllegalArgumentException
+ ("JTextPanes can only handle StyledEditorKits");
+ super.setEditorKit(editor);
+ }
+
+ /**
+ * Returns a param string that can be used for debugging.
+ *
+ * @return a param string that can be used for debugging.
+ */
+ protected String paramString()
+ {
+ return super.paramString(); // TODO
+ }
+}
diff --git a/javax/swing/JToggleButton.java b/javax/swing/JToggleButton.java
index d5fcdd76c..25d67f59e 100644
--- a/javax/swing/JToggleButton.java
+++ b/javax/swing/JToggleButton.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,6 +38,7 @@ exception statement from your version. */
package javax.swing;
+import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
@@ -133,19 +134,47 @@ public class JToggleButton extends AbstractButton implements Accessible
* Sets the pressed state of the button. The selected state
* of the button also changes follwing the button being pressed.
*
- * @param b true if the button is pressed down.
+ * @param p true if the button is pressed down.
*/
- public void setPressed(boolean b)
+ public void setPressed(boolean p)
{
+ // cannot change PRESSED state unless button is enabled
if (! isEnabled())
return;
- super.setPressed(b);
-
+ // if this call does not represent a CHANGE in state, then return
+ if ((p && isPressed()) || (!p && !isPressed()))
+ return;
+
+ // The JDK first fires events in the following order:
+ // 1. ChangeEvent for selected
+ // 2. ChangeEvent for pressed
+ // 3. ActionEvent
+ // So do we.
+
// setPressed(false) == mouse release on us,
// if we were armed, we flip the selected state.
- if (!b && isArmed())
- setSelected(! isSelected());
+ if (!p && isArmed())
+ {
+ setSelected(! isSelected());
+ }
+
+ // make the change
+ if (p)
+ stateMask = stateMask | PRESSED;
+ else
+ stateMask = stateMask & (~PRESSED);
+
+ // notify interested ChangeListeners
+ fireStateChanged();
+
+ if (!p && isArmed())
+ {
+ fireActionPerformed(new ActionEvent(this,
+ ActionEvent.ACTION_PERFORMED,
+ actionCommand));
+ }
+
}
}
@@ -242,11 +271,11 @@ public class JToggleButton extends AbstractButton implements Accessible
*/
public JToggleButton (String text, Icon icon, boolean selected)
{
- super(text, icon);
+ super();
+ init(text, icon);
setModel(new ToggleButtonModel());
model.setSelected(selected);
- model.setActionCommand("");
}
/**
@@ -287,7 +316,7 @@ public class JToggleButton extends AbstractButton implements Accessible
*/
protected String paramString()
{
- return "JToggleButton";
+ return super.paramString();
}
/**
diff --git a/javax/swing/JToolBar.java b/javax/swing/JToolBar.java
index 2b994a555..649919e06 100644
--- a/javax/swing/JToolBar.java
+++ b/javax/swing/JToolBar.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/JToolTip.java b/javax/swing/JToolTip.java
index 871f15cca..8d7747827 100644
--- a/javax/swing/JToolTip.java
+++ b/javax/swing/JToolTip.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 823c5b104..638f28ff3 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -1,6 +1,6 @@
-/* JTree.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
-
+/* JTree.java
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -35,7 +35,6 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.swing;
import java.awt.Dimension;
@@ -69,1715 +68,1762 @@ import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
-
-public class JTree extends JComponent
- implements Scrollable, Accessible
+public class JTree
+ extends JComponent
+ implements Scrollable, Accessible
{
- /**
- * Listens to the model of the JTree and updates the property
- * <code>expandedState</code> if nodes are removed or changed.
- */
- protected class TreeModelHandler
- implements TreeModelListener
- {
-
- /**
- * Creates a new instance of TreeModelHandler.
- */
- protected TreeModelHandler()
- {
- }
-
- /**
- * Notifies when a node has changed in some ways. This does not include
- * that a node has changed its location or changed it's children. It
- * only means that some attributes of the node have changed that might
- * affect its presentation.
- *
- * This method is called after the actual change occured.
- *
- * @param ev the TreeModelEvent describing the change
- */
- public void treeNodesChanged(TreeModelEvent ev)
- {
- // nothing to do here
- }
-
- /**
- * Notifies when a node is inserted into the tree.
- *
- * This method is called after the actual change occured.
- *
- * @param ev the TreeModelEvent describing the change
- */
- public void treeNodesInserted(TreeModelEvent ev)
- {
- // nothing to do here
- }
-
- /**
- * Notifies when a node is removed from the tree.
- *
- * This method is called after the actual change occured.
- *
- * @param ev the TreeModelEvent describing the change
- */
- public void treeNodesRemoved(TreeModelEvent ev)
- {
- // TODO: The API docs suggest that this method should do something
- // but I cannot really see what has to be done here ...
- }
-
- /**
- * Notifies when the structure of the tree is changed.
- *
- * This method is called after the actual change occured.
- *
- * @param ev the TreeModelEvent describing the change
- */
- public void treeStructureChanged(TreeModelEvent ev)
- {
- // set state of new path
- TreePath path = ev.getTreePath();
- setExpandedState(path, isExpanded(path));
- }
- } // TreeModelHandler
-
- /**
- * This redirects TreeSelectionEvents and rewrites the source of it
- * to be this JTree. This is typically done when the tree model
- * generates an event, but the JTree object associated with that model
- * should be listed as the actual source of the event.
- */
- protected class TreeSelectionRedirector
- implements TreeSelectionListener, Serializable
- {
- /** The serial version UID. */
- private static final long serialVersionUID = -3505069663646241664L;
-
- /**
- * Creates a new instance of TreeSelectionRedirector
- */
- protected TreeSelectionRedirector()
- {
- }
-
- /**
- * Notifies when the tree selection changes.
- *
- * @param ev the TreeSelectionEvent that describes the change
- */
- public void valueChanged(TreeSelectionEvent ev)
- {
- TreeSelectionEvent rewritten =
- (TreeSelectionEvent) ev.cloneWithSource(JTree.this);
- fireValueChanged(rewritten);
- }
- } // TreeSelectionRedirector
-
- /**
- * A TreeModel that does not allow anything to be selected.
- */
- protected static class EmptySelectionModel
- extends DefaultTreeSelectionModel
- {
- /** The serial version UID. */
- private static final long serialVersionUID = -5815023306225701477L;
-
- /**
- * The shared instance of this model.
- */
- protected static final EmptySelectionModel sharedInstance =
- new EmptySelectionModel();
-
- /**
- * Creates a new instance of EmptySelectionModel.
- */
- protected EmptySelectionModel()
- {
- }
-
- /**
- * Returns the shared instance of EmptySelectionModel.
- *
- * @return the shared instance of EmptySelectionModel
- */
- public static EmptySelectionModel sharedInstance()
- {
- return sharedInstance;
- }
-
- /**
- * This catches attempts to set a selection and sets nothing
- * instead.
- *
- * @param paths not used here
- */
- public void setSelectionPaths(TreePath[] paths)
- {
- // we don't allow selections in this class
- }
-
- /**
- * This catches attempts to add something to the selection.
- *
- * @param paths not used here
- */
- public void addSelectionPaths(TreePath[] paths)
- {
- // we don't allow selections in this class
- }
-
- /**
- * This catches attempts to remove something from the selection.
- *
- * @param paths not used here
- */
- public void removeSelectionPaths(TreePath[] paths)
- {
- // we don't allow selections in this class
- }
- }// EmptySelectionModel
-
- private static final long serialVersionUID = 7559816092864483649L;
-
- public static final String CELL_EDITOR_PROPERTY = "cellEditor";
- public static final String CELL_RENDERER_PROPERTY = "cellRenderer";
- public static final String EDITABLE_PROPERTY = "editable";
- public static final String INVOKES_STOP_CELL_EDITING_PROPERTY = "invokesStopCellEditing";
- public static final String LARGE_MODEL_PROPERTY = "largeModel";
- public static final String ROOT_VISIBLE_PROPERTY = "rootVisible";
- public static final String ROW_HEIGHT_PROPERTY = "rowHeight";
- public static final String SCROLLS_ON_EXPAND_PROPERTY = "scrollsOnExpand";
- public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
- public static final String SHOWS_ROOT_HANDLES_PROPERTY = "showsRootHandles";
- public static final String TOGGLE_CLICK_COUNT_PROPERTY = "toggleClickCount";
- public static final String TREE_MODEL_PROPERTY = "model";
- public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount";
-
- /** @since 1.3 */
- public static final String ANCHOR_SELECTION_PATH_PROPERTY = "anchorSelectionPath";
- /** @since 1.3 */
- public static final String LEAD_SELECTION_PATH_PROPERTY = "leadSelectionPath";
- /** @since 1.3 */
- public static final String EXPANDS_SELECTED_PATHS_PROPERTY = "expandsSelectedPaths";
-
- private static final Object EXPANDED = new Object();
- private static final Object COLLAPSED = new Object();
-
- private boolean dragEnabled;
- private boolean expandsSelectedPaths;
- private TreePath anchorSelectionPath;
- private TreePath leadSelectionPath;
-
- /*
- * This contains the state of all nodes in the tree. Al/ entries map the
- * TreePath of a note to to its state. Valid states are EXPANDED and
- * COLLAPSED. Nodes not in this Hashtable are assumed state COLLAPSED.
- */
- private Hashtable nodeStates;
-
- protected transient TreeCellEditor cellEditor;
- protected transient TreeCellRenderer cellRenderer;
- protected boolean editable;
- protected boolean invokesStopCellEditing;
- protected boolean largeModel;
- protected boolean rootVisible;
- protected int rowHeight;
- protected boolean scrollsOnExpand;
- protected transient TreeSelectionModel selectionModel;
- protected boolean showsRootHandles;
- protected int toggleClickCount;
- protected transient TreeModel treeModel;
- protected int visibleRowCount;
-
- /**
- * Handles TreeModelEvents to update the expandedState.
- */
- protected transient TreeModelListener treeModelListener;
-
- /**
- * Redirects TreeSelectionEvents so that the source is this JTree.
- */
- protected TreeSelectionRedirector selectionRedirector =
- new TreeSelectionRedirector();
-
- /**
- * Creates a new <code>JTree</code> object.
- */
- public JTree()
- {
- this(createTreeModel(null));
- }
-
- /**
- * Creates a new <code>JTree</code> object.
- *
- * @param value the initial nodes in the tree
- */
- public JTree(Hashtable value)
- {
- this(createTreeModel(value));
- }
-
- /**
- * Creates a new <code>JTree</code> object.
- *
- * @param value the initial nodes in the tree
- */
- public JTree(Object[] value)
- {
- this(createTreeModel(value));
- }
-
- /**
- * Creates a new <code>JTree</code> object.
- *
- * @param model the model to use
- */
- public JTree(TreeModel model)
- {
- setModel(model);
- setSelectionModel(EmptySelectionModel.sharedInstance());
- selectionModel.addTreeSelectionListener(selectionRedirector);
- setCellRenderer(new DefaultTreeCellRenderer());
- updateUI();
- }
-
- /**
- * Creates a new <code>JTree</code> object.
- *
- * @param root the root node
- */
- public JTree(TreeNode root)
- {
- this(root, false);
- }
-
- /**
- * Creates a new <code>JTree</code> object.
- *
- * @param root the root node
- * @param asksAllowChildren if false, all nodes without children are leaf nodes.
- * If true, only nodes that do not allow children are leaf nodes.
- */
- public JTree(TreeNode root, boolean asksAllowChildren)
- {
- this(new DefaultTreeModel(root, asksAllowChildren));
- }
-
- /**
- * Creates a new <code>JTree</code> object.
- *
- * @param value the initial nodes in the tree
- */
- public JTree(Vector value)
- {
- this(createTreeModel(value));
- }
-
- public static class DynamicUtilTreeNode
- extends DefaultMutableTreeNode
- {
- protected Object childValue;
- protected boolean loadedChildren;
-
- /**
- * Currently not set or used by this class.
- * It might be set and used in later versions of this class.
- */
- protected boolean hasChildren;
-
- public DynamicUtilTreeNode(Object value,
- Object children)
- {
- super(value);
- childValue = children;
- loadedChildren = false;
- }
-
- public int getChildCount()
- {
- loadChildren();
- return super.getChildCount();
- }
-
- protected void loadChildren()
- {
- if (!loadedChildren)
- {
- createChildren(this, childValue);
- loadedChildren = true;
- }
- }
-
- public Enumeration children()
- {
- loadChildren();
- return super.children();
- }
-
- /**
- * Returns the child node at position <code>pos</code>. Subclassed here
- * to load the children if necessary.
- *
- * @param pos the position of the child node to fetch
- *
- * @return the childnode at the specified position
- */
- public TreeNode getChildAt(int pos)
- {
- loadChildren();
- return super.getChildAt(pos);
- }
-
- public boolean isLeaf()
- {
- return (childValue == null ||
- !(childValue instanceof Hashtable
- || childValue instanceof Vector
- || childValue.getClass().isArray()));
- }
-
- public static void createChildren(DefaultMutableTreeNode parent,
- Object children)
- {
- if (children instanceof Hashtable)
- {
- Hashtable tab = (Hashtable) children;
- Enumeration e = tab.keys();
- while (e.hasMoreElements())
- {
- Object key = e.nextElement();
- Object val = tab.get(key);
- parent.add(new DynamicUtilTreeNode(key, val));
- }
- }
- else if (children instanceof Vector)
- {
- Iterator i = ((Vector)children).iterator();
- while (i.hasNext())
- {
- Object n = i.next();
- parent.add(new DynamicUtilTreeNode(n,n));
- }
- }
- else if (children.getClass().isArray())
- {
- Object[] arr = (Object[]) children;
- for (int i = 0; i < arr.length; ++i)
- parent.add(new DynamicUtilTreeNode(arr[i], arr[i]));
- }
- }
- }
-
- public int getRowForPath(TreePath path)
- {
- TreeUI ui = getUI();
-
- if (ui != null)
- return ui.getRowForPath(this, path);
-
- return -1;
- }
-
- public TreePath getPathForRow(int row)
- {
- TreeUI ui = getUI();
- return ui != null ? ui.getPathForRow(this, row) : null;
- }
-
- protected TreePath[] getPathBetweenRows(int index0, int index1)
- {
- TreeUI ui = getUI();
-
- if (ui == null)
- return null;
-
- int minIndex = Math.min(index0, index1);
- int maxIndex = Math.max(index0, index1);
- TreePath[] paths = new TreePath[maxIndex - minIndex + 1];
-
- for (int i = minIndex; i <= maxIndex; ++i)
- paths[i - minIndex] = ui.getPathForRow(this, i);
-
- return paths;
- }
-
- /**
- * Creates a new <code>TreeModel</code> object.
- *
- * @param value the values stored in the model
- */
- protected static TreeModel createTreeModel(Object value)
- {
- return new DefaultTreeModel(new DynamicUtilTreeNode(value, value));
- }
-
- /**
- * Return the UI associated with this <code>JTree</code> object.
- *
- * @return the associated <code>TreeUI</code> object
- */
- public TreeUI getUI()
- {
- return (TreeUI) ui;
- }
-
- /**
- * Sets the UI associated with this <code>JTree</code> object.
- *
- * @param ui the <code>TreeUI</code> to associate
- */
- public void setUI(TreeUI ui)
- {
- super.setUI(ui);
- }
-
- /**
- * This method resets the UI used to the Look and Feel defaults..
- */
- public void updateUI()
- {
- setUI((TreeUI) UIManager.getUI(this));
- revalidate();
- repaint();
- }
-
- /**
- * This method returns the String ID of the UI class of Separator.
- *
- * @return The UI class' String ID.
- */
- public String getUIClassID()
- {
- return "TreeUI";
- }
-
- /**
- * Gets the AccessibleContext associated with this <code>JToggleButton</code>.
- *
- * @return the associated context
- */
- public AccessibleContext getAccessibleContext()
- {
- return null;
- }
-
- /**
- * Returns the preferred viewport size..
- *
- * @return the preferred size
- */
- public Dimension getPreferredScrollableViewportSize()
- {
- return null;
- }
-
- public int getScrollableUnitIncrement(Rectangle visibleRect,
- int orientation, int direction)
- {
- return 1;
- }
-
- public int getScrollableBlockIncrement(Rectangle visibleRect,
- int orientation, int direction)
- {
- return 1;
- }
-
- public boolean getScrollableTracksViewportWidth()
- {
- return false;
- }
-
- public boolean getScrollableTracksViewportHeight()
- {
- return false;
- }
-
- /**
- * Adds a <code>TreeExpansionListener</code> object to the tree.
- *
- * @param listener the listener to add
- */
- public void addTreeExpansionListener(TreeExpansionListener listener)
- {
- listenerList.add(TreeExpansionListener.class, listener);
- }
-
- /**
- * Removes a <code>TreeExpansionListener</code> object from the tree.
- *
- * @param listener the listener to remove
- */
- public void removeTreeExpansionListener(TreeExpansionListener listener)
- {
- listenerList.remove(TreeExpansionListener.class, listener);
- }
-
- /**
- * Returns all added <code>TreeExpansionListener</code> objects.
- *
- * @return an array of listeners
- */
- public TreeExpansionListener[] getTreeExpansionListeners()
- {
- return (TreeExpansionListener[]) getListeners(TreeExpansionListener.class);
- }
-
- /**
- * Notifies all listeners that the tree was collapsed.
- *
- * @param path the path to the node that was collapsed
- */
- public void fireTreeCollapsed(TreePath path)
- {
- TreeExpansionEvent event = new TreeExpansionEvent(this, path);
- TreeExpansionListener[] listeners = getTreeExpansionListeners();
-
- for (int index = 0; index < listeners.length; ++index)
- listeners[index].treeCollapsed(event);
- }
-
- /**
- * Notifies all listeners that the tree was expanded.
- *
- * @param path the path to the node that was expanded
- */
- public void fireTreeExpanded(TreePath path)
- {
- TreeExpansionEvent event = new TreeExpansionEvent(this, path);
- TreeExpansionListener[] listeners = getTreeExpansionListeners();
-
- for (int index = 0; index < listeners.length; ++index)
- listeners[index].treeExpanded(event);
- }
-
- /**
- * Adds a <code>TreeSelctionListener</code> object to the tree.
- *
- * @param listener the listener to add
- */
- public void addTreeSelectionListener(TreeSelectionListener listener)
- {
- listenerList.add(TreeSelectionListener.class, listener);
- }
-
- /**
- * Removes a <code>TreeSelectionListener</code> object from the tree.
- *
- * @param listener the listener to remove
- */
- public void removeTreeSelectionListener(TreeSelectionListener listener)
- {
- listenerList.remove(TreeSelectionListener.class, listener);
- }
-
- /**
- * Returns all added <code>TreeSelectionListener</code> objects.
- *
- * @return an array of listeners
- */
- public TreeSelectionListener[] getTreeSelectionListeners()
- {
- return (TreeSelectionListener[]) getListeners(TreeSelectionListener.class);
- }
-
- /**
- * Notifies all listeners when the selection of the tree changed.
- *
- * @param event the event to send
- */
- protected void fireValueChanged(TreeSelectionEvent event)
- {
- TreeSelectionListener[] listeners = getTreeSelectionListeners();
-
- for (int index = 0; index < listeners.length; ++index)
- listeners[index].valueChanged(event);
- }
-
- /**
- * Adds a <code>TreeWillExpandListener</code> object to the tree.
- *
- * @param listener the listener to add
- */
- public void addTreeWillExpandListener(TreeWillExpandListener listener)
- {
- listenerList.add(TreeWillExpandListener.class, listener);
- }
-
- /**
- * Removes a <code>TreeWillExpandListener</code> object from the tree.
- *
- * @param listener the listener to remove
- */
- public void removeTreeWillExpandListener(TreeWillExpandListener listener)
- {
- listenerList.remove(TreeWillExpandListener.class, listener);
- }
-
- /**
- * Returns all added <code>TreeWillExpandListener</code> objects.
- *
- * @return an array of listeners
- */
- public TreeWillExpandListener[] getTreeWillExpandListeners()
- {
- return (TreeWillExpandListener[]) getListeners(TreeWillExpandListener.class);
- }
-
- /**
- * Notifies all listeners that the tree will collapse.
- *
- * @param path the path to the node that will collapse
- */
- public void fireTreeWillCollapse(TreePath path)
- throws ExpandVetoException
- {
- TreeExpansionEvent event = new TreeExpansionEvent(this, path);
- TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
-
- for (int index = 0; index < listeners.length; ++index)
- listeners[index].treeWillCollapse(event);
- }
-
- /**
- * Notifies all listeners that the tree will expand.
- *
- * @param path the path to the node that will expand
- */
- public void fireTreeWillExpand(TreePath path)
- throws ExpandVetoException
- {
- TreeExpansionEvent event = new TreeExpansionEvent(this, path);
- TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
-
- for (int index = 0; index < listeners.length; ++index)
- listeners[index].treeWillExpand(event);
- }
-
- /**
- * Returns the model of this <code>JTree</code> object.
- *
- * @return the associated <code>TreeModel</code>
- */
- public TreeModel getModel()
- {
- return treeModel;
- }
-
- /**
- * Sets the model to use in <code>JTree</code>.
- *
- * @param model the <code>TreeModel</code> to use
- */
- public void setModel(TreeModel model)
- {
- if (treeModel == model)
- return;
-
- TreeModel oldValue = treeModel;
- treeModel = model;
- firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
-
- // add treeModelListener to the new model
- if (treeModelListener == null)
- treeModelListener = createTreeModelListener();
- model.addTreeModelListener(treeModelListener);
- }
-
- /**
- * Checks if this <code>JTree</code> object is editable.
- *
- * @return <code>true</code> if this tree object is editable,
- * <code>false</code> otherwise
- */
- public boolean isEditable()
- {
- return editable;
- }
-
- /**
- * Sets the <code>editable</code> property.
- *
- * @param flag <code>true</code> to make this tree object editable,
- * <code>false</code> otherwise
- */
- public void setEditable(boolean flag)
- {
- if (editable == flag)
- return;
-
- boolean oldValue = editable;
- editable = flag;
- firePropertyChange(EDITABLE_PROPERTY, oldValue, editable);
- }
-
- /**
- * Checks if the root element is visible.
- *
- * @return <code>true</code> if the root element is visible,
- * <code>false</code> otherwise
- */
- public boolean isRootVisible()
- {
- return rootVisible;
- }
-
- public void setRootVisible(boolean flag)
- {
- if (rootVisible == flag)
- return;
-
- boolean oldValue = rootVisible;
- rootVisible = flag;
- firePropertyChange(ROOT_VISIBLE_PROPERTY, oldValue, flag);
- }
-
- public boolean getShowsRootHandles()
- {
- return showsRootHandles;
- }
-
- public void setShowsRootHandles(boolean flag)
- {
- if (showsRootHandles == flag)
- return;
-
- boolean oldValue = showsRootHandles;
- showsRootHandles = flag;
- firePropertyChange(SHOWS_ROOT_HANDLES_PROPERTY, oldValue, flag);
- }
-
- public TreeCellEditor getCellEditor()
- {
- return cellEditor;
- }
-
- public void setCellEditor(TreeCellEditor editor)
- {
- if (cellEditor == editor)
- return;
-
- TreeCellEditor oldValue = cellEditor;
- cellEditor = editor;
- firePropertyChange(CELL_EDITOR_PROPERTY, oldValue, editor);
- }
-
- public TreeCellRenderer getCellRenderer()
- {
- return cellRenderer;
- }
-
- public void setCellRenderer(TreeCellRenderer newRenderer)
- {
- if (cellRenderer == newRenderer)
- return;
-
- TreeCellRenderer oldValue = cellRenderer;
- cellRenderer = newRenderer;
- firePropertyChange(CELL_RENDERER_PROPERTY, oldValue, newRenderer);
- }
-
- public TreeSelectionModel getSelectionModel()
- {
- return selectionModel;
- }
-
- public void setSelectionModel(TreeSelectionModel model)
- {
- if (selectionModel == model)
- return;
-
- TreeSelectionModel oldValue = selectionModel;
- selectionModel = model;
- firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, model);
- }
-
- public int getVisibleRowCount()
- {
- return visibleRowCount;
- }
-
- public void setVisibleRowCount(int rows)
- {
- if (visibleRowCount == rows)
- return;
-
- int oldValue = visibleRowCount;
- visibleRowCount = rows;
- firePropertyChange(VISIBLE_ROW_COUNT_PROPERTY, oldValue, rows);
- }
-
- public boolean isLargeModel()
- {
- return largeModel;
- }
-
- public void setLargeModel(boolean large)
- {
- if (largeModel == large)
- return;
-
- boolean oldValue = largeModel;
- largeModel = large;
- firePropertyChange(LARGE_MODEL_PROPERTY, oldValue, large);
- }
-
- public int getRowHeight()
- {
- return rowHeight;
- }
-
- public void setRowHeight(int height)
- {
- if (rowHeight == height)
- return;
-
- int oldValue = rowHeight;
- rowHeight = height;
- firePropertyChange(ROW_HEIGHT_PROPERTY, oldValue, height);
- }
-
- public boolean isFixedRowHeight()
- {
- return rowHeight > 0;
- }
-
- public boolean getInvokesStopCellEditing()
- {
- return invokesStopCellEditing;
- }
-
- public void setInvokesStopCellEditing(boolean invoke)
- {
- if (invokesStopCellEditing == invoke)
- return;
-
- boolean oldValue = invokesStopCellEditing;
- invokesStopCellEditing = invoke;
- firePropertyChange(INVOKES_STOP_CELL_EDITING_PROPERTY, oldValue, invoke);
- }
-
- /**
- * @since 1.3
- */
- public int getToggleClickCount()
- {
- return toggleClickCount;
- }
-
- /**
- * @since 1.3
- */
- public void setToggleClickCount(int count)
- {
- if (toggleClickCount == count)
- return;
-
- int oldValue = toggleClickCount;
- toggleClickCount = count;
- firePropertyChange(TOGGLE_CLICK_COUNT_PROPERTY, oldValue, count);
- }
-
- public void scrollPathToVisible(TreePath path)
- {
- if (path == null)
- return;
-
- Rectangle rect = getPathBounds(path);
-
- if (rect == null)
- return;
-
- scrollRectToVisible(rect);
- }
-
- public void scrollRowToVisible(int row)
- {
- scrollPathToVisible(getPathForRow(row));
- }
-
- public boolean getScrollsOnExpand()
- {
- return scrollsOnExpand;
- }
-
- public void setScrollsOnExpand(boolean scroll)
- {
- if (scrollsOnExpand == scroll)
- return;
-
- boolean oldValue = scrollsOnExpand;
- scrollsOnExpand = scroll;
- firePropertyChange(SCROLLS_ON_EXPAND_PROPERTY, oldValue, scroll);
- }
-
- public void setSelectionPath(TreePath path)
- {
- selectionModel.setSelectionPath(path);
- }
-
- public void setSelectionPaths(TreePath[] paths)
- {
- selectionModel.setSelectionPaths(paths);
- }
-
- public void setSelectionRow(int row)
- {
- TreePath path = getPathForRow(row);
-
- if (path != null)
- selectionModel.setSelectionPath(path);
- }
-
- public void setSelectionRows(int[] rows)
- {
- // Make sure we have an UI so getPathForRow() does not return null.
- if (rows == null || getUI() == null)
- return;
-
- TreePath[] paths = new TreePath[rows.length];
-
- for (int i = rows.length - 1; i >= 0; --i)
- paths[i] = getPathForRow(rows[i]);
-
- setSelectionPaths(paths);
- }
-
- public void setSelectionInterval(int index0, int index1)
- {
- TreePath[] paths = getPathBetweenRows(index0, index1);
-
- if (paths != null)
- setSelectionPaths(paths);
- }
-
- public void addSelectionPath(TreePath path)
- {
- selectionModel.addSelectionPath(path);
- }
-
- public void addSelectionPaths(TreePath[] paths)
- {
- selectionModel.addSelectionPaths(paths);
- }
-
- public void addSelectionRow(int row)
- {
- TreePath path = getPathForRow(row);
-
- if (path != null)
- selectionModel.addSelectionPath(path);
- }
-
- public void addSelectionRows(int[] rows)
- {
- // Make sure we have an UI so getPathForRow() does not return null.
- if (rows == null || getUI() == null)
- return;
-
- TreePath[] paths = new TreePath[rows.length];
-
- for (int i = rows.length - 1; i >= 0; --i)
- paths[i] = getPathForRow(rows[i]);
-
- addSelectionPaths(paths);
- }
-
- public void addSelectionInterval(int index0, int index1)
- {
- TreePath[] paths = getPathBetweenRows(index0, index1);
-
- if (paths != null)
- addSelectionPaths(paths);
- }
-
- public void removeSelectionPath(TreePath path)
- {
- selectionModel.removeSelectionPath(path);
- }
-
- public void removeSelectionPaths(TreePath[] paths)
- {
- selectionModel.removeSelectionPaths(paths);
- }
-
- public void removeSelectionRow(int row)
- {
- TreePath path = getPathForRow(row);
-
- if (path != null)
- selectionModel.removeSelectionPath(path);
- }
-
- public void removeSelectionRows(int[] rows)
- {
- // Make sure we have an UI so getPathForRow() does not return null.
- if (rows == null || getUI() == null)
- return;
-
- TreePath[] paths = new TreePath[rows.length];
-
- for (int i = rows.length - 1; i >= 0; --i)
- paths[i] = getPathForRow(rows[i]);
-
- removeSelectionPaths(paths);
- }
-
- public void removeSelectionInterval(int index0, int index1)
- {
- TreePath[] paths = getPathBetweenRows(index0, index1);
-
- if (paths != null)
- removeSelectionPaths(paths);
- }
-
- public void clearSelection()
- {
- selectionModel.clearSelection();
- }
-
- public TreePath getLeadSelectionPath()
- {
- return leadSelectionPath;
- }
-
- /**
- * @since 1.3
- */
- public void setLeadSelectionPath(TreePath path)
- {
- if (leadSelectionPath == path)
- return;
-
- TreePath oldValue = leadSelectionPath;
- leadSelectionPath = path;
- firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, path);
- }
-
- /**
- * @since 1.3
- */
- public TreePath getAnchorSelectionPath()
- {
- return anchorSelectionPath;
- }
-
- /**
- * @since 1.3
- */
- public void setAnchorSelectionPath(TreePath path)
- {
- if (anchorSelectionPath == path)
- return;
-
- TreePath oldValue = anchorSelectionPath;
- anchorSelectionPath = path;
- firePropertyChange(ANCHOR_SELECTION_PATH_PROPERTY, oldValue, path);
- }
-
- public int getLeadSelectionRow()
- {
- return selectionModel.getLeadSelectionRow();
- }
-
- public int getMaxSelectionRow()
- {
- return selectionModel.getMaxSelectionRow();
- }
-
- public int getMinSelectionRow()
- {
- return selectionModel.getMinSelectionRow();
- }
-
- public int getSelectionCount()
- {
- return selectionModel.getSelectionCount();
- }
-
- public TreePath getSelectionPath()
- {
- return selectionModel.getSelectionPath();
- }
-
- public TreePath[] getSelectionPaths()
- {
- return selectionModel.getSelectionPaths();
- }
-
- public int[] getSelectionRows()
- {
- return selectionModel.getSelectionRows();
- }
-
- public boolean isPathSelected(TreePath path)
- {
- return selectionModel.isPathSelected(path);
- }
-
- public boolean isRowSelected(int row)
- {
- return selectionModel.isRowSelected(row);
- }
-
- public boolean isSelectionEmpty()
- {
- return selectionModel.isSelectionEmpty();
- }
-
- /**
- * Return the value of the <code>dragEnabled</code> property.
- *
- * @return the value
- *
- * @since 1.4
- */
- public boolean getDragEnabled()
- {
- return dragEnabled;
- }
-
- /**
- * Set the <code>dragEnabled</code> property.
- *
- * @param enabled new value
- *
- * @since 1.4
- */
- public void setDragEnabled(boolean enabled)
- {
- dragEnabled = enabled;
- }
-
- public int getRowCount()
- {
- TreeUI ui = getUI();
-
- if (ui != null)
- return ui.getRowCount(this);
-
- return 0;
- }
-
- public void collapsePath(TreePath path)
- {
- setExpandedState(path, false);
- }
-
- public void collapseRow(int row)
- {
- if (row < 0 || row >= getRowCount())
- return;
-
- TreePath path = getPathForRow(row);
-
- if (path != null)
- collapsePath(path);
- }
-
- public void expandPath(TreePath path)
- {
- // Don't expand if last path component is a leaf node.
- if ((path == null)
- || (treeModel.isLeaf(path.getLastPathComponent())))
- return;
-
- setExpandedState(path, true);
- }
-
- public void expandRow(int row)
- {
- if (row < 0 || row >= getRowCount())
- return;
-
- TreePath path = getPathForRow(row);
-
- if (path != null)
- expandPath(path);
- }
-
- public boolean isCollapsed(TreePath path)
- {
- return ! isExpanded(path);
- }
-
- public boolean isCollapsed(int row)
- {
- if (row < 0 || row >= getRowCount())
- return false;
-
- TreePath path = getPathForRow(row);
-
- if (path != null)
- return isCollapsed(path);
-
- return false;
- }
-
- public boolean isExpanded(TreePath path)
- {
- if (path == null)
- return false;
-
- Object state = nodeStates.get(path);
-
- if ((state == null) || (state != EXPANDED))
- return false;
-
- TreePath parent = path.getParentPath();
-
- if (parent != null)
- return isExpanded(parent);
-
- return true;
- }
-
- public boolean isExpanded(int row)
- {
- if (row < 0 || row >= getRowCount())
- return false;
-
- TreePath path = getPathForRow(row);
-
- if (path != null)
- return isExpanded(path);
-
- return false;
- }
-
- /**
- * @since 1.3
- */
- public boolean getExpandsSelectedPaths()
- {
- return expandsSelectedPaths;
- }
-
- /**
- * @since 1.3
- */
- public void setExpandsSelectedPaths(boolean flag)
- {
- if (expandsSelectedPaths == flag)
- return;
-
- boolean oldValue = expandsSelectedPaths;
- expandsSelectedPaths = flag;
- firePropertyChange(EXPANDS_SELECTED_PATHS_PROPERTY, oldValue, flag);
- }
-
- public Rectangle getPathBounds(TreePath path)
- {
- TreeUI ui = getUI();
-
- if (ui == null)
- return null;
-
- return ui.getPathBounds(this, path);
- }
-
- public Rectangle getRowBounds(int row)
- {
- TreePath path = getPathForRow(row);
+ /**
+ * Listens to the model of the JTree and updates the property
+ * <code>expandedState</code> if nodes are removed or changed.
+ */
+ protected class TreeModelHandler
+ implements
+ TreeModelListener
+ {
+
+ /**
+ * Creates a new instance of TreeModelHandler.
+ */
+ protected TreeModelHandler()
+ {
+ }
+
+ /**
+ * Notifies when a node has changed in some ways. This does not include
+ * that a node has changed its location or changed it's children. It
+ * only means that some attributes of the node have changed that might
+ * affect its presentation.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeNodesChanged(TreeModelEvent ev)
+ {
+ // nothing to do here
+ }
+
+ /**
+ * Notifies when a node is inserted into the tree.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeNodesInserted(TreeModelEvent ev)
+ {
+ // nothing to do here
+ }
+
+ /**
+ * Notifies when a node is removed from the tree.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeNodesRemoved(TreeModelEvent ev)
+ {
+ // TODO: The API docs suggest that this method should do something
+ // but I cannot really see what has to be done here ...
+ }
+
+ /**
+ * Notifies when the structure of the tree is changed.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeStructureChanged(TreeModelEvent ev)
+ {
+ // set state of new path
+ TreePath path = ev.getTreePath();
+ setExpandedState(path, isExpanded(path));
+ }
+ } // TreeModelHandler
+
+ /**
+ * This redirects TreeSelectionEvents and rewrites the source of it to be
+ * this JTree. This is typically done when the tree model generates an
+ * event, but the JTree object associated with that model should be listed
+ * as the actual source of the event.
+ */
+ protected class TreeSelectionRedirector
+ implements
+ TreeSelectionListener,
+ Serializable
+ {
+ /** The serial version UID. */
+ private static final long serialVersionUID = -3505069663646241664L;
+
+ /**
+ * Creates a new instance of TreeSelectionRedirector
+ */
+ protected TreeSelectionRedirector()
+ {
+ }
+
+ /**
+ * Notifies when the tree selection changes.
+ *
+ * @param ev the TreeSelectionEvent that describes the change
+ */
+ public void valueChanged(TreeSelectionEvent ev)
+ {
+ TreeSelectionEvent rewritten = (TreeSelectionEvent) ev
+ .cloneWithSource(JTree.this);
+ fireValueChanged(rewritten);
+ JTree.this.repaint();
+ }
+ } // TreeSelectionRedirector
+
+ /**
+ * A TreeModel that does not allow anything to be selected.
+ */
+ protected static class EmptySelectionModel
+ extends
+ DefaultTreeSelectionModel
+ {
+ /** The serial version UID. */
+ private static final long serialVersionUID = -5815023306225701477L;
+
+ /**
+ * The shared instance of this model.
+ */
+ protected static final EmptySelectionModel sharedInstance = new EmptySelectionModel();
+
+ /**
+ * Creates a new instance of EmptySelectionModel.
+ */
+ protected EmptySelectionModel()
+ {
+ }
+
+ /**
+ * Returns the shared instance of EmptySelectionModel.
+ *
+ * @return the shared instance of EmptySelectionModel
+ */
+ public static EmptySelectionModel sharedInstance()
+ {
+ return sharedInstance;
+ }
+
+ /**
+ * This catches attempts to set a selection and sets nothing instead.
+ *
+ * @param paths not used here
+ */
+ public void setSelectionPaths(TreePath[] paths)
+ {
+ // we don't allow selections in this class
+ }
+
+ /**
+ * This catches attempts to add something to the selection.
+ *
+ * @param paths not used here
+ */
+ public void addSelectionPaths(TreePath[] paths)
+ {
+ // we don't allow selections in this class
+ }
+
+ /**
+ * This catches attempts to remove something from the selection.
+ *
+ * @param paths not used here
+ */
+ public void removeSelectionPaths(TreePath[] paths)
+ {
+ // we don't allow selections in this class
+ }
+ }// EmptySelectionModel
+
+ private static final long serialVersionUID = 7559816092864483649L;
+ public static final String CELL_EDITOR_PROPERTY = "cellEditor";
+ public static final String CELL_RENDERER_PROPERTY = "cellRenderer";
+ public static final String EDITABLE_PROPERTY = "editable";
+ public static final String INVOKES_STOP_CELL_EDITING_PROPERTY = "invokesStopCellEditing";
+ public static final String LARGE_MODEL_PROPERTY = "largeModel";
+ public static final String ROOT_VISIBLE_PROPERTY = "rootVisible";
+ public static final String ROW_HEIGHT_PROPERTY = "rowHeight";
+ public static final String SCROLLS_ON_EXPAND_PROPERTY = "scrollsOnExpand";
+ public static final String SELECTION_MODEL_PROPERTY = "selectionModel";
+ public static final String SHOWS_ROOT_HANDLES_PROPERTY = "showsRootHandles";
+ public static final String TOGGLE_CLICK_COUNT_PROPERTY = "toggleClickCount";
+ public static final String TREE_MODEL_PROPERTY = "model";
+ public static final String VISIBLE_ROW_COUNT_PROPERTY = "visibleRowCount";
+
+ /** @since 1.3 */
+ public static final String ANCHOR_SELECTION_PATH_PROPERTY = "anchorSelectionPath";
+
+ /** @since 1.3 */
+ public static final String LEAD_SELECTION_PATH_PROPERTY = "leadSelectionPath";
+
+ /** @since 1.3 */
+ public static final String EXPANDS_SELECTED_PATHS_PROPERTY = "expandsSelectedPaths";
+ private static final Object EXPANDED = new Object();
+ private static final Object COLLAPSED = new Object();
+ private boolean dragEnabled;
+ private boolean expandsSelectedPaths;
+ private TreePath anchorSelectionPath;
+ private TreePath leadSelectionPath;
+
+ /*
+ * This contains the state of all nodes in the tree. Al/ entries map the
+ * TreePath of a note to to its state. Valid states are EXPANDED and
+ * COLLAPSED. Nodes not in this Hashtable are assumed state COLLAPSED.
+ */
+ private Hashtable nodeStates = new Hashtable();
+ protected transient TreeCellEditor cellEditor;
+ protected transient TreeCellRenderer cellRenderer;
+ protected boolean editable;
+ protected boolean invokesStopCellEditing;
+ protected boolean largeModel;
+ protected boolean rootVisible;
+ protected int rowHeight;
+ protected boolean scrollsOnExpand;
+ protected transient TreeSelectionModel selectionModel;
+ protected boolean showsRootHandles;
+ protected int toggleClickCount;
+ protected transient TreeModel treeModel;
+ protected int visibleRowCount;
+
+ /**
+ * Handles TreeModelEvents to update the expandedState.
+ */
+ protected transient TreeModelListener treeModelListener;
+
+ /**
+ * Redirects TreeSelectionEvents so that the source is this JTree.
+ */
+ protected TreeSelectionRedirector selectionRedirector =
+ new TreeSelectionRedirector();
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ */
+ public JTree()
+ {
+ this(createTreeModel(null));
+ }
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ *
+ * @param value the initial nodes in the tree
+ */
+ public JTree(Hashtable value)
+ {
+ this(createTreeModel(value));
+ }
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ *
+ * @param value the initial nodes in the tree
+ */
+ public JTree(Object[] value)
+ {
+ this(createTreeModel(value));
+ }
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ *
+ * @param model the model to use
+ */
+ public JTree(TreeModel model)
+ {
+ setModel(model);
+ setSelectionModel(EmptySelectionModel.sharedInstance());
+ selectionModel.addTreeSelectionListener(selectionRedirector);
+ setCellRenderer(new DefaultTreeCellRenderer());
+ updateUI();
+ }
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ *
+ * @param root the root node
+ */
+ public JTree(TreeNode root)
+ {
+ this(root, false);
+ }
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ *
+ * @param root the root node
+ * @param asksAllowChildren if false, all nodes without children are leaf
+ * nodes. If true, only nodes that do not allow children are leaf
+ * nodes.
+ */
+ public JTree(TreeNode root, boolean asksAllowChildren)
+ {
+ this(new DefaultTreeModel(root, asksAllowChildren));
+ }
+
+ /**
+ * Creates a new <code>JTree</code> object.
+ *
+ * @param value the initial nodes in the tree
+ */
+ public JTree(Vector value)
+ {
+ this(createTreeModel(value));
+ }
+
+ public static class DynamicUtilTreeNode
+ extends
+ DefaultMutableTreeNode
+ {
+ protected Object childValue;
+ protected boolean loadedChildren;
+
+ /**
+ * Currently not set or used by this class. It might be set and used in
+ * later versions of this class.
+ */
+ protected boolean hasChildren;
+
+ public DynamicUtilTreeNode(Object value, Object children)
+ {
+ super(value);
+ childValue = children;
+ loadedChildren = false;
+ }
+
+ public int getChildCount()
+ {
+ loadChildren();
+ return super.getChildCount();
+ }
+
+ protected void loadChildren()
+ {
+ if (!loadedChildren)
+ {
+ createChildren(this, childValue);
+ loadedChildren = true;
+ }
+ }
+
+ public Enumeration children()
+ {
+ loadChildren();
+ return super.children();
+ }
+
+ /**
+ * Returns the child node at position <code>pos</code>. Subclassed
+ * here to load the children if necessary.
+ *
+ * @param pos the position of the child node to fetch
+ *
+ * @return the childnode at the specified position
+ */
+ public TreeNode getChildAt(int pos)
+ {
+ loadChildren();
+ return super.getChildAt(pos);
+ }
+
+ public boolean isLeaf()
+ {
+ return (childValue == null || !(childValue instanceof Hashtable
+ || childValue instanceof Vector || childValue.getClass()
+ .isArray()));
+ }
+
+ public static void createChildren(DefaultMutableTreeNode parent,
+ Object children)
+ {
+ if (children instanceof Hashtable)
+ {
+ Hashtable tab = (Hashtable) children;
+ Enumeration e = tab.keys();
+ while (e.hasMoreElements())
+ {
+ Object key = e.nextElement();
+ Object val = tab.get(key);
+ parent.add(new DynamicUtilTreeNode(key, val));
+ }
+ } else if (children instanceof Vector)
+ {
+ Iterator i = ((Vector) children).iterator();
+ while (i.hasNext())
+ {
+ Object n = i.next();
+ parent.add(new DynamicUtilTreeNode(n, n));
+ }
+ } else if (children != null && children.getClass().isArray())
+ {
+ Object[] arr = (Object[]) children;
+ for (int i = 0; i < arr.length; ++i)
+ parent.add(new DynamicUtilTreeNode(arr[i], arr[i]));
+ }
+ }
+ }
+
+ public int getRowForPath(TreePath path)
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getRowForPath(this, path);
+
+ return -1;
+ }
+
+ public TreePath getPathForRow(int row)
+ {
+ TreeUI ui = getUI();
+ return ui != null ? ui.getPathForRow(this, row) : null;
+ }
+
+ protected TreePath[] getPathBetweenRows(int index0, int index1)
+ {
+ TreeUI ui = getUI();
+
+ if (ui == null)
+ return null;
+
+ int minIndex = Math.min(index0, index1);
+ int maxIndex = Math.max(index0, index1);
+ TreePath[] paths = new TreePath[maxIndex - minIndex + 1];
+
+ for (int i = minIndex; i <= maxIndex; ++i)
+ paths[i - minIndex] = ui.getPathForRow(this, i);
+
+ return paths;
+ }
+
+ /**
+ * Creates a new <code>TreeModel</code> object.
+ *
+ * @param value the values stored in the model
+ */
+ protected static TreeModel createTreeModel(Object value)
+ {
+ return new DefaultTreeModel(new DynamicUtilTreeNode(value, value));
+ }
+
+ /**
+ * Return the UI associated with this <code>JTree</code> object.
+ *
+ * @return the associated <code>TreeUI</code> object
+ */
+ public TreeUI getUI()
+ {
+ return (TreeUI) ui;
+ }
+
+ /**
+ * Sets the UI associated with this <code>JTree</code> object.
+ *
+ * @param ui the <code>TreeUI</code> to associate
+ */
+ public void setUI(TreeUI ui)
+ {
+ super.setUI(ui);
+ }
+
+ /**
+ * This method resets the UI used to the Look and Feel defaults..
+ */
+ public void updateUI()
+ {
+ setUI((TreeUI) UIManager.getUI(this));
+ revalidate();
+ repaint();
+ }
+
+ /**
+ * This method returns the String ID of the UI class of Separator.
+ *
+ * @return The UI class' String ID.
+ */
+ public String getUIClassID()
+ {
+ return "TreeUI";
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this
+ * <code>JToggleButton</code>.
+ *
+ * @return the associated context
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the preferred viewport size..
+ *
+ * @return the preferred size
+ */
+ public Dimension getPreferredScrollableViewportSize()
+ {
+ return null;
+ }
+
+ public int getScrollableUnitIncrement(Rectangle visibleRect,
+ int orientation, int direction)
+ {
+ return 1;
+ }
+
+ public int getScrollableBlockIncrement(Rectangle visibleRect,
+ int orientation, int direction)
+ {
+ return 1;
+ }
+
+ public boolean getScrollableTracksViewportWidth()
+ {
+ return false;
+ }
+
+ public boolean getScrollableTracksViewportHeight()
+ {
+ return false;
+ }
+
+ /**
+ * Adds a <code>TreeExpansionListener</code> object to the tree.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeExpansionListener(TreeExpansionListener listener)
+ {
+ listenerList.add(TreeExpansionListener.class, listener);
+ }
+
+ /**
+ * Removes a <code>TreeExpansionListener</code> object from the tree.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeExpansionListener(TreeExpansionListener listener)
+ {
+ listenerList.remove(TreeExpansionListener.class, listener);
+ }
+
+ /**
+ * Returns all added <code>TreeExpansionListener</code> objects.
+ *
+ * @return an array of listeners
+ */
+ public TreeExpansionListener[] getTreeExpansionListeners()
+ {
+ return (TreeExpansionListener[]) getListeners(TreeExpansionListener.class);
+ }
+
+ /**
+ * Notifies all listeners that the tree was collapsed.
+ *
+ * @param path the path to the node that was collapsed
+ */
+ public void fireTreeCollapsed(TreePath path)
+ {
+ TreeExpansionEvent event = new TreeExpansionEvent(this, path);
+ TreeExpansionListener[] listeners = getTreeExpansionListeners();
+
+ for (int index = 0; index < listeners.length; ++index)
+ listeners[index].treeCollapsed(event);
+ }
+
+ /**
+ * Notifies all listeners that the tree was expanded.
+ *
+ * @param path the path to the node that was expanded
+ */
+ public void fireTreeExpanded(TreePath path)
+ {
+ TreeExpansionEvent event = new TreeExpansionEvent(this, path);
+ TreeExpansionListener[] listeners = getTreeExpansionListeners();
+
+ for (int index = 0; index < listeners.length; ++index)
+ listeners[index].treeExpanded(event);
+ }
+
+ /**
+ * Adds a <code>TreeSelctionListener</code> object to the tree.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeSelectionListener(TreeSelectionListener listener)
+ {
+ listenerList.add(TreeSelectionListener.class, listener);
+ }
+
+ /**
+ * Removes a <code>TreeSelectionListener</code> object from the tree.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeSelectionListener(TreeSelectionListener listener)
+ {
+ listenerList.remove(TreeSelectionListener.class, listener);
+ }
+
+ /**
+ * Returns all added <code>TreeSelectionListener</code> objects.
+ *
+ * @return an array of listeners
+ */
+ public TreeSelectionListener[] getTreeSelectionListeners()
+ {
+ return (TreeSelectionListener[])
+ getListeners(TreeSelectionListener.class);
+ }
+
+ /**
+ * Notifies all listeners when the selection of the tree changed.
+ *
+ * @param event the event to send
+ */
+ protected void fireValueChanged(TreeSelectionEvent event)
+ {
+ TreeSelectionListener[] listeners = getTreeSelectionListeners();
+
+ for (int index = 0; index < listeners.length; ++index)
+ listeners[index].valueChanged(event);
+ }
+
+ /**
+ * Adds a <code>TreeWillExpandListener</code> object to the tree.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeWillExpandListener(TreeWillExpandListener listener)
+ {
+ listenerList.add(TreeWillExpandListener.class, listener);
+ }
+
+ /**
+ * Removes a <code>TreeWillExpandListener</code> object from the tree.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeWillExpandListener(TreeWillExpandListener listener)
+ {
+ listenerList.remove(TreeWillExpandListener.class, listener);
+ }
+
+ /**
+ * Returns all added <code>TreeWillExpandListener</code> objects.
+ *
+ * @return an array of listeners
+ */
+ public TreeWillExpandListener[] getTreeWillExpandListeners()
+ {
+ return (TreeWillExpandListener[])
+ getListeners(TreeWillExpandListener.class);
+ }
+
+ /**
+ * Notifies all listeners that the tree will collapse.
+ *
+ * @param path the path to the node that will collapse
+ */
+ public void fireTreeWillCollapse(TreePath path) throws ExpandVetoException
+ {
+ TreeExpansionEvent event = new TreeExpansionEvent(this, path);
+ TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
+
+ for (int index = 0; index < listeners.length; ++index)
+ listeners[index].treeWillCollapse(event);
+ }
+
+ /**
+ * Notifies all listeners that the tree will expand.
+ *
+ * @param path the path to the node that will expand
+ */
+ public void fireTreeWillExpand(TreePath path) throws ExpandVetoException
+ {
+ TreeExpansionEvent event = new TreeExpansionEvent(this, path);
+ TreeWillExpandListener[] listeners = getTreeWillExpandListeners();
+
+ for (int index = 0; index < listeners.length; ++index)
+ listeners[index].treeWillExpand(event);
+ }
+
+ /**
+ * Returns the model of this <code>JTree</code> object.
+ *
+ * @return the associated <code>TreeModel</code>
+ */
+ public TreeModel getModel()
+ {
+ return treeModel;
+ }
+
+ /**
+ * Sets the model to use in <code>JTree</code>.
+ *
+ * @param model the <code>TreeModel</code> to use
+ */
+ public void setModel(TreeModel model)
+ {
+ if (treeModel == model)
+ return;
+
+ TreeModel oldValue = treeModel;
+ treeModel = model;
+
+ firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
+
+ // add treeModelListener to the new model
+ if (treeModelListener == null)
+ treeModelListener = createTreeModelListener();
+ model.addTreeModelListener(treeModelListener);
+ }
+
+ /**
+ * Checks if this <code>JTree</code> object is editable.
+ *
+ * @return <code>true</code> if this tree object is editable,
+ * <code>false</code> otherwise
+ */
+ public boolean isEditable()
+ {
+ return editable;
+ }
+
+ /**
+ * Sets the <code>editable</code> property.
+ *
+ * @param flag <code>true</code> to make this tree object editable,
+ * <code>false</code> otherwise
+ */
+ public void setEditable(boolean flag)
+ {
+ if (editable == flag)
+ return;
+
+ boolean oldValue = editable;
+ editable = flag;
+ firePropertyChange(EDITABLE_PROPERTY, oldValue, editable);
+ }
+
+ /**
+ * Checks if the root element is visible.
+ *
+ * @return <code>true</code> if the root element is visible,
+ * <code>false</code> otherwise
+ */
+ public boolean isRootVisible()
+ {
+ return rootVisible;
+ }
+
+ public void setRootVisible(boolean flag)
+ {
+ if (rootVisible == flag)
+ return;
+
+ boolean oldValue = rootVisible;
+ rootVisible = flag;
+ firePropertyChange(ROOT_VISIBLE_PROPERTY, oldValue, flag);
+ }
+
+ public boolean getShowsRootHandles()
+ {
+ return showsRootHandles;
+ }
+
+ public void setShowsRootHandles(boolean flag)
+ {
+ if (showsRootHandles == flag)
+ return;
+
+ boolean oldValue = showsRootHandles;
+ showsRootHandles = flag;
+ firePropertyChange(SHOWS_ROOT_HANDLES_PROPERTY, oldValue, flag);
+ }
+
+ public TreeCellEditor getCellEditor()
+ {
+
+ return cellEditor;
+ }
+
+ public void setCellEditor(TreeCellEditor editor)
+ {
+ if (cellEditor == editor)
+ return;
+
+ TreeCellEditor oldValue = cellEditor;
+ cellEditor = editor;
+ firePropertyChange(CELL_EDITOR_PROPERTY, oldValue, editor);
+ }
+
+ public TreeCellRenderer getCellRenderer()
+ {
+ return cellRenderer;
+ }
+
+ public void setCellRenderer(TreeCellRenderer newRenderer)
+ {
+ if (cellRenderer == newRenderer)
+ return;
+
+ TreeCellRenderer oldValue = cellRenderer;
+ cellRenderer = newRenderer;
+ firePropertyChange(CELL_RENDERER_PROPERTY, oldValue, newRenderer);
+ }
+
+ public TreeSelectionModel getSelectionModel()
+ {
+ return selectionModel;
+ }
+
+ public void setSelectionModel(TreeSelectionModel model)
+ {
+ if (selectionModel == model)
+ return;
+
+ if (selectionModel != null)
+ selectionModel.removeTreeSelectionListener(selectionRedirector);
+
+ TreeSelectionModel oldValue = selectionModel;
+ selectionModel = model;
+
+ if (selectionModel != null)
+ selectionModel.addTreeSelectionListener(selectionRedirector);
+
+ firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, model);
+ revalidate();
+ repaint();
+ }
+
+ public int getVisibleRowCount()
+ {
+ return visibleRowCount;
+ }
+
+ public void setVisibleRowCount(int rows)
+ {
+ if (visibleRowCount == rows)
+ return;
+
+ int oldValue = visibleRowCount;
+ visibleRowCount = rows;
+ firePropertyChange(VISIBLE_ROW_COUNT_PROPERTY, oldValue, rows);
+ }
+
+ public boolean isLargeModel()
+ {
+ return largeModel;
+ }
+
+ public void setLargeModel(boolean large)
+ {
+ if (largeModel == large)
+ return;
+
+ boolean oldValue = largeModel;
+ largeModel = large;
+ firePropertyChange(LARGE_MODEL_PROPERTY, oldValue, large);
+ }
+
+ public int getRowHeight()
+ {
+
+ return rowHeight;
+ }
+
+ public void setRowHeight(int height)
+ {
+ if (rowHeight == height)
+ return;
+
+ int oldValue = rowHeight;
+ rowHeight = height;
+ firePropertyChange(ROW_HEIGHT_PROPERTY, oldValue, height);
+ }
+
+ public boolean isFixedRowHeight()
+ {
+ return rowHeight > 0;
+ }
+
+ public boolean getInvokesStopCellEditing()
+ {
+ return invokesStopCellEditing;
+ }
+
+ public void setInvokesStopCellEditing(boolean invoke)
+ {
+ if (invokesStopCellEditing == invoke)
+ return;
+
+ boolean oldValue = invokesStopCellEditing;
+ invokesStopCellEditing = invoke;
+ firePropertyChange(INVOKES_STOP_CELL_EDITING_PROPERTY,
+ oldValue, invoke);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public int getToggleClickCount()
+ {
+ return toggleClickCount;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setToggleClickCount(int count)
+ {
+ if (toggleClickCount == count)
+ return;
+
+ int oldValue = toggleClickCount;
+ toggleClickCount = count;
+ firePropertyChange(TOGGLE_CLICK_COUNT_PROPERTY, oldValue, count);
+ }
+
+ public void scrollPathToVisible(TreePath path)
+ {
+ if (path == null)
+ return;
+
+ Rectangle rect = getPathBounds(path);
+
+ if (rect == null)
+ return;
+
+ scrollRectToVisible(rect);
+ }
+
+ public void scrollRowToVisible(int row)
+ {
+ scrollPathToVisible(getPathForRow(row));
+ }
+
+ public boolean getScrollsOnExpand()
+ {
+ return scrollsOnExpand;
+ }
+
+ public void setScrollsOnExpand(boolean scroll)
+ {
+ if (scrollsOnExpand == scroll)
+ return;
+
+ boolean oldValue = scrollsOnExpand;
+ scrollsOnExpand = scroll;
+ firePropertyChange(SCROLLS_ON_EXPAND_PROPERTY, oldValue, scroll);
+ }
+
+ public void setSelectionPath(TreePath path)
+ {
+ selectionModel.setSelectionPath(path);
+ }
+
+ public void setSelectionPaths(TreePath[] paths)
+ {
+ selectionModel.setSelectionPaths(paths);
+ }
+
+ public void setSelectionRow(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ selectionModel.setSelectionPath(path);
+ }
+
+ public void setSelectionRows(int[] rows)
+ {
+ // Make sure we have an UI so getPathForRow() does not return null.
+ if (rows == null || getUI() == null)
+ return;
+
+ TreePath[] paths = new TreePath[rows.length];
+
+ for (int i = rows.length - 1; i >= 0; --i)
+ paths[i] = getPathForRow(rows[i]);
+
+ setSelectionPaths(paths);
+ }
+
+ public void setSelectionInterval(int index0, int index1)
+ {
+ TreePath[] paths = getPathBetweenRows(index0, index1);
+
+ if (paths != null)
+ setSelectionPaths(paths);
+ }
+
+ public void addSelectionPath(TreePath path)
+ {
+ selectionModel.addSelectionPath(path);
+ }
+
+ public void addSelectionPaths(TreePath[] paths)
+ {
+ selectionModel.addSelectionPaths(paths);
+ }
+
+ public void addSelectionRow(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ selectionModel.addSelectionPath(path);
+ }
+
+ public void addSelectionRows(int[] rows)
+ {
+ // Make sure we have an UI so getPathForRow() does not return null.
+ if (rows == null || getUI() == null)
+ return;
+
+ TreePath[] paths = new TreePath[rows.length];
+
+ for (int i = rows.length - 1; i >= 0; --i)
+ paths[i] = getPathForRow(rows[i]);
+
+ addSelectionPaths(paths);
+ }
+
+ public void addSelectionInterval(int index0, int index1)
+ {
+ TreePath[] paths = getPathBetweenRows(index0, index1);
+
+ if (paths != null)
+ addSelectionPaths(paths);
+ }
+
+ public void removeSelectionPath(TreePath path)
+ {
+ selectionModel.removeSelectionPath(path);
+ }
+
+ public void removeSelectionPaths(TreePath[] paths)
+ {
+ selectionModel.removeSelectionPaths(paths);
+ }
+
+ public void removeSelectionRow(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ selectionModel.removeSelectionPath(path);
+ }
+
+ public void removeSelectionRows(int[] rows)
+ {
+ if (rows == null || getUI() == null)
+ return;
+
+ TreePath[] paths = new TreePath[rows.length];
+
+ for (int i = rows.length - 1; i >= 0; --i)
+ paths[i] = getPathForRow(rows[i]);
+
+ removeSelectionPaths(paths);
+ }
+
+ public void removeSelectionInterval(int index0, int index1)
+ {
+ TreePath[] paths = getPathBetweenRows(index0, index1);
+
+ if (paths != null)
+ removeSelectionPaths(paths);
+ }
+
+ public void clearSelection()
+ {
+ selectionModel.clearSelection();
+ setLeadSelectionPath(null);
+ }
+
+ public TreePath getLeadSelectionPath()
+ {
+ return leadSelectionPath;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setLeadSelectionPath(TreePath path)
+ {
+ if (leadSelectionPath == path)
+ return;
+
+ TreePath oldValue = leadSelectionPath;
+ leadSelectionPath = path;
+ firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, path);
+ }
+
+ /**
+ * @since 1.3
+ */
+ public TreePath getAnchorSelectionPath()
+ {
+ return anchorSelectionPath;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setAnchorSelectionPath(TreePath path)
+ {
+ if (anchorSelectionPath == path)
+ return;
+
+ TreePath oldValue = anchorSelectionPath;
+ anchorSelectionPath = path;
+ firePropertyChange(ANCHOR_SELECTION_PATH_PROPERTY, oldValue, path);
+ }
+
+ public int getLeadSelectionRow()
+ {
+ return selectionModel.getLeadSelectionRow();
+ }
+
+ public int getMaxSelectionRow()
+ {
+ return selectionModel.getMaxSelectionRow();
+ }
+
+ public int getMinSelectionRow()
+ {
+ return selectionModel.getMinSelectionRow();
+ }
+
+ public int getSelectionCount()
+ {
+ return selectionModel.getSelectionCount();
+ }
+
+ public TreePath getSelectionPath()
+ {
+ return selectionModel.getSelectionPath();
+ }
+
+ public TreePath[] getSelectionPaths()
+ {
+ return selectionModel.getSelectionPaths();
+ }
+
+ public int[] getSelectionRows()
+ {
+ return selectionModel.getSelectionRows();
+ }
+
+ public boolean isPathSelected(TreePath path)
+ {
+ return selectionModel.isPathSelected(path);
+ }
+
+ public boolean isRowSelected(int row)
+ {
+ return selectionModel.isPathSelected(getPathForRow(row));
+ }
+
+ public boolean isSelectionEmpty()
+ {
+ return selectionModel.isSelectionEmpty();
+ }
+
+ /**
+ * Return the value of the <code>dragEnabled</code> property.
+ *
+ * @return the value
+ *
+ * @since 1.4
+ */
+ public boolean getDragEnabled()
+ {
+ return dragEnabled;
+ }
+
+ /**
+ * Set the <code>dragEnabled</code> property.
+ *
+ * @param enabled new value
+ *
+ * @since 1.4
+ */
+ public void setDragEnabled(boolean enabled)
+ {
+
+ dragEnabled = enabled;
+ }
+
+ public int getRowCount()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getRowCount(this);
+
+ return 0;
+ }
+
+ public void collapsePath(TreePath path)
+ {
+ setExpandedState(path, false);
+ }
+
+ public void collapseRow(int row)
+ {
+ if (row < 0 || row >= getRowCount())
+ return;
+
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ collapsePath(path);
+ }
+
+ public void expandPath(TreePath path)
+ {
+ // Don't expand if last path component is a leaf node.
+ if ((path == null) || (treeModel.isLeaf(path.getLastPathComponent())))
+ return;
+
+ setExpandedState(path, true);
+ }
+
+ public void expandRow(int row)
+ {
+ if (row < 0 || row >= getRowCount())
+ return;
+
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ expandPath(path);
+ }
+
+ public boolean isCollapsed(TreePath path)
+ {
+ return !isExpanded(path);
+ }
+
+ public boolean isCollapsed(int row)
+ {
+ if (row < 0 || row >= getRowCount())
+ return false;
+
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ return isCollapsed(path);
+
+ return false;
+ }
+
+ public boolean isExpanded(TreePath path)
+ {
+ if (path == null)
+ return false;
+
+ Object state = nodeStates.get(path);
+
+ if ((state == null) || (state != EXPANDED))
+ return false;
+
+ TreePath parent = path.getParentPath();
+
+ if (parent != null)
+ return isExpanded(parent);
+
+ return true;
+ }
+
+ public boolean isExpanded(int row)
+ {
+ if (row < 0 || row >= getRowCount())
+ return false;
+
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ return isExpanded(path);
+
+ return false;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public boolean getExpandsSelectedPaths()
+ {
+ return expandsSelectedPaths;
+ }
+
+ /**
+ * @since 1.3
+ */
+ public void setExpandsSelectedPaths(boolean flag)
+ {
+ if (expandsSelectedPaths == flag)
+ return;
+
+ boolean oldValue = expandsSelectedPaths;
+ expandsSelectedPaths = flag;
+ firePropertyChange(EXPANDS_SELECTED_PATHS_PROPERTY, oldValue, flag);
+ }
+
+ public Rectangle getPathBounds(TreePath path)
+ {
+ TreeUI ui = getUI();
+
+ if (ui == null)
+ return null;
+
+ return ui.getPathBounds(this, path);
+ }
+
+ public Rectangle getRowBounds(int row)
+ {
+ TreePath path = getPathForRow(row);
+
+ if (path != null)
+ return getPathBounds(path);
+
+ return null;
+ }
+
+ public boolean isEditing()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.isEditing(this);
+
+ return false;
+ }
+
+ public boolean stopEditing()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.stopEditing(this);
+
+ return false;
+ }
+
+ public void cancelEditing()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ ui.cancelEditing(this);
+ }
+
+ public void startEditingAtPath(TreePath path)
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ ui.startEditingAtPath(this, path);
+ }
+
+ public TreePath getEditingPath()
+ {
+ TreeUI ui = getUI();
+
+ if (ui != null)
+ return ui.getEditingPath(this);
+
+ return null;
+ }
+
+ public TreePath getPathForLocation(int x, int y)
+ {
+ TreePath path = getClosestPathForLocation(x, y);
+
+ if (path != null)
+ {
+ Rectangle rect = getPathBounds(path);
+
+ if ((rect != null) && rect.contains(x, y))
+ return path;
+ }
+
+ return null;
+ }
+
+ public int getRowForLocation(int x, int y)
+ {
+ TreePath path = getPathForLocation(x, y);
+
+ if (path != null)
+ return getRowForPath(path);
- if (path != null)
- return getPathBounds(path);
+ return -1;
+ }
- return null;
- }
+ public TreePath getClosestPathForLocation(int x, int y)
+ {
+ TreeUI ui = getUI();
- public boolean isEditing()
- {
- TreeUI ui = getUI();
+ if (ui != null)
+ return ui.getClosestPathForLocation(this, x, y);
- if (ui != null)
- return ui.isEditing(this);
+ return null;
+ }
- return false;
- }
+ public int getClosestRowForLocation(int x, int y)
+ {
+ TreePath path = getClosestPathForLocation(x, y);
- public boolean stopEditing()
- {
- TreeUI ui = getUI();
+ if (path != null)
+ return getRowForPath(path);
- if (ui != null)
- return ui.stopEditing(this);
+ return -1;
+ }
- return false;
- }
+ public Object getLastSelectedPathComponent()
+ {
+ TreePath path = getSelectionPath();
- public void cancelEditing()
- {
- TreeUI ui = getUI();
+ if (path != null)
+ return path.getLastPathComponent();
- if (ui != null)
- ui.cancelEditing(this);
- }
+ return null;
+ }
- public void startEditingAtPath(TreePath path)
- {
- TreeUI ui = getUI();
+ private void checkExpandParents(TreePath path) throws ExpandVetoException
+ {
- if (ui != null)
- ui.startEditingAtPath(this, path);
- }
-
- public TreePath getEditingPath()
- {
- TreeUI ui = getUI();
-
- if (ui != null)
- return ui.getEditingPath(this);
-
- return null;
- }
-
- public TreePath getPathForLocation(int x, int y)
- {
- TreePath path = getClosestPathForLocation(x, y);
-
- if (path != null)
- {
- Rectangle rect = getPathBounds(path);
-
- if ((rect != null) && rect.contains(x, y))
- return path;
- }
-
- return null;
- }
-
- public int getRowForLocation(int x, int y)
- {
- TreePath path = getPathForLocation(x, y);
-
- if (path != null)
- return getRowForPath(path);
-
- return -1;
- }
-
- public TreePath getClosestPathForLocation(int x, int y)
- {
- TreeUI ui = getUI();
+ TreePath parent = path.getParentPath();
- if (ui != null)
- return ui.getClosestPathForLocation(this, x, y);
-
- return null;
- }
-
- public int getClosestRowForLocation(int x, int y)
- {
- TreePath path = getClosestPathForLocation(x, y);
+ if (parent != null)
+ checkExpandParents(parent);
- if (path != null)
- return getRowForPath(path);
+ fireTreeWillExpand(path);
+ }
- return -1;
- }
+ private void doExpandParents(TreePath path, boolean state)
+ {
+ TreePath parent = path.getParentPath();
+
+ if (isExpanded(parent))
+ {
+ nodeStates.put(path, state ? EXPANDED : COLLAPSED);
+ return;
+ }
- public Object getLastSelectedPathComponent()
- {
- TreePath path = getSelectionPath();
-
- if (path != null)
- return path.getLastPathComponent();
-
- return null;
- }
-
- private void checkExpandParents(TreePath path)
- throws ExpandVetoException
- {
- TreePath parent = path.getParentPath();
-
- if (parent != null)
- checkExpandParents(parent);
-
- fireTreeWillExpand(path);
- }
-
- private void doExpandParents(TreePath path, boolean state)
- {
- TreePath parent = path.getParentPath();
-
- if (isExpanded(parent))
- return;
-
- if (parent != null)
- doExpandParents(parent, false);
-
- nodeStates.put(path, state ? EXPANDED : COLLAPSED);
- }
-
- protected void setExpandedState(TreePath path, boolean state)
- {
- if (path == null)
- return;
-
- TreePath parent = path.getParentPath();
-
- try
- {
- while (parent != null)
- checkExpandParents(parent);
- }
- catch (ExpandVetoException e)
- {
- // Expansion vetoed.
- return;
- }
-
- doExpandParents(path, state);
- }
-
- protected void clearToggledPaths()
- {
- nodeStates.clear();
- }
-
- protected Enumeration getDescendantToggledPaths(TreePath parent)
- {
- if (parent == null)
- return null;
-
- Enumeration nodes = nodeStates.keys();
- Vector result = new Vector();
-
- while (nodes.hasMoreElements())
- {
- TreePath path = (TreePath) nodes.nextElement();
-
- if (path.isDescendant(parent))
- result.addElement(path);
- }
-
- return result.elements();
- }
-
- public boolean hasBeenExpanded(TreePath path)
- {
- if (path == null)
- return false;
-
- return nodeStates.get(path) != null;
- }
-
- public boolean isVisible(TreePath path)
- {
- if (path == null)
- return false;
-
- TreePath parent = path.getParentPath();
-
- if (parent == null)
- return true; // Is root node.
-
- return isExpanded(parent);
- }
-
- public void makeVisible(TreePath path)
- {
- if (path == null)
- return;
-
- expandPath(path.getParentPath());
- }
-
- public boolean isPathEditable(TreePath path)
- {
- return isEditable();
- }
-
- /**
- * Creates and returns an instance of {@link TreeModelHandler}.
- *
- * @returns an instance of {@link TreeModelHandler}
- */
- protected TreeModelListener createTreeModelListener()
- {
- return new TreeModelHandler();
- }
-
- /**
- * Returns a sample TreeModel that can be used in a JTree. This can
- * be used in Bean- or GUI-Builders to show something interesting.
- *
- * @return a sample TreeModel that can be used in a JTree
- */
- protected static TreeModel getDefaultTreeModel()
- {
- DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root node");
- DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child node 1");
- DefaultMutableTreeNode child11 =
- new DefaultMutableTreeNode("Child node 1.1");
- DefaultMutableTreeNode child12 =
- new DefaultMutableTreeNode("Child node 1.2");
- DefaultMutableTreeNode child13 =
- new DefaultMutableTreeNode("Child node 1.3");
- DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child node 2");
- DefaultMutableTreeNode child21 =
- new DefaultMutableTreeNode("Child node 2.1");
- DefaultMutableTreeNode child22 =
- new DefaultMutableTreeNode("Child node 2.2");
- DefaultMutableTreeNode child23 =
- new DefaultMutableTreeNode("Child node 2.3");
- DefaultMutableTreeNode child24 =
- new DefaultMutableTreeNode("Child node 2.4");
-
- DefaultMutableTreeNode child3 = new DefaultMutableTreeNode("Child node 3");
- root.add(child1);
- root.add(child2);
- root.add(child3);
- child1.add(child11);
- child1.add(child12);
- child1.add(child13);
- child2.add(child21);
- child2.add(child22);
- child2.add(child23);
- child2.add(child24);
- return new DefaultTreeModel(root);
- }
-
- /**
- * Converts the specified value to a String. This is used by the
- * renderers of this JTree and its nodes.
- *
- * This implementation simply returns <code>value.toString()</code> and
- * ignores all other parameters.
- * Subclass this method to control the conversion.
- *
- * @param value the value that is converted to a String
- * @param selected indicates if that value is selected or not
- * @param expanded indicates if that value is expanded or not
- * @param leaf indicates if that value is a leaf node or not
- * @param row the row of the node
- * @param hasFocus indicates if that node has focus or not
- */
- public String convertValueToText(Object value, boolean selected,
- boolean expanded, boolean leaf, int row,
- boolean hasFocus)
- {
- return value.toString();
- }
-
- /**
- * A String representation of this JTree. This is intended to be used
- * for debugging. The returned string may be empty but may not be
- * <code>null</code>.
- *
- * @return a String representation of this JTree
- */
- public String paramString()
- {
- // TODO: this is completely legal, but it would possibly be nice
- // to return some more content, like the tree structure, some properties
- // etc ...
- return "";
- }
-
- /**
- * Returns all TreePath objects which are a descendants of
- * the given path and are exapanded at the moment of the
- * execution of this method. If the state of any node
- * is beeing toggled while this method is executing this
- * change may be left unaccounted.
- *
- * @param path The parent of this request
- * @return An Enumeration containing TreePath objects
- */
- public Enumeration getExpandedDescendants(TreePath path)
- {
- Enumeration paths = nodeStates.keys();
- Vector relevantPaths = new Vector();
- while(paths.hasMoreElements())
- {
- TreePath nextPath = (TreePath) paths.nextElement();
- if(nodeStates.get(nextPath) == EXPANDED &&
- path.isDescendant(nextPath))
- {
- relevantPaths.add(nextPath);
- }
- }
- return relevantPaths.elements();
- }
-
- /**
- * Returns the next table element (beginning from the row
- * <code>startingRow</code>
- * that starts with <code>prefix</code>. Searching is done in the direction
- * specified by <code>bias</code>.
- *
- * @param prefix the prefix to search for in the cell values
- * @param startingRow the index of the row where to start searching from
- * @param bias the search direction, either {@link Position.Bias.Forward}
- * or {@link Position.Bias.Backward}
- *
- * @return the path to the found element or -1 if no such element has
- * been found
- *
- * @throws IllegalArgumentException if prefix is <code>null</code> or
- * startingRow is not valid
- *
- * @since 1.4
- */
- public TreePath getNextMatch(String prefix, int startingRow,
- Position.Bias bias)
- {
- if (prefix == null)
- throw new IllegalArgumentException("The argument 'prefix' must not be"
- + " null.");
- if (startingRow < 0)
- throw new IllegalArgumentException("The argument 'startingRow' must not"
- + " be less than zero.");
-
- int size = getRowCount();
- if (startingRow > size)
- throw new IllegalArgumentException("The argument 'startingRow' must not"
- + " be greater than the number of"
- + " elements in the TreeModel.");
-
- TreePath foundPath = null;
- if (bias == Position.Bias.Forward)
- {
- for (int i = startingRow; i < size; i++)
- {
- TreePath path = getPathForRow(i);
- Object o = path.getLastPathComponent();
- // FIXME: in the following call to convertValueToText the
- // last argument (hasFocus) should be done right.
- String item = convertValueToText(o, isRowSelected(i),
- isExpanded(i),
- treeModel.isLeaf(o), i, false);
- if (item.startsWith(prefix))
- {
- foundPath = path;
- break;
- }
- }
- }
- else
- {
- for (int i = startingRow; i >= 0; i--)
- {
- TreePath path = getPathForRow(i);
- Object o = path.getLastPathComponent();
- // FIXME: in the following call to convertValueToText the
- // last argument (hasFocus) should be done right.
- String item = convertValueToText(o, isRowSelected(i),
- isExpanded(i),
- treeModel.isLeaf(o), i, false);
- if (item.startsWith(prefix))
- {
- foundPath = path;
- break;
- }
- }
- }
- return foundPath;
- }
+ if (parent != null)
+ doExpandParents(parent, false);
+
+ nodeStates.put(path, state ? EXPANDED : COLLAPSED);
+ }
+
+ protected void setExpandedState(TreePath path, boolean state)
+ {
+ if (path == null)
+ return;
+
+ TreePath parent = path.getParentPath();
+
+ try
+ {
+ if (parent != null)
+ checkExpandParents(parent);
+ }
+ catch (ExpandVetoException e)
+ {
+ // Expansion vetoed.
+ return;
+ }
+
+ doExpandParents(path, state);
+ }
+
+ protected void clearToggledPaths()
+ {
+ nodeStates.clear();
+ }
+
+ protected Enumeration getDescendantToggledPaths(TreePath parent)
+ {
+ if (parent == null)
+ return null;
+
+ Enumeration nodes = nodeStates.keys();
+ Vector result = new Vector();
+
+ while (nodes.hasMoreElements())
+ {
+ TreePath path = (TreePath) nodes.nextElement();
+
+ if (path.isDescendant(parent))
+ result.addElement(path);
+ }
+
+ return result.elements();
+ }
+
+ public boolean hasBeenExpanded(TreePath path)
+ {
+ if (path == null)
+ return false;
+
+ return nodeStates.get(path) != null;
+ }
+
+ public boolean isVisible(TreePath path)
+ {
+ if (path == null)
+ return false;
+
+ TreePath parent = path.getParentPath();
+
+ if (parent == null)
+ return true; // Is root node.
+
+ return isExpanded(parent);
+ }
+
+ public void makeVisible(TreePath path)
+ {
+ if (path == null)
+ return;
+
+ expandPath(path.getParentPath());
+ }
+
+ public boolean isPathEditable(TreePath path)
+ {
+ return isEditable();
+ }
+
+ /**
+ * Creates and returns an instance of {@link TreeModelHandler}.
+ *
+ * @returns an instance of {@link TreeModelHandler}
+ */
+ protected TreeModelListener createTreeModelListener()
+ {
+ return new TreeModelHandler();
+ }
+
+ /**
+ * Returns a sample TreeModel that can be used in a JTree. This can be used
+ * in Bean- or GUI-Builders to show something interesting.
+ *
+ * @return a sample TreeModel that can be used in a JTree
+ */
+ protected static TreeModel getDefaultTreeModel()
+ {
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root node");
+ DefaultMutableTreeNode child1 = new DefaultMutableTreeNode(
+ "Child node 1");
+ DefaultMutableTreeNode child11 = new DefaultMutableTreeNode(
+ "Child node 1.1");
+ DefaultMutableTreeNode child12 = new DefaultMutableTreeNode(
+ "Child node 1.2");
+ DefaultMutableTreeNode child13 = new DefaultMutableTreeNode(
+ "Child node 1.3");
+ DefaultMutableTreeNode child2 = new DefaultMutableTreeNode(
+ "Child node 2");
+ DefaultMutableTreeNode child21 = new DefaultMutableTreeNode(
+ "Child node 2.1");
+ DefaultMutableTreeNode child22 = new DefaultMutableTreeNode(
+ "Child node 2.2");
+ DefaultMutableTreeNode child23 = new DefaultMutableTreeNode(
+ "Child node 2.3");
+ DefaultMutableTreeNode child24 = new DefaultMutableTreeNode(
+ "Child node 2.4");
+
+ DefaultMutableTreeNode child3 = new DefaultMutableTreeNode(
+ "Child node 3");
+ root.add(child1);
+ root.add(child2);
+ root.add(child3);
+ child1.add(child11);
+ child1.add(child12);
+ child1.add(child13);
+ child2.add(child21);
+ child2.add(child22);
+ child2.add(child23);
+ child2.add(child24);
+ return new DefaultTreeModel(root);
+ }
+
+ /**
+ * Converts the specified value to a String. This is used by the renderers
+ * of this JTree and its nodes.
+ *
+ * This implementation simply returns <code>value.toString()</code> and
+ * ignores all other parameters. Subclass this method to control the
+ * conversion.
+ *
+ * @param value the value that is converted to a String
+ * @param selected indicates if that value is selected or not
+ * @param expanded indicates if that value is expanded or not
+ * @param leaf indicates if that value is a leaf node or not
+ * @param row the row of the node
+ * @param hasFocus indicates if that node has focus or not
+ */
+ public String convertValueToText(Object value, boolean selected,
+ boolean expanded, boolean leaf, int row, boolean hasFocus)
+ {
+ return value.toString();
+ }
+
+ /**
+ * A String representation of this JTree. This is intended to be used for
+ * debugging. The returned string may be empty but may not be
+ * <code>null</code>.
+ *
+ * @return a String representation of this JTree
+ */
+ public String paramString()
+ {
+ // TODO: this is completely legal, but it would possibly be nice
+ // to return some more content, like the tree structure, some properties
+ // etc ...
+ return "";
+ }
+
+ /**
+ * Returns all TreePath objects which are a descendants of the given path
+ * and are exapanded at the moment of the execution of this method. If the
+ * state of any node is beeing toggled while this method is executing this
+ * change may be left unaccounted.
+ *
+ * @param path The parent of this request
+ * @return An Enumeration containing TreePath objects
+ */
+ public Enumeration getExpandedDescendants(TreePath path)
+ {
+ Enumeration paths = nodeStates.keys();
+ Vector relevantPaths = new Vector();
+ while (paths.hasMoreElements())
+ {
+ TreePath nextPath = (TreePath) paths.nextElement();
+ if (nodeStates.get(nextPath) == EXPANDED
+ && path.isDescendant(nextPath))
+ {
+ relevantPaths.add(nextPath);
+ }
+ }
+ return relevantPaths.elements();
+ }
+
+ /**
+ * Returns the next table element (beginning from the row
+ * <code>startingRow</code> that starts with <code>prefix</code>.
+ * Searching is done in the direction specified by <code>bias</code>.
+ *
+ * @param prefix the prefix to search for in the cell values
+ * @param startingRow the index of the row where to start searching from
+ * @param bias the search direction, either {@link Position.Bias#Forward} or
+ * {@link Position.Bias#Backward}
+ *
+ * @return the path to the found element or -1 if no such element has been
+ * found
+ *
+ * @throws IllegalArgumentException if prefix is <code>null</code> or
+ * startingRow is not valid
+ *
+ * @since 1.4
+ */
+ public TreePath getNextMatch(String prefix, int startingRow,
+ Position.Bias bias)
+ {
+ if (prefix == null)
+ throw new IllegalArgumentException(
+ "The argument 'prefix' must not be" + " null.");
+ if (startingRow < 0)
+ throw new IllegalArgumentException(
+ "The argument 'startingRow' must not"
+ + " be less than zero.");
+
+ int size = getRowCount();
+ if (startingRow > size)
+ throw new IllegalArgumentException(
+ "The argument 'startingRow' must not"
+ + " be greater than the number of"
+ + " elements in the TreeModel.");
+
+ TreePath foundPath = null;
+ if (bias == Position.Bias.Forward)
+ {
+ for (int i = startingRow; i < size; i++)
+ {
+ TreePath path = getPathForRow(i);
+ Object o = path.getLastPathComponent();
+ // FIXME: in the following call to convertValueToText the
+ // last argument (hasFocus) should be done right.
+ String item = convertValueToText(o, isRowSelected(i),
+ isExpanded(i), treeModel.isLeaf(o), i, false);
+ if (item.startsWith(prefix))
+ {
+ foundPath = path;
+ break;
+ }
+ }
+ } else
+ {
+ for (int i = startingRow; i >= 0; i--)
+ {
+ TreePath path = getPathForRow(i);
+ Object o = path.getLastPathComponent();
+ // FIXME: in the following call to convertValueToText the
+ // last argument (hasFocus) should be done right.
+ String item = convertValueToText(o, isRowSelected(i),
+ isExpanded(i), treeModel.isLeaf(o), i, false);
+ if (item.startsWith(prefix))
+ {
+ foundPath = path;
+ break;
+ }
+ }
+ }
+ return foundPath;
+ }
+
+ /**
+ * Removes any paths in the current set of selected paths that are
+ * descendants of <code>path</code>. If <code>includePath</code> is set
+ * to <code>true</code> and <code>path</code> itself is selected, then
+ * it will be removed too.
+ *
+ * @param path the path from which selected descendants are to be removed
+ * @param includeSelected if <code>true</code> then <code>path</code> itself
+ * will also be remove if it's selected
+ *
+ * @return <code>true</code> if something has been removed,
+ * <code>false</code> otherwise
+ *
+ * @since 1.3
+ */
+ protected boolean removeDescendantSelectedPaths(TreePath path,
+ boolean includeSelected)
+ {
+ boolean removedSomething = false;
+ TreePath[] selected = getSelectionPaths();
+ for (int index = 0; index < selected.length; index++)
+ {
+ if ((selected[index] == path && includeSelected)
+ || (selected[index].isDescendant(path)))
+ {
+ removeSelectionPath(selected[index]);
+ removedSomething = true;
+ }
+ }
+ return removedSomething;
+ }
}
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index d097081fb..f5eee8a19 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -89,7 +89,7 @@ import javax.swing.plaf.ViewportUI;
*
* <p>But in terms of drawing its child, the viewport thinks of itself as
* covering a particular position <em>of the view's coordinate space</em>.
- * For example, the {@link javax.JViewPort.getViewPosition} method returns
+ * For example, the {@link #getViewPosition} method returns
* the position <code>(VX,VY)</code> shown above, which is an position in
* "view space", even though this is <em>implemented</em> by positioning
* the underlying child at position <code>(-VX,-VY)</code></p>
@@ -487,4 +487,47 @@ public class JViewport extends JComponent
{
return new ViewportLayout();
}
+
+ /**
+ * Scrolls the view so that contentRect becomes visible.
+ *
+ * @param contentRect the rectangle to make visible within the view
+ */
+ public void scrollRectToVisible(Rectangle contentRect)
+ {
+ Point pos = getViewPosition();
+ Rectangle viewBounds = getView().getBounds();
+ Rectangle portBounds = getBounds();
+
+ // FIXME: should validate the view if it is not valid, however
+ // this may cause excessive validation when the containment
+ // hierarchy is being created.
+
+ // if contentRect is larger than the portBounds, center the view
+ if (contentRect.height > portBounds.height ||
+ contentRect.width > portBounds.width)
+ {
+ setViewPosition(new Point(contentRect.x, contentRect.y));
+ return;
+ }
+
+ // Y-DIRECTION
+ if (contentRect.y + viewBounds.y < portBounds.y)
+ setViewPosition(new Point(pos.x, contentRect.y));
+ else if (contentRect.y + viewBounds.y + contentRect.height >
+ (portBounds.y+portBounds.height))
+ setViewPosition (new Point(pos.x, contentRect.y -
+ (portBounds.height - contentRect.height) -
+ portBounds.y));
+
+ // X-DIRECTION
+ pos = getViewPosition();
+ if (contentRect.x + viewBounds.x < portBounds.x)
+ setViewPosition(new Point(contentRect.x, pos.y));
+ else if (contentRect.x + viewBounds.x + contentRect.width >
+ (portBounds.x + portBounds.height))
+ setViewPosition (new Point(contentRect.x -
+ (portBounds.width - contentRect.width)
+ - portBounds.x, pos.y));
+ }
}
diff --git a/javax/swing/JWindow.java b/javax/swing/JWindow.java
index 94efa3aa7..449900370 100644
--- a/javax/swing/JWindow.java
+++ b/javax/swing/JWindow.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -63,9 +63,21 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
private static final long serialVersionUID = 5420698392125238833L;
protected JRootPane rootPane;
- protected boolean rootPaneCheckingEnabled;
+
+ /**
+ * @specnote rootPaneCheckingEnabled is false to comply with J2SE 5.0
+ */
+ protected boolean rootPaneCheckingEnabled = false;
+
protected AccessibleContext accessibleContext;
+ /**
+ * Tells us if we're in the initialization stage.
+ * If so, adds go to top-level Container, otherwise they go
+ * to the content pane for this container.
+ */
+ private boolean initStageDone = false;
+
public JWindow()
{
super(SwingUtilities.getOwnerFrame());
@@ -100,6 +112,8 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
{
super.setLayout(new BorderLayout(1, 1));
getRootPane(); // will do set/create
+ // Now we're done init stage, adds and layouts go to content pane.
+ initStageDone = true;
}
public Dimension getPreferredSize()
@@ -109,7 +123,17 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
public void setLayout(LayoutManager manager)
{
- super.setLayout(manager);
+ // Check if we're in initialization stage. If so, call super.setLayout
+ // otherwise, valid calls go to the content pane.
+ if (initStageDone)
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Cannot set layout. Use getContentPane().setLayout()"
+ + " instead.");
+ getContentPane().setLayout(manager);
+ }
+ else
+ super.setLayout(manager);
}
public void setLayeredPane(JLayeredPane layeredPane)
@@ -163,14 +187,30 @@ public class JWindow extends Window implements Accessible, RootPaneContainer
getRootPane().setGlassPane(glassPane);
}
+
protected void addImpl(Component comp, Object constraints, int index)
{
- super.addImpl(comp, constraints, index);
+ // If we're adding in the initialization stage use super.add.
+ // otherwise pass the add onto the content pane.
+ if (!initStageDone)
+ super.addImpl(comp, constraints, index);
+ else
+ {
+ if (isRootPaneCheckingEnabled())
+ throw new Error("Do not use add() on JWindow directly. Use "
+ + "getContentPane().add() instead");
+ getContentPane().add(comp, constraints, index);
+ }
}
public void remove(Component comp)
{
- getContentPane().remove(comp);
+ // If we're removing the root pane, use super.remove. Otherwise
+ // pass it on to the content pane instead.
+ if (comp == rootPane)
+ super.remove(rootPane);
+ else
+ getContentPane().remove(comp);
}
protected boolean isRootPaneCheckingEnabled()
diff --git a/javax/swing/KeyStroke.java b/javax/swing/KeyStroke.java
index 239c8dd1f..12a280c21 100644
--- a/javax/swing/KeyStroke.java
+++ b/javax/swing/KeyStroke.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/LayoutFocusTraversalPolicy.java b/javax/swing/LayoutFocusTraversalPolicy.java
index e61f724eb..2d135157d 100644
--- a/javax/swing/LayoutFocusTraversalPolicy.java
+++ b/javax/swing/LayoutFocusTraversalPolicy.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/ListCellRenderer.java b/javax/swing/ListCellRenderer.java
index 34c250cb9..6ce115ea7 100644
--- a/javax/swing/ListCellRenderer.java
+++ b/javax/swing/ListCellRenderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,6 +39,9 @@ package javax.swing;
import java.awt.Component;
+/**
+ * Renders the cells of a {@link JList}.
+ */
public interface ListCellRenderer
{
Component getListCellRendererComponent(JList list,
diff --git a/javax/swing/ListModel.java b/javax/swing/ListModel.java
index 405df0e65..736627e85 100644
--- a/javax/swing/ListModel.java
+++ b/javax/swing/ListModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,8 +40,7 @@ package javax.swing;
import javax.swing.event.ListDataListener;
/**
- * This is an interface to general list-like data, typically used as the
- * model object of a {@link JList} component.
+ * The data model that is typically used in {@link JList}.
*
* @author Graydon Hoare (graydon@redhat.com)
*/
diff --git a/javax/swing/ListSelectionModel.java b/javax/swing/ListSelectionModel.java
index c2e9648ac..f4680d737 100644
--- a/javax/swing/ListSelectionModel.java
+++ b/javax/swing/ListSelectionModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,6 +40,10 @@ package javax.swing;
import javax.swing.event.ListSelectionListener;
+/**
+ * The model that is used in {@link JList} to define the selected/not-selected
+ * cells of that list.
+ */
public interface ListSelectionModel
{
int SINGLE_SELECTION = 0;
diff --git a/javax/swing/LookAndFeel.java b/javax/swing/LookAndFeel.java
index a2508386d..885874271 100644
--- a/javax/swing/LookAndFeel.java
+++ b/javax/swing/LookAndFeel.java
@@ -1,5 +1,5 @@
/* LookAndFeel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -56,16 +56,32 @@ public abstract class LookAndFeel
return null;
}
+ /**
+ * Returns a description of the look and feel.
+ *
+ * @return A description of the look and feel.
+ */
public abstract String getDescription();
- public static Object getDesktopPropertyValue(String systemPropertyName, Object fallbackValue)
+ public static Object getDesktopPropertyValue(String systemPropertyName,
+ Object fallbackValue)
{
Object value = Toolkit.getDefaultToolkit().getDesktopProperty(systemPropertyName);
return value != null ? value : fallbackValue;
}
+ /**
+ * Returns an identifier for the look and feel.
+ *
+ * @return An identifier for the look and feel.
+ */
public abstract String getID();
+ /**
+ * Returns the name for the look and feel.
+ *
+ * @return The name for the look and feel.
+ */
public abstract String getName();
/**
@@ -118,8 +134,25 @@ public abstract class LookAndFeel
{
}
+ /**
+ * Returns <code>true</code> if the look and feel is the "native" look and
+ * feel for the current platform, and <code>false</code> otherwise.
+ *
+ * @return A flag indicating whether or not this is the native look and feel
+ * for the current platform.
+ */
public abstract boolean isNativeLookAndFeel();
+ /**
+ * Returns <code>true</code> if the look and feel is supported on the
+ * current operating system, and <code>false</code> otherwise. This
+ * mechanism is provided so that it is possible to prevent a look and feel
+ * from being used on some operating systems (usually for legal, not
+ * technical, reasons).
+ *
+ * @return A flag indicating whether or not the look and feel is supported
+ * on the current platform.
+ */
public abstract boolean isSupportedLookAndFeel();
/**
diff --git a/javax/swing/MenuElement.java b/javax/swing/MenuElement.java
index 60ae1afa6..46eb8c2a5 100644
--- a/javax/swing/MenuElement.java
+++ b/javax/swing/MenuElement.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,9 +42,10 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
/**
- * MenuElement
- * @author Andrew Selkirk
- * @version 1.0
+ * Defines the methods that any menu element in a {@link JMenu} must
+ * implement.
+ *
+ * @author Andrew Selkirk
*/
public interface MenuElement {
diff --git a/javax/swing/MenuSelectionManager.java b/javax/swing/MenuSelectionManager.java
index f01d8b837..32d56b958 100644
--- a/javax/swing/MenuSelectionManager.java
+++ b/javax/swing/MenuSelectionManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -211,17 +211,18 @@ public class MenuSelectionManager
public boolean isComponentPartOfCurrentMenu(Component c)
{
MenuElement[] subElements;
- for (int i = 0; i < selectedPath.size(); i++)
+ for (int i = 0; i < selectedPath.size(); i++)
{
- subElements = ((MenuElement) selectedPath.get(i)).getSubElements();
- for (int j = 0; j < subElements.length; j++)
- {
- if ((subElements[j].getComponent()).equals(c))
- return true;
- }
+ subElements = ((MenuElement) selectedPath.get(i)).getSubElements();
+ for (int j = 0; j < subElements.length; j++)
+ {
+ MenuElement me = subElements[j];
+ if (me != null && (me.getComponent()).equals(c))
+ return true;
+ }
}
- return false;
+ return false;
}
/**
diff --git a/javax/swing/MutableComboBoxModel.java b/javax/swing/MutableComboBoxModel.java
index 2c0f4149d..ee79dac03 100644
--- a/javax/swing/MutableComboBoxModel.java
+++ b/javax/swing/MutableComboBoxModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,14 +38,13 @@ exception statement from your version. */
package javax.swing;
/**
- * MutableComboBoxModel is interface for data model that keeps track of the
+ * A data model used in {@link JComboBox}es 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.
+ * 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
{
diff --git a/javax/swing/OverlayLayout.java b/javax/swing/OverlayLayout.java
index 706ffe2a2..e8aef98a5 100644
--- a/javax/swing/OverlayLayout.java
+++ b/javax/swing/OverlayLayout.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/Popup.java b/javax/swing/Popup.java
index 1b8d08e33..69e1f5168 100644
--- a/javax/swing/Popup.java
+++ b/javax/swing/Popup.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/PopupFactory.java b/javax/swing/PopupFactory.java
index 571de22d0..29cf86d55 100644
--- a/javax/swing/PopupFactory.java
+++ b/javax/swing/PopupFactory.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/ProgressMonitor.java b/javax/swing/ProgressMonitor.java
index aec483c3e..844258f1b 100644
--- a/javax/swing/ProgressMonitor.java
+++ b/javax/swing/ProgressMonitor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/ProgressMonitorInputStream.java b/javax/swing/ProgressMonitorInputStream.java
index 56ae3bcf7..2022a1c24 100644
--- a/javax/swing/ProgressMonitorInputStream.java
+++ b/javax/swing/ProgressMonitorInputStream.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/Renderer.java b/javax/swing/Renderer.java
index 1f1a30052..c803e38fc 100644
--- a/javax/swing/Renderer.java
+++ b/javax/swing/Renderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,9 +40,14 @@ package javax.swing;
import java.awt.Component;
/**
- * Renderer
- * @author Andrew Selkirk
- * @version 1.0
+ * This interface is not used and exists only for compatibility.
+ * It probably has been replaced by {@link ListCellRenderer}, {@link
+ * javax.swing.table.TableCellRenderer} and {@link
+ * javax.swing.tree.TreeCellRenderer}.
+ *
+ * @specnote This interface is not used and exists only for compatibility.
+ *
+ * @author Andrew Selkirk
*/
public interface Renderer {
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index b6611bfdb..698dbe8e8 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,6 +42,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
+import java.awt.image.VolatileImage;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
@@ -72,7 +73,7 @@ public class RepaintManager
* typically only one of these objects active at any time. When the
* {@link RepaintManager} is told to queue a repaint, it checks to see if
* a {@link RepaintWorker} is "live" in the system event queue, and if
- * not it inserts one using {@link SwingUtilities.invokeLater}.</p>
+ * not it inserts one using {@link SwingUtilities#invokeLater}.</p>
*
* <p>When the {@link RepaintWorker} comes to the head of the system
* event queue, its {@link RepaintWorker#run} method is executed by the
@@ -235,7 +236,7 @@ public class RepaintManager
*
* @param manager The new value of the shared instance
*
- * @see #currentManager
+ * @see #currentManager(JComponent)
*/
public static void setCurrentManager(RepaintManager manager)
{
@@ -501,7 +502,7 @@ public class RepaintManager
*
* @since 1.4
*
- * @see {@link VolatileImage}
+ * @see VolatileImage
*/
public Image getVolatileOffscreenBuffer(Component comp, int proposedWidth,
int proposedHeight)
@@ -542,7 +543,7 @@ public class RepaintManager
*
* @param buffer The new value of the property
*
- * @see #getDoubleBufferingEnabled
+ * @see #isDoubleBufferingEnabled
*/
public void setDoubleBufferingEnabled(boolean buffer)
{
diff --git a/javax/swing/RootPaneContainer.java b/javax/swing/RootPaneContainer.java
index d2eff356c..b121f958a 100644
--- a/javax/swing/RootPaneContainer.java
+++ b/javax/swing/RootPaneContainer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,9 +42,11 @@ import java.awt.Component;
import java.awt.Container;
/**
- * RootPaneContainer
- * @author Andrew Selkirk
- * @version 1.0
+ * Components that contain a single {@link JRootPane} as only child
+ * implement this interface, typically this is implemented by the
+ * Swing top-level containers.
+ *
+ * @author Andrew Selkirk
*/
public interface RootPaneContainer {
diff --git a/javax/swing/ScrollPaneConstants.java b/javax/swing/ScrollPaneConstants.java
index b4e24be01..b5860609f 100644
--- a/javax/swing/ScrollPaneConstants.java
+++ b/javax/swing/ScrollPaneConstants.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,9 +38,10 @@ exception statement from your version. */
package javax.swing;
/**
- * ScrollPaneConstants
- * @author Andrew Selkirk
- * @version 1.0
+ * Defines some constants that are used in {@link JScrollPane} and related
+ * components.
+ *
+ * @author Andrew Selkirk
*/
public interface ScrollPaneConstants
{
diff --git a/javax/swing/ScrollPaneLayout.java b/javax/swing/ScrollPaneLayout.java
index 6fbb3048a..75a6f9aa2 100644
--- a/javax/swing/ScrollPaneLayout.java
+++ b/javax/swing/ScrollPaneLayout.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/Scrollable.java b/javax/swing/Scrollable.java
index a69e34712..197321923 100644
--- a/javax/swing/Scrollable.java
+++ b/javax/swing/Scrollable.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,6 +40,12 @@ package javax.swing;
import java.awt.Dimension;
import java.awt.Rectangle;
+/**
+ * Defines the method that a component should implement to behave nicely
+ * in {@link JScrollPane}s. Note that this is not required for a component
+ * to be used in a <code>JScrollPane</code>, but can highly improve the
+ * user experience when scrolling the component.
+ */
public interface Scrollable
{
Dimension getPreferredScrollableViewportSize();
diff --git a/javax/swing/SingleSelectionModel.java b/javax/swing/SingleSelectionModel.java
index c2683921f..b5380c857 100644
--- a/javax/swing/SingleSelectionModel.java
+++ b/javax/swing/SingleSelectionModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,9 +40,11 @@ package javax.swing;
import javax.swing.event.ChangeListener;
/**
- * SingleSelectionModel
- * @author Andrew Selkirk
- * @version 1.0
+ * A data model that is used in components that support at most one
+ * selected element, like {@link JTabbedPane}, {@link JMenu} and
+ * {@link JPopupMenu}.
+ *
+ * @author Andrew Selkirk
*/
public interface SingleSelectionModel {
diff --git a/javax/swing/SizeRequirements.java b/javax/swing/SizeRequirements.java
index 8de16b16b..77b42db1c 100644
--- a/javax/swing/SizeRequirements.java
+++ b/javax/swing/SizeRequirements.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -295,7 +295,6 @@ public class SizeRequirements implements Serializable
* @param allocated the amount of allocated space
* @param total the total size requirements of the components
* @param children the size requirement of each component
- * @param offsets will hold the offset values for each component
* @param spans will hold the span values for each component
* @param forward whether the components should be placed in the forward
* direction (left-right or top-bottom) or reverse direction
diff --git a/javax/swing/SizeSequence.java b/javax/swing/SizeSequence.java
index d03699f18..cf6e5f042 100644
--- a/javax/swing/SizeSequence.java
+++ b/javax/swing/SizeSequence.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/SortingFocusTraversalPolicy.java b/javax/swing/SortingFocusTraversalPolicy.java
index 07a4e6561..fada17c63 100644
--- a/javax/swing/SortingFocusTraversalPolicy.java
+++ b/javax/swing/SortingFocusTraversalPolicy.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -89,7 +89,7 @@ public class SortingFocusTraversalPolicy
* Creates a new <code>SortingFocusTraversalPolicy</code> with the given
* comparator set.
*
- * @param the comparator to set
+ * @param comparator the comparator to set
*/
public SortingFocusTraversalPolicy(Comparator comparator)
{
@@ -306,12 +306,12 @@ public class SortingFocusTraversalPolicy
}
/**
- * Return the current value of the {@link implicitDownCycleTraversal}
+ * Return the current value of the {@link #implicitDownCycleTraversal}
* property.
*
* @return the current value of the property
*
- * @see setImplicitDownCycleTraversal
+ * @see #setImplicitDownCycleTraversal
*/
public boolean getImplicitDownCycleTraversal()
{
@@ -319,12 +319,12 @@ public class SortingFocusTraversalPolicy
}
/**
- * Set the current value of the {@link implicitDownCycleTraversal}
+ * Set the current value of the {@link #implicitDownCycleTraversal}
* property.
*
* @param down the new value of the property
*
- * @see getImplicitDownCycleTraversal
+ * @see #getImplicitDownCycleTraversal
*/
public void setImplicitDownCycleTraversal(boolean down)
{
diff --git a/javax/swing/SpinnerDateModel.java b/javax/swing/SpinnerDateModel.java
index 8e577fad5..c0de7d55c 100644
--- a/javax/swing/SpinnerDateModel.java
+++ b/javax/swing/SpinnerDateModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/SpinnerListModel.java b/javax/swing/SpinnerListModel.java
index 9b2667182..85dc4efa6 100644
--- a/javax/swing/SpinnerListModel.java
+++ b/javax/swing/SpinnerListModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,6 +42,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import javax.swing.event.ChangeEvent;
+
/**
* An implementation of <code>SpinnerModel</code> which uses the values
* contained within a list or an array. The backing list or array is
diff --git a/javax/swing/SpinnerModel.java b/javax/swing/SpinnerModel.java
index ea5f431d4..4ad962bbf 100644
--- a/javax/swing/SpinnerModel.java
+++ b/javax/swing/SpinnerModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,6 +41,8 @@ package javax.swing;
import javax.swing.event.ChangeListener;
/**
+ * The data model that is used in {@link JSpinner}s.
+ *
* @since 1.4
*/
public interface SpinnerModel
diff --git a/javax/swing/SpinnerNumberModel.java b/javax/swing/SpinnerNumberModel.java
index 370007cb8..2274c9ec0 100644
--- a/javax/swing/SpinnerNumberModel.java
+++ b/javax/swing/SpinnerNumberModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/Spring.java b/javax/swing/Spring.java
index aa47e20e1..69c88c77d 100644
--- a/javax/swing/Spring.java
+++ b/javax/swing/Spring.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -189,9 +189,9 @@ public abstract class Spring
/**
* Creates a new SimpleSpring object.
*
- * @param min the constant minimum value.
- * @param pref the constant preferred value.
- * @param max the constant maximum value.
+ * @param newMin the constant minimum value.
+ * @param newPref the constant preferred value.
+ * @param newMax the constant maximum value.
*/
public SimpleSpring(int newMin, int newPref, int newMax)
{
diff --git a/javax/swing/SpringLayout.java b/javax/swing/SpringLayout.java
index 07357dcc8..df9ddffb6 100644
--- a/javax/swing/SpringLayout.java
+++ b/javax/swing/SpringLayout.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -152,7 +152,7 @@ public class SpringLayout implements LayoutManager2
/**
* Returns the constraint for the edge with the <code>edgeName</code>.
* This is expected to be one of
- * {@link #EAST}, {@link #WEST}, {@link NORTH} or {@link SOUTH}.
+ * {@link #EAST}, {@link #WEST}, {@link #NORTH} or {@link #SOUTH}.
*
* @param edgeName the name of the edge.
* @return the constraint for the specified edge.
@@ -246,7 +246,7 @@ public class SpringLayout implements LayoutManager2
* the mathematics still hold true.
*
* @param edgeName the name of the edge, one of {@link #EAST},
- * {@link #WEST}, {@link NORTH} or {@link SOUTH}.
+ * {@link #WEST}, {@link #NORTH} or {@link #SOUTH}.
* @param s the constraint to be set.
*/
public void setConstraint(String edgeName, Spring s)
@@ -361,8 +361,8 @@ public class SpringLayout implements LayoutManager2
* Method. This method does nothing, since SpringLayout does not manage
* String-indexed components.
*
- * @param component the component to be added.
- * @param constraint the constraint to be set.
+ * @param name the name.
+ * @param c the component to be added.
*/
public void addLayoutComponent(String name, Component c)
{
@@ -374,7 +374,7 @@ public class SpringLayout implements LayoutManager2
*
* @param c the component from which to get the constraint.
* @param edgeName the name of the edge, one of {@link #EAST},
- * {@link #WEST}, {@link NORTH} or {@link SOUTH}.
+ * {@link #WEST}, {@link #NORTH} or {@link #SOUTH}.
* @return the constraint of the edge <code>edgeName</code> of the
* component c.
*/
diff --git a/javax/swing/SwingConstants.java b/javax/swing/SwingConstants.java
index f3e90977f..bed8a467b 100644
--- a/javax/swing/SwingConstants.java
+++ b/javax/swing/SwingConstants.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,6 +38,9 @@ exception statement from your version. */
package javax.swing;
+/**
+ * Defines constant values that are used throughout the Swing packages.
+ */
public interface SwingConstants
{
int CENTER = 0;
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index 13470f304..3425fc97d 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -63,7 +63,7 @@ import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.InputMapUIResource;
/**
- * This class contains a number of static utility functions which are
+ * A number of static utility functions which are
* useful when drawing swing components, dispatching events, or calculating
* regions which need painting.
*
@@ -848,8 +848,14 @@ public class SwingUtilities
}
else
{
+ int fromIndex = 0;
textR.width = fm.stringWidth(text);
textR.height = fm.getHeight();
+ while (text.indexOf('\n', fromIndex) != -1)
+ {
+ textR.height += fm.getHeight();
+ fromIndex = text.indexOf('\n', fromIndex) + 1;
+ }
}
// Work out the position of text and icon, assuming the top-left coord
diff --git a/javax/swing/Timer.java b/javax/swing/Timer.java
index 5b5380f87..87f420a43 100644
--- a/javax/swing/Timer.java
+++ b/javax/swing/Timer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/ToolTipManager.java b/javax/swing/ToolTipManager.java
index 667e26094..616937638 100644
--- a/javax/swing/ToolTipManager.java
+++ b/javax/swing/ToolTipManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -424,6 +424,10 @@ public class ToolTipManager extends MouseAdapter implements MouseMotionListener
insideTimer.stop();
hideTip();
}
+
+ if (currentComponent == null)
+ currentComponent = (Component) event.getSource();
+
currentComponent.invalidate();
currentComponent.validate();
currentComponent.repaint();
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index 85d4a8c4d..96cb9d42a 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/UIDefaults.java b/javax/swing/UIDefaults.java
index b679ff352..ab78ca644 100644
--- a/javax/swing/UIDefaults.java
+++ b/javax/swing/UIDefaults.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -74,6 +74,13 @@ public class UIDefaults extends Hashtable
/** We use this for firing PropertyChangeEvents. */
private PropertyChangeSupport propertyChangeSupport;
+ /**
+ * Used for lazy instantiation of UIDefaults values so that they are not
+ * all loaded when a Swing application starts up, but only the values that
+ * are really needed. An <code>ActiveValue</code> is newly instantiated
+ * every time when the value is requested, as opposed to the normal
+ * {@link LazyValue} that is only instantiated once.
+ */
public static interface ActiveValue
{
Object createValue(UIDefaults table);
@@ -98,6 +105,13 @@ public class UIDefaults extends Hashtable
}
}
+ /**
+ * Used for lazy instantiation of UIDefaults values so that they are not
+ * all loaded when a Swing application starts up, but only the values that
+ * are really needed. A <code>LazyValue</code> is only instantiated once,
+ * as opposed to the {@link ActiveValue} that is newly created every time
+ * it is requested.
+ */
public static interface LazyValue
{
Object createValue(UIDefaults table);
@@ -407,9 +421,9 @@ public class UIDefaults extends Hashtable
* @return the font entry for <code>key</code> or null if no such entry
* exists
*/
- public Font getFont(Object key, Locale l)
+ public Font getFont(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Font ? (Font) o : null;
}
@@ -436,9 +450,9 @@ public class UIDefaults extends Hashtable
* @return the color entry for <code>key</code> or null if no such entry
* exists
*/
- public Color getColor(Object key, Locale l)
+ public Color getColor(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Color ? (Color) o : null;
}
@@ -465,9 +479,9 @@ public class UIDefaults extends Hashtable
* @return the icon entry for <code>key</code> or null if no such entry
* exists
*/
- public Icon getIcon(Object key, Locale l)
+ public Icon getIcon(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Icon ? (Icon) o : null;
}
@@ -494,9 +508,9 @@ public class UIDefaults extends Hashtable
* @return the border entry for <code>key</code> or null if no such entry
* exists
*/
- public Border getBorder(Object key, Locale l)
+ public Border getBorder(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Border ? (Border) o : null;
}
@@ -523,9 +537,9 @@ public class UIDefaults extends Hashtable
* @return the string entry for <code>key</code> or null if no such entry
* exists
*/
- public String getString(Object key, Locale l)
+ public String getString(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof String ? (String) o : null;
}
@@ -552,9 +566,9 @@ public class UIDefaults extends Hashtable
* @return the integer entry for <code>key</code> or null if no such entry
* exists
*/
- public int getInt(Object key, Locale l)
+ public int getInt(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Integer ? ((Integer) o).intValue() : 0;
}
@@ -580,9 +594,9 @@ public class UIDefaults extends Hashtable
* @return the boolean entry for <code>key</code> or null if no such entry
* exists
*/
- public boolean getBoolean(Object key, Locale l)
+ public boolean getBoolean(Object key, Locale locale)
{
- return Boolean.TRUE.equals(get(key, l));
+ return Boolean.TRUE.equals(get(key, locale));
}
/**
@@ -608,9 +622,9 @@ public class UIDefaults extends Hashtable
* @return the boolean entry for <code>key</code> or null if no such entry
* exists
*/
- public Insets getInsets(Object key, Locale l)
+ public Insets getInsets(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Insets ? (Insets) o : null;
}
@@ -637,9 +651,9 @@ public class UIDefaults extends Hashtable
* @return the boolean entry for <code>key</code> or null if no such entry
* exists
*/
- public Dimension getDimension(Object key, Locale l)
+ public Dimension getDimension(Object key, Locale locale)
{
- Object o = get(key, l);
+ Object o = get(key, locale);
return o instanceof Dimension ? (Dimension) o : null;
}
diff --git a/javax/swing/UIManager.java b/javax/swing/UIManager.java
index 056e944be..46f6e959d 100644
--- a/javax/swing/UIManager.java
+++ b/javax/swing/UIManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/UnsupportedLookAndFeelException.java b/javax/swing/UnsupportedLookAndFeelException.java
index 2e032cd94..5abe45fe1 100644
--- a/javax/swing/UnsupportedLookAndFeelException.java
+++ b/javax/swing/UnsupportedLookAndFeelException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/ViewportLayout.java b/javax/swing/ViewportLayout.java
index 3abf31da3..18b491257 100644
--- a/javax/swing/ViewportLayout.java
+++ b/javax/swing/ViewportLayout.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/WindowConstants.java b/javax/swing/WindowConstants.java
index 3f9936c18..5e3644344 100644
--- a/javax/swing/WindowConstants.java
+++ b/javax/swing/WindowConstants.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,9 +38,10 @@ exception statement from your version. */
package javax.swing;
/**
- * WindowConstants
- * @author Andrew Selkirk
- * @version 1.0
+ * Defines some constants that are used in Swing's top-level
+ * containers.
+ *
+ * @author Andrew Selkirk
*/
public interface WindowConstants {
diff --git a/javax/swing/border/AbstractBorder.java b/javax/swing/border/AbstractBorder.java
index 9c1f06be7..951debd52 100644
--- a/javax/swing/border/AbstractBorder.java
+++ b/javax/swing/border/AbstractBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -118,7 +118,7 @@ public abstract class AbstractBorder
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets (Component c, Insets insets)
{
diff --git a/javax/swing/border/BevelBorder.java b/javax/swing/border/BevelBorder.java
index dd5a52b01..fcdc1c646 100644
--- a/javax/swing/border/BevelBorder.java
+++ b/javax/swing/border/BevelBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -172,7 +172,7 @@ public class BevelBorder
* @throws NullPointerException if <code>highlight</code> or
* <code>shadow</code> is <code>null</code>.
*
- * @see java.awt.Color.brighter()
+ * @see java.awt.Color#brighter()
*/
public BevelBorder(int bevelType, Color highlight, Color shadow)
{
@@ -289,7 +289,7 @@ public class BevelBorder
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
diff --git a/javax/swing/border/Border.java b/javax/swing/border/Border.java
index a9ad6e5b0..11bddfe78 100644
--- a/javax/swing/border/Border.java
+++ b/javax/swing/border/Border.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/border/CompoundBorder.java b/javax/swing/border/CompoundBorder.java
index d75f4c0dc..2130a0e34 100644
--- a/javax/swing/border/CompoundBorder.java
+++ b/javax/swing/border/CompoundBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/border/EmptyBorder.java b/javax/swing/border/EmptyBorder.java
index 6360063ff..0f3b7b693 100644
--- a/javax/swing/border/EmptyBorder.java
+++ b/javax/swing/border/EmptyBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/border/EtchedBorder.java b/javax/swing/border/EtchedBorder.java
index 859e5f832..0bd76ff0f 100644
--- a/javax/swing/border/EtchedBorder.java
+++ b/javax/swing/border/EtchedBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -246,7 +246,7 @@ public class EtchedBorder
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
diff --git a/javax/swing/border/LineBorder.java b/javax/swing/border/LineBorder.java
index 2b8c8bae9..c34e38c57 100644
--- a/javax/swing/border/LineBorder.java
+++ b/javax/swing/border/LineBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -287,7 +287,7 @@ public class LineBorder
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
diff --git a/javax/swing/border/MatteBorder.java b/javax/swing/border/MatteBorder.java
index b95814b45..f7ff1ca01 100644
--- a/javax/swing/border/MatteBorder.java
+++ b/javax/swing/border/MatteBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/border/SoftBevelBorder.java b/javax/swing/border/SoftBevelBorder.java
index 341954c3c..379ecb65a 100644
--- a/javax/swing/border/SoftBevelBorder.java
+++ b/javax/swing/border/SoftBevelBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -120,7 +120,7 @@ public class SoftBevelBorder
* @throws NullPointerException if <code>highlight</code> or
* <code>shadow</code> is <code>null</code>.
*
- * @see java.awt.Color.brighter()
+ * @see java.awt.Color#brighter()
*/
public SoftBevelBorder(int bevelType, Color highlight, Color shadow)
{
@@ -235,7 +235,7 @@ public class SoftBevelBorder
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
diff --git a/javax/swing/border/TitledBorder.java b/javax/swing/border/TitledBorder.java
index b257ce1c7..ceae2b1c9 100644
--- a/javax/swing/border/TitledBorder.java
+++ b/javax/swing/border/TitledBorder.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -675,7 +675,7 @@ public class TitledBorder
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
@@ -1117,7 +1117,7 @@ public class TitledBorder
/**
* Determines the insets of the nested component when it has a
* TitledBorder as its border. Used by {@link
- * TitledBorder#getBorderInsets()}.
+ * TitledBorder#getBorderInsets(Component, Insets)}.
*
* @param i an Insets object for storing the results into, or
* <code>null</code> to cause the creation of a
@@ -1140,7 +1140,7 @@ public class TitledBorder
/**
* Calculates the minimum size needed for displaying the border
- * and its title. Used by {@link TitledBorder#getMiminumSize()}.
+ * and its title. Used by {@link TitledBorder#getMinimumSize(Component)}.
*/
public Dimension getMinimumSize()
{
diff --git a/javax/swing/border/package.html b/javax/swing/border/package.html
index 23b95d478..de8479a6a 100644
--- a/javax/swing/border/package.html
+++ b/javax/swing/border/package.html
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.border</title></head>
<body>
-<p></p>
+<p>Provides borders for use by components in the <code>javax.swing</code>
+package.</p>
</body>
</html>
diff --git a/javax/swing/colorchooser/AbstractColorChooserPanel.java b/javax/swing/colorchooser/AbstractColorChooserPanel.java
index 4ecfab4a3..d55346aaf 100644
--- a/javax/swing/colorchooser/AbstractColorChooserPanel.java
+++ b/javax/swing/colorchooser/AbstractColorChooserPanel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/ColorChooserComponentFactory.java b/javax/swing/colorchooser/ColorChooserComponentFactory.java
index 6e7ca33d7..77e319c70 100644
--- a/javax/swing/colorchooser/ColorChooserComponentFactory.java
+++ b/javax/swing/colorchooser/ColorChooserComponentFactory.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/ColorSelectionModel.java b/javax/swing/colorchooser/ColorSelectionModel.java
index 2dc0e87c5..5f3070813 100644
--- a/javax/swing/colorchooser/ColorSelectionModel.java
+++ b/javax/swing/colorchooser/ColorSelectionModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/DefaultColorSelectionModel.java b/javax/swing/colorchooser/DefaultColorSelectionModel.java
index 8852935e5..aae2bed68 100644
--- a/javax/swing/colorchooser/DefaultColorSelectionModel.java
+++ b/javax/swing/colorchooser/DefaultColorSelectionModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/DefaultHSBChooserPanel.java b/javax/swing/colorchooser/DefaultHSBChooserPanel.java
index ea18e4296..71d6c75b5 100644
--- a/javax/swing/colorchooser/DefaultHSBChooserPanel.java
+++ b/javax/swing/colorchooser/DefaultHSBChooserPanel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/DefaultPreviewPanel.java b/javax/swing/colorchooser/DefaultPreviewPanel.java
index e1e7aa91f..2462add3d 100644
--- a/javax/swing/colorchooser/DefaultPreviewPanel.java
+++ b/javax/swing/colorchooser/DefaultPreviewPanel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/DefaultRGBChooserPanel.java b/javax/swing/colorchooser/DefaultRGBChooserPanel.java
index 7cd9bfe3a..39a173250 100644
--- a/javax/swing/colorchooser/DefaultRGBChooserPanel.java
+++ b/javax/swing/colorchooser/DefaultRGBChooserPanel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/DefaultSwatchChooserPanel.java b/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
index 505de95dc..f28af4cac 100644
--- a/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
+++ b/javax/swing/colorchooser/DefaultSwatchChooserPanel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/colorchooser/package.html b/javax/swing/colorchooser/package.html
index 67ca509d7..c04e96ebb 100644
--- a/javax/swing/colorchooser/package.html
+++ b/javax/swing/colorchooser/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.event package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.colorchooser</title></head>
<body>
-<p></p>
+<p>Provides support classes for the {@link javax.swing.JColorChooser}
+component.</p>
</body>
</html>
diff --git a/javax/swing/event/AncestorEvent.java b/javax/swing/event/AncestorEvent.java
index 63f00a4e5..d06c6e396 100644
--- a/javax/swing/event/AncestorEvent.java
+++ b/javax/swing/event/AncestorEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/AncestorListener.java b/javax/swing/event/AncestorListener.java
index bc0f91d85..61d5aedb7 100644
--- a/javax/swing/event/AncestorListener.java
+++ b/javax/swing/event/AncestorListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/CaretEvent.java b/javax/swing/event/CaretEvent.java
index 876bf4f7e..c4870a800 100644
--- a/javax/swing/event/CaretEvent.java
+++ b/javax/swing/event/CaretEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/CaretListener.java b/javax/swing/event/CaretListener.java
index 5765b634b..aeee434e5 100644
--- a/javax/swing/event/CaretListener.java
+++ b/javax/swing/event/CaretListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/CellEditorListener.java b/javax/swing/event/CellEditorListener.java
index abbb1039e..d2dd5bab8 100644
--- a/javax/swing/event/CellEditorListener.java
+++ b/javax/swing/event/CellEditorListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/ChangeEvent.java b/javax/swing/event/ChangeEvent.java
index 1d2d4e14f..f75c15aac 100644
--- a/javax/swing/event/ChangeEvent.java
+++ b/javax/swing/event/ChangeEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/ChangeListener.java b/javax/swing/event/ChangeListener.java
index b952fc10f..1e58b1d82 100644
--- a/javax/swing/event/ChangeListener.java
+++ b/javax/swing/event/ChangeListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/DocumentEvent.java b/javax/swing/event/DocumentEvent.java
index eccc9d3e5..6a005ea7a 100644
--- a/javax/swing/event/DocumentEvent.java
+++ b/javax/swing/event/DocumentEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/DocumentListener.java b/javax/swing/event/DocumentListener.java
index 7593880f6..df5e784e4 100644
--- a/javax/swing/event/DocumentListener.java
+++ b/javax/swing/event/DocumentListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/EventListenerList.java b/javax/swing/event/EventListenerList.java
index 226cac179..3b9f4c807 100644
--- a/javax/swing/event/EventListenerList.java
+++ b/javax/swing/event/EventListenerList.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -133,7 +133,7 @@ public class EventListenerList
* @throws IllegalArgumentException if <code>listener</code> is not
* an instance of <code>t</code> (or a subclass thereof).
*
- * @throws Exception if <code>t</code> is <code>null</code>.
+ * @throws NullPointerException if <code>t</code> is <code>null</code>.
*/
public void add(Class t, EventListener listener)
{
@@ -246,7 +246,7 @@ public class EventListenerList
* @throws IllegalArgumentException if <code>listener</code> is not
* an instance of <code>t</code> (or a subclass thereof).
*
- * @throws Exception if <code>t</code> is <code>null</code>.
+ * @throws NullPointerException if <code>t</code> is <code>null</code>.
*/
public void remove(Class t, EventListener listener)
{
diff --git a/javax/swing/event/HyperlinkEvent.java b/javax/swing/event/HyperlinkEvent.java
index a3a155a31..4afa009f4 100644
--- a/javax/swing/event/HyperlinkEvent.java
+++ b/javax/swing/event/HyperlinkEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/HyperlinkListener.java b/javax/swing/event/HyperlinkListener.java
index 3e448ce54..5dede993f 100644
--- a/javax/swing/event/HyperlinkListener.java
+++ b/javax/swing/event/HyperlinkListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/InternalFrameAdapter.java b/javax/swing/event/InternalFrameAdapter.java
index 76f3d89da..a2878e76e 100644
--- a/javax/swing/event/InternalFrameAdapter.java
+++ b/javax/swing/event/InternalFrameAdapter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/InternalFrameEvent.java b/javax/swing/event/InternalFrameEvent.java
index 9f0311677..badfa80ac 100644
--- a/javax/swing/event/InternalFrameEvent.java
+++ b/javax/swing/event/InternalFrameEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/InternalFrameListener.java b/javax/swing/event/InternalFrameListener.java
index 7b297846d..d1b2812a8 100644
--- a/javax/swing/event/InternalFrameListener.java
+++ b/javax/swing/event/InternalFrameListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/ListDataEvent.java b/javax/swing/event/ListDataEvent.java
index c86e86abe..2a6e6dbe9 100644
--- a/javax/swing/event/ListDataEvent.java
+++ b/javax/swing/event/ListDataEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/ListDataListener.java b/javax/swing/event/ListDataListener.java
index eeaf07ada..7ce17d86f 100644
--- a/javax/swing/event/ListDataListener.java
+++ b/javax/swing/event/ListDataListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/ListSelectionEvent.java b/javax/swing/event/ListSelectionEvent.java
index c2289f014..e5e4c33ba 100644
--- a/javax/swing/event/ListSelectionEvent.java
+++ b/javax/swing/event/ListSelectionEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/ListSelectionListener.java b/javax/swing/event/ListSelectionListener.java
index 17293bd4e..4ebf58304 100644
--- a/javax/swing/event/ListSelectionListener.java
+++ b/javax/swing/event/ListSelectionListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MenuDragMouseEvent.java b/javax/swing/event/MenuDragMouseEvent.java
index 8d3a0a542..997616706 100644
--- a/javax/swing/event/MenuDragMouseEvent.java
+++ b/javax/swing/event/MenuDragMouseEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MenuDragMouseListener.java b/javax/swing/event/MenuDragMouseListener.java
index 226d291d2..bfca315e3 100644
--- a/javax/swing/event/MenuDragMouseListener.java
+++ b/javax/swing/event/MenuDragMouseListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MenuEvent.java b/javax/swing/event/MenuEvent.java
index de8174473..35bb5b97b 100644
--- a/javax/swing/event/MenuEvent.java
+++ b/javax/swing/event/MenuEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MenuKeyEvent.java b/javax/swing/event/MenuKeyEvent.java
index aecc99268..511cb2254 100644
--- a/javax/swing/event/MenuKeyEvent.java
+++ b/javax/swing/event/MenuKeyEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -76,7 +76,7 @@ public class MenuKeyEvent extends KeyEvent {
* @param when Time
* @param modifiers Modifier keys
* @param keyCode Key code
- * @param keyhar Key char
+ * @param keyChar Key char
* @param path Path
* @param manager MenuSelectionManager
*/
diff --git a/javax/swing/event/MenuKeyListener.java b/javax/swing/event/MenuKeyListener.java
index bb956f4e4..7a1eb89b4 100644
--- a/javax/swing/event/MenuKeyListener.java
+++ b/javax/swing/event/MenuKeyListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MenuListener.java b/javax/swing/event/MenuListener.java
index 6e37c34cd..dba704a8e 100644
--- a/javax/swing/event/MenuListener.java
+++ b/javax/swing/event/MenuListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MouseInputAdapter.java b/javax/swing/event/MouseInputAdapter.java
index b94b5f8d9..2da5543eb 100644
--- a/javax/swing/event/MouseInputAdapter.java
+++ b/javax/swing/event/MouseInputAdapter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/MouseInputListener.java b/javax/swing/event/MouseInputListener.java
index 35d79cd4e..3c3ca2347 100644
--- a/javax/swing/event/MouseInputListener.java
+++ b/javax/swing/event/MouseInputListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/PopupMenuEvent.java b/javax/swing/event/PopupMenuEvent.java
index b51f74b51..055555086 100644
--- a/javax/swing/event/PopupMenuEvent.java
+++ b/javax/swing/event/PopupMenuEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/PopupMenuListener.java b/javax/swing/event/PopupMenuListener.java
index 84cc25199..dc917d241 100644
--- a/javax/swing/event/PopupMenuListener.java
+++ b/javax/swing/event/PopupMenuListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/SwingPropertyChangeSupport.java b/javax/swing/event/SwingPropertyChangeSupport.java
index b2c6a4e4d..ddbb48658 100644
--- a/javax/swing/event/SwingPropertyChangeSupport.java
+++ b/javax/swing/event/SwingPropertyChangeSupport.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TableColumnModelEvent.java b/javax/swing/event/TableColumnModelEvent.java
index 17a71e409..2ca4148aa 100644
--- a/javax/swing/event/TableColumnModelEvent.java
+++ b/javax/swing/event/TableColumnModelEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TableColumnModelListener.java b/javax/swing/event/TableColumnModelListener.java
index 4234ba93d..90e1b29cc 100644
--- a/javax/swing/event/TableColumnModelListener.java
+++ b/javax/swing/event/TableColumnModelListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TableModelEvent.java b/javax/swing/event/TableModelEvent.java
index ba8a36d3b..e15174cc6 100644
--- a/javax/swing/event/TableModelEvent.java
+++ b/javax/swing/event/TableModelEvent.java
@@ -1,5 +1,5 @@
/* TableModelEvent.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,38 +43,74 @@ import java.util.EventObject;
import javax.swing.table.TableModel;
/**
+ * An event that describes changes to a {@link TableModel}.
+ *
+ * @see javax.swing.event.TableModelListener
+ *
* @author Andrew Selkirk
*/
public class TableModelEvent extends EventObject
{
private static final long serialVersionUID = -7849342674552212824L;
+ /** A column index representing all columns. */
public static final int ALL_COLUMNS = -1;
+
+ /**
+ * An event type indicating that one or more rows have been deleted from the
+ * model.
+ */
public static final int DELETE = -1;
+
+ /** A row index representing the header row. */
public static final int HEADER_ROW = -1;
+
+ /**
+ * An event type indicating that one or more rows have been inserted into the
+ * model.
+ */
public static final int INSERT = 1;
+
+ /** An event type indicating that data has been updated in the model. */
public static final int UPDATE = 0;
+ /** The column in the table model that the event relates to. */
protected int column = 0;
+
+ /** The first row in the table model that the event relates to. */
protected int firstRow = 0;
+
+ /** The last row in the table model that the event relates to. */
protected int lastRow = 0;
+
+ /**
+ * The event type (one of {@link #UPDATE}, {@link #INSERT}, {@link #DELETE}).
+ */
protected int type = 0;
/**
- * Creates a <code>TableModelEvent</code> event.
+ * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
+ * to the data in all columns and rows.
+ *
+ * @param source the source object (<code>null</code> not permitted).
*
- * @param source The source object
+ * @throws IllegalArgumentException if <code>source</code> is
+ * <code>null</code>.
*/
public TableModelEvent(TableModel source)
{
- this(source, 0, source.getRowCount(), ALL_COLUMNS, UPDATE);
+ this(source, 0, Integer.MAX_VALUE, ALL_COLUMNS, UPDATE);
}
/**
- * Creates a <code>TableModelEvent</code> event.
+ * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
+ * to the data in a single row across all columns.
+ *
+ * @param source the source object (<code>null</code> not permitted).
+ * @param row the updated row.
*
- * @param source The source object
- * @param row The updated row
+ * @throws IllegalArgumentException if <code>source</code> is
+ * <code>null</code>.
*/
public TableModelEvent(TableModel source, int row)
{
@@ -82,11 +118,15 @@ public class TableModelEvent extends EventObject
}
/**
- * Creates a <code>TableModelEvent</code> event.
+ * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
+ * to the data in the specified rows across all columns.
*
- * @param source The source object
- * @param firstRow The first row of update
- * @param lastRow The last row of update
+ * @param source the source object (<code>null</code> not permitted).
+ * @param firstRow the first row of update.
+ * @param lastRow the last row of update.
+ *
+ * @throws IllegalArgumentException if <code>source</code> is
+ * <code>null</code>.
*/
public TableModelEvent(TableModel source, int firstRow, int lastRow)
{
@@ -94,28 +134,41 @@ public class TableModelEvent extends EventObject
}
/**
- * Creates a <code>TableModelEvent</code> event.
+ * Creates a new <code>TableModelEvent</code> indicating an {@link #UPDATE}
+ * to the data in the specified rows and column. Use {@link #ALL_COLUMNS}
+ * for the <code>column</code> argument to indicate all columns.
*
- * @param source The source object
- * @param firstRow The first row of update
- * @param lastRow The last row of update
- * @param column The affected column
+ * @param source the source object (<code>null</code> not permitted).
+ * @param firstRow the first row of update.
+ * @param lastRow the last row of update.
+ * @param column the affected column.
+ *
+ * @throws IllegalArgumentException if <code>source</code> is
+ * <code>null</code>.
*/
- public TableModelEvent(TableModel source, int firstRow, int lastRow, int column)
+ public TableModelEvent(TableModel source, int firstRow, int lastRow,
+ int column)
{
this(source, firstRow, lastRow, column, UPDATE);
}
/**
- * Creates a <code>TableModelEvent</code> event.
+ * Creates a new <code>TableModelEvent</code> indicating an operation of
+ * the specified <code>type</code> on the data in the specified rows and
+ * column. The event type is usually one of {@link #UPDATE}, {@link #INSERT},
+ * and {@link #DELETE}.
+ *
+ * @param source the source object (<code>null</code> not permitted).
+ * @param firstRow the first row of update.
+ * @param lastRow the last row of update.
+ * @param column the affected column.
+ * @param type the type of change.
*
- * @param source The source object
- * @param firstRow The first row of update
- * @param lastRow The last row of update
- * @param column The affected column
- * @param type The type of change
+ * @throws IllegalArgumentException if <code>source</code> is
+ * <code>null</code>.
*/
- public TableModelEvent(TableModel source, int firstRow, int lastRow, int column, int type)
+ public TableModelEvent(TableModel source, int firstRow, int lastRow,
+ int column, int type)
{
super(source);
this.firstRow = firstRow;
@@ -126,6 +179,8 @@ public class TableModelEvent extends EventObject
/**
* Returns the affected column of this event.
+ *
+ * @return The column index.
*/
public int getColumn()
{
@@ -134,6 +189,8 @@ public class TableModelEvent extends EventObject
/**
* Returns the first affected row of this event.
+ *
+ * @return The row index.
*/
public int getFirstRow()
{
@@ -142,6 +199,8 @@ public class TableModelEvent extends EventObject
/**
* Returns the last affected row of this event.
+ *
+ * @return The row index.
*/
public int getLastRow()
{
@@ -149,7 +208,10 @@ public class TableModelEvent extends EventObject
}
/**
- * Returns the type of change of this event.
+ * Returns the type of change indicated by this event (usually one of
+ * {@link #UPDATE}, {@link #INSERT}, {@link #DELETE}).
+ *
+ * @return The type.
*/
public int getType()
{
diff --git a/javax/swing/event/TableModelListener.java b/javax/swing/event/TableModelListener.java
index 9b6122286..c8d6e8f8d 100644
--- a/javax/swing/event/TableModelListener.java
+++ b/javax/swing/event/TableModelListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TreeExpansionEvent.java b/javax/swing/event/TreeExpansionEvent.java
index 40d08f027..c4b331346 100644
--- a/javax/swing/event/TreeExpansionEvent.java
+++ b/javax/swing/event/TreeExpansionEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TreeExpansionListener.java b/javax/swing/event/TreeExpansionListener.java
index 621963b3c..08507a0ff 100644
--- a/javax/swing/event/TreeExpansionListener.java
+++ b/javax/swing/event/TreeExpansionListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TreeModelEvent.java b/javax/swing/event/TreeModelEvent.java
index 7dbbc7953..a217e3b40 100644
--- a/javax/swing/event/TreeModelEvent.java
+++ b/javax/swing/event/TreeModelEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TreeModelListener.java b/javax/swing/event/TreeModelListener.java
index 7a46fa936..57b5c511b 100644
--- a/javax/swing/event/TreeModelListener.java
+++ b/javax/swing/event/TreeModelListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TreeSelectionEvent.java b/javax/swing/event/TreeSelectionEvent.java
index 6d2f461e9..9b87667a3 100644
--- a/javax/swing/event/TreeSelectionEvent.java
+++ b/javax/swing/event/TreeSelectionEvent.java
@@ -1,5 +1,5 @@
/* TreeSelectionEvent.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -49,142 +49,151 @@ import javax.swing.tree.TreePath;
*/
public class TreeSelectionEvent extends EventObject {
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * paths
- */
- protected TreePath[] paths;
-
- /**
- * areNew
- */
- protected boolean[] areNew;
-
- /**
- * oldLeadSelectionPath
- */
- protected TreePath oldLeadSelectionPath;
-
- /**
- * newLeadSelectionPath
- */
- protected TreePath newLeadSelectionPath;
-
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor TreeSelectionEvent
- * @param source TODO
- * @param paths TODO
- * @param areNew TODO
- * @param oldLeadSelectionPath TODO
- * @param newLeadSelectionPath TODO
- */
- public TreeSelectionEvent(Object source, TreePath[] paths,
- boolean[] areNew, TreePath oldLeadSelectionPath,
- TreePath newLeadSelectionPath) {
- super(source);
- this.paths = paths;
- this.areNew = areNew;
- this.oldLeadSelectionPath = oldLeadSelectionPath;
- this.newLeadSelectionPath = newLeadSelectionPath;
- } // TreeSelectionEvent()
-
- /**
- * Constructor TreeSelectionEvent
- * @param source TODO
- * @param paths TODO
- * @param areNew TODO
- * @param oldLeadSelectionPath TODO
- * @param newLeadSelectionPath TODO
- */
- public TreeSelectionEvent(Object source, TreePath path,
- boolean isNew, TreePath oldLeadSelectionPath,
- TreePath newLeadSelectionPath) {
- super(source);
-//TODO this.paths = new TreePath[1]{path};
-//TODO this.areNew = new boolean[1]{isNew};
- this.oldLeadSelectionPath = oldLeadSelectionPath;
- this.newLeadSelectionPath = newLeadSelectionPath;
- } // TreeSelectionEvent()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * getPath
- * @returns TreePath
- */
- public TreePath getPath() {
- return paths[0];
- } // getPath()
-
- /**
- * getPaths
- * @returns TreePath[]
- */
- public TreePath[] getPaths() {
- return paths;
- } // getPaths()
-
- /**
- * isAddedPath
- * @returns boolean
- */
- public boolean isAddedPath() {
- return false; // TODO
- } // isAddedPath()
-
- /**
- * isAddedPath
- * @param path TODO
- * @returns boolean
- */
- public boolean isAddedPath(TreePath path) {
- return false; // TODO
- } // isAddedPath()
-
- /**
- * isAddedPath
- * @param index TODO
- * @returns boolean
- */
- public boolean isAddedPath(int index) {
- return false; // TODO
- } // isAddedPath()
-
- /**
- * getOldLeadSelectionPath
- * @returns TreePath
- */
- public TreePath getOldLeadSelectionPath() {
- return oldLeadSelectionPath;
- } // getOldLeadSelectionPath()
-
- /**
- * getNewLeadSelectionPath
- * @returns TreePath
- */
- public TreePath getNewLeadSelectionPath() {
- return newLeadSelectionPath;
- } // getNewLeadSelectionPath()
-
- /**
- * cloneWithSource
- * @param source TODO
- * @returns Object
- */
- public Object cloneWithSource(Object source) {
- return null; // TODO
- } // cloneWithSource()
+ //-------------------------------------------------------------
+ // Variables --------------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * paths
+ */
+ protected TreePath[] paths;
+
+ /**
+ * areNew
+ */
+ protected boolean[] areNew;
+
+ /**
+ * oldLeadSelectionPath
+ */
+ protected TreePath oldLeadSelectionPath;
+
+ /**
+ * newLeadSelectionPath
+ */
+ protected TreePath newLeadSelectionPath;
+
+
+ //-------------------------------------------------------------
+ // Initialization ---------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * Constructor TreeSelectionEvent
+ * @param source TODO
+ * @param paths TODO
+ * @param areNew TODO
+ * @param oldLeadSelectionPath TODO
+ * @param newLeadSelectionPath TODO
+ */
+ public TreeSelectionEvent(Object source, TreePath[] paths,
+ boolean[] areNew, TreePath oldLeadSelectionPath,
+ TreePath newLeadSelectionPath)
+ {
+ super(source);
+ this.paths = paths;
+ this.areNew = areNew;
+ this.oldLeadSelectionPath = oldLeadSelectionPath;
+ this.newLeadSelectionPath = newLeadSelectionPath;
+ } // TreeSelectionEvent()
+
+ /**
+ * Constructor TreeSelectionEvent
+ * @param source TODO
+ * @param path TODO
+ * @param isNew TODO
+ * @param oldLeadSelectionPath TODO
+ * @param newLeadSelectionPath TODO
+ */
+ public TreeSelectionEvent(Object source, TreePath path,
+ boolean isNew, TreePath oldLeadSelectionPath,
+ TreePath newLeadSelectionPath)
+ {
+ super(source);
+ this.paths = new TreePath[]{path};
+ this.areNew = new boolean[]{isNew};
+ this.oldLeadSelectionPath = oldLeadSelectionPath;
+ this.newLeadSelectionPath = newLeadSelectionPath;
+ } // TreeSelectionEvent()
+
+
+ //-------------------------------------------------------------
+ // Methods ----------------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * @returns the first path element
+ */
+ public TreePath getPath()
+ {
+ return paths[0];
+ } // getPath()
+
+ /**
+ *
+ * @returns the paths with selection changed
+ */
+ public TreePath[] getPaths()
+ {
+ return (TreePath[]) paths.clone();
+ } // getPaths()
+
+ /**
+ * @return true if the first path is added to the selection, false otherwise
+ */
+ public boolean isAddedPath()
+ {
+ return areNew[0];
+ } // isAddedPath()
+
+ /**
+ * @param path the path to check
+ * @return true if the path is added to the selection, false otherwise
+ */
+ public boolean isAddedPath(TreePath path)
+ {
+ for (int i = paths.length - 1; i >= 0; i--)
+ if (paths[i].equals(path))
+ return areNew[i];
+
+ return false;
+ } // isAddedPath()
+
+ /**
+ * @param index the index'th path
+ * @return true if the path is added to the selection, false otherwise
+ */
+ public boolean isAddedPath(int index)
+ {
+ return areNew[index];
+ } // isAddedPath()
+
+ /**
+ * @return the previous lead selection path
+ */
+ public TreePath getOldLeadSelectionPath()
+ {
+ return oldLeadSelectionPath;
+ } // getOldLeadSelectionPath()
+
+ /**
+ * @returns the current lead selection path
+ */
+ public TreePath getNewLeadSelectionPath()
+ {
+ return newLeadSelectionPath;
+ } // getNewLeadSelectionPath()
+
+ /**
+ * @param source the new event source
+ * @return a cloned event with another event source
+ */
+ public Object cloneWithSource(Object source)
+ {
+ return new TreeSelectionEvent (source, paths, areNew,
+ oldLeadSelectionPath,
+ newLeadSelectionPath);
+ } // cloneWithSource()
} // TreeSelectionEvent
diff --git a/javax/swing/event/TreeSelectionListener.java b/javax/swing/event/TreeSelectionListener.java
index 78d138aa2..b844a6e0b 100644
--- a/javax/swing/event/TreeSelectionListener.java
+++ b/javax/swing/event/TreeSelectionListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/TreeWillExpandListener.java b/javax/swing/event/TreeWillExpandListener.java
index 35364b9fb..89d3764f3 100644
--- a/javax/swing/event/TreeWillExpandListener.java
+++ b/javax/swing/event/TreeWillExpandListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/UndoableEditEvent.java b/javax/swing/event/UndoableEditEvent.java
index 9e989d1a4..147c2e5b1 100644
--- a/javax/swing/event/UndoableEditEvent.java
+++ b/javax/swing/event/UndoableEditEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/UndoableEditListener.java b/javax/swing/event/UndoableEditListener.java
index 9031afe62..13eecf51a 100644
--- a/javax/swing/event/UndoableEditListener.java
+++ b/javax/swing/event/UndoableEditListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/event/package.html b/javax/swing/event/package.html
index 3625b0738..faef7e15a 100644
--- a/javax/swing/event/package.html
+++ b/javax/swing/event/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.event package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.event</title></head>
<body>
-<p></p>
+<p>Provides events and listeners used by components in the
+<code>javax.swing</code> package.</p>
</body>
</html>
diff --git a/javax/swing/filechooser/FileFilter.java b/javax/swing/filechooser/FileFilter.java
index 7e0be6d1b..42770d981 100644
--- a/javax/swing/filechooser/FileFilter.java
+++ b/javax/swing/filechooser/FileFilter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/filechooser/FileSystemView.java b/javax/swing/filechooser/FileSystemView.java
index 6be4773aa..ffa41ca07 100644
--- a/javax/swing/filechooser/FileSystemView.java
+++ b/javax/swing/filechooser/FileSystemView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -134,7 +134,7 @@ public abstract class FileSystemView
*/
public File[] getFiles(File dir, boolean useFileHiding)
{
- if (dir == null)
+ if (dir == null || dir.listFiles() == null)
return null;
File[] files = dir.listFiles();
if (! useFileHiding)
diff --git a/javax/swing/filechooser/FileView.java b/javax/swing/filechooser/FileView.java
index f680e8fec..c431fd461 100644
--- a/javax/swing/filechooser/FileView.java
+++ b/javax/swing/filechooser/FileView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/filechooser/UnixFileSystemView.java b/javax/swing/filechooser/UnixFileSystemView.java
index ccf054305..f2360ec52 100644
--- a/javax/swing/filechooser/UnixFileSystemView.java
+++ b/javax/swing/filechooser/UnixFileSystemView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/filechooser/package.html b/javax/swing/filechooser/package.html
index 228233151..bf897abb5 100644
--- a/javax/swing/filechooser/package.html
+++ b/javax/swing/filechooser/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.event package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.filechooser</title></head>
<body>
-<p></p>
+<p>Provides support classes for the {@link javax.swing.JFileChooser}
+component.</p>
</body>
</html>
diff --git a/javax/swing/package.html b/javax/swing/package.html
index 1e4db5952..30ceb88bf 100644
--- a/javax/swing/package.html
+++ b/javax/swing/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing</title></head>
<body>
-<p></p>
+<p>Provides a collection of cross-platform user interface
+components.</p>
</body>
</html>
diff --git a/javax/swing/plaf/ActionMapUIResource.java b/javax/swing/plaf/ActionMapUIResource.java
index 640f3a756..f6af0880d 100644
--- a/javax/swing/plaf/ActionMapUIResource.java
+++ b/javax/swing/plaf/ActionMapUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/BorderUIResource.java b/javax/swing/plaf/BorderUIResource.java
index 6b61f48a0..4402bbb48 100644
--- a/javax/swing/plaf/BorderUIResource.java
+++ b/javax/swing/plaf/BorderUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -556,7 +556,7 @@ public class BorderUIResource
* @param shadow the color that will be used for painting
* the shadow part of the border.
*
- * @see #EtchedBorderUIResource(int, Color, Color)
+ * @see EtchedBorderUIResource#EtchedBorderUIResource(int, Color, Color)
*/
public EtchedBorderUIResource(Color highlight, Color shadow)
{
@@ -684,7 +684,7 @@ public class BorderUIResource
* @param left the width of the border at its left edge.
* @param bottom the width of the border at its bottom edge.
* @param right the width of the border at its right edge.
- * @param matteColor the color for filling the border.
+ * @param color the color for filling the border.
*/
public MatteBorderUIResource(int top, int left,
int bottom, int right,
diff --git a/javax/swing/plaf/ButtonUI.java b/javax/swing/plaf/ButtonUI.java
index 4fdaee505..197299e0c 100644
--- a/javax/swing/plaf/ButtonUI.java
+++ b/javax/swing/plaf/ButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ColorChooserUI.java b/javax/swing/plaf/ColorChooserUI.java
index e290a972a..68ffd916d 100644
--- a/javax/swing/plaf/ColorChooserUI.java
+++ b/javax/swing/plaf/ColorChooserUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ColorUIResource.java b/javax/swing/plaf/ColorUIResource.java
index caa644c49..33b1676e0 100644
--- a/javax/swing/plaf/ColorUIResource.java
+++ b/javax/swing/plaf/ColorUIResource.java
@@ -1,5 +1,5 @@
/* ColorUIResource.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -63,6 +63,9 @@ public class ColorUIResource
* @param r the red intensity, which must be in the range [0 .. 255].
* @param g the green intensity, which must be in the range [0 .. 255].
* @param b the blue intensity, which must be in the range [0 .. 255].
+ *
+ * @throws IllegalArgumentException if any of the values is outside the
+ * specified range.
*/
public ColorUIResource(int r, int g, int b)
{
@@ -71,7 +74,7 @@ public class ColorUIResource
/**
- * Consructs a <code>ColorUIResource</code> using the specified
+ * Constructs a <code>ColorUIResource</code> using the specified
* RGB value. The blue value is in bits 0-7, green in bits 8-15, and
* red in bits 16-23. The other bits are ignored. The alpha value is set
* to 255, meaning that the color is fully opaque.
@@ -93,6 +96,9 @@ public class ColorUIResource
* @param r the red intensity, which must be in the range [0.0 .. 1.0].
* @param g the green intensity, which must be in the range [0.0 .. 1.0].
* @param b the blue intensity, which must be in the range [0.0 .. 1.0].
+ *
+ * @throws IllegalArgumentException if any of the values is outside the
+ * specified range.
*/
public ColorUIResource(float r, float g, float b)
{
@@ -105,7 +111,10 @@ public class ColorUIResource
* of another color.
*
* @param c the color whose intensities will be considered when
- * constructing this <code>ColorUIResource</code>.
+ * constructing this <code>ColorUIResource</code> (<code>null</code>
+ * not permitted).
+ *
+ * @throws NullPointerException if <code>c</code> is <code>null</code>.
*/
public ColorUIResource(Color c)
{
diff --git a/javax/swing/plaf/ComboBoxUI.java b/javax/swing/plaf/ComboBoxUI.java
index 83286d95b..9498a4815 100644
--- a/javax/swing/plaf/ComboBoxUI.java
+++ b/javax/swing/plaf/ComboBoxUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ComponentInputMapUIResource.java b/javax/swing/plaf/ComponentInputMapUIResource.java
index 40a70552e..e1418710f 100644
--- a/javax/swing/plaf/ComponentInputMapUIResource.java
+++ b/javax/swing/plaf/ComponentInputMapUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ComponentUI.java b/javax/swing/plaf/ComponentUI.java
index 80e60c8f1..0e7680542 100644
--- a/javax/swing/plaf/ComponentUI.java
+++ b/javax/swing/plaf/ComponentUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/DesktopIconUI.java b/javax/swing/plaf/DesktopIconUI.java
index dfe69cc63..2e44088ca 100644
--- a/javax/swing/plaf/DesktopIconUI.java
+++ b/javax/swing/plaf/DesktopIconUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/DesktopPaneUI.java b/javax/swing/plaf/DesktopPaneUI.java
index 6943bf30f..de553eaf4 100644
--- a/javax/swing/plaf/DesktopPaneUI.java
+++ b/javax/swing/plaf/DesktopPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/DimensionUIResource.java b/javax/swing/plaf/DimensionUIResource.java
index 06ec16670..63c6838c4 100644
--- a/javax/swing/plaf/DimensionUIResource.java
+++ b/javax/swing/plaf/DimensionUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/FileChooserUI.java b/javax/swing/plaf/FileChooserUI.java
index 903718154..8b661e399 100644
--- a/javax/swing/plaf/FileChooserUI.java
+++ b/javax/swing/plaf/FileChooserUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -98,7 +98,7 @@ public abstract class FileChooserUI
* @param chooser the <code>JFileChooser</code> whose
* button text is requested.
*
- * @see javax.swing.JFileChoose#getApproveButtonText
+ * @see javax.swing.JFileChooser#getApproveButtonText
*/
public abstract String getApproveButtonText(JFileChooser chooser);
@@ -111,7 +111,7 @@ public abstract class FileChooserUI
* @param chooser the <code>JFileChooser</code> whose
* dialog title is requested.
*
- * @see javax.swing.JFileChoose#getDialogtitle
+ * @see javax.swing.JFileChooser#getDialogTitle
*/
public abstract String getDialogTitle(JFileChooser chooser);
diff --git a/javax/swing/plaf/FontUIResource.java b/javax/swing/plaf/FontUIResource.java
index a4a45de72..1c1731048 100644
--- a/javax/swing/plaf/FontUIResource.java
+++ b/javax/swing/plaf/FontUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/IconUIResource.java b/javax/swing/plaf/IconUIResource.java
index 3af16b757..1b09ed31f 100644
--- a/javax/swing/plaf/IconUIResource.java
+++ b/javax/swing/plaf/IconUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/InputMapUIResource.java b/javax/swing/plaf/InputMapUIResource.java
index f638dd7b8..ae032e51f 100644
--- a/javax/swing/plaf/InputMapUIResource.java
+++ b/javax/swing/plaf/InputMapUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/InsetsUIResource.java b/javax/swing/plaf/InsetsUIResource.java
index ad2eb1b21..755d8add1 100644
--- a/javax/swing/plaf/InsetsUIResource.java
+++ b/javax/swing/plaf/InsetsUIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/InternalFrameUI.java b/javax/swing/plaf/InternalFrameUI.java
index 69bfb6506..fd1e3374c 100644
--- a/javax/swing/plaf/InternalFrameUI.java
+++ b/javax/swing/plaf/InternalFrameUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/LabelUI.java b/javax/swing/plaf/LabelUI.java
index bda4448b9..8fc1d711b 100644
--- a/javax/swing/plaf/LabelUI.java
+++ b/javax/swing/plaf/LabelUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ListUI.java b/javax/swing/plaf/ListUI.java
index 1639c41d3..66d5cf588 100644
--- a/javax/swing/plaf/ListUI.java
+++ b/javax/swing/plaf/ListUI.java
@@ -1,5 +1,5 @@
/* ListUI.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -75,7 +75,7 @@ public abstract class ListUI
* @return the index of the closest cell, or -1 if the list model
* is empty.
*/
- public abstract int locationToIndex(JList index, Point location);
+ public abstract int locationToIndex(JList list, Point location);
/**
diff --git a/javax/swing/plaf/MenuBarUI.java b/javax/swing/plaf/MenuBarUI.java
index fa350b660..8835571ac 100644
--- a/javax/swing/plaf/MenuBarUI.java
+++ b/javax/swing/plaf/MenuBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/MenuItemUI.java b/javax/swing/plaf/MenuItemUI.java
index c44d1f441..31d73194a 100644
--- a/javax/swing/plaf/MenuItemUI.java
+++ b/javax/swing/plaf/MenuItemUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/OptionPaneUI.java b/javax/swing/plaf/OptionPaneUI.java
index 8a954537a..13d1caa6a 100644
--- a/javax/swing/plaf/OptionPaneUI.java
+++ b/javax/swing/plaf/OptionPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/PanelUI.java b/javax/swing/plaf/PanelUI.java
index d39d2e547..b1171b80d 100644
--- a/javax/swing/plaf/PanelUI.java
+++ b/javax/swing/plaf/PanelUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/PopupMenuUI.java b/javax/swing/plaf/PopupMenuUI.java
index 7e71a4b2e..c70ad2a4e 100644
--- a/javax/swing/plaf/PopupMenuUI.java
+++ b/javax/swing/plaf/PopupMenuUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ProgressBarUI.java b/javax/swing/plaf/ProgressBarUI.java
index 28ea6f3a9..79c1b95a3 100644
--- a/javax/swing/plaf/ProgressBarUI.java
+++ b/javax/swing/plaf/ProgressBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/RootPaneUI.java b/javax/swing/plaf/RootPaneUI.java
index 0943c9882..ff7d0a6e7 100644
--- a/javax/swing/plaf/RootPaneUI.java
+++ b/javax/swing/plaf/RootPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ScrollBarUI.java b/javax/swing/plaf/ScrollBarUI.java
index 37c0cf783..3cad39327 100644
--- a/javax/swing/plaf/ScrollBarUI.java
+++ b/javax/swing/plaf/ScrollBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ScrollPaneUI.java b/javax/swing/plaf/ScrollPaneUI.java
index 7d0bb892a..14d2ac61e 100644
--- a/javax/swing/plaf/ScrollPaneUI.java
+++ b/javax/swing/plaf/ScrollPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/SeparatorUI.java b/javax/swing/plaf/SeparatorUI.java
index 03778b95d..6855bd035 100644
--- a/javax/swing/plaf/SeparatorUI.java
+++ b/javax/swing/plaf/SeparatorUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/SliderUI.java b/javax/swing/plaf/SliderUI.java
index 2a839f802..775f19620 100644
--- a/javax/swing/plaf/SliderUI.java
+++ b/javax/swing/plaf/SliderUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/SpinnerUI.java b/javax/swing/plaf/SpinnerUI.java
index 497fdb237..fb4a3b13a 100644
--- a/javax/swing/plaf/SpinnerUI.java
+++ b/javax/swing/plaf/SpinnerUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/SplitPaneUI.java b/javax/swing/plaf/SplitPaneUI.java
index 146db7664..ea9af2b17 100644
--- a/javax/swing/plaf/SplitPaneUI.java
+++ b/javax/swing/plaf/SplitPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/TabbedPaneUI.java b/javax/swing/plaf/TabbedPaneUI.java
index f0cf69919..6ab823b50 100644
--- a/javax/swing/plaf/TabbedPaneUI.java
+++ b/javax/swing/plaf/TabbedPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/TableHeaderUI.java b/javax/swing/plaf/TableHeaderUI.java
index 26bc9e29b..f23ca74d7 100644
--- a/javax/swing/plaf/TableHeaderUI.java
+++ b/javax/swing/plaf/TableHeaderUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/TableUI.java b/javax/swing/plaf/TableUI.java
index 7062b93cc..e56bcd131 100644
--- a/javax/swing/plaf/TableUI.java
+++ b/javax/swing/plaf/TableUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/TextUI.java b/javax/swing/plaf/TextUI.java
index b28dd372e..dcabdfcdb 100644
--- a/javax/swing/plaf/TextUI.java
+++ b/javax/swing/plaf/TextUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,6 +40,7 @@ package javax.swing.plaf;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.Shape;
import javax.swing.text.BadLocationException;
import javax.swing.text.EditorKit;
@@ -83,9 +84,7 @@ public abstract class TextUI
* @throws BadLocationException if <code>pos</code> does not
* designate a valid position in the document model.
*
- * @see javax.swing.text.View#modelToView(int,
- * javax.swing.text.Position.Bias, int,
- * javax.swing.text.position.Bias, java.awt.Shape)
+ * @see javax.swing.text.ComponentView#modelToView(int, Shape, Position.Bias)
*/
public abstract Rectangle modelToView(JTextComponent tc, int pos)
throws BadLocationException;
@@ -113,9 +112,7 @@ public abstract class TextUI
* @throws BadLocationException if <code>pos</code> does not
* designate a valid position in the document model.
*
- * @see javax.swing.text.View#modelToView(int,
- * javax.swing.text.Position.Bias, int,
- * javax.swing.text.position.Bias, java.awt.Shape)
+ * @see javax.swing.text.ComponentView#modelToView(int, Shape, Position.Bias)
*/
public abstract Rectangle modelToView(JTextComponent tc, int pos,
Position.Bias bias)
@@ -126,10 +123,10 @@ public abstract class TextUI
* Finds the caret position which is closest to the specified visual
* location.
*
- * @param tc the <code>JTextComponent</code> for which this
+ * @param t the <code>JTextComponent</code> for which this
* delegate object provides the user interface.
*
- * @param loc the position in view coordinates.
+ * @param pt the position in view coordinates.
*
* @return the caret position which is closest to <code>loc</code>.
*
@@ -191,7 +188,7 @@ public abstract class TextUI
*
* @throws IllegalArgumentException if <code>direction</code>
* is not one of <code>Position.Bias.Forward</code>
- * or <code>Position.Biad.Backward</code>.
+ * or <code>Position.Bias.Backward</code>.
*/
public abstract int getNextVisualPositionFrom(JTextComponent tc,
int pos,
diff --git a/javax/swing/plaf/ToolBarUI.java b/javax/swing/plaf/ToolBarUI.java
index 18b27d3ae..730cf4887 100644
--- a/javax/swing/plaf/ToolBarUI.java
+++ b/javax/swing/plaf/ToolBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/ToolTipUI.java b/javax/swing/plaf/ToolTipUI.java
index 4f332a635..4383d0edd 100644
--- a/javax/swing/plaf/ToolTipUI.java
+++ b/javax/swing/plaf/ToolTipUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/TreeUI.java b/javax/swing/plaf/TreeUI.java
index d4bee57cf..e32952de7 100644
--- a/javax/swing/plaf/TreeUI.java
+++ b/javax/swing/plaf/TreeUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/UIResource.java b/javax/swing/plaf/UIResource.java
index 1fff8488c..59edf5666 100644
--- a/javax/swing/plaf/UIResource.java
+++ b/javax/swing/plaf/UIResource.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,7 @@ package javax.swing.plaf;
/**
* This public interface is used to designate which objects were created by
- * <code>ComponentUI</code> delegates. When uninstalling the user public interface
+ * {@link ComponentUI} delegates. When uninstalling the user public interface
* renderer with <code>ComponentUI.uninstallUI()</code> the renderer
* property is set to <code>null</code>.
* <br>
@@ -50,6 +50,6 @@ package javax.swing.plaf;
* they are initialized or set to <code>null</code>.
*
* @author Brian Jones
- * @see java.lang.ComponentUI
+ * @see ComponentUI
*/
public interface UIResource { }
diff --git a/javax/swing/plaf/ViewportUI.java b/javax/swing/plaf/ViewportUI.java
index 3b2892049..087938f1e 100644
--- a/javax/swing/plaf/ViewportUI.java
+++ b/javax/swing/plaf/ViewportUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicArrowButton.java b/javax/swing/plaf/basic/BasicArrowButton.java
index 0526961a9..4da4691f6 100644
--- a/javax/swing/plaf/basic/BasicArrowButton.java
+++ b/javax/swing/plaf/basic/BasicArrowButton.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicBorders.java b/javax/swing/plaf/basic/BasicBorders.java
index dd668e353..e7d6e4338 100644
--- a/javax/swing/plaf/basic/BasicBorders.java
+++ b/javax/swing/plaf/basic/BasicBorders.java
@@ -1,5 +1,5 @@
/* BasicBorders.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -89,9 +89,9 @@ public class BasicBorders
* height="170" alt="[A screen shot of the returned border]" />
*
* @return a {@link
- * javax.swing.plaf.BorderUIResource#CompoundBorderUIResource}
- * whose outer border is a {@link #ButtonBorder} and whose
- * inner border is a {@link #MarginBorder}.
+ * javax.swing.plaf.BorderUIResource.CompoundBorderUIResource}
+ * whose outer border is a {@link ButtonBorder} and whose
+ * inner border is a {@link MarginBorder}.
*/
public static Border getButtonBorder()
{
@@ -139,9 +139,9 @@ public class BasicBorders
* height="135" alt="[A screen shot of the returned border]" />
*
* @return a {@link
- * javax.swing.plaf.BorderUIResource#CompoundBorderUIResource}
- * whose outer border is a {@link #RadioButtonBorder} and whose
- * inner border is a {@link #MarginBorder}.
+ * javax.swing.plaf.BorderUIResource.CompoundBorderUIResource}
+ * whose outer border is a {@link RadioButtonBorder} and whose
+ * inner border is a {@link MarginBorder}.
*/
public static Border getRadioButtonBorder()
{
@@ -191,9 +191,9 @@ public class BasicBorders
* height="135" alt="[A screen shot of the returned border]" />
*
* @return a {@link
- * javax.swing.plaf.BorderUIResource#CompoundBorderUIResource}
- * whose outer border is a {@link #ToggleButtonBorder} and whose
- * inner border is a {@link #MarginBorder}.
+ * javax.swing.plaf.BorderUIResource.CompoundBorderUIResource}
+ * whose outer border is a {@link ToggleButtonBorder} and whose
+ * inner border is a {@link MarginBorder}.
*/
public static Border getToggleButtonBorder()
{
@@ -241,7 +241,7 @@ public class BasicBorders
* <p><img src="doc-files/BasicBorders.MenuBarBorder-1.png" width="500"
* height="140" alt="[A screen shot of a JMenuBar with this border]" />
*
- * @return a {@link #MenuBarBorder}.
+ * @return a {@link MenuBarBorder}.
*
* @see javax.swing.JMenuBar
*/
@@ -272,7 +272,7 @@ public class BasicBorders
* <p><img src="doc-files/BasicBorders.SplitPaneBorder-2.png" width="520"
* height="200" alt="[A screen shot for JSplitPane.VERTICAL_SPLIT]" />
*
- * @return a {@link #SplitPaneBorder}.
+ * @return a {@link SplitPaneBorder}.
*
* @see javax.swing.JSplitPane
* @see #getSplitPaneDividerBorder()
@@ -339,8 +339,7 @@ public class BasicBorders
* height="200" alt="[A screen shot of a border returned by
* this method]" />
*
- * @return an instance of
- * {@link javax.swing.plaf.basic.BasicBorders$FieldBorder}.
+ * @return an instance of {@link FieldBorder}.
*
* @see javax.swing.JTextField
* @see javax.swing.text.JTextComponent
@@ -592,7 +591,7 @@ public class BasicBorders
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
@@ -756,7 +755,7 @@ public class BasicBorders
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
@@ -1020,7 +1019,7 @@ public class BasicBorders
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
@@ -1176,7 +1175,7 @@ public class BasicBorders
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
@@ -1230,7 +1229,7 @@ public class BasicBorders
* Paints the border around a rollover button. If <code>c</code>
* is not an {@link javax.swing.AbstractButton} whose model
* returns <code>true</code> for {@link
- * javax.swing.ButtonModel#isRollver}, nothing gets painted at
+ * javax.swing.ButtonModel#isRollover}, nothing gets painted at
* all.
*
* @param c the button whose border is to be painted.
@@ -1309,8 +1308,8 @@ public class BasicBorders
* appearance of the Sun reference implementation. A bug report has
* been filed with Sun (review ID 188774).
*
- * @see {@link #getSplitPaneBorder()}
- * @see {@link #getSplitPaneDividerBorder()}
+ * @see #getSplitPaneBorder()
+ * @see #getSplitPaneDividerBorder()
*
* @author Sascha Brawer (brawer@dandelis.ch)
*/
@@ -1797,7 +1796,7 @@ public class BasicBorders
*
* @return the same object that was passed for <code>insets</code>.
*
- * @see #getBorderInsets()
+ * @see #getBorderInsets(Component)
*/
public Insets getBorderInsets(Component c, Insets insets)
{
diff --git a/javax/swing/plaf/basic/BasicButtonListener.java b/javax/swing/plaf/basic/BasicButtonListener.java
index 3a81e3ff9..5349f5240 100644
--- a/javax/swing/plaf/basic/BasicButtonListener.java
+++ b/javax/swing/plaf/basic/BasicButtonListener.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -87,9 +87,6 @@ public class BasicButtonListener
if (e.getSource() instanceof AbstractButton)
{
AbstractButton button = (AbstractButton) e.getSource();
- ButtonModel model = button.getModel();
- model.setArmed(false);
-
if (button.isFocusPainted())
button.repaint();
}
diff --git a/javax/swing/plaf/basic/BasicButtonUI.java b/javax/swing/plaf/basic/BasicButtonUI.java
index 6c0ac38b8..0c069da0f 100644
--- a/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/javax/swing/plaf/basic/BasicButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -200,7 +200,7 @@ public class BasicButtonUI extends ButtonUI
/**
* Calculate the preferred size of this component, by delegating to
- * {@link BasicGraphicsUtils.getPreferredButtonSize}.
+ * {@link BasicGraphicsUtils#getPreferredButtonSize}.
*
* @param c The component to measure
*
@@ -285,7 +285,8 @@ public class BasicButtonUI extends ButtonUI
paintIcon(g, c, ir);
if (text != null)
paintText(g, b, tr, text);
- paintFocus(g, b, vr, tr, ir);
+ if (b.isFocusOwner())
+ paintFocus(g, b, vr, tr, ir);
}
/**
@@ -300,21 +301,14 @@ public class BasicButtonUI extends ButtonUI
* @param tr Text rectangle, contained in visible rectangle
* @param ir Icon rectangle, contained in visible rectangle
*
- * @see AbstractButton.isFocusPainted()
- * @see JComponent.hasFocus()
+ * @see AbstractButton#isFocusPainted()
+ * @see JComponent#hasFocus()
*/
protected void paintFocus(Graphics g, AbstractButton b, Rectangle vr,
Rectangle tr, Rectangle ir)
{
- if (b.hasFocus() && b.isFocusPainted())
- {
- 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);
- }
+ // In the BasicLookAndFeel no focus border is drawn. This can be
+ // overridden in subclasses to implement such behaviour.
}
/**
diff --git a/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java b/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
index 5d7bbcd2c..da11898bf 100644
--- a/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicCheckBoxUI.java b/javax/swing/plaf/basic/BasicCheckBoxUI.java
index 5e1e0f5a9..e3167327c 100644
--- a/javax/swing/plaf/basic/BasicCheckBoxUI.java
+++ b/javax/swing/plaf/basic/BasicCheckBoxUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicColorChooserUI.java b/javax/swing/plaf/basic/BasicColorChooserUI.java
index 5b876284c..4e6d38154 100644
--- a/javax/swing/plaf/basic/BasicColorChooserUI.java
+++ b/javax/swing/plaf/basic/BasicColorChooserUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicComboBoxEditor.java b/javax/swing/plaf/basic/BasicComboBoxEditor.java
index a55e13c95..dd867f0dc 100644
--- a/javax/swing/plaf/basic/BasicComboBoxEditor.java
+++ b/javax/swing/plaf/basic/BasicComboBoxEditor.java
@@ -1,5 +1,5 @@
/* BasicComboBoxEditor.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -81,17 +81,20 @@ public class BasicComboBoxEditor extends Object implements ComboBoxEditor,
}
/**
- * Sets item that should be editted when any editting operation is performed
+ * Sets item that should be edited when any editing 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
+ * combo box list then this method should be called to change editing
* item to the new selected item.
*
- * @param selectedItem item that is currently selected in the combo box
+ * @param item item that is currently selected in the combo box
*/
public void setItem(Object item)
{
- editor.setText(item.toString());
+ if (item == null)
+ editor.setText("");
+ else
+ editor.setText(item.toString());
}
/**
diff --git a/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/javax/swing/plaf/basic/BasicComboBoxRenderer.java
index 9f61e0d18..e4fbb8352 100644
--- a/javax/swing/plaf/basic/BasicComboBoxRenderer.java
+++ b/javax/swing/plaf/basic/BasicComboBoxRenderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicComboBoxUI.java b/javax/swing/plaf/basic/BasicComboBoxUI.java
index 572902ec3..68e18a6ab 100644
--- a/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicComboPopup.java b/javax/swing/plaf/basic/BasicComboPopup.java
index 2acc21fa7..73aac8d4e 100644
--- a/javax/swing/plaf/basic/BasicComboPopup.java
+++ b/javax/swing/plaf/basic/BasicComboPopup.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicDesktopIconUI.java b/javax/swing/plaf/basic/BasicDesktopIconUI.java
index 2a87761ee..561b497f1 100644
--- a/javax/swing/plaf/basic/BasicDesktopIconUI.java
+++ b/javax/swing/plaf/basic/BasicDesktopIconUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicDesktopPaneUI.java b/javax/swing/plaf/basic/BasicDesktopPaneUI.java
index a9e7ffceb..b15700d6f 100644
--- a/javax/swing/plaf/basic/BasicDesktopPaneUI.java
+++ b/javax/swing/plaf/basic/BasicDesktopPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicDirectoryModel.java b/javax/swing/plaf/basic/BasicDirectoryModel.java
index f83887e69..a694f3280 100644
--- a/javax/swing/plaf/basic/BasicDirectoryModel.java
+++ b/javax/swing/plaf/basic/BasicDirectoryModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicEditorPaneUI.java b/javax/swing/plaf/basic/BasicEditorPaneUI.java
index 18cacab11..d5b34d9ee 100644
--- a/javax/swing/plaf/basic/BasicEditorPaneUI.java
+++ b/javax/swing/plaf/basic/BasicEditorPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,30 +39,69 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import javax.swing.JComponent;
+import javax.swing.JEditorPane;
import javax.swing.plaf.ComponentUI;
+import javax.swing.text.EditorKit;
import javax.swing.text.Element;
+import javax.swing.text.JTextComponent;
import javax.swing.text.PlainView;
import javax.swing.text.View;
+/**
+ * The UI class for {@link JEditorPane}s.
+ *
+ * @author original author unknown
+ * @author Roman Kennke (roman@kennke.org)
+ */
public class BasicEditorPaneUI extends BasicTextUI
{
+ /**
+ * Creates an instance of <code>BasicEditorPaneUI</code> for the text
+ * component <code>comp</code>.
+ *
+ * @param comp the component for which to create an UI
+ *
+ * @return the UI for <code>comp</code>
+ */
public static ComponentUI createUI(JComponent comp)
{
return new BasicEditorPaneUI();
}
+ /**
+ * Creates a new <code>BasicEditorPaneUI</code>
+ */
public BasicEditorPaneUI()
{
// Do nothing here.
}
+ // FIXME: Should not be overridden here but instead be handled by the
+ // JEditorPane's EditorKit. However, as long as we don't have styles in
+ // place this doesn't make much sense.
public View create(Element elem)
{
return new PlainView(elem);
}
+ /**
+ * Returns the property prefix to be used by this UI class. This is
+ * <code>EditorPane</code> in this case.
+ *
+ * @return <code>EditorPane</code>
+ */
protected String getPropertyPrefix()
{
return "EditorPane";
}
+
+ /**
+ * Gets the EditorKit for the text component.
+ *
+ * @param textComponent the text component for which to fetch the editor kit
+ */
+ public EditorKit getEditorKit(JTextComponent textComponent)
+ {
+ return ((JEditorPane) textComponent).getEditorKit();
+ }
}
diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java
index d425ad324..fd34fbd62 100644
--- a/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -152,8 +152,9 @@ public class BasicFileChooserUI extends FileChooserUI
{
File f = filechooser.getFileSystemView().createFileObject(obj
.toString());
- if (filechooser.isTraversable(f))
- filechooser.setCurrentDirectory(f);
+ if (filechooser.isTraversable(f) &&
+ filechooser.getFileSelectionMode() == JFileChooser.FILES_ONLY)
+ filechooser.setCurrentDirectory(f);
else
{
filechooser.setSelectedFile(f);
@@ -873,76 +874,74 @@ public class BasicFileChooserUI extends FileChooserUI
}
};
- // -- begin private --
+ // -- begin private, but package local since used in inner classes --
- /** DOCUMENT ME! */
- private JFileChooser filechooser;
+ JFileChooser filechooser;
/** DOCUMENT ME! */
- private JList filelist;
+ JList filelist;
/** DOCUMENT ME! */
- private JComboBox filters;
+ JComboBox filters;
/** DOCUMENT ME! */
- private BasicDirectoryModel model;
+ BasicDirectoryModel model;
/** DOCUMENT ME! */
- private FileFilter acceptAll = new AcceptAllFileFilter();
+ FileFilter acceptAll = new AcceptAllFileFilter();
/** DOCUMENT ME! */
- private FileView fv = new BasicFileView();
+ FileView fv = new BasicFileView();
/** DOCUMENT ME! */
- private static final int ICON_SIZE = 24;
+ static final int ICON_SIZE = 24;
/** DOCUMENT ME! */
- private JComboBox parents;
+ JComboBox parents;
/** DOCUMENT ME! */
- private String filename;
+ String filename;
/** DOCUMENT ME! */
- private JButton accept;
+ JButton accept;
/** DOCUMENT ME! */
- private JButton cancel;
+ JButton cancel;
/** DOCUMENT ME! */
- private JButton upFolderButton;
+ JButton upFolderButton;
/** DOCUMENT ME! */
- private JButton newFolderButton;
+ JButton newFolderButton;
/** DOCUMENT ME! */
- private JButton homeFolderButton;
+ JButton homeFolderButton;
/** DOCUMENT ME! */
- private JPanel accessoryPanel;
+ JPanel accessoryPanel;
/** DOCUMENT ME! */
- private PropertyChangeListener propertyChangeListener;
+ PropertyChangeListener propertyChangeListener;
/** DOCUMENT ME! */
- private String acceptAllFileFilterText;
+ String acceptAllFileFilterText;
/** DOCUMENT ME! */
- private String dirDescText;
+ String dirDescText;
/** DOCUMENT ME! */
- private String fileDescText;
+ String fileDescText;
/** DOCUMENT ME! */
- private boolean dirSelected = false;
+ boolean dirSelected = false;
/** DOCUMENT ME! */
- private File currDir = null;
+ File currDir = null;
- /** DOCUMENT ME! */
- private JPanel bottomPanel;
+ JPanel bottomPanel;
/** DOCUMENT ME! */
- private JPanel closePanel;
+ JPanel closePanel;
// -- end private --
private class ListLabelRenderer
@@ -1028,10 +1027,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
}
- /**
- * DOCUMENT ME!
- */
- private void closeDialog()
+ void closeDialog()
{
Window owner = SwingUtilities.windowForComponent(filechooser);
if (owner instanceof JDialog)
@@ -1167,10 +1163,7 @@ public class BasicFileChooserUI extends FileChooserUI
};
}
- /**
- * DOCUMENT ME!
- */
- private void filterEntries()
+ void filterEntries()
{
FileFilter[] list = filechooser.getChoosableFileFilters();
if (filters.getItemCount() > 0)
diff --git a/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java b/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
index c61dc40a5..3abd76fe2 100644
--- a/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
+++ b/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicGraphicsUtils.java b/javax/swing/plaf/basic/BasicGraphicsUtils.java
index 7eef7760f..78ee62f95 100644
--- a/javax/swing/plaf/basic/BasicGraphicsUtils.java
+++ b/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -51,6 +51,8 @@ import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;
import javax.swing.AbstractButton;
+import javax.swing.Icon;
+import javax.swing.JComponent;
import javax.swing.SwingUtilities;
@@ -585,7 +587,9 @@ public class BasicGraphicsUtils
* and <code>height</code> fields indicate the preferred
* extent in pixels.
*
- * @see javax.swing.SwingUtilities#layoutCompoundLabel
+ * @see javax.swing.SwingUtilities#layoutCompoundLabel(JComponent,
+ * FontMetrics, String, Icon, int, int, int, int, Rectangle, Rectangle,
+ * Rectangle, int)
*/
public static Dimension getPreferredButtonSize(AbstractButton b,
int textIconGap)
diff --git a/javax/swing/plaf/basic/BasicIconFactory.java b/javax/swing/plaf/basic/BasicIconFactory.java
index a2acc8116..43380c203 100644
--- a/javax/swing/plaf/basic/BasicIconFactory.java
+++ b/javax/swing/plaf/basic/BasicIconFactory.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -70,10 +70,100 @@ public class BasicIconFactory implements Serializable
}
}
+ /**
+ * The icon used for CheckBoxes in the BasicLookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class CheckBoxIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon. The BasicLookAndFeel CheckBox icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
- public BasicIconFactory()
+ /**
+ * Returns the width of the icon. The BasicLookAndFeel CheckBox icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The BasicLookAndFeel CheckBox icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // The icon is empty and needs no painting.
+ }
+ }
+
+ /**
+ * The icon used for RadioButtons in the BasicLookAndFeel. This is an empty
+ * icon with a size of 13x13 pixels.
+ */
+ static class RadioButtonIcon
+ implements Icon
{
+ /**
+ * Returns the height of the icon. The BasicLookAndFeel RadioButton icon
+ * has a height of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon. The BasicLookAndFeel RadioButton icon
+ * has a width of 13 pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. The BasicLookAndFeel RadioButton icon is empty and does
+ * not need to be painted.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // The icon is empty and needs no painting.
+ }
}
+
+ /** The cached CheckBoxIcon instance. */
+ private static CheckBoxIcon checkBoxIcon;
+
+ /** The cached CheckBoxIcon instance. */
+ private static RadioButtonIcon radioButtonIcon;
+
public static Icon getMenuItemCheckIcon()
{
return new DummyIcon();
@@ -114,115 +204,34 @@ public class BasicIconFactory implements Serializable
};
}
+ /**
+ * Returns an icon for CheckBoxes in the BasicLookAndFeel. CheckBox icons
+ * in the Basic L&amp;F are empty and have a size of 13x13 pixels.
+ * This method returns a shared single instance of this icon.
+ *
+ * @return an icon for CheckBoxes in the BasicLookAndFeel
+ */
public static Icon getCheckBoxIcon()
{
- return new Icon()
- {
- public int getIconHeight()
- {
- return 10;
- }
- public int getIconWidth()
- {
- return 10;
- }
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- if (c instanceof AbstractButton)
- {
- UIDefaults defaults;
- defaults = UIManager.getLookAndFeelDefaults();
- Color hi = defaults.getColor("CheckBox.highlight");
- Color low = defaults.getColor("CheckBox.darkShadow");
- Color sel = defaults.getColor("CheckBox.foreground");
- Color dim = defaults.getColor("CheckBox.shadow");
- Polygon check = new Polygon(new int[] {x+3, x+3, x+8},
- new int[] {y+5, y+9, y+3}, 3);
- AbstractButton b = (AbstractButton) c;
- Color saved = g.getColor();
- if (b.isEnabled())
- {
- g.setColor(low);
- g.drawRect(x, y, 10, 10);
- g.setColor(hi);
- g.drawRect(x+1, y+1, 10, 10);
- if (b.isSelected())
- {
- g.setColor(sel);
- if (b.isSelected())
- {
- g.drawLine(x+3, y+5, x+3, y+8);
- g.drawLine(x+4, y+5, x+4, y+8);
- g.drawLine(x+3, y+8, x+8, y+3);
- g.drawLine(x+4, y+8, x+8, y+3);
- }
- }
- }
- else
- {
- g.setColor(hi);
- g.drawRect(x, y, 10, 10);
- if (b.isSelected())
- {
- g.drawLine(x+3, y+5, x+3, y+9);
- g.drawLine(x+3, y+9, x+8, y+3);
- }
- }
- g.setColor(saved);
- }
- }
- };
+ if (checkBoxIcon == null)
+ checkBoxIcon = new CheckBoxIcon();
+ return checkBoxIcon;
}
+ /**
+ * Returns an icon for RadioButtons in the BasicLookAndFeel. RadioButton
+ * icons in the Basic L&amp;F are empty and have a size of 13x13 pixels.
+ * This method returns a shared single instance of this icon.
+ *
+ * @return an icon for RadioButtons in the BasicLookAndFeel
+ */
public static Icon getRadioButtonIcon()
{
- return new Icon()
- {
- public int getIconHeight()
- {
- return 12;
- }
- public int getIconWidth()
- {
- return 12;
- }
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- UIDefaults defaults;
- defaults = UIManager.getLookAndFeelDefaults();
- Color hi = defaults.getColor("RadioButton.highlight");
- Color low = defaults.getColor("RadioButton.darkShadow");
- Color sel = defaults.getColor("RadioButton.foreground");
- Color dim = defaults.getColor("RadioButton.shadow");
-
- if (c instanceof AbstractButton)
- {
- AbstractButton b = (AbstractButton) c;
- Color saved = g.getColor();
- if (b.isEnabled())
- {
- g.setColor(low);
- g.drawOval(x, y, 12, 12);
- g.setColor(hi);
- g.drawOval(x+1, y+1, 12, 12);
- if (b.isSelected())
- {
- g.setColor(sel);
- g.fillOval(x+4, y+4, 6, 6);
- }
- }
- else
- {
- g.setColor(hi);
- g.drawOval(x, y, 12, 12);
- if (b.isSelected())
- g.fillOval(x+4, y+4, 6, 6);
- }
- g.setColor(saved);
- }
- }
- };
+ if (radioButtonIcon == null)
+ radioButtonIcon = new RadioButtonIcon();
+ return radioButtonIcon;
}
+
public static Icon getCheckBoxMenuItemIcon()
{
return getCheckBoxIcon();
diff --git a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index f3939ac6b..92a6ea0bf 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -253,11 +253,29 @@ public class BasicInternalFrameTitlePane extends JComponent
*/
public void propertyChange(PropertyChangeEvent evt)
{
- // The title and frameIcon are taken care of during painting time.
- // The only other thing this will care about are the "is----izable"
- // properties. So we call enable actions to properly handle the
- // buttons and menu items for us.
- enableActions();
+ String propName = evt.getPropertyName();
+ if (propName.equals("closable"))
+ {
+ if (evt.getNewValue().equals(Boolean.TRUE))
+ closeButton.setVisible(true);
+ else
+ closeButton.setVisible(false);
+ }
+ else if (propName.equals("iconifiable"))
+ {
+ if (evt.getNewValue().equals(Boolean.TRUE))
+ iconButton.setVisible(true);
+ else
+ iconButton.setVisible(false);
+ }
+ else if (propName.equals("maximizable"))
+ {
+ if (evt.getNewValue().equals(Boolean.TRUE))
+ maxButton.setVisible(true);
+ else
+ maxButton.setVisible(false);
+ }
+
}
}
@@ -349,48 +367,36 @@ public class BasicInternalFrameTitlePane extends JComponent
*/
public void layoutContainer(Container c)
{
- enableActions();
-
+ Dimension size = c.getSize();
Insets insets = c.getInsets();
- int width = c.getBounds().width - insets.left - insets.right;
- int height = c.getBounds().height - insets.top - insets.bottom;
+ int width = size.width - insets.left - insets.right;
+ int height = size.height - insets.top - insets.bottom;
// MenuBar is always present and located at the top left corner.
Dimension menupref = menuBar.getPreferredSize();
menuBar.setBounds(insets.left, insets.top, menupref.width, height);
- int loc = width + insets.left;
-
- Insets i = closeButton.getInsets();
- Dimension prefs = new Dimension(iconSize + i.left + i.right,
- iconSize + i.top + i.bottom);
- int top = insets.top + (height - prefs.height) / 2;
- if (closeAction.isEnabled())
+ int loc = width + insets.left - 1;
+ int top = insets.top + 1;
+ int buttonWidth = height - 2;
+ int buttonHeight = height - 4;
+ if (closeButton.isVisible())
{
- loc -= prefs.width;
- closeButton.setVisible(true);
- closeButton.setBounds(loc, top, prefs.width, prefs.height);
+ loc -= buttonWidth + 2;
+ closeButton.setBounds(loc, top, buttonWidth, buttonHeight);
}
- else
- closeButton.setVisible(false);
- if (maximizeAction.isEnabled())
+ if (maxButton.isVisible())
{
- loc -= prefs.width;
- maxButton.setVisible(true);
- maxButton.setBounds(loc, top, prefs.width, prefs.height);
+ loc -= buttonWidth + 2;
+ maxButton.setBounds(loc, top, buttonWidth, buttonHeight);
}
- else
- maxButton.setVisible(false);
- if (iconifyAction.isEnabled())
+ if (iconButton.isVisible())
{
- loc -= prefs.width;
- iconButton.setVisible(true);
- iconButton.setBounds(loc, top, prefs.width, prefs.height);
+ loc -= buttonWidth + 2;
+ iconButton.setBounds(loc, top, buttonWidth, buttonHeight);
}
- else
- iconButton.setVisible(false);
if (title != null)
title.setBounds(insets.left + menupref.width, insets.top,
@@ -420,26 +426,7 @@ public class BasicInternalFrameTitlePane extends JComponent
*/
public Dimension preferredLayoutSize(Container c)
{
- Insets frameInsets = frame.getInsets();
-
- // Height is the max of the preferredHeights of all components
- // inside the pane
- int height = 0;
- int width = 0;
- Dimension d;
-
- Component[] components = BasicInternalFrameTitlePane.this.getComponents();
- for (int i = 0; i < components.length; i++)
- {
- d = components[i].getPreferredSize();
- height = Math.max(height, d.height);
- width += d.width;
- }
-
- Insets insets = BasicInternalFrameTitlePane.this.getInsets();
- height += insets.top + insets.bottom;
-
- return new Dimension(width, height);
+ return new Dimension(22, 18);
}
/**
@@ -468,7 +455,6 @@ public class BasicInternalFrameTitlePane extends JComponent
{
super(a);
setMargin(new Insets(0, 0, 0, 0));
- setBorder(null);
}
/**
@@ -540,110 +526,14 @@ public class BasicInternalFrameTitlePane extends JComponent
/** Inactive foreground color. */
protected Color inactiveFGColor;
- // FIXME: These icons need to be moved to MetalIconFactory.
-
- /** The size of the icons in the buttons. */
- private static final int iconSize = 16;
-
- /** The icon displayed in the close button. */
- protected Icon closeIcon = new Icon()
- {
- public int getIconHeight()
- {
- return iconSize;
- }
-
- public int getIconWidth()
- {
- return iconSize;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- g.translate(x, y);
- Color saved = g.getColor();
- g.setColor(Color.BLACK);
-
- int four = iconSize / 4;
- int six = iconSize * 6 / 16;
- int ten = iconSize * 10 / 16;
- int twelve = iconSize * 12 / 16;
-
- Polygon a = new Polygon(new int[] { four, six, ten, twelve },
- new int[] { six, four, twelve, ten }, 4);
- Polygon b = new Polygon(new int[] { four, six, ten, twelve },
- new int[] { ten, twelve, four, six }, 4);
-
- g.fillPolygon(a);
- g.fillPolygon(b);
-
- g.setColor(saved);
- g.translate(-x, -y);
- }
- };
-
- // FIXME: Create new icon.
-
/** The icon displayed in the restore button. */
- protected Icon minIcon;
+ protected Icon minIcon = BasicIconFactory.createEmptyFrameIcon();
/** The icon displayed in the maximize button. */
- protected Icon maxIcon = new Icon()
- {
- public int getIconHeight()
- {
- return iconSize;
- }
-
- public int getIconWidth()
- {
- return iconSize;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- g.translate(x, y);
- Color saved = g.getColor();
- g.setColor(Color.BLACK);
-
- int four = iconSize / 4;
- int two = four / 2;
- int six = iconSize * 6 / 16;
- int eight = four * 2;
-
- g.fillRect(four, four, eight, two);
- g.drawRect(four, six, eight, six);
-
- g.setColor(saved);
- g.translate(-x, -y);
- }
- };
+ protected Icon maxIcon = BasicIconFactory.createEmptyFrameIcon();
/** The icon displayed in the iconify button. */
- protected Icon iconIcon = new Icon()
- {
- public int getIconHeight()
- {
- return iconSize;
- }
-
- public int getIconWidth()
- {
- return iconSize;
- }
-
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- g.translate(x, y);
- Color saved = g.getColor();
- g.setColor(Color.BLACK);
-
- g.fillRect(iconSize / 4, iconSize * 10 / 16, iconSize / 2, iconSize / 8);
-
- g.setColor(saved);
- g.translate(-x, -y);
- }
- };
+ protected Icon iconIcon = BasicIconFactory.createEmptyFrameIcon();
/** The JInternalFrame that this TitlePane is used in. */
protected JInternalFrame frame;
@@ -702,6 +592,7 @@ public class BasicInternalFrameTitlePane extends JComponent
setOpaque(true);
setBackground(Color.LIGHT_GRAY);
+ setOpaque(true);
installTitlePane();
}
@@ -813,26 +704,23 @@ public class BasicInternalFrameTitlePane extends JComponent
protected void createButtons()
{
closeButton = new PaneButton(closeAction);
- closeButton.setOpaque(false);
-
+ if (!frame.isClosable())
+ closeButton.setVisible(false);
iconButton = new PaneButton(iconifyAction);
- iconButton.setOpaque(false);
-
+ if (!frame.isIconifiable())
+ iconButton.setVisible(false);
maxButton = new PaneButton(maximizeAction);
- maxButton.setOpaque(false);
+ if (!frame.isMaximizable())
+ maxButton.setVisible(false);
}
/**
- * This method sets the icons in the buttons.
+ * This method sets the icons in the buttons. This is a no-op method here, it
+ * can be overridden by subclasses to set icons for the minimize-, maximize-
+ * and close-buttons.
*/
protected void setButtonIcons()
{
- if (closeButton != null)
- closeButton.setIcon(closeIcon);
- if (iconButton != null)
- iconButton.setIcon(iconIcon);
- if (maxButton != null)
- maxButton.setIcon(maxIcon);
}
/**
diff --git a/javax/swing/plaf/basic/BasicInternalFrameUI.java b/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 088c26272..3febe58f4 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -53,7 +53,10 @@ import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import javax.swing.BorderFactory;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JComponent;
@@ -62,11 +65,16 @@ import javax.swing.JInternalFrame;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.event.MouseInputAdapter;
import javax.swing.event.MouseInputListener;
+import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.UIResource;
@@ -642,6 +650,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
/** The last component entered. */
private transient Component lastComponentEntered;
+ /** Used to store/reset lastComponentEntered. */
+ private transient Component tempComponent;
+
/** The number of presses. */
private transient int pressCount;
@@ -762,8 +773,9 @@ public class BasicInternalFrameUI extends InternalFrameUI
tp.x, tp.y, me.getClickCount(),
me.isPopupTrigger(),
me.getButton());
- lastComponentEntered.dispatchEvent(exited);
+ tempComponent = lastComponentEntered;
lastComponentEntered = null;
+ tempComponent.dispatchEvent(exited);
}
// If we have a candidate, maybe enter it.
@@ -864,8 +876,32 @@ public class BasicInternalFrameUI extends InternalFrameUI
* JInternalFrame.
*/
public class InternalFramePropertyChangeListener
- implements PropertyChangeListener
+ implements PropertyChangeListener, VetoableChangeListener
{
+
+ /**
+ * This method is called when one of the JInternalFrame's properties
+ * change. This method is to allow JInternalFrame to veto an attempt
+ * to close the internal frame. This allows JInternalFrame to honour
+ * its defaultCloseOperation if that is DO_NOTHING_ON_CLOSE.
+ */
+ public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
+ {
+ if (e.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY))
+ {
+ if (frame.getDefaultCloseOperation() == JInternalFrame.HIDE_ON_CLOSE)
+ {
+ frame.setVisible(false);
+ frame.getDesktopPane().repaint();
+ throw new PropertyVetoException ("close operation is HIDE_ON_CLOSE\n", e);
+ }
+ else if (frame.getDefaultCloseOperation() == JInternalFrame.DISPOSE_ON_CLOSE)
+ closeFrame(frame);
+ else
+ throw new PropertyVetoException ("close operation is DO_NOTHING_ON_CLOSE\n", e);
+ }
+ }
+
/**
* This method is called when one of the JInternalFrame's properties
* change.
@@ -881,8 +917,6 @@ public class BasicInternalFrameUI extends InternalFrameUI
else
minimizeFrame(frame);
}
- else if (evt.getPropertyName().equals(JInternalFrame.IS_CLOSED_PROPERTY))
- closeFrame(frame);
else if (evt.getPropertyName().equals(JInternalFrame.IS_ICON_PROPERTY))
{
if (frame.isIcon())
@@ -1031,6 +1065,13 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
protected PropertyChangeListener propertyChangeListener;
+ /**
+ * The VetoableChangeListener. Listens to PropertyChangeEvents
+ * from the JInternalFrame and allows the JInternalFrame to
+ * veto attempts to close it.
+ */
+ private VetoableChangeListener internalFrameVetoableChangeListener;
+
/** The InternalFrameListener that listens to the JInternalFrame. */
private transient BasicInternalFrameListener internalFrameListener;
@@ -1109,7 +1150,6 @@ public class BasicInternalFrameUI extends InternalFrameUI
installKeyboardActions();
frame.setOpaque(true);
- titlePane.setOpaque(true);
frame.invalidate();
}
}
@@ -1137,9 +1177,31 @@ public class BasicInternalFrameUI extends InternalFrameUI
* This method installs the defaults specified by the look and feel.
*/
protected void installDefaults()
- {
- // FIXME: Move border to MetalBorders
- frame.setBorder(new InternalFrameBorder());
+ {
+ // This is the border of InternalFrames in the BasicLookAndFeel.
+ // Note that there exist entries for various border colors in
+ // BasicLookAndFeel's defaults, but obviously they differ
+ // from the colors that are actually used by the JDK.
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ Color borderColor = defaults.getColor("InternalFrame.borderColor");
+ Border inner = BorderFactory.createLineBorder(borderColor, 1);
+ Color borderDarkShadow = defaults.getColor
+ ("InternalFrame.borderDarkShadow");
+ Color borderHighlight = defaults.getColor
+ ("InternalFrame.borderHighlight");
+ Color borderShadow = defaults.getColor("InternalFrame.borderShadow");
+ Color borderLight = defaults.getColor("InternalFrame.borderLight");
+ Border outer = BorderFactory.createBevelBorder(BevelBorder.RAISED,
+ borderShadow,
+ borderHighlight,
+ borderDarkShadow,
+ borderShadow);
+ Border border = new BorderUIResource.CompoundBorderUIResource(outer,
+ inner);
+ frame.setBorder(border);
+ frame.setFrameIcon(defaults.getIcon("InternalFrame.icon"));
+ // InternalFrames are invisible by default.
+ frame.setVisible(false);
}
/**
@@ -1171,12 +1233,13 @@ public class BasicInternalFrameUI extends InternalFrameUI
borderListener = createBorderListener(frame);
componentListener = createComponentListener();
propertyChangeListener = createPropertyChangeListener();
+ internalFrameVetoableChangeListener = new InternalFramePropertyChangeListener();
frame.addMouseListener(borderListener);
frame.addMouseMotionListener(borderListener);
frame.addInternalFrameListener(internalFrameListener);
frame.addPropertyChangeListener(propertyChangeListener);
-
+ frame.addVetoableChangeListener(internalFrameVetoableChangeListener);
frame.getRootPane().getGlassPane().addMouseListener(glassPaneDispatcher);
frame.getRootPane().getGlassPane().addMouseMotionListener(glassPaneDispatcher);
}
@@ -1552,7 +1615,10 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
protected DesktopManager getDesktopManager()
{
- DesktopManager value = frame.getDesktopPane().getDesktopManager();
+ DesktopManager value = null;
+ JDesktopPane pane = frame.getDesktopPane();
+ if (pane != null)
+ value = frame.getDesktopPane().getDesktopManager();
if (value == null)
value = createDesktopManager();
return value;
diff --git a/javax/swing/plaf/basic/BasicLabelUI.java b/javax/swing/plaf/basic/BasicLabelUI.java
index b278f1f59..e71e82f03 100644
--- a/javax/swing/plaf/basic/BasicLabelUI.java
+++ b/javax/swing/plaf/basic/BasicLabelUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -92,7 +92,8 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
/**
* Returns the preferred size of this component as calculated by the
- * {@link layoutCL} method.
+ * {@link #layoutCL(JLabel, FontMetrics, String, Icon, Rectangle, Rectangle,
+ * Rectangle)} method.
*
* @param c This {@link JComponent} to get a preferred size for.
*
@@ -350,8 +351,6 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
c.setForeground(defaults.getColor("Label.foreground"));
c.setBackground(defaults.getColor("Label.background"));
c.setFont(defaults.getFont("Label.font"));
- c.setBorder(defaults.getBorder("Label.border"));
- c.setOpaque(true);
//XXX: There are properties we don't use called disabledForeground
//and disabledShadow.
}
@@ -367,7 +366,6 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
c.setForeground(null);
c.setBackground(null);
c.setFont(null);
- c.setBorder(null);
}
/**
diff --git a/javax/swing/plaf/basic/BasicListUI.java b/javax/swing/plaf/basic/BasicListUI.java
index baaa04655..841bd670f 100644
--- a/javax/swing/plaf/basic/BasicListUI.java
+++ b/javax/swing/plaf/basic/BasicListUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -49,6 +49,9 @@ import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -93,7 +96,7 @@ public class BasicListUI extends ListUI
}
/**
- * A helper class which listens for {@link FocusEvents}
+ * A helper class which listens for {@link FocusEvent}s
* from the JList.
*/
public class FocusHandler implements FocusListener
@@ -131,7 +134,7 @@ public class BasicListUI extends ListUI
* A helper class which listens for {@link ListDataEvent}s generated by
* the {@link JList}'s {@link ListModel}.
*
- * @see javax.swing.JList#model
+ * @see javax.swing.JList#getModel()
*/
public class ListDataHandler implements ListDataListener
{
@@ -184,6 +187,138 @@ public class BasicListUI extends ListUI
}
/**
+ * A helper class which listens for {@link KeyEvents}s
+ * from the {@link JList}.
+ */
+ private class KeyHandler extends KeyAdapter
+ {
+ public KeyHandler()
+ {
+ }
+
+ public void keyPressed( KeyEvent evt )
+ {
+ int lead = BasicListUI.this.list.getLeadSelectionIndex();
+ int max = BasicListUI.this.list.getModel().getSize() - 1;
+ // Do nothing if list is empty
+ if (max == -1)
+ return;
+
+ // Process the key event. Bindings can be found in
+ // javax.swing.plaf.basic.BasicLookAndFeel.java
+ if ((evt.getKeyCode() == KeyEvent.VK_DOWN)
+ || (evt.getKeyCode() == KeyEvent.VK_KP_DOWN))
+ {
+ if (evt.getModifiers() == 0)
+ {
+ BasicListUI.this.list.clearSelection();
+ BasicListUI.this.list.setSelectedIndex(Math.min(lead+1,max));
+ }
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(Math.min(lead+1,max));
+ }
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_UP)
+ || (evt.getKeyCode() == KeyEvent.VK_KP_UP))
+ {
+ if (evt.getModifiers() == 0)
+ {
+ BasicListUI.this.list.clearSelection();
+ BasicListUI.this.list.setSelectedIndex(Math.max(lead-1,0));
+ }
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(Math.max(lead-1,0));
+ }
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_PAGE_UP)
+ {
+ int target;
+ if (lead == BasicListUI.this.list.getFirstVisibleIndex())
+ {
+ target = Math.max
+ (0, lead - (BasicListUI.this.list.getLastVisibleIndex() -
+ BasicListUI.this.list.getFirstVisibleIndex() + 1));
+ }
+ else
+ {
+ target = BasicListUI.this.list.getFirstVisibleIndex();
+ }
+ if (evt.getModifiers() == 0)
+ BasicListUI.this.list.setSelectedIndex(target);
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(target);
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_PAGE_DOWN)
+ {
+ int target;
+ if (lead == BasicListUI.this.list.getLastVisibleIndex())
+ {
+ target = Math.min
+ (max, lead + (BasicListUI.this.list.getLastVisibleIndex() -
+ BasicListUI.this.list.getFirstVisibleIndex() + 1));
+ }
+ else
+ {
+ target = BasicListUI.this.list.getLastVisibleIndex();
+ }
+ if (evt.getModifiers() == 0)
+ BasicListUI.this.list.setSelectedIndex(target);
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(target);
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_BACK_SLASH
+ && (evt.getModifiers() == InputEvent.CTRL_MASK))
+ {
+ BasicListUI.this.list.clearSelection();
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_HOME)
+ || evt.getKeyCode() == KeyEvent.VK_END)
+ {
+ if (evt.getModifiers() != 0 &&
+ evt.getModifiers() != InputEvent.SHIFT_MASK)
+ return;
+ // index is either 0 for HOME, or last cell for END
+ int index = (evt.getKeyCode() == KeyEvent.VK_HOME) ? 0 : max;
+
+ if (!evt.isShiftDown() ||(BasicListUI.this.list.getSelectionMode()
+ == ListSelectionModel.SINGLE_SELECTION))
+ BasicListUI.this.list.setSelectedIndex(index);
+ else if (BasicListUI.this.list.getSelectionMode() ==
+ ListSelectionModel.SINGLE_INTERVAL_SELECTION)
+ BasicListUI.this.list.setSelectionInterval
+ (BasicListUI.this.list.getAnchorSelectionIndex(), index);
+ else
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(index);
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_A || evt.getKeyCode()
+ == KeyEvent.VK_SLASH) && (evt.getModifiers() ==
+ InputEvent.CTRL_MASK))
+ {
+ BasicListUI.this.list.setSelectionInterval(0, max);
+ // this next line is to restore the lead selection index to the old
+ // position, because select-all should not change the lead index
+ BasicListUI.this.list.addSelectionInterval(lead, lead);
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_SPACE &&
+ (evt.getModifiers() == InputEvent.CTRL_MASK))
+ {
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(Math.min(lead+1,max));
+ }
+
+ BasicListUI.this.list.ensureIndexIsVisible
+ (BasicListUI.this.list.getLeadSelectionIndex());
+ }
+ }
+
+ /**
* A helper class which listens for {@link MouseEvent}s
* from the {@link JList}.
*/
@@ -197,6 +332,49 @@ public class BasicListUI extends ListUI
*/
public void mouseClicked(MouseEvent event)
{
+ Point click = event.getPoint();
+ int index = BasicListUI.this.locationToIndex(list, click);
+ if (index == -1)
+ return;
+ if (event.isShiftDown())
+ {
+ if (BasicListUI.this.list.getSelectionMode() ==
+ ListSelectionModel.SINGLE_SELECTION)
+ BasicListUI.this.list.setSelectedIndex(index);
+ else if (BasicListUI.this.list.getSelectionMode() ==
+ ListSelectionModel.SINGLE_INTERVAL_SELECTION)
+ // COMPAT: the IBM VM is compatible with the following line of code.
+ // However, compliance with Sun's VM would correspond to replacing
+ // getAnchorSelectionIndex() with getLeadSelectionIndex().This is
+ // both unnatural and contradictory to the way they handle other
+ // similar UI interactions.
+ BasicListUI.this.list.setSelectionInterval
+ (BasicListUI.this.list.getAnchorSelectionIndex(), index);
+ else
+ // COMPAT: both Sun and IBM are compatible instead with:
+ // BasicListUI.this.list.setSelectionInterval
+ // (BasicListUI.this.list.getLeadSelectionIndex(),index);
+ // Note that for IBM this is contradictory to what they did in
+ // the above situation for SINGLE_INTERVAL_SELECTION.
+ // The most natural thing to do is the following:
+ BasicListUI.this.list.getSelectionModel().
+ setLeadSelectionIndex(index);
+ }
+ else if (event.isControlDown())
+ {
+ if (BasicListUI.this.list.getSelectionMode() ==
+ ListSelectionModel.SINGLE_SELECTION)
+ BasicListUI.this.list.setSelectedIndex(index);
+ else if (BasicListUI.this.list.isSelectedIndex(index))
+ BasicListUI.this.list.removeSelectionInterval(index,index);
+ else
+ BasicListUI.this.list.addSelectionInterval(index,index);
+ }
+ else
+ BasicListUI.this.list.setSelectedIndex(index);
+
+ BasicListUI.this.list.ensureIndexIsVisible
+ (BasicListUI.this.list.getLeadSelectionIndex());
}
/**
@@ -207,12 +385,6 @@ public class BasicListUI extends ListUI
*/
public void mousePressed(MouseEvent event)
{
- Point click = event.getPoint();
- int index = BasicListUI.this.locationToIndex(list, click);
- if (index == -1)
- return;
-
- BasicListUI.this.list.setSelectedIndex(index);
}
/**
@@ -315,6 +487,9 @@ public class BasicListUI extends ListUI
/** The mouse listener listening to the list. */
protected MouseInputListener mouseInputListener;
+ /** The key listener listening to the list */
+ private KeyHandler keyListener;
+
/** The property change listener listening to the list. */
protected PropertyChangeListener propertyChangeListener;
@@ -499,8 +674,6 @@ public class BasicListUI extends ListUI
void damageLayout()
{
updateLayoutStateNeeded = 1;
- if (list != null)
- list.revalidate();
}
/**
@@ -525,6 +698,7 @@ public class BasicListUI extends ListUI
listDataListener = new ListDataHandler();
listSelectionListener = new ListSelectionHandler();
mouseInputListener = new MouseInputHandler();
+ keyListener = new KeyHandler();
propertyChangeListener = new PropertyChangeHandler();
componentListener = new ComponentHandler();
updateLayoutStateNeeded = 1;
@@ -572,6 +746,7 @@ public class BasicListUI extends ListUI
list.getModel().addListDataListener(listDataListener);
list.addListSelectionListener(listSelectionListener);
list.addMouseListener(mouseInputListener);
+ list.addKeyListener(keyListener);
list.addMouseMotionListener(mouseInputListener);
list.addPropertyChangeListener(propertyChangeListener);
list.addComponentListener(componentListener);
@@ -586,6 +761,7 @@ public class BasicListUI extends ListUI
list.getModel().removeListDataListener(listDataListener);
list.removeListSelectionListener(listSelectionListener);
list.removeMouseListener(mouseInputListener);
+ list.removeKeyListener(keyListener);
list.removeMouseMotionListener(mouseInputListener);
list.removePropertyChangeListener(propertyChangeListener);
}
@@ -711,11 +887,11 @@ public class BasicListUI extends ListUI
ListCellRenderer rend, ListModel data,
ListSelectionModel sel, int lead)
{
- boolean is_sel = list.isSelectedIndex(row);
- boolean has_focus = false;
+ boolean isSel = list.isSelectedIndex(row);
+ boolean hasFocus = (list.getLeadSelectionIndex() == row) && BasicListUI.this.list.hasFocus();
Component comp = rend.getListCellRendererComponent(list,
data.getElementAt(row),
- 0, is_sel, has_focus);
+ 0, isSel, hasFocus);
//comp.setBounds(new Rectangle(0, 0, bounds.width, bounds.height));
//comp.paint(g);
rendererPane.paintComponent(g, comp, list, bounds);
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 67cf25057..54d91d888 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -47,10 +47,12 @@ import java.io.Serializable;
import java.util.Enumeration;
import java.util.ResourceBundle;
-import javax.swing.ImageIcon;
+import javax.swing.BorderFactory;
import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.DimensionUIResource;
@@ -69,7 +71,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
static final long serialVersionUID = -6096995660290287879L;
/**
- * Constructor BasicLookAndFeel
+ * Creates a new instance of the Basic look and feel.
*/
public BasicLookAndFeel()
{
@@ -77,8 +79,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}
/**
- * getDefaults
- * @return UIDefaults
+ * Creates and returns a new instance of the default resources for this look
+ * and feel.
+ *
+ * @return The UI defaults.
*/
public UIDefaults getDefaults()
{
@@ -95,8 +99,10 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}
/**
- * initClassDefaults
- * @param value0 TODO
+ * Populates the <code>defaults</code> table with mappings between class IDs
+ * and fully qualified class names for the UI delegates.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
*/
protected void initClassDefaults(UIDefaults defaults)
{
@@ -155,8 +161,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}
/**
- * initSystemColorDefaults
- * @param defaults TODO
+ * Populates the <code>defaults</code> table with system color defaults.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
*/
protected void initSystemColorDefaults(UIDefaults defaults)
{
@@ -198,13 +205,14 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}
/**
- * loadSystemColors
- * @param defaults TODO
- * @param value1 TODO
- * @param value2 TODO
+ * Loads the system colors. This method is not implemented yet.
+ *
+ * @param defaults the defaults table (<code>null</code> not permitted).
+ * @param systemColors TODO
+ * @param useNative TODO
*/
- protected void loadSystemColors(UIDefaults defaults, String[] value1,
- boolean value2)
+ protected void loadSystemColors(UIDefaults defaults, String[] systemColors,
+ boolean useNative)
{
// TODO
}
@@ -232,7 +240,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
/**
* initComponentDefaults
- * @param defaults TODO
+ * @param defaults the defaults table (<code>null</code> not permitted).
*/
protected void initComponentDefaults(UIDefaults defaults)
{
@@ -247,7 +255,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"AbstractUndoableEdit.undoText", "Undo",
"AbstractUndoableEdit.redoText", "Redo",
- "Button.background", new ColorUIResource(light),
+ "Button.background", new ColorUIResource(Color.LIGHT_GRAY),
"Button.border",
new UIDefaults.LazyValue()
{
@@ -256,17 +264,17 @@ public abstract class BasicLookAndFeel extends LookAndFeel
return BasicBorders.getButtonBorder();
}
},
- "Button.darkShadow", new ColorUIResource(shadow),
+ "Button.darkShadow", new ColorUIResource(Color.BLACK),
"Button.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
"SPACE", "pressed",
"released SPACE", "released"
}),
"Button.font", new FontUIResource("Dialog", Font.PLAIN, 12),
- "Button.foreground", new ColorUIResource(darkShadow),
- "Button.highlight", new ColorUIResource(highLight),
- "Button.light", new ColorUIResource(highLight),
+ "Button.foreground", new ColorUIResource(Color.BLACK),
+ "Button.highlight", new ColorUIResource(Color.WHITE),
+ "Button.light", new ColorUIResource(Color.LIGHT_GRAY),
"Button.margin", new InsetsUIResource(2, 2, 2, 2),
- "Button.shadow", new ColorUIResource(shadow),
+ "Button.shadow", new ColorUIResource(Color.GRAY),
"Button.textIconGap", new Integer(4),
"Button.textShiftOffset", new Integer(0),
"CheckBox.background", new ColorUIResource(light),
@@ -278,7 +286,14 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"CheckBox.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"CheckBox.foreground", new ColorUIResource(darkShadow),
- "CheckBox.icon", BasicIconFactory.getCheckBoxIcon(),
+ "CheckBox.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return BasicIconFactory.getCheckBoxIcon();
+ }
+ },
"CheckBox.margin",new InsetsUIResource(2, 2, 2, 2),
"CheckBox.textIconGap", new Integer(4),
"CheckBox.textShiftOffset", new Integer(0),
@@ -449,15 +464,39 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"InternalFrame.activeTitleBackground", new ColorUIResource(0, 0, 128),
"InternalFrame.activeTitleForeground", new ColorUIResource(Color.white),
"InternalFrame.border",
- new BorderUIResource.CompoundBorderUIResource(null, null),
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults table)
+ {
+ Color lineColor = new Color(238, 238, 238);
+ Border inner = BorderFactory.createLineBorder(lineColor, 1);
+ Color shadowInner = new Color(184, 207, 229);
+ Color shadowOuter = new Color(122, 138, 153);
+ Border outer = BorderFactory.createBevelBorder(BevelBorder.RAISED,
+ Color.WHITE,
+ Color.WHITE,
+ shadowOuter,
+ shadowInner);
+ Border border = new BorderUIResource.CompoundBorderUIResource(outer,
+ inner);
+ return border;
+ }
+ },
"InternalFrame.borderColor", new ColorUIResource(light),
- "InternalFrame.borderDarkShadow", new ColorUIResource(shadow),
- "InternalFrame.borderHighlight", new ColorUIResource(highLight),
- "InternalFrame.borderLight", new ColorUIResource(light),
- "InternalFrame.borderShadow", new ColorUIResource(shadow),
+ "InternalFrame.borderDarkShadow", new ColorUIResource(Color.BLACK),
+ "InternalFrame.borderHighlight", new ColorUIResource(Color.WHITE),
+ "InternalFrame.borderLight", new ColorUIResource(Color.LIGHT_GRAY),
+ "InternalFrame.borderShadow", new ColorUIResource(Color.GRAY),
"InternalFrame.closeIcon", BasicIconFactory.createEmptyFrameIcon(),
- // XXX Don't use gif
-// "InternalFrame.icon", new IconUIResource(new ImageIcon("icons/JavaCup.gif")),
+ // FIXME: Set a nice icon for InternalFrames here.
+ "InternalFrame.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return new IconUIResource(BasicIconFactory.createEmptyFrameIcon());
+ }
+ },
"InternalFrame.iconifyIcon", BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.inactiveTitleBackground", new ColorUIResource(Color.gray),
"InternalFrame.inactiveTitleForeground",
@@ -500,6 +539,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"List.foreground", new ColorUIResource(darkShadow),
"List.selectionBackground", new ColorUIResource(Color.black),
"List.selectionForeground", new ColorUIResource(Color.white),
+ "List.focusCellHighlightBorder",
+ new BorderUIResource.
+ LineBorderUIResource(new ColorUIResource(Color.yellow)),
"Menu.acceleratorFont", new FontUIResource("Dialog", Font.PLAIN, 12),
"Menu.acceleratorForeground", new ColorUIResource(darkShadow),
"Menu.acceleratorSelectionForeground", new ColorUIResource(Color.white),
@@ -625,7 +667,14 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"RadioButton.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"RadioButton.foreground", new ColorUIResource(darkShadow),
"RadioButton.highlight", new ColorUIResource(highLight),
- "RadioButton.icon", BasicIconFactory.getRadioButtonIcon(),
+ "RadioButton.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return BasicIconFactory.getRadioButtonIcon();
+ }
+ },
"RadioButton.light", new ColorUIResource(highLight),
"RadioButton.margin", new InsetsUIResource(2, 2, 2, 2),
"RadioButton.shadow", new ColorUIResource(shadow),
@@ -724,7 +773,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Slider.highlight", new ColorUIResource(highLight),
"Slider.shadow", new ColorUIResource(shadow),
"Slider.thumbHeight", new Integer(20),
- "Slider.thumbWidth", new Integer(10),
+ "Slider.thumbWidth", new Integer(11),
"Slider.tickHeight", new Integer(12),
"Spinner.background", new ColorUIResource(light),
"Spinner.foreground", new ColorUIResource(light),
@@ -826,7 +875,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Table.focusCellBackground", new ColorUIResource(light),
"Table.focusCellForeground", new ColorUIResource(darkShadow),
"Table.focusCellHighlightBorder",
- new BorderUIResource.LineBorderUIResource(Color.white),
+ new BorderUIResource.LineBorderUIResource(
+ new ColorUIResource(255, 255, 0)),
"Table.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"Table.foreground", new ColorUIResource(darkShadow),
"Table.gridColor", new ColorUIResource(Color.gray),
@@ -838,7 +888,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TableHeader.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"TableHeader.foreground", new ColorUIResource(darkShadow),
- "TextArea.background", new ColorUIResource(light),
+ "TextArea.background", new ColorUIResource(light),
"TextArea.border", new BasicBorders.MarginBorder(),
"TextArea.caretBlinkRate", new Integer(500),
"TextArea.caretForeground", new ColorUIResource(Color.black),
@@ -879,11 +929,11 @@ public abstract class BasicLookAndFeel extends LookAndFeel
0),
"notify-field-accept"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
- InputEvent.SHIFT_DOWN_MASK),
- "selection-backward"),
+ InputEvent.SHIFT_DOWN_MASK),
+ "selection-backward"),
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
- InputEvent.SHIFT_DOWN_MASK),
- "selection-forward"),
+ InputEvent.SHIFT_DOWN_MASK),
+ "selection-forward"),
},
"TextField.margin", new InsetsUIResource(0, 0, 0, 0),
"TextField.selectionBackground", new ColorUIResource(Color.black),
@@ -1011,20 +1061,18 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"PAGE_UP", "scrollUpChangeSelection",
"ctrl PAGE_DOWN", "scrollDownChangeLead"
}),
- "Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
-// "Tree.expandedIcon", new IconUIResource(new ImageIcon("icons/TreeExpanded.png")),
+ "Tree.font", new FontUIResource(new Font("Helvetica", Font.PLAIN, 12)),
"Tree.foreground", new ColorUIResource(Color.black),
- "Tree.hash", new ColorUIResource(Color.gray),
-// "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.png")),
+ "Tree.hash", new ColorUIResource(new Color(128, 128, 128)),
"Tree.leftChildIndent", new Integer(7),
-// "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.png")),
"Tree.rightChildIndent", new Integer(13),
- "Tree.rowHeight", new Integer(16),
+ "Tree.rowHeight", new Integer(20), // FIXME
"Tree.scrollsOnExpand", Boolean.TRUE,
"Tree.selectionBackground", new ColorUIResource(Color.black),
+ "Tree.nonSelectionBackground", new ColorUIResource(new Color(239, 235, 231)),
"Tree.selectionBorderColor", new ColorUIResource(Color.black),
- "Tree.selectionForeground", new ColorUIResource(Color.white),
- "Tree.textBackground", new ColorUIResource(Color.white),
+ "Tree.selectionForeground", new ColorUIResource(new Color(255, 255, 255)),
+ "Tree.textBackground", new ColorUIResource(new Color(255, 255, 255)),
"Tree.textForeground", new ColorUIResource(Color.black),
"Viewport.background", new ColorUIResource(light),
"Viewport.foreground", new ColorUIResource(Color.black),
diff --git a/javax/swing/plaf/basic/BasicMenuBarUI.java b/javax/swing/plaf/basic/BasicMenuBarUI.java
index 62b047506..95f6b84fb 100644
--- a/javax/swing/plaf/basic/BasicMenuBarUI.java
+++ b/javax/swing/plaf/basic/BasicMenuBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -105,7 +105,7 @@ public class BasicMenuBarUI extends MenuBarUI
* Factory method to create a BasicMenuBarUI for the given {@link
* JComponent}, which should be a {@link JMenuBar}.
*
- * @param b The {@link JComponent} a UI is being created for.
+ * @param x The {@link JComponent} a UI is being created for.
*
* @return A BasicMenuBarUI for the {@link JComponent}.
*/
@@ -165,6 +165,7 @@ public class BasicMenuBarUI extends MenuBarUI
menuBar.setBorder(defaults.getBorder("MenuBar.border"));
menuBar.setFont(defaults.getFont("MenuBar.font"));
menuBar.setForeground(defaults.getColor("MenuBar.foreground"));
+ menuBar.setOpaque(true);
}
/**
diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java
index ae8b6c54c..bbacc5028 100644
--- a/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -506,11 +506,10 @@ public class BasicMenuItemUI extends MenuItemUI
br.width += insets.right + insets.left;
br.height += insets.top + insets.bottom;
- /* Menu item is considered to be highlighted when it is selected.
- It is considered to be selected if menu item is inside some menu
- and is armed or if it is both armed and pressed */
- if (m.getModel().isArmed()
- && (m.getParent() instanceof MenuElement || m.getModel().isPressed()))
+ // Menu item is considered to be highlighted when it is selected.
+ // But we don't want to paint the background of JCheckBoxMenuItems
+ if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() &&
+ (m.getParent() instanceof MenuElement))
{
if (m.isContentAreaFilled())
{
@@ -606,12 +605,10 @@ public class BasicMenuItemUI extends MenuItemUI
{
if (menuItem.isEnabled())
{
- /* Menu item is considered to be highlighted when it is selected.
- It is considered to be selected if menu item is inside some menu
- and is armed or if it is both armed and pressed */
- if (menuItem.getModel().isArmed()
- && (menuItem.getParent() instanceof MenuElement
- || menuItem.getModel().isPressed()))
+ // Menu item is considered to be highlighted when it is selected.
+ // But not if it's a JCheckBoxMenuItem
+ if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() &&
+ (menuItem.getParent() instanceof MenuElement))
g.setColor(selectionForeground);
else
g.setColor(menuItem.getForeground());
@@ -619,7 +616,10 @@ public class BasicMenuItemUI extends MenuItemUI
else
// FIXME: should fix this to use 'disabledForeground', but its
// default value in BasicLookAndFeel is null.
- g.setColor(Color.gray);
+
+ // FIXME: should there be different foreground colours for selected
+ // or deselected, when disabled?
+ g.setColor(Color.gray);
int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
diff --git a/javax/swing/plaf/basic/BasicMenuUI.java b/javax/swing/plaf/basic/BasicMenuUI.java
index 89daf3245..4b07d7069 100644
--- a/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/javax/swing/plaf/basic/BasicMenuUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,6 +46,7 @@ import java.beans.PropertyChangeListener;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.MenuSelectionManager;
import javax.swing.UIDefaults;
@@ -179,6 +180,12 @@ public class BasicMenuUI extends BasicMenuItemUI
*/
public Dimension getMaximumSize(JComponent c)
{
+ // If this menu is in a popup menu, treat it like a regular JMenuItem
+ if (!((JMenu)c).isTopLevelMenu())
+ {
+ JMenuItem menuItem = new JMenuItem(((JMenu)c).getText(), ((JMenu)c).getIcon());
+ return menuItem.getMaximumSize();
+ }
return c.getPreferredSize();
}
@@ -292,19 +299,42 @@ public class BasicMenuUI extends BasicMenuItemUI
manager.processMouseEvent(e);
}
+ private boolean popupVisible()
+ {
+ JMenuBar mb = (JMenuBar) ((JMenu) menuItem).getParent();
+ // check if mb.isSelected because if no menus are selected
+ // we don't have to look through the list for popup menus
+ if (!mb.isSelected())
+ return false;
+ for (int i = 0; i < mb.getMenuCount(); i++)
+ {
+ JMenu m = mb.getMenu(i);
+ if (m != null && m.isPopupMenuVisible())
+ return true;
+ }
+ return false;
+ }
+
public void mouseEntered(MouseEvent e)
{
/* When mouse enters menu item, it should be considered selected
if (i) if this menu is a submenu in some other menu
- (ii) or if this menu is in a menu bar and some other menu in a menu bar was just
- selected. (If nothing was selected, menu should be pressed before
+ (ii) or if this menu is in a menu bar and some other menu in a
+ menu bar was just selected and has its popup menu visible.
+ (If nothing was selected, menu should be pressed before
it will be selected)
*/
JMenu menu = (JMenu) menuItem;
- if (! menu.isTopLevelMenu()
- || (menu.isTopLevelMenu()
- && (((JMenuBar) menu.getParent()).isSelected() && ! menu.isArmed())))
+
+ // NOTE: the following if used to require !menu.isArmed but I could find
+ // no reason for this and it was preventing some JDK-compatible behaviour.
+ // Specifically, if a menu is selected but its popup menu not visible,
+ // and then another menu is selected whose popup menu IS visible, when
+ // the mouse is moved over the first menu, its popup menu should become
+ // visible.
+
+ if (! menu.isTopLevelMenu() || popupVisible())
{
// set new selection and forward this event to MenuSelectionManager
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
@@ -419,7 +449,7 @@ public class BasicMenuUI extends BasicMenuItemUI
*
* @param e The PropertyChangeEvent.
*/
- public void propertyChange(PropertyChangeEvent evt)
+ public void propertyChange(PropertyChangeEvent e)
{
}
}
diff --git a/javax/swing/plaf/basic/BasicOptionPaneUI.java b/javax/swing/plaf/basic/BasicOptionPaneUI.java
index 21bdf33ae..c9f623259 100644
--- a/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -161,8 +161,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
* but was made public by a compiler bug and is now
* public for compatibility.
*/
- // FIXME: should be static
- public class ButtonAreaLayout implements LayoutManager
+ public static class ButtonAreaLayout implements LayoutManager
{
/** Whether this layout will center the buttons. */
protected boolean centersChildren = true;
@@ -249,7 +248,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
for (int i = 0; i < buttonList.length; i++)
{
Dimension dims = buttonList[i].getPreferredSize();
- if (getSizeButtonsToSameWidth())
+ if (syncAllWidths)
{
buttonList[i].setBounds(x, 0, widthOfWidestButton, dims.height);
x += widthOfWidestButton + getPadding();
@@ -347,7 +346,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
public void setCentersChildren(boolean newValue)
{
centersChildren = newValue;
- optionPane.invalidate();
}
/**
@@ -358,7 +356,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
public void setPadding(int newPadding)
{
padding = newPadding;
- optionPane.invalidate();
}
/**
@@ -369,7 +366,6 @@ public class BasicOptionPaneUI extends OptionPaneUI
public void setSyncAllWidths(boolean newValue)
{
syncAllWidths = newValue;
- optionPane.invalidate();
}
}
@@ -914,7 +910,9 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
protected Container createSeparator()
{
- return (Container) Box.createVerticalStrut(17);
+ // FIXME: Figure out what this method is supposed to return and where
+ // this should be added to the OptionPane.
+ return null;
}
/**
@@ -1119,6 +1117,10 @@ public class BasicOptionPaneUI extends OptionPaneUI
optionPane.add(msg);
}
+ // FIXME: Figure out if the separator should be inserted here or what
+ // this thing is supposed to do. Note: The JDK does NOT insert another
+ // component at this place. The JOptionPane only has two panels in it
+ // and there actually are applications that depend on this beeing so.
Container sep = createSeparator();
if (sep != null)
optionPane.add(sep);
@@ -1146,6 +1148,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
optionPane.setBackground(defaults.getColor("OptionPane.background"));
optionPane.setForeground(defaults.getColor("OptionPane.foreground"));
optionPane.setBorder(defaults.getBorder("OptionPane.border"));
+ optionPane.setOpaque(true);
messageBorder = defaults.getBorder("OptionPane.messageAreaBorder");
messageForeground = defaults.getColor("OptionPane.messageForeground");
diff --git a/javax/swing/plaf/basic/BasicPanelUI.java b/javax/swing/plaf/basic/BasicPanelUI.java
index 7e72d730d..b715c57b3 100644
--- a/javax/swing/plaf/basic/BasicPanelUI.java
+++ b/javax/swing/plaf/basic/BasicPanelUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,18 +39,33 @@ exception statement from your version. */
package javax.swing.plaf.basic;
import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.PanelUI;
public class BasicPanelUI extends PanelUI
{
- public static ComponentUI createUI(JComponent x)
- {
- return new BasicPanelUI();
- }
-
- public void installUI(JComponent c)
- {
- super.installUI(c);
- }
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicPanelUI();
+ }
+
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ if (c instanceof JPanel)
+ {
+ JPanel p = (JPanel) c;
+ installDefaults(p);
+ }
+ }
+
+ public void installDefaults(JPanel p)
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ p.setBackground(defaults.getColor("Panel.background"));
+ p.setOpaque(true);
+ }
}
diff --git a/javax/swing/plaf/basic/BasicPasswordFieldUI.java b/javax/swing/plaf/basic/BasicPasswordFieldUI.java
index 0350f7437..044027b0b 100644
--- a/javax/swing/plaf/basic/BasicPasswordFieldUI.java
+++ b/javax/swing/plaf/basic/BasicPasswordFieldUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java b/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
index d0df9d347..b62947722 100644
--- a/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
+++ b/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicPopupMenuUI.java b/javax/swing/plaf/basic/BasicPopupMenuUI.java
index b7cbb3284..247117bc9 100644
--- a/javax/swing/plaf/basic/BasicPopupMenuUI.java
+++ b/javax/swing/plaf/basic/BasicPopupMenuUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -51,6 +51,7 @@ import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
+import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
@@ -73,8 +74,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
/* popupMenu for which this UI delegate is for*/
protected JPopupMenu popupMenu;
- /* MouseInputListener listens to mouse events */
- private static transient MouseInputListener mouseInputListener;
+ /* MouseInputListener listens to mouse events. Package private for inner classes. */
+ static transient MouseInputListener mouseInputListener;
/* PopupMenuListener listens to popup menu events fired by JPopupMenu*/
private transient PopupMenuListener popupMenuListener;
@@ -415,6 +416,7 @@ public class BasicPopupMenuUI extends PopupMenuUI
private transient Component mouseEventTarget;
private transient Component pressedComponent;
private transient Component lastComponentEntered;
+ private transient Component tempComponent;
private transient int pressCount;
/**
@@ -552,7 +554,9 @@ public class BasicPopupMenuUI extends PopupMenuUI
me.isPopupTrigger(),
me.getButton());
- lastComponentEntered.dispatchEvent(exited);
+ tempComponent = lastComponentEntered;
+ lastComponentEntered = null;
+ tempComponent.dispatchEvent(exited);
}
lastComponentEntered = null;
diff --git a/javax/swing/plaf/basic/BasicProgressBarUI.java b/javax/swing/plaf/basic/BasicProgressBarUI.java
index acf6a97d7..d00628f53 100644
--- a/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java b/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
index 55cfdc033..d5cd7f448 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index 15d2e7af9..98738251c 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,50 +38,125 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
+/**
+ * The BasicLookAndFeel UI implementation for
+ * {@link javax.swing.JRadioButton}s.
+ */
public class BasicRadioButtonUI extends BasicToggleButtonUI
{
-
+ /**
+ * The default icon for JRadioButtons. The default icon displays the usual
+ * RadioButton and is sensible to the selection state of the button,
+ * and can be used both as normal icon as well as selectedIcon.
+ */
protected Icon icon;
+ /**
+ * Creates and returns a new instance of <code>BasicRadioButtonUI</code>.
+ *
+ * @return a new instance of <code>BasicRadioButtonUI</code>
+ */
public static ComponentUI createUI(final JComponent c) {
return new BasicRadioButtonUI();
}
+ /**
+ * Creates a new instance of <code>BasicButtonUI</code>.
+ */
public BasicRadioButtonUI()
{
icon = getDefaultIcon();
}
- public void installUI(final JComponent c) {
- super.installUI(c);
- if (c instanceof AbstractButton)
- {
- AbstractButton b = (AbstractButton) c;
- b.setIcon(icon);
- }
+ /**
+ * Installs defaults from the Look &amp; Feel table on the specified
+ * button.
+ *
+ * @param b the button on which to install the defaults
+ */
+ protected void installDefaults(AbstractButton b)
+ {
+ super.installDefaults(b);
+ if (b.getIcon() == null)
+ b.setIcon(icon);
+ if (b.getSelectedIcon() == null)
+ b.setSelectedIcon(icon);
}
+ /**
+ * Returns the prefix used for UIDefaults properties. This is
+ * <code>RadioButton</code> in this case.
+ *
+ * @return the prefix used for UIDefaults properties
+ */
+ protected String getPropertyPrefix()
+ {
+ return "RadioButton";
+ }
+
+ /**
+ * Returns the default icon for JRadioButtons.
+ * The default icon displays the usual
+ * RadioButton and is sensible to the selection state of the button,
+ * and can be used both as normal icon as well as selectedIcon.
+ *
+ * @return the default icon for JRadioButtons
+ */
public Icon getDefaultIcon()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- return defaults.getIcon("RadioButton.icon");
+ return defaults.getIcon(getPropertyPrefix() + ".icon");
}
-
-}
-
-
-
-
+ /**
+ * Paints the RadioButton.
+ *
+ * @param g the Graphics context to paint with
+ * @param c the button to paint
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+ Rectangle tr = new Rectangle();
+ Rectangle ir = new Rectangle();
+ Rectangle vr = new Rectangle();
+ Font f = c.getFont();
+ g.setFont(f);
+ Icon currentIcon = null;
+ if (b.isSelected())
+ currentIcon = b.getSelectedIcon();
+ else
+ currentIcon = b.getIcon();
+ SwingUtilities.calculateInnerArea(b, vr);
+ String text = SwingUtilities.layoutCompoundLabel
+ (c, g.getFontMetrics(f), b.getText(), currentIcon,
+ b.getVerticalAlignment(), b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
+ vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
+
+ if (currentIcon != null)
+ {
+ currentIcon.paintIcon(c, g, ir.x, ir.y);
+ }
+ if (text != null)
+ paintText(g, b, tr, text);
+ paintFocus(g, b, vr, tr, ir);
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicRootPaneUI.java b/javax/swing/plaf/basic/BasicRootPaneUI.java
index 4923b90b2..d97f7baea 100644
--- a/javax/swing/plaf/basic/BasicRootPaneUI.java
+++ b/javax/swing/plaf/basic/BasicRootPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -56,7 +56,6 @@ public class BasicRootPaneUI extends RootPaneUI
public void installUI(JComponent c)
{
- c.setOpaque(true);
c.setBackground(UIManager.getColor("control"));
super.installUI(c);
}
diff --git a/javax/swing/plaf/basic/BasicScrollBarUI.java b/javax/swing/plaf/basic/BasicScrollBarUI.java
index b7c5074aa..892db2b03 100644
--- a/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -45,8 +45,6 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
-import java.awt.Point;
-import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -124,7 +122,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
// System.err.println(this + ".stateChanged()");
calculatePreferredSize();
- layoutContainer(scrollbar);
getThumbBounds();
scrollbar.repaint();
}
@@ -167,9 +164,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
incrButton.addMouseListener(buttonListener);
decrButton.addMouseListener(buttonListener);
calculatePreferredSize();
- layoutContainer(scrollbar);
}
- layoutContainer(scrollbar);
scrollbar.repaint();
}
}
@@ -820,6 +815,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
scrollbar.setBackground(defaults.getColor("ScrollBar.background"));
scrollbar.setBorder(defaults.getBorder("ScrollBar.border"));
scrollbar.setOpaque(true);
+ scrollbar.setLayout(this);
thumbColor = defaults.getColor("ScrollBar.thumb");
thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
@@ -888,7 +884,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
installListeners();
calculatePreferredSize();
- layoutContainer(scrollbar);
}
}
@@ -973,7 +968,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
public void paint(Graphics g, JComponent c)
{
- layoutContainer(scrollbar);
paintTrack(g, c, getTrackBounds());
paintThumb(g, c, getThumbBounds());
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java
index 938548aeb..bd1576f37 100644
--- a/javax/swing/plaf/basic/BasicScrollPaneUI.java
+++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -102,14 +102,6 @@ public class BasicScrollPaneUI extends ScrollPaneUI
return sl.minimumLayoutSize(c);
}
- public Dimension getPreferredSize(JComponent c)
- {
- JScrollPane p = (JScrollPane ) c;
- ScrollPaneLayout sl = (ScrollPaneLayout) p.getLayout();
- return sl.preferredLayoutSize(c);
- }
-
-
public void paint(Graphics g, JComponent c)
{
// do nothing; the normal painting-of-children algorithm, along with
diff --git a/javax/swing/plaf/basic/BasicSeparatorUI.java b/javax/swing/plaf/basic/BasicSeparatorUI.java
index db2d16458..38c9c7a28 100644
--- a/javax/swing/plaf/basic/BasicSeparatorUI.java
+++ b/javax/swing/plaf/basic/BasicSeparatorUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -125,7 +125,7 @@ public class BasicSeparatorUI extends SeparatorUI
shadow = defaults.getColor("Separator.shadow");
highlight = defaults.getColor("Separator.highlight");
- s.setOpaque(true);
+ s.setOpaque(false);
}
/**
diff --git a/javax/swing/plaf/basic/BasicSliderUI.java b/javax/swing/plaf/basic/BasicSliderUI.java
index 9169a6bb7..0b4058429 100644
--- a/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/javax/swing/plaf/basic/BasicSliderUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -470,15 +470,6 @@ public class BasicSliderUI extends SliderUI
}
}
- /** The preferred height of the thumb. */
- private transient int thumbHeight;
-
- /** The preferred width of the thumb. */
- private transient int thumbWidth;
-
- /** The preferred height of the tick rectangle. */
- private transient int tickHeight;
-
/** Listener for changes from the model. */
protected ChangeListener changeListener;
@@ -698,11 +689,6 @@ public class BasicSliderUI extends SliderUI
focusColor = defaults.getColor("Slider.focus");
slider.setBorder(defaults.getBorder("Slider.border"));
slider.setOpaque(true);
-
- thumbHeight = defaults.getInt("Slider.thumbHeight");
- thumbWidth = defaults.getInt("Slider.thumbWidth");
- tickHeight = defaults.getInt("Slider.tickHeight");
-
focusInsets = defaults.getInsets("Slider.focusInsets");
}
@@ -899,11 +885,11 @@ public class BasicSliderUI extends SliderUI
width += insets.left + insets.right + focusInsets.left + focusInsets.right;
// Height is determined by the thumb, the ticks and the labels.
- int height = thumbHeight;
+ int height = getThumbSize().height;
if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
|| slider.getMinorTickSpacing() > 0)
- height += tickHeight;
+ height += getTickLength();
if (slider.getPaintLabels())
height += getHeightOfTallestLabel();
@@ -934,11 +920,11 @@ public class BasicSliderUI extends SliderUI
height += insets.top + insets.bottom + focusInsets.top
+ focusInsets.bottom;
- int width = thumbHeight;
+ int width = getThumbSize().width;
if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
|| slider.getMinorTickSpacing() > 0)
- width += tickHeight;
+ width += getTickLength();
if (slider.getPaintLabels())
width += getWidthOfWidestLabel();
@@ -956,7 +942,21 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMinimumHorizontalSize()
{
- return getPreferredHorizontalSize();
+ Insets insets = slider.getInsets();
+ // Height is determined by the thumb, the ticks and the labels.
+ int height = getThumbSize().height;
+
+ if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
+ || slider.getMinorTickSpacing() > 0)
+ height += getTickLength();
+
+ if (slider.getPaintLabels())
+ height += getHeightOfTallestLabel();
+
+ height += insets.top + insets.bottom + focusInsets.top
+ + focusInsets.bottom;
+
+ return new Dimension(36, height);
}
/**
@@ -967,7 +967,19 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMinimumVerticalSize()
{
- return getPreferredVerticalSize();
+ Insets insets = slider.getInsets();
+ int width = getThumbSize().width;
+
+ if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
+ || slider.getMinorTickSpacing() > 0)
+ width += getTickLength();
+
+ if (slider.getPaintLabels())
+ width += getWidthOfWidestLabel();
+
+ width += insets.left + insets.right + focusInsets.left + focusInsets.right;
+
+ return new Dimension(width, 36);
}
/**
@@ -999,15 +1011,14 @@ public class BasicSliderUI extends SliderUI
public Dimension getMinimumSize(JComponent c)
{
if (slider.getOrientation() == JSlider.HORIZONTAL)
- return getPreferredHorizontalSize();
+ return getMinimumHorizontalSize();
else
- return getPreferredVerticalSize();
+ return getMinimumVerticalSize();
}
/**
* This method returns the maximum size for this {@link JSlider} for this
- * look and feel. If it returns null, then it is up to the Layout Manager
- * to give the {@link JComponent} a size.
+ * look and feel.
*
* @param c The {@link JComponent} to find a maximum size for.
*
@@ -1015,10 +1026,40 @@ public class BasicSliderUI extends SliderUI
*/
public Dimension getMaximumSize(JComponent c)
{
+ Insets insets = slider.getInsets();
if (slider.getOrientation() == JSlider.HORIZONTAL)
- return getPreferredHorizontalSize();
+ {
+ // Height is determined by the thumb, the ticks and the labels.
+ int height = getThumbSize().height;
+
+ if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
+ || slider.getMinorTickSpacing() > 0)
+ height += getTickLength();
+
+ if (slider.getPaintLabels())
+ height += getHeightOfTallestLabel();
+
+ height += insets.top + insets.bottom + focusInsets.top
+ + focusInsets.bottom;
+
+ return new Dimension(32767, height);
+ }
else
- return getPreferredVerticalSize();
+ {
+ int width = getThumbSize().width;
+
+ if (slider.getPaintTicks() && slider.getMajorTickSpacing() > 0
+ || slider.getMinorTickSpacing() > 0)
+ width += getTickLength();
+
+ if (slider.getPaintLabels())
+ width += getWidthOfWidestLabel();
+
+ width += insets.left + insets.right + focusInsets.left
+ + focusInsets.right;
+
+ return new Dimension(width, 32767);
+ }
}
/**
@@ -1045,7 +1086,6 @@ public class BasicSliderUI extends SliderUI
{
insetCache = slider.getInsets();
focusRect = SwingUtilities.calculateInnerArea(slider, focusRect);
-
if (focusRect.width < 0)
focusRect.width = 0;
if (focusRect.height < 0)
@@ -1058,30 +1098,13 @@ public class BasicSliderUI extends SliderUI
*/
protected void calculateThumbSize()
{
+ Dimension d = getThumbSize();
+ thumbRect.width = d.width;
+ thumbRect.height = d.height;
if (slider.getOrientation() == JSlider.HORIZONTAL)
- {
- if (thumbWidth > contentRect.width)
- thumbRect.width = contentRect.width / 4;
- else
- thumbRect.width = thumbWidth;
- if (thumbHeight > contentRect.height)
- thumbRect.height = contentRect.height;
- else
- thumbRect.height = thumbHeight;
- }
+ thumbRect.y = trackRect.y;
else
- {
- // The thumb gets flipped when inverted, so thumbWidth
- // actually is the height and vice versa.
- if (thumbWidth > contentRect.height)
- thumbRect.height = contentRect.height / 4;
- else
- thumbRect.height = thumbWidth;
- if (thumbHeight > contentRect.width)
- thumbRect.width = contentRect.width;
- else
- thumbRect.width = thumbHeight;
- }
+ thumbRect.x = trackRect.x;
}
/**
@@ -1092,9 +1115,10 @@ public class BasicSliderUI extends SliderUI
{
contentRect.x = focusRect.x + focusInsets.left;
contentRect.y = focusRect.y + focusInsets.top;
+
contentRect.width = focusRect.width - focusInsets.left - focusInsets.right;
- contentRect.height = focusRect.height - focusInsets.top
- - focusInsets.bottom;
+ contentRect.height = focusRect.height - focusInsets.top
+ - focusInsets.bottom;
if (contentRect.width < 0)
contentRect.width = 0;
@@ -1113,11 +1137,11 @@ public class BasicSliderUI extends SliderUI
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
thumbRect.x = xPositionForValue(value) - thumbRect.width / 2;
- thumbRect.y = contentRect.y;
+ thumbRect.y = trackRect.y;
}
else
{
- thumbRect.x = contentRect.x;
+ thumbRect.x = trackRect.x;
thumbRect.y = yPositionForValue(value) - thumbRect.height / 2;
}
}
@@ -1129,9 +1153,9 @@ public class BasicSliderUI extends SliderUI
protected void calculateTrackBuffer()
{
if (slider.getOrientation() == JSlider.HORIZONTAL)
- trackBuffer = thumbRect.width;
+ trackBuffer = thumbRect.width / 2;
else
- trackBuffer = thumbRect.height;
+ trackBuffer = thumbRect.height / 2;
}
/**
@@ -1141,9 +1165,11 @@ public class BasicSliderUI extends SliderUI
*/
protected Dimension getThumbSize()
{
- // This is really just the bounds box for the thumb.
- // The thumb will actually be pointed (like a rectangle + triangle at bottom)
- return thumbRect.getSize();
+ // TODO: shouldn't create new objects every time
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ return new Dimension(11, 20);
+ else
+ return new Dimension(20, 11);
}
/**
@@ -1155,13 +1181,21 @@ public class BasicSliderUI extends SliderUI
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
trackRect.x = contentRect.x + trackBuffer;
- trackRect.y = contentRect.y;
+ int h = getThumbSize().height;
+ if (slider.getPaintTicks() && (slider.getMajorTickSpacing() > 0
+ || slider.getMinorTickSpacing() > 0))
+ h += getTickLength();
+ trackRect.y = contentRect.y + (contentRect.height - h) / 2 - 1;
trackRect.width = contentRect.width - 2 * trackBuffer;
trackRect.height = thumbRect.height;
}
else
{
- trackRect.x = contentRect.x;
+ int w = getThumbSize().width;
+ if (slider.getPaintTicks() && (slider.getMajorTickSpacing() > 0
+ || slider.getMinorTickSpacing() > 0))
+ w += getTickLength();
+ trackRect.x = contentRect.x + (contentRect.width - w) / 2 - 1;
trackRect.y = contentRect.y + trackBuffer;
trackRect.width = thumbRect.width;
trackRect.height = contentRect.height - 2 * trackBuffer;
@@ -1180,7 +1214,7 @@ public class BasicSliderUI extends SliderUI
*/
protected int getTickLength()
{
- return tickHeight;
+ return 8;
}
/**
@@ -1536,9 +1570,6 @@ public class BasicSliderUI extends SliderUI
Point c = new Point(a);
Point d = new Point(a);
- Polygon high;
- Polygon shadow;
-
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
width = trackRect.width;
@@ -1591,74 +1622,78 @@ public class BasicSliderUI extends SliderUI
{
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
- double loc = tickRect.x;
+ double loc = tickRect.x + 0.5;
double increment = (max == min) ? 0
- : majorSpace * (double) tickRect.width / (max
- - min);
- if (drawInverted())
+ : majorSpace * (double) (tickRect.width - 1) / (max - min);
+ if (drawInverted())
{
loc += tickRect.width;
increment *= -1;
}
+ g.translate(0, tickRect.y);
for (int i = min; i <= max; i += majorSpace)
{
paintMajorTickForHorizSlider(g, tickRect, (int) loc);
loc += increment;
}
+ g.translate(0, -tickRect.y);
}
else
{
- double loc = tickRect.height + tickRect.y;
+ double loc = tickRect.height + tickRect.y + 0.5;
double increment = (max == min) ? 0
- : -majorSpace * (double) tickRect.height / (max
- - min);
+ : -majorSpace * (double) (tickRect.height - 1) / (max - min);
if (drawInverted())
{
- loc = tickRect.y;
+ loc = tickRect.y + 0.5;
increment *= -1;
}
+ g.translate(tickRect.x, 0);
for (int i = min; i <= max; i += majorSpace)
{
paintMajorTickForVertSlider(g, tickRect, (int) loc);
loc += increment;
}
+ g.translate(-tickRect.x, 0);
}
}
if (minorSpace > 0)
{
if (slider.getOrientation() == JSlider.HORIZONTAL)
{
- double loc = tickRect.x;
+ double loc = tickRect.x + 0.5;
double increment = (max == min) ? 0
- : minorSpace * (double) tickRect.width / (max
- - min);
+ : minorSpace * (double) (tickRect.width - 1) / (max - min);
if (drawInverted())
{
loc += tickRect.width;
increment *= -1;
}
+ g.translate(0, tickRect.y);
for (int i = min; i <= max; i += minorSpace)
{
paintMinorTickForHorizSlider(g, tickRect, (int) loc);
loc += increment;
}
+ g.translate(0, -tickRect.y);
}
else
{
- double loc = tickRect.height + tickRect.y;
+ double loc = tickRect.height + tickRect.y + 0.5;
double increment = (max == min) ? 0
- : -minorSpace * (double) tickRect.height / (max
- - min);
+ : -minorSpace * (double) (tickRect.height - 1) / (max - min);
if (drawInverted())
{
- loc = tickRect.y;
+ loc = tickRect.y + 0.5;
increment *= -1;
}
+ g.translate(tickRect.x, 0);
for (int i = min; i <= max; i += minorSpace)
{
paintMinorTickForVertSlider(g, tickRect, (int) loc);
loc += increment;
}
+ g.translate(-tickRect.x, 0);
}
}
}
@@ -1680,7 +1715,7 @@ public class BasicSliderUI extends SliderUI
protected void paintMinorTickForHorizSlider(Graphics g,
Rectangle tickBounds, int x)
{
- int y = tickRect.y + tickRect.height / 4;
+ int y = tickRect.height / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
@@ -1699,7 +1734,7 @@ public class BasicSliderUI extends SliderUI
protected void paintMajorTickForHorizSlider(Graphics g,
Rectangle tickBounds, int x)
{
- int y = tickRect.y + tickRect.height / 4;
+ int y = tickRect.height / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
@@ -1718,7 +1753,7 @@ public class BasicSliderUI extends SliderUI
protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds,
int y)
{
- int x = tickRect.x + tickRect.width / 4;
+ int x = tickRect.width / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
@@ -1737,7 +1772,7 @@ public class BasicSliderUI extends SliderUI
protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds,
int y)
{
- int x = tickRect.x + tickRect.width / 4;
+ int x = tickRect.width / 4;
Color saved = g.getColor();
g.setColor(Color.BLACK);
@@ -1924,8 +1959,6 @@ public class BasicSliderUI extends SliderUI
{
Color saved_color = g.getColor();
- Polygon thumb = new Polygon();
-
Point a = new Point(thumbRect.x, thumbRect.y);
Point b = new Point(a);
Point c = new Point(a);
@@ -1933,7 +1966,8 @@ public class BasicSliderUI extends SliderUI
Point e = new Point(a);
Polygon bright;
- Polygon dark;
+ Polygon light; // light shadow
+ Polygon dark; // dark shadow
Polygon all;
// This will be in X-dimension if the slider is inverted and y if it isn't.
@@ -1943,36 +1977,42 @@ public class BasicSliderUI extends SliderUI
{
turnPoint = thumbRect.height * 3 / 4;
- b.translate(thumbRect.width, 0);
- c.translate(thumbRect.width, turnPoint);
- d.translate(thumbRect.width / 2, thumbRect.height);
+ b.translate(thumbRect.width - 1, 0);
+ c.translate(thumbRect.width - 1, turnPoint);
+ d.translate(thumbRect.width / 2 - 1, thumbRect.height - 1);
e.translate(0, turnPoint);
- bright = new Polygon(new int[] { b.x, a.x, e.x, d.x },
+ bright = new Polygon(new int[] { b.x - 1, a.x, e.x, d.x },
new int[] { b.y, a.y, e.y, d.y }, 4);
- dark = new Polygon(new int[] { b.x, c.x, d.x },
- new int[] { b.y, c.y, d.y }, 3);
- all = new Polygon(new int[] { a.x + 1, b.x, c.x, d.x, e.x + 1 },
- new int[] { a.y + 1, b.y + 1, c.y, d.y + 1, e.y }, 5);
+ dark = new Polygon(new int[] { b.x, c.x, d.x + 1 },
+ new int[] { b.y, c.y - 1, d.y }, 3);
+
+ light = new Polygon(new int[] { b.x - 1, c.x - 1, d.x + 1 },
+ new int[] { b.y + 1, c.y - 1, d.y - 1 }, 3);
+
+ all = new Polygon(new int[] { a.x + 1, b.x - 2, c.x - 2, d.x, e.x + 1 },
+ new int[] { a.y + 1, b.y + 1, c.y - 1, d.y - 1, e.y }, 5);
}
else
{
- turnPoint = thumbRect.width * 3 / 4;
+ turnPoint = thumbRect.width * 3 / 4 - 1;
b.translate(turnPoint, 0);
- c.translate(thumbRect.width, thumbRect.height / 2);
- d.translate(turnPoint, thumbRect.height);
- e.translate(0, thumbRect.height);
+ c.translate(thumbRect.width - 1, thumbRect.height / 2);
+ d.translate(turnPoint, thumbRect.height - 1);
+ e.translate(0, thumbRect.height - 1);
- bright = new Polygon(new int[] { c.x, b.x, a.x, e.x },
- new int[] { c.y, b.y, a.y, e.y }, 4);
+ bright = new Polygon(new int[] { c.x - 1, b.x, a.x, e.x },
+ new int[] { c.y - 1, b.y, a.y, e.y - 1 }, 4);
- dark = new Polygon(new int[] { c.x, d.x, e.x + 1 },
+ dark = new Polygon(new int[] { c.x, d.x, e.x },
new int[] { c.y, d.y, e.y }, 3);
- all = new Polygon(new int[] { a.x + 1, b.x, c.x - 1, d.x, e.x + 1 },
- new int[] { a.y + 1, b.y + 1, c.y, d.y, e.y }, 5);
+ light = new Polygon(new int[] { c.x - 1, d.x, e.x + 1},
+ new int[] { c.y, d.y - 1, e.y - 1}, 3);
+ all = new Polygon(new int[] { a.x + 1, b.x, c.x - 2, c.x - 2, d.x, e.x + 1 },
+ new int[] { a.y + 1, b.y + 1, c.y - 1, c.y, d.y - 2, e.y - 2 }, 6);
}
g.setColor(Color.WHITE);
@@ -1982,6 +2022,10 @@ public class BasicSliderUI extends SliderUI
g.drawPolyline(dark.xpoints, dark.ypoints, dark.npoints);
g.setColor(Color.GRAY);
+ g.drawPolyline(light.xpoints, light.ypoints, light.npoints);
+
+ g.setColor(Color.LIGHT_GRAY);
+ g.drawPolyline(all.xpoints, all.ypoints, all.npoints);
g.fillPolygon(all);
g.setColor(saved_color);
@@ -2065,8 +2109,7 @@ public class BasicSliderUI extends SliderUI
{
int min = slider.getMinimum();
int max = slider.getMaximum();
- int extent = slider.getExtent();
- int len = trackRect.width;
+ int len = trackRect.width - 1;
int xPos = (max == min) ? 0 : (value - min) * len / (max - min);
@@ -2074,7 +2117,7 @@ public class BasicSliderUI extends SliderUI
xPos += trackRect.x;
else
{
- xPos = trackRect.width - xPos;
+ xPos = len - xPos;
xPos += trackRect.x;
}
return xPos;
@@ -2091,14 +2134,13 @@ public class BasicSliderUI extends SliderUI
{
int min = slider.getMinimum();
int max = slider.getMaximum();
- int extent = slider.getExtent();
- int len = trackRect.height;
+ int len = trackRect.height - 1;
int yPos = (max == min) ? 0 : (value - min) * len / (max - min);
if (! drawInverted())
{
- yPos = trackRect.height - yPos;
+ yPos = len - yPos;
yPos += trackRect.y;
}
else
@@ -2123,8 +2165,9 @@ public class BasicSliderUI extends SliderUI
int value;
- // If the length is 0, you shouldn't be able to even see where the slider is.
- // This really shouldn't ever happen, but just in case, we'll return the middle.
+ // If the length is 0, you shouldn't be able to even see where the slider
+ // is. This really shouldn't ever happen, but just in case, we'll return
+ // the middle.
if (len == 0)
return ((max - min) / 2);
@@ -2158,8 +2201,9 @@ public class BasicSliderUI extends SliderUI
int value;
- // If the length is 0, you shouldn't be able to even see where the slider is.
- // This really shouldn't ever happen, but just in case, we'll return the middle.
+ // If the length is 0, you shouldn't be able to even see where the slider
+ // is. This really shouldn't ever happen, but just in case, we'll return
+ // the middle.
if (len == 0)
return ((max - min) / 2);
diff --git a/javax/swing/plaf/basic/BasicSpinnerUI.java b/javax/swing/plaf/basic/BasicSpinnerUI.java
index 919cde786..97ab97b89 100644
--- a/javax/swing/plaf/basic/BasicSpinnerUI.java
+++ b/javax/swing/plaf/basic/BasicSpinnerUI.java
@@ -1,5 +1,5 @@
/* SpinnerUI.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -161,7 +161,7 @@ public class BasicSpinnerUI extends SpinnerUI
* obtained from <code>UIManager.getLookAndFeelDefaults</code>, as well as
* set the layout obtained from <code>createLayout</code>
*
- * @see #javax.swing.UIManager#getLookAndFeelDefaults
+ * @see javax.swing.UIManager#getLookAndFeelDefaults
* @see #createLayout
* @see #installUI
*/
@@ -178,6 +178,7 @@ public class BasicSpinnerUI extends SpinnerUI
spinner.setBorder(defaults.getBorder("Spinner.border"));
*/
spinner.setLayout(createLayout());
+ spinner.setOpaque(true);
}
/*
diff --git a/javax/swing/plaf/basic/BasicSplitPaneDivider.java b/javax/swing/plaf/basic/BasicSplitPaneDivider.java
index 3b8596e7e..b8674ed2f 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneDivider.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneDivider.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -273,7 +273,7 @@ public class BasicSplitPaneDivider extends Container
*
* @param border the new border. Typically, this will be an instance of
* {@link
- * javax.swing.plaf.basic.BasicBorders.SplitPaneDividerBorder}.
+ * javax.swing.plaf.basic.BasicBorders.SplitPaneBorder}.
*
* @since 1.3
*/
diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java
index b701a63d6..ff7e8acfb 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -348,7 +348,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
height = Math.max(height, dims.height);
}
}
- return new Dimension(500, 500); //width, height);
+ return new Dimension(width, height);
}
return null;
}
@@ -613,7 +613,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
width = Math.max(width, dims.width);
}
}
- return new Dimension(500, 500); //width, height);
+ return new Dimension(width, height);
}
return null;
}
@@ -990,8 +990,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
protected void installDefaults()
{
- resetLayoutManager();
divider = createDefaultDivider();
+ resetLayoutManager();
nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider();
splitPane.add(divider, JSplitPane.DIVIDER);
@@ -1000,6 +1000,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
splitPane.setBackground(defaults.getColor("SplitPane.background"));
splitPane.setBorder(defaults.getBorder("SplitPane.border"));
splitPane.setDividerSize(defaults.getInt("SplitPane.dividerSize"));
+ splitPane.setOpaque(true);
}
/**
@@ -1384,11 +1385,6 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
public void paint(Graphics g, JComponent jc)
{
- // Make sure that the location is valid
- int divLoc = splitPane.getDividerLocation();
- int valLoc = validLocation(divLoc);
- if (divLoc != valLoc)
- splitPane.setDividerLocation(valLoc);
}
/**
@@ -1449,9 +1445,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
layoutManager = new BasicHorizontalLayoutManager();
else
layoutManager = new BasicVerticalLayoutManager();
- layoutManager.invalidateLayout(splitPane);
- layoutManager.updateComponents();
getSplitPane().setLayout(layoutManager);
+ layoutManager.updateComponents();
// invalidating by itself does not invalidate the layout.
getSplitPane().revalidate();
diff --git a/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index 9ea653e7f..7e9d9b982 100644
--- a/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -1541,7 +1541,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
tabPane.setFont(defaults.getFont("TabbedPane.font"));
tabPane.setForeground(defaults.getColor("TabbedPane.foreground"));
tabPane.setBackground(defaults.getColor("TabbedPane.background"));
- tabPane.setOpaque(true);
+ tabPane.setOpaque(false);
highlight = defaults.getColor("TabbedPane.highlight");
lightHighlight = defaults.getColor("TabbedPane.lightHighlight");
@@ -1680,18 +1680,6 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
}
/**
- * This method returns the preferred size of the JTabbedPane.
- *
- * @param c The JComponent to find a size for.
- *
- * @return The preferred size.
- */
- public Dimension getPreferredSize(JComponent c)
- {
- return layoutManager.preferredLayoutSize(tabPane);
- }
-
- /**
* This method returns the minimum size of the JTabbedPane.
*
* @param c The JComponent to find a size for.
diff --git a/javax/swing/plaf/basic/BasicTableHeaderUI.java b/javax/swing/plaf/basic/BasicTableHeaderUI.java
index ebc702ad3..700b406d0 100644
--- a/javax/swing/plaf/basic/BasicTableHeaderUI.java
+++ b/javax/swing/plaf/basic/BasicTableHeaderUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index 93483804c..aa8f21a62 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,16 +46,19 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
+import javax.swing.BorderFactory;
import javax.swing.CellRendererPane;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
+import javax.swing.border.Border;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TableUI;
@@ -77,6 +80,12 @@ public class BasicTableUI
protected CellRendererPane rendererPane;
protected JTable table;
+ /** The normal cell border. */
+ Border cellBorder;
+
+ /** The cell border for selected/highlighted cells. */
+ Border highlightCellBorder;
+
class FocusHandler implements FocusListener
{
public void focusGained(FocusEvent e)
@@ -89,12 +98,418 @@ public class BasicTableUI
class KeyHandler implements KeyListener
{
- public void keyPressed(KeyEvent e)
+
+ /**
+ * A helper method for the keyPressed event. Used because the actions
+ * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar.
+ *
+ * Selects the next (previous if SHIFT pressed) column for TAB, or row for
+ * ENTER from within the currently selected cells.
+ *
+ * @param firstModel the ListSelectionModel for columns (TAB) or
+ * rows (ENTER)
+ * @param firstMin the first selected index in firstModel
+ * @param firstMax the last selected index in firstModel
+ * @param secondModel the ListSelectionModel for rows (TAB) or
+ * columns (ENTER)
+ * @param secondMin the first selected index in secondModel
+ * @param secondMax the last selected index in secondModel
+ * @param reverse true if shift was held for the event
+ * @param eventIsTab true if TAB was pressed, false if ENTER pressed
+ */
+ void advanceMultipleSelection (ListSelectionModel firstModel, int firstMin,
+ int firstMax, ListSelectionModel secondModel,
+ int secondMin, int secondMax, boolean reverse,
+ boolean eventIsTab)
{
+ // If eventIsTab, all the "firsts" correspond to columns, otherwise, to rows
+ // "seconds" correspond to the opposite
+ int firstLead = firstModel.getLeadSelectionIndex();
+ int secondLead = secondModel.getLeadSelectionIndex();
+ int numFirsts = eventIsTab ?
+ table.getModel().getColumnCount() : table.getModel().getRowCount();
+ int numSeconds = eventIsTab ?
+ table.getModel().getRowCount() : table.getModel().getColumnCount();
+
+ // check if we have to wrap the "firsts" around, going to the other side
+ if ((firstLead == firstMax && !reverse) ||
+ (reverse && firstLead == firstMin))
+ {
+ firstModel.addSelectionInterval(reverse ? firstMax : firstMin,
+ reverse ? firstMax : firstMin);
+
+ // check if we have to wrap the "seconds"
+ if ((secondLead == secondMax && !reverse) ||
+ (reverse && secondLead == secondMin))
+ secondModel.addSelectionInterval(reverse ? secondMax : secondMin,
+ reverse ? secondMax : secondMin);
+
+ // if we're not wrapping the seconds, we have to find out where we
+ // are within the secondModel and advance to the next cell (or
+ // go back to the previous cell if reverse == true)
+ else
+ {
+ int[] secondsSelected;
+ if (eventIsTab && table.getRowSelectionAllowed() ||
+ !eventIsTab && table.getColumnSelectionAllowed())
+ secondsSelected = eventIsTab ?
+ table.getSelectedRows() : table.getSelectedColumns();
+ else
+ {
+ // if row selection is not allowed, then the entire column gets
+ // selected when you click on it, so consider ALL rows selected
+ secondsSelected = new int[numSeconds];
+ for (int i = 0; i < numSeconds; i++)
+ secondsSelected[i] = i;
+ }
+
+ // and now find the "next" index within the model
+ int secondIndex = reverse ? secondsSelected.length - 1 : 0;
+ if (!reverse)
+ while (secondsSelected[secondIndex] <= secondLead)
+ secondIndex++;
+ else
+ while (secondsSelected[secondIndex] >= secondLead)
+ secondIndex--;
+
+ // and select it - updating the lead selection index
+ secondModel.addSelectionInterval(secondsSelected[secondIndex],
+ secondsSelected[secondIndex]);
+ }
+ }
+ // We didn't have to wrap the firsts, so just find the "next" first
+ // and select it, we don't have to change "seconds"
+ else
+ {
+ int[] firstsSelected;
+ if (eventIsTab && table.getColumnSelectionAllowed() ||
+ !eventIsTab && table.getRowSelectionAllowed())
+ firstsSelected = eventIsTab ?
+ table.getSelectedColumns() : table.getSelectedRows();
+ else
+ {
+ // if selection not allowed, consider ALL firsts to be selected
+ firstsSelected = new int[numFirsts];
+ for (int i = 0; i < numFirsts; i++)
+ firstsSelected[i] = i;
+ }
+ int firstIndex = reverse ? firstsSelected.length - 1 : 0;
+ if (!reverse)
+ while (firstsSelected[firstIndex] <= firstLead)
+ firstIndex++;
+ else
+ while (firstsSelected[firstIndex] >= firstLead)
+ firstIndex--;
+ firstModel.addSelectionInterval(firstsSelected[firstIndex],
+ firstsSelected[firstIndex]);
+ secondModel.addSelectionInterval(secondLead, secondLead);
+ }
+ }
+
+ /**
+ * A helper method for the keyPressed event. Used because the actions
+ * for TAB, SHIFT-TAB, ENTER, and SHIFT-ENTER are very similar.
+ *
+ * Selects the next (previous if SHIFT pressed) column (TAB) or row (ENTER)
+ * in the table, changing the current selection. All cells in the table
+ * are eligible, not just the ones that are currently selected.
+ * @param firstModel the ListSelectionModel for columns (TAB) or rows
+ * (ENTER)
+ * @param firstMax the last index in firstModel
+ * @param secondModel the ListSelectionModel for rows (TAB) or columns
+ * (ENTER)
+ * @param secondMax the last index in secondModel
+ * @param reverse true if SHIFT was pressed for the event
+ */
+
+ void advanceSingleSelection (ListSelectionModel firstModel, int firstMax,
+ ListSelectionModel secondModel, int secondMax,
+ boolean reverse)
+ {
+ // for TABs, "first" corresponds to columns and "seconds" to rows.
+ // the opposite is true for ENTERs
+ int firstLead = firstModel.getLeadSelectionIndex();
+ int secondLead = secondModel.getLeadSelectionIndex();
+
+ // if we are going backwards subtract 2 because we later add 1
+ // for a net change of -1
+ if (reverse && (firstLead == 0))
+ {
+ // check if we have to wrap around
+ if (secondLead == 0)
+ secondLead += secondMax + 1;
+ secondLead -= 2;
+ }
+
+ // do we have to wrap the "seconds"?
+ if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax))
+ secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1),
+ (secondLead + 1)%(secondMax + 1));
+ // if not, just reselect the current lead
+ else
+ secondModel.setSelectionInterval(secondLead, secondLead);
+
+ // if we are going backwards, subtract 2 because we add 1 later
+ // for net change of -1
+ if (reverse)
+ {
+ // check for wraparound
+ if (firstLead == 0)
+ firstLead += firstMax + 1;
+ firstLead -= 2;
+ }
+ // select the next "first"
+ firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1),
+ (firstLead + 1)%(firstMax + 1));
+ }
+
+ public void keyPressed(KeyEvent evt)
+ {
+ ListSelectionModel rowModel = table.getSelectionModel();
+ ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
+
+ int rowLead = rowModel.getLeadSelectionIndex();
+ int rowMax = table.getModel().getRowCount() - 1;
+
+ int colLead = colModel.getLeadSelectionIndex();
+ int colMax = table.getModel().getColumnCount() - 1;
+
+ if ((evt.getKeyCode() == KeyEvent.VK_DOWN)
+ || (evt.getKeyCode() == KeyEvent.VK_KP_DOWN))
+ {
+ if (evt.getModifiers() == 0)
+ {
+
+ table.clearSelection();
+ rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax),
+ Math.min(rowLead + 1, rowMax));
+ colModel.setSelectionInterval(colLead,colLead);
+ }
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax));
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_UP)
+ || (evt.getKeyCode() == KeyEvent.VK_KP_UP))
+ {
+ if (evt.getModifiers() == 0)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(Math.max(rowLead - 1, 0),
+ Math.max(rowLead - 1, 0));
+ colModel.setSelectionInterval(colLead,colLead);
+ }
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0));
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_LEFT)
+ || (evt.getKeyCode() == KeyEvent.VK_KP_LEFT))
+ {
+ if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0));
+ rowModel.setLeadSelectionIndex(rowLead);
+ }
+ else if (evt.getModifiers() == 0)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(rowLead,rowLead);
+ colModel.setSelectionInterval(Math.max(colLead - 1, 0),
+ Math.max(colLead - 1, 0));
+ }
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_RIGHT)
+ || (evt.getKeyCode() == KeyEvent.VK_KP_RIGHT))
+ {
+ if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax));
+ rowModel.setLeadSelectionIndex(rowLead);
+ }
+ else if (evt.getModifiers() == 0)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(rowLead,rowLead);
+ colModel.setSelectionInterval(Math.min(colLead + 1, colMax),
+ Math.min(colLead + 1, colMax));
+ }
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_END)
+ {
+ if (evt.getModifiers() == (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK))
+ {
+ rowModel.setLeadSelectionIndex(rowMax);
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ else if (evt.getModifiers() == InputEvent.CTRL_MASK)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(rowMax,rowMax);
+ colModel.setSelectionInterval(colLead, colLead);
+ }
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ colModel.setLeadSelectionIndex(colMax);
+ rowModel.setLeadSelectionIndex(rowLead);
+ }
+ else if (evt.getModifiers() == 0)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(rowLead, rowLead);
+ colModel.setSelectionInterval(colMax, colMax);
+ }
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_HOME)
+ {
+ if (evt.getModifiers() == (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK))
+ {
+ rowModel.setLeadSelectionIndex(0);
+ colModel.setLeadSelectionIndex(colLead);
+ }
+ else if (evt.getModifiers() == InputEvent.CTRL_MASK)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(0,0);
+ colModel.setSelectionInterval(colLead, colLead);
+ }
+ else if (evt.getModifiers() == InputEvent.SHIFT_MASK)
+ {
+ colModel.setLeadSelectionIndex(0);
+ rowModel.setLeadSelectionIndex(rowLead);
+ }
+ else if (evt.getModifiers() == 0)
+ {
+ table.clearSelection();
+ rowModel.setSelectionInterval(rowLead, rowLead);
+ colModel.setSelectionInterval(0, 0);
+ }
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_F2)
+ {
+ // FIXME: Implement "start editing"
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_PAGE_UP)
+ {
+ // FIXME: implement, need JList.ensureIndexIsVisible to work
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_PAGE_DOWN)
+ {
+ // FIXME: implement, need JList.ensureIndexIsVisible to work
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_TAB
+ || evt.getKeyCode() == KeyEvent.VK_ENTER)
+ {
+ // If modifers other than SHIFT are pressed, do nothing
+ if (evt.getModifiers() != 0 && evt.getModifiers() !=
+ InputEvent.SHIFT_MASK)
+ return;
+
+ // If nothing is selected, select the first cell in the table
+ if (table.getSelectedRowCount() == 0 &&
+ table.getSelectedColumnCount() == 0)
+ {
+ rowModel.setSelectionInterval(0, 0);
+ colModel.setSelectionInterval(0, 0);
+ return;
+ }
+
+ // If the lead selection index isn't selected (ie a remove operation
+ // happened, then set the lead to the first selected cell in the
+ // table
+ if (!table.isCellSelected(rowLead, colLead))
+ {
+ rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(),
+ rowModel.getMinSelectionIndex());
+ colModel.addSelectionInterval(colModel.getMinSelectionIndex(),
+ colModel.getMinSelectionIndex());
+ return;
+ }
+
+ // multRowsSelected and multColsSelected tell us if multiple rows or
+ // columns are selected, respectively
+ boolean multRowsSelected, multColsSelected;
+ multRowsSelected = (table.getSelectedRowCount() > 1) ||
+ (!table.getRowSelectionAllowed() &&
+ table.getSelectedColumnCount() > 0);
+ multColsSelected = (table.getSelectedColumnCount() > 1) ||
+ (!table.getColumnSelectionAllowed() &&
+ table.getSelectedRowCount() > 0);
+
+ // If there is just one selection, select the next cell, and wrap
+ // when you get to the edges of the table.
+ if (!multColsSelected || !multRowsSelected)
+ {
+ if (evt.getKeyCode() == KeyEvent.VK_TAB)
+ advanceSingleSelection(colModel, colMax, rowModel, rowMax,
+ (evt.getModifiers() ==
+ InputEvent.SHIFT_MASK));
+ else
+ advanceSingleSelection(rowModel, rowMax, colModel, colMax,
+ (evt.getModifiers() ==
+ InputEvent.SHIFT_MASK));
+ return;
+ }
+
+
+ // rowMinSelected and rowMaxSelected are the minimum and maximum
+ // values respectively of selected cells in the row selection model
+ // Similarly for colMinSelected and colMaxSelected.
+ int rowMaxSelected = table.getRowSelectionAllowed() ?
+ rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1;
+ int rowMinSelected = table.getRowSelectionAllowed() ?
+ rowModel.getMinSelectionIndex() : 0;
+ int colMaxSelected = table.getColumnSelectionAllowed() ?
+ colModel.getMaxSelectionIndex() :
+ table.getModel().getColumnCount() - 1;
+ int colMinSelected = table.getColumnSelectionAllowed() ?
+ colModel.getMinSelectionIndex() : 0;
+
+ // If there are multiple rows and columns selected, select the next
+ // cell and wrap at the edges of the selection.
+ if (evt.getKeyCode() == KeyEvent.VK_TAB)
+ advanceMultipleSelection(colModel, colMinSelected, colMaxSelected,
+ rowModel, rowMinSelected, rowMaxSelected,
+ (evt.getModifiers() ==
+ InputEvent.SHIFT_MASK), true);
+ else
+ advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected,
+ colModel, colMinSelected, colMaxSelected,
+ (evt.getModifiers() ==
+ InputEvent.SHIFT_MASK), false);
+
+ table.repaint();
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_ESCAPE)
+ {
+ // FIXME: implement "cancel"
+ }
+ else if ((evt.getKeyCode() == KeyEvent.VK_A || evt.getKeyCode()
+ == KeyEvent.VK_SLASH) && (evt.getModifiers() ==
+ InputEvent.CTRL_MASK))
+ {
+ table.selectAll();
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_BACK_SLASH
+ && (evt.getModifiers() == InputEvent.CTRL_MASK))
+ {
+ table.clearSelection();
+ }
+ else if (evt.getKeyCode() == KeyEvent.VK_SPACE
+ && (evt.getModifiers() == InputEvent.CTRL_MASK))
+ {
+ table.changeSelection(rowLead, colLead, true, false);
+ }
}
+
public void keyReleased(KeyEvent e)
{
}
+
public void keyTyped(KeyEvent e)
{
}
@@ -104,23 +519,32 @@ public class BasicTableUI
{
Point begin, curr;
- private void updateSelection()
+ private void updateSelection(boolean controlPressed)
{
- if (table.getRowSelectionAllowed())
+ // Update the rows
+ int lo_row = table.rowAtPoint(begin);
+ int hi_row = table.rowAtPoint(curr);
+ ListSelectionModel rowModel = table.getSelectionModel();
+ if (lo_row != -1 && hi_row != -1)
{
- int lo_row = table.rowAtPoint(begin);
- int hi_row = table.rowAtPoint(curr);
- ListSelectionModel rowModel = table.getSelectionModel();
- if (lo_row != -1 && hi_row != -1)
+ if (controlPressed && rowModel.getSelectionMode()
+ != ListSelectionModel.SINGLE_SELECTION)
+ rowModel.addSelectionInterval(lo_row, hi_row);
+ else
rowModel.setSelectionInterval(lo_row, hi_row);
}
-
- if (table.getColumnSelectionAllowed())
+
+ // Update the columns
+ int lo_col = table.columnAtPoint(begin);
+ int hi_col = table.columnAtPoint(curr);
+ ListSelectionModel colModel = table.getColumnModel().
+ getSelectionModel();
+ if (lo_col != -1 && hi_col != -1)
{
- int lo_col = table.columnAtPoint(begin);
- int hi_col = table.columnAtPoint(curr);
- ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
- if (lo_col != -1 && hi_col != -1)
+ if (controlPressed && colModel.getSelectionMode() !=
+ ListSelectionModel.SINGLE_SELECTION)
+ colModel.addSelectionInterval(lo_col, hi_col);
+ else
colModel.setSelectionInterval(lo_col, hi_col);
}
}
@@ -131,7 +555,7 @@ public class BasicTableUI
public void mouseDragged(MouseEvent e)
{
curr = new Point(e.getX(), e.getY());
- updateSelection();
+ updateSelection(e.isControlDown());
}
public void mouseEntered(MouseEvent e)
{
@@ -146,7 +570,20 @@ public class BasicTableUI
{
begin = new Point(e.getX(), e.getY());
curr = new Point(e.getX(), e.getY());
- updateSelection();
+ //if control is pressed and the cell is already selected, deselect it
+ if (e.isControlDown() && table.
+ isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin)))
+ {
+ table.getSelectionModel().
+ removeSelectionInterval(table.rowAtPoint(begin),
+ table.rowAtPoint(begin));
+ table.getColumnModel().getSelectionModel().
+ removeSelectionInterval(table.columnAtPoint(begin),
+ table.columnAtPoint(begin));
+ }
+ else
+ updateSelection(e.isControlDown());
+
}
public void mouseReleased(MouseEvent e)
{
@@ -195,6 +632,9 @@ public class BasicTableUI
table.setSelectionForeground(defaults.getColor("Table.selectionForeground"));
table.setSelectionBackground(defaults.getColor("Table.selectionBackground"));
table.setOpaque(true);
+
+ highlightCellBorder = defaults.getBorder("Table.focusCellHighlightBorder");
+ cellBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
}
protected void installKeyboardActions()
{
@@ -205,6 +645,7 @@ public class BasicTableUI
table.addFocusListener(focusListener);
table.addKeyListener(keyListener);
table.addMouseListener(mouseInputListener);
+ table.addMouseMotionListener(mouseInputListener);
}
protected void uninstallDefaults()
@@ -236,6 +677,7 @@ public class BasicTableUI
table.removeFocusListener(focusListener);
table.removeKeyListener(keyListener);
table.removeMouseListener(mouseInputListener);
+ table.removeMouseMotionListener(mouseInputListener);
}
public void installUI(JComponent comp)
@@ -292,6 +734,17 @@ public class BasicTableUI
Component comp = table.prepareRenderer(rend, r, c);
gfx.translate(x, y);
comp.setBounds(new Rectangle(0, 0, width, height));
+ // Set correct border on cell renderer.
+ // Only the lead selection cell gets a border
+ if (comp instanceof JComponent)
+ {
+ if (table.getSelectionModel().getLeadSelectionIndex() == r
+ && table.getColumnModel().getSelectionModel().
+ getLeadSelectionIndex() == c)
+ ((JComponent) comp).setBorder(highlightCellBorder);
+ else
+ ((JComponent) comp).setBorder(cellBorder);
+ }
comp.paint(gfx);
gfx.translate(-x, -y);
}
@@ -347,5 +800,4 @@ public class BasicTableUI
}
}
-
}
diff --git a/javax/swing/plaf/basic/BasicTextAreaUI.java b/javax/swing/plaf/basic/BasicTextAreaUI.java
index 61d025ddd..97b0ccb6e 100644
--- a/javax/swing/plaf/basic/BasicTextAreaUI.java
+++ b/javax/swing/plaf/basic/BasicTextAreaUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicTextFieldUI.java b/javax/swing/plaf/basic/BasicTextFieldUI.java
index e7cf33b1b..a300446c2 100644
--- a/javax/swing/plaf/basic/BasicTextFieldUI.java
+++ b/javax/swing/plaf/basic/BasicTextFieldUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicTextPaneUI.java b/javax/swing/plaf/basic/BasicTextPaneUI.java
index ac20a0a99..55d908e1b 100644
--- a/javax/swing/plaf/basic/BasicTextPaneUI.java
+++ b/javax/swing/plaf/basic/BasicTextPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index 1bb0fe4b2..acd0261ed 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -78,10 +78,20 @@ import javax.swing.text.Position;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
-
+/**
+ * The abstract base class from which the UI classes for Swings text
+ * components are derived. This provides most of the functionality for
+ * the UI classes.
+ *
+ * @author original author unknown
+ * @author Roman Kennke (roman@kennke.org)
+ */
public abstract class BasicTextUI extends TextUI
implements ViewFactory
{
+ /**
+ * A {@link DefaultCaret} that implements {@link UIResource}.
+ */
public static class BasicCaret extends DefaultCaret
implements UIResource
{
@@ -90,6 +100,9 @@ public abstract class BasicTextUI extends TextUI
}
}
+ /**
+ * A {@link DefaultHighlighter} that implements {@link UIResource}.
+ */
public static class BasicHighlighter extends DefaultHighlighter
implements UIResource
{
@@ -97,40 +110,80 @@ public abstract class BasicTextUI extends TextUI
{
}
}
-
+
+ /**
+ * This view forms the root of the View hierarchy. However, it delegates
+ * most calls to another View which is the real root of the hierarchy.
+ * The purpose is to make sure that all Views in the hierarchy, including
+ * the (real) root have a well-defined parent to which they can delegate
+ * calls like {@link #preferenceChanged}, {@link #getViewFactory} and
+ * {@link #getContainer}.
+ */
private class RootView extends View
{
+ /** The real root view. */
private View view;
-
+
+ /**
+ * Creates a new RootView.
+ */
public RootView()
{
super(null);
}
- // View methods.
-
+ /**
+ * Returns the ViewFactory for this RootView. If the current EditorKit
+ * provides a ViewFactory, this is used. Otherwise the TextUI itself
+ * is returned as a ViewFactory.
+ *
+ * @return the ViewFactory for this RootView
+ */
public ViewFactory getViewFactory()
{
- // FIXME: Handle EditorKit somehow.
- return BasicTextUI.this;
+ ViewFactory factory = null;
+ EditorKit editorKit = BasicTextUI.this.getEditorKit(getComponent());
+ factory = editorKit.getViewFactory();
+ if (factory == null)
+ factory = BasicTextUI.this;
+ return factory;
}
+ /**
+ * Sets the real root view.
+ *
+ * @param v the root view to set
+ */
public void setView(View v)
{
if (view != null)
view.setParent(null);
if (v != null)
- v.setParent(null);
+ v.setParent(this);
view = v;
}
+ /**
+ * Returns the <code>Container</code> that contains this view. This
+ * normally will be the text component that is managed by this TextUI.
+ *
+ * @return the <code>Container</code> that contains this view
+ */
public Container getContainer()
{
return textComponent;
}
-
+
+ /**
+ * Returns the preferred span along the specified <code>axis</code>.
+ * This is delegated to the real root view.
+ *
+ * @param axis the axis for which the preferred span is queried
+ *
+ * @return the preferred span along the axis
+ */
public float getPreferredSpan(int axis)
{
if (view != null)
@@ -139,19 +192,47 @@ public abstract class BasicTextUI extends TextUI
return Integer.MAX_VALUE;
}
+ /**
+ * Paints the view. This is delegated to the real root view.
+ *
+ * @param g the <code>Graphics</code> context to paint to
+ * @param s the allocation for the View
+ */
public void paint(Graphics g, Shape s)
{
if (view != null)
view.paint(g, s);
}
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * This is delegated to the real root view.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
public Shape modelToView(int position, Shape a, Position.Bias bias)
throws BadLocationException
{
if (view == null)
return null;
- return ((PlainView) view).modelToView(position, a, bias).getBounds();
+ return ((View) view).modelToView(position, a, bias);
}
/**
@@ -194,8 +275,16 @@ public abstract class BasicTextUI extends TextUI
}
}
+ /**
+ * Receives notifications when properties of the text component change.
+ */
class UpdateHandler implements PropertyChangeListener
{
+ /**
+ * Notifies when a property of the text component changes.
+ *
+ * @param event the PropertyChangeEvent describing the change
+ */
public void propertyChange(PropertyChangeEvent event)
{
if (event.getPropertyName().equals("document"))
@@ -208,7 +297,7 @@ public abstract class BasicTextUI extends TextUI
/**
* Listens for changes on the underlying model and forwards notifications
- * to the View.
+ * to the View. This also updates the caret position of the text component.
*
* TODO: Maybe this should somehow be handled through EditorKits
*/
@@ -236,6 +325,9 @@ public abstract class BasicTextUI extends TextUI
Dimension size = textComponent.getSize();
rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height),
BasicTextUI.this);
+ int caretPos = textComponent.getCaretPosition();
+ if (caretPos >= ev.getOffset())
+ textComponent.setCaretPosition(caretPos + ev.getLength());
}
/**
@@ -248,37 +340,79 @@ public abstract class BasicTextUI extends TextUI
Dimension size = textComponent.getSize();
rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height),
BasicTextUI.this);
+ int caretPos = textComponent.getCaretPosition();
+ if (caretPos >= ev.getOffset())
+ textComponent.setCaretPosition(ev.getOffset());
}
}
+ /**
+ * The EditorKit used by this TextUI.
+ */
+ // FIXME: should probably be non-static.
static EditorKit kit = new DefaultEditorKit();
+ /**
+ * The root view.
+ */
RootView rootView = new RootView();
+
+ /**
+ * The text component that we handle.
+ */
JTextComponent textComponent;
+
+ /**
+ * Receives notification when the model changes.
+ */
UpdateHandler updateHandler = new UpdateHandler();
/** The DocumentEvent handler. */
DocumentHandler documentHandler = new DocumentHandler();
+ /**
+ * Creates a new <code>BasicTextUI</code> instance.
+ */
public BasicTextUI()
{
}
+ /**
+ * Creates a {@link Caret} that should be installed into the text component.
+ *
+ * @return a caret that should be installed into the text component
+ */
protected Caret createCaret()
{
return new BasicCaret();
}
+ /**
+ * Creates a {@link Highlighter} that should be installed into the text
+ * component.
+ *
+ * @return a <code>Highlighter</code> for the text component
+ */
protected Highlighter createHighlighter()
{
return new BasicHighlighter();
}
-
+
+ /**
+ * The text component that is managed by this UI.
+ *
+ * @return the text component that is managed by this UI
+ */
protected final JTextComponent getComponent()
{
return textComponent;
}
-
+
+ /**
+ * Installs this UI on the text component.
+ *
+ * @param c the text component on which to install the UI
+ */
public void installUI(final JComponent c)
{
super.installUI(c);
@@ -301,6 +435,9 @@ public abstract class BasicTextUI extends TextUI
installKeyboardActions();
}
+ /**
+ * Installs UI defaults on the text components.
+ */
protected void installDefaults()
{
Caret caret = textComponent.getCaret();
@@ -325,6 +462,9 @@ public abstract class BasicTextUI extends TextUI
caret.setBlinkRate(defaults.getInt(prefix + ".caretBlinkRate"));
}
+ /**
+ * This FocusListener triggers repaints on focus shift.
+ */
private FocusListener focuslistener = new FocusListener() {
public void focusGained(FocusEvent e)
{
@@ -336,6 +476,9 @@ public abstract class BasicTextUI extends TextUI
}
};
+ /**
+ * Install all listeners on the text component.
+ */
protected void installListeners()
{
textComponent.addFocusListener(focuslistener);
@@ -352,23 +495,49 @@ public abstract class BasicTextUI extends TextUI
doc.addDocumentListener(documentHandler);
}
+ /**
+ * Returns the name of the keymap for this type of TextUI.
+ *
+ * This is implemented so that the classname of this TextUI
+ * without the package prefix is returned. This way subclasses
+ * don't have to override this method.
+ *
+ * @return the name of the keymap for this TextUI
+ */
protected String getKeymapName()
{
- return "BasicTextUI";
+ String fullClassName = getClass().getName();
+ int index = fullClassName.lastIndexOf('.');
+ String className = fullClassName.substring(index + 1);
+ return className;
}
+ /**
+ * Creates the {@link Keymap} that is installed on the text component.
+ *
+ * @return the {@link Keymap} that is installed on the text component
+ */
protected Keymap createKeymap()
{
String prefix = getPropertyPrefix();
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
JTextComponent.KeyBinding[] bindings =
(JTextComponent.KeyBinding[]) defaults.get(prefix + ".keyBindings");
+ if (bindings == null)
+ {
+ bindings = new JTextComponent.KeyBinding[0];
+ defaults.put(prefix + ".keyBindings", bindings);
+ }
+
Keymap km = JTextComponent.addKeymap(getKeymapName(),
JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP));
JTextComponent.loadKeymap(km, bindings, textComponent.getActions());
return km;
}
+ /**
+ * Installs the keyboard actions on the text components.
+ */
protected void installKeyboardActions()
{
// load any bindings for the older Keymap interface
@@ -384,6 +553,13 @@ public abstract class BasicTextUI extends TextUI
SwingUtilities.replaceUIActionMap(textComponent, getActionMap());
}
+ /**
+ * Gets the input map for the specified <code>condition</code>.
+ *
+ * @param condition the condition for the InputMap
+ *
+ * @return the InputMap for the specified condition
+ */
InputMap getInputMap(int condition)
{
String prefix = getPropertyPrefix();
@@ -401,6 +577,13 @@ public abstract class BasicTextUI extends TextUI
}
}
+ /**
+ * Returns the ActionMap to be installed on the text component.
+ *
+ * @return the ActionMap to be installed on the text component
+ */
+ // FIXME: The UIDefaults have no entries for .actionMap, so this should
+ // be handled somehow different.
ActionMap getActionMap()
{
String prefix = getPropertyPrefix();
@@ -414,6 +597,11 @@ public abstract class BasicTextUI extends TextUI
return am;
}
+ /**
+ * Creates an ActionMap to be installed on the text component.
+ *
+ * @return an ActionMap to be installed on the text component
+ */
ActionMap createActionMap()
{
Action[] actions = textComponent.getActions();
@@ -426,7 +614,12 @@ public abstract class BasicTextUI extends TextUI
}
return am;
}
-
+
+ /**
+ * Uninstalls this TextUI from the text component.
+ *
+ * @param component the text component to uninstall the UI from
+ */
public void uninstallUI(final JComponent component)
{
super.uninstallUI(component);
@@ -441,23 +634,49 @@ public abstract class BasicTextUI extends TextUI
textComponent = null;
}
+ /**
+ * Uninstalls all default properties that have previously been installed by
+ * this UI.
+ */
protected void uninstallDefaults()
{
// Do nothing here.
}
+ /**
+ * Uninstalls all listeners that have previously been installed by
+ * this UI.
+ */
protected void uninstallListeners()
{
textComponent.removeFocusListener(focuslistener);
}
+ /**
+ * Uninstalls all keyboard actions that have previously been installed by
+ * this UI.
+ */
protected void uninstallKeyboardActions()
{
- // Do nothing here.
+ // FIXME: Uninstall keyboard actions here.
}
-
+
+ /**
+ * Returns the property prefix by which the text component's UIDefaults
+ * are looked up.
+ *
+ * @return the property prefix by which the text component's UIDefaults
+ * are looked up
+ */
protected abstract String getPropertyPrefix();
+ /**
+ * Returns the preferred size of the text component.
+ *
+ * @param c not used here
+ *
+ * @return the preferred size of the text component
+ */
public Dimension getPreferredSize(JComponent c)
{
View v = getRootView(textComponent);
@@ -473,6 +692,8 @@ public abstract class BasicTextUI extends TextUI
*
* This returns (Integer.MAX_VALUE, Integer.MAX_VALUE).
*
+ * @param c not used here
+ *
* @return the maximum size for text components that use this UI
*/
public Dimension getMaximumSize(JComponent c)
@@ -481,11 +702,22 @@ public abstract class BasicTextUI extends TextUI
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
}
+ /**
+ * Paints the text component.
+ *
+ * @param g the <code>Graphics</code> context to paint to
+ * @param c not used here
+ */
public final void paint(Graphics g, JComponent c)
{
paintSafely(g);
}
+ /**
+ * Actually performs the painting.
+ *
+ * @param g the <code>Graphics</code> context to paint to
+ */
protected void paintSafely(Graphics g)
{
Caret caret = textComponent.getCaret();
@@ -504,74 +736,213 @@ public abstract class BasicTextUI extends TextUI
caret.paint(g);
}
+ /**
+ * Paints the background of the text component.
+ *
+ * @param g the <code>Graphics</code> context to paint to
+ */
protected void paintBackground(Graphics g)
{
g.setColor(textComponent.getBackground());
g.fillRect(0, 0, textComponent.getWidth(), textComponent.getHeight());
}
+ /**
+ * Marks the specified range inside the text component's model as
+ * damaged and queues a repaint request.
+ *
+ * @param t the text component
+ * @param p0 the start location inside the document model of the range that
+ * is damaged
+ * @param p1 the end location inside the document model of the range that
+ * is damaged
+ */
public void damageRange(JTextComponent t, int p0, int p1)
{
damageRange(t, p0, p1, null, null);
}
+ /**
+ * Marks the specified range inside the text component's model as
+ * damaged and queues a repaint request. This variant of this method
+ * allows a {@link Position.Bias} object to be specified for the start
+ * and end location of the range.
+ *
+ * @param t the text component
+ * @param p0 the start location inside the document model of the range that
+ * is damaged
+ * @param p1 the end location inside the document model of the range that
+ * is damaged
+ * @param firstBias the bias for the start location
+ * @param secondBias the bias for the end location
+ */
public void damageRange(JTextComponent t, int p0, int p1,
Position.Bias firstBias, Position.Bias secondBias)
{
+ // TODO: Implement me.
}
+ /**
+ * Returns the {@link EditorKit} used for the text component that is managed
+ * by this UI.
+ *
+ * @param t the text component
+ *
+ * @return the {@link EditorKit} used for the text component that is managed
+ * by this UI
+ */
public EditorKit getEditorKit(JTextComponent t)
{
return kit;
}
+ /**
+ * Gets the next position inside the document model that is visible on
+ * screen, starting from <code>pos</code>.
+ *
+ * @param t the text component
+ * @param pos the start positionn
+ * @param b the bias for pos
+ * @param direction the search direction
+ * @param biasRet filled by the method to indicate the bias of the return
+ * value
+ *
+ * @return the next position inside the document model that is visible on
+ * screen
+ */
public int getNextVisualPositionFrom(JTextComponent t, int pos,
Position.Bias b, int direction,
Position.Bias[] biasRet)
throws BadLocationException
{
- return 0;
+ return 0; // TODO: Implement me.
}
+ /**
+ * Returns the root {@link View} of a text component.
+ *
+ * @return the root {@link View} of a text component
+ */
public View getRootView(JTextComponent t)
{
return rootView;
}
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero. A bias of {@link Position.Bias.Forward} is used in this method.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
public Rectangle modelToView(JTextComponent t, int pos)
throws BadLocationException
{
return modelToView(t, pos, Position.Bias.Forward);
}
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias)
throws BadLocationException
{
return rootView.modelToView(pos, getVisibleEditorRect(), bias).getBounds();
}
+ /**
+ * Maps a point in the <code>View</code> coordinate space to a position
+ * inside a document model.
+ *
+ * @param t the text component
+ * @param pt the point to be mapped
+ *
+ * @return the position inside the document model that corresponds to
+ * <code>pt</code>
+ */
public int viewToModel(JTextComponent t, Point pt)
{
return viewToModel(t, pt, null);
}
+ /**
+ * Maps a point in the <code>View</code> coordinate space to a position
+ * inside a document model.
+ *
+ * @param t the text component
+ * @param pt the point to be mapped
+ * @param biasReturn filled in by the method to indicate the bias of the
+ * return value
+ *
+ * @return the position inside the document model that corresponds to
+ * <code>pt</code>
+ */
public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
{
- return 0;
+ return 0; // FIXME: Implement me.
}
+ /**
+ * Creates a {@link View} for the specified {@link Element}.
+ *
+ * @param elem the <code>Element</code> to create a <code>View</code> for
+ *
+ * @see ViewFactory
+ */
public View create(Element elem)
{
// Subclasses have to implement this to get this functionality.
return null;
}
+ /**
+ * Creates a {@link View} for the specified {@link Element}.
+ *
+ * @param elem the <code>Element</code> to create a <code>View</code> for
+ * @param p0 the start offset
+ * @param p1 the end offset
+ *
+ * @see ViewFactory
+ */
public View create(Element elem, int p0, int p1)
{
// Subclasses have to implement this to get this functionality.
return null;
}
-
+
+ /**
+ * Returns the allocation to give the root view.
+ *
+ * @return the allocation to give the root view
+ *
+ * @specnote The allocation has nothing to do with visibility. According
+ * to the specs the naming of this method is unfortunate and
+ * has historical reasons
+ */
protected Rectangle getVisibleEditorRect()
{
int width = textComponent.getWidth();
@@ -586,12 +957,20 @@ public abstract class BasicTextUI extends TextUI
height - insets.top + insets.bottom);
}
+ /**
+ * Sets the root view for the text component.
+ *
+ * @param view the <code>View</code> to be set as root view
+ */
protected final void setView(View view)
{
rootView.setView(view);
- view.setParent(rootView);
}
+ /**
+ * Indicates that the model of a text component has changed. This
+ * triggers a rebuild of the view hierarchy.
+ */
protected void modelChanged()
{
if (textComponent == null || rootView == null)
diff --git a/javax/swing/plaf/basic/BasicToggleButtonUI.java b/javax/swing/plaf/basic/BasicToggleButtonUI.java
index 677e6a575..84509ad6e 100644
--- a/javax/swing/plaf/basic/BasicToggleButtonUI.java
+++ b/javax/swing/plaf/basic/BasicToggleButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java b/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
index 72554c0f4..db29fdca5 100644
--- a/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
+++ b/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/BasicToolBarUI.java b/javax/swing/plaf/basic/BasicToolBarUI.java
index 18477c9dd..8be89efcf 100644
--- a/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -542,19 +542,6 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
}
/**
- * This method returns the preferred size of the given JComponent for this
- * UI.
- *
- * @param c The JComponent to find a preferred size for.
- *
- * @return The preferred size for this UI.
- */
- public Dimension getPreferredSize(JComponent c)
- {
- return toolBar.getLayout().preferredLayoutSize(c);
- }
-
- /**
* This method installs the needed components for the JToolBar.
*/
protected void installComponents()
diff --git a/javax/swing/plaf/basic/BasicToolTipUI.java b/javax/swing/plaf/basic/BasicToolTipUI.java
index b561cce71..b7a08aa72 100644
--- a/javax/swing/plaf/basic/BasicToolTipUI.java
+++ b/javax/swing/plaf/basic/BasicToolTipUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -97,7 +97,7 @@ public class BasicToolTipUI extends ToolTipUI
* @param x The x coordinate to start painting at.
* @param y The y coordinate to start painting at.
* @param w The width of the Component.
- * @param y The height of the Component.
+ * @param h The height of the Component.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int w,
int h)
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
index db74f067e..067cb0c3b 100644
--- a/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -1,5 +1,5 @@
/* BasicTreeUI.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -41,358 +41,2843 @@ package javax.swing.plaf.basic;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.Graphics;
+import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Hashtable;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.CellRendererPane;
+import javax.swing.Icon;
import javax.swing.JComponent;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.MouseInputListener;
+import javax.swing.event.TreeExpansionEvent;
+import javax.swing.event.TreeExpansionListener;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.TreeUI;
+import javax.swing.tree.AbstractLayoutCache;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellEditor;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.FixedHeightLayoutCache;
+import javax.swing.tree.TreeCellEditor;
+import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
/**
- * A delegate providing the user interface for <code>JTree</code>
- * according to the Basic look and feel. The current implementation
- * of GNU Classpath does really work; it is just a stub that allows
- * compiling the code.
- *
+ * A delegate providing the user interface for <code>JTree</code> according to
+ * the Basic look and feel.
+ *
* @see javax.swing.JTree
- *
* @author Sascha Brawer (brawer@dandelis.ch)
+ * @author Lillian Angel (langel@redhat.com)
*/
-public class BasicTreeUI
- extends TreeUI
+public class BasicTreeUI extends TreeUI
{
-
+ /** Collapse Icon for the tree. */
+ protected transient Icon collapsedIcon;
+
+ /** Expanded Icon for the tree. */
+ protected transient Icon expandedIcon;
+
+ /** Distance between left margin and where vertical dashes will be drawn. */
+ protected int leftChildIndent;
+
+ /**
+ * Distance between leftChildIndent and where cell contents will be drawn.
+ */
+ protected int rightChildIndent;
+
+ /**
+ * Total fistance that will be indented. The sum of leftChildIndent and
+ * rightChildIndent .
+ */
+ protected int totalChildIndent;
+
+ /** Minimum preferred size. */
+ protected Dimension preferredMinsize;
+
+ /** Index of the row that was last selected. */
+ protected int lastSelectedRow;
+
+ /** Component that we're going to be drawing onto. */
+ protected JTree tree;
+
+ /** Renderer that is being used to do the actual cell drawing. */
+ protected transient TreeCellRenderer currentCellRenderer;
+
+ /**
+ * Set to true if the renderer that is currently in the tree was created by
+ * this instance.
+ */
+ protected boolean createdRenderer;
+
+ /** Editor for the tree. */
+ protected transient TreeCellEditor cellEditor;
+
+ /**
+ * Set to true if editor that is currently in the tree was created by this
+ * instance.
+ */
+ protected boolean createdCellEditor;
+
+ /**
+ * Set to false when editing and shouldSelectCall() returns true meaning the
+ * node should be selected before editing, used in completeEditing.
+ */
+ protected boolean stopEditingInCompleteEditing;
+
+ /** Used to paint the TreeCellRenderer. */
+ protected CellRendererPane rendererPane;
+
+ /** Size needed to completely display all the nodes. */
+ protected Dimension preferredSize;
+
+ /** Is the preferredSize valid? */
+ protected boolean validCachedPreferredSize;
+
+ /** Object responsible for handling sizing and expanded issues. */
+ protected AbstractLayoutCache treeState;
+
+ /** Used for minimizing the drawing of vertical lines. */
+ protected Hashtable drawingCache;
+
+ /**
+ * True if doing optimizations for a largeModel. Subclasses that don't
+ * support this may wish to override createLayoutCache to not return a
+ * FixedHeightLayoutCache instance.
+ */
+ protected boolean largeModel;
+
+ /** Responsible for telling the TreeState the size needed for a node. */
+ protected AbstractLayoutCache.NodeDimensions nodeDimensions;
+
+ /** Used to determine what to display. */
+ protected TreeModel treeModel;
+
+ /** Model maintaining the selection. */
+ protected TreeSelectionModel treeSelectionModel;
+
+ /**
+ * How much the depth should be offset to properly calculate x locations.
+ * This is based on whether or not the root is visible, and if the root
+ * handles are visible.
+ */
+ protected int depthOffset;
+
+ /**
+ * When editing, this will be the Component that is doing the actual editing.
+ */
+ protected Component editingComponent;
+
+ /** Path that is being edited. */
+ protected TreePath editingPath;
+
+ /**
+ * Row that is being edited. Should only be referenced if editingComponent is
+ * null.
+ */
+ protected int editingRow;
+
+ /** Set to true if the editor has a different size than the renderer. */
+ protected boolean editorHasDifferentSize;
+
+ /** Listeners */
+ private PropertyChangeListener propertyChangeListener;
+ private FocusListener focusListener;
+ private TreeSelectionListener treeSelectionListener;
+ private MouseInputListener mouseInputListener;
+ private KeyListener keyListener;
+ private PropertyChangeListener selectionModelPropertyChangeListener;
+ private ComponentListener componentListener;
+ private CellEditorListener cellEditorListener;
+ private TreeExpansionListener treeExpansionListener;
+ private TreeModelListener treeModelListener;
+
+ /**
+ * Creates a new BasicTreeUI object.
+ */
+ public BasicTreeUI()
+ {
+ drawingCache = new Hashtable();
+ cellEditor = createDefaultCellEditor();
+ currentCellRenderer = createDefaultCellRenderer();
+ nodeDimensions = createNodeDimensions();
+ rendererPane = createCellRendererPane();
+ configureLayoutCache();
+
+ propertyChangeListener = createPropertyChangeListener();
+ focusListener = createFocusListener();
+ treeSelectionListener = createTreeSelectionListener();
+ mouseInputListener = new MouseInputHandler(null, null, null);
+ keyListener = createKeyListener();
+ selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();
+ componentListener = createComponentListener();
+ cellEditorListener = createCellEditorListener();
+ treeExpansionListener = createTreeExpansionListener();
+ treeModelListener = createTreeModelListener();
+
+ createdRenderer = true;
+ createdCellEditor = true;
+ editingRow = -1;
+ lastSelectedRow = -1;
+ }
+
+ /**
+ * Returns an instance of the UI delegate for the specified component.
+ *
+ * @param c the <code>JComponent</code> for which we need a UI delegate
+ * for.
+ * @return the <code>ComponentUI</code> for c.
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicTreeUI();
+ }
+
+ /**
+ * Returns the Hash color.
+ *
+ * @return the <code>Color</code> of the Hash.
+ */
+ protected Color getHashColor()
+ {
+ return UIManager.getLookAndFeelDefaults().getColor("Tree.hash");
+ }
+
+ /**
+ * Sets the Hash color.
+ *
+ * @param color the <code>Color</code> to set the Hash to.
+ */
+ protected void setHashColor(Color color)
+ {
+ // FIXME: not implemented
+
+ }
+
+ /**
+ * Sets the left child's indent value.
+ *
+ * @param newAmount is the new indent value for the left child.
+ */
+ public void setLeftChildIndent(int newAmount)
+ {
+ leftChildIndent = newAmount;
+ }
+
+ /**
+ * Returns the indent value for the left child.
+ *
+ * @return the indent value for the left child.
+ */
+ public int getLeftChildIndent(int newAmount)
+ {
+ return leftChildIndent;
+ }
+
+ /**
+ * Sets the right child's indent value.
+ *
+ * @param newAmount is the new indent value for the right child.
+ */
+ public void setRightChildIndent(int newAmount)
+ {
+ rightChildIndent = newAmount;
+ }
+
+ /**
+ * Returns the indent value for the right child.
+ *
+ * @return the indent value for the right child.
+ */
+ public int getRightChildIndent(int newAmount)
+ {
+ return rightChildIndent;
+ }
+
+ /**
+ * Sets the expanded icon.
+ *
+ * @param newG is the new expanded icon.
+ */
+ public void setExpandedIcon(Icon newG)
+ {
+ expandedIcon = newG;
+ }
+
+ /**
+ * Returns the current expanded icon.
+ *
+ * @return the current expanded icon.
+ */
+ public Icon getExpandedIcon()
+ {
+ return expandedIcon;
+ }
+
+ /**
+ * Sets the collapsed icon.
+ *
+ * @param newG is the new collapsed icon.
+ */
+ public void setCollapsedIcon(Icon newG)
+ {
+ collapsedIcon = newG;
+ }
+
+ /**
+ * Returns the current collapsed icon.
+ *
+ * @return the current collapsed icon.
+ */
+ public Icon getCollapsedIcon()
+ {
+ return collapsedIcon;
+ }
+
+ /**
+ * Updates the componentListener, if necessary.
+ *
+ * @param largeModel sets this.largeModel to it.
+ */
+ protected void setLargeModel(boolean largeModel)
+ {
+ if (largeModel != this.largeModel)
+ {
+ tree.removeComponentListener(componentListener);
+ this.largeModel = largeModel;
+ tree.addComponentListener(componentListener);
+ }
+ }
+
+ /**
+ * Returns true if largeModel is set
+ *
+ * @return true if largeModel is set, otherwise false.
+ */
+ protected boolean isLargeModel()
+ {
+ return largeModel;
+ }
+
+ /**
+ * Sets the row height.
+ *
+ * @param rowHeight is the height to set this.rowHeight to.
+ */
+ protected void setRowHeight(int rowHeight)
+ {
+ treeState.setRowHeight(rowHeight);
+ }
+
+ /**
+ * Returns the current row height.
+ *
+ * @return current row height.
+ */
+ protected int getRowHeight()
+ {
+ return treeState.getRowHeight();
+ }
+
+ /**
+ * Sets the TreeCellRenderer to <code>tcr</code>. This invokes
+ * <code>updateRenderer</code>.
+ *
+ * @param tcr is the new TreeCellRenderer.
+ */
+ protected void setCellRenderer(TreeCellRenderer tcr)
+ {
+ currentCellRenderer = tcr;
+ updateRenderer();
+ }
+
+ /**
+ * Return currentCellRenderer, which will either be the trees renderer, or
+ * defaultCellRenderer, which ever was not null.
+ *
+ * @return the current Cell Renderer
+ */
+ protected TreeCellRenderer getCellRenderer()
+ {
+ if (currentCellRenderer != null)
+ return currentCellRenderer;
+
+ return createDefaultCellRenderer();
+ }
+
+ /**
+ * Sets the tree's model.
+ *
+ * @param model to set the treeModel to.
+ */
+ protected void setModel(TreeModel model)
+ {
+ tree.setModel(model);
+ treeModel = model;
+ }
+
+ /**
+ * Returns the tree's model
+ *
+ * @return treeModel
+ */
+ protected TreeModel getModel()
+ {
+ return treeModel;
+ }
+
/**
- * Determines the geometric extent of the label that is
- * drawn for a path.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @param path the path whose label extent is requested.
- *
- * @return a rectangle enclosing the label, or <code>null</code>
- * if <code>path</code> contains invalid nodes.
+ * Sets the root to being visible.
+ *
+ * @param newValue sets the visibility of the root
+ */
+ protected void setRootVisible(boolean newValue)
+ {
+ tree.setRootVisible(newValue);
+ }
+
+ /**
+ * Returns true if the root is visible.
+ *
+ * @return true if the root is visible.
+ */
+ protected boolean isRootVisible()
+ {
+ return tree.isRootVisible();
+ }
+
+ /**
+ * Determines whether the node handles are to be displayed.
+ *
+ * @param newValue sets whether or not node handles should be displayed.
+ */
+ protected void setShowsRootHandles(boolean newValue)
+ {
+ tree.setShowsRootHandles(newValue);
+ }
+
+ /**
+ * Returns true if the node handles are to be displayed.
+ *
+ * @return true if the node handles are to be displayed.
+ */
+ protected boolean getShowsRootHandles()
+ {
+ return tree.getShowsRootHandles();
+ }
+
+ /**
+ * Sets the cell editor.
+ *
+ * @param editor to set the cellEditor to.
+ */
+ protected void setCellEditor(TreeCellEditor editor)
+ {
+ cellEditor = editor;
+ }
+
+ /**
+ * Returns the <code>TreeCellEditor</code> for this tree.
+ *
+ * @return the cellEditor for this tree.
+ */
+ protected TreeCellEditor getCellEditor()
+ {
+ return cellEditor;
+ }
+
+ /**
+ * Configures the receiver to allow, or not allow, editing.
+ *
+ * @param newValue sets the receiver to allow editing if true.
+ */
+ protected void setEditable(boolean newValue)
+ {
+ tree.setEditable(newValue);
+ }
+
+ /**
+ * Returns true if the receiver allows editing.
+ *
+ * @return true if the receiver allows editing.
+ */
+ protected boolean isEditable()
+ {
+ return tree.isEditable();
+ }
+
+ /**
+ * Resets the selection model. The appropriate listeners are installed on the
+ * model.
+ *
+ * @param newLSM resets the selection model.
+ */
+ protected void setSelectionModel(TreeSelectionModel newLSM)
+ {
+ if (newLSM != null)
+ {
+ treeSelectionModel = newLSM;
+ tree.setSelectionModel(treeSelectionModel);
+ }
+ }
+
+ /**
+ * Returns the current selection model.
+ *
+ * @return the current selection model.
+ */
+ protected TreeSelectionModel getSelectionModel()
+ {
+ return treeSelectionModel;
+ }
+
+ /**
+ * Returns the Rectangle enclosing the label portion that the last item in
+ * path will be drawn to. Will return null if any component in path is
+ * currently valid.
+ *
+ * @param tree is the current tree the path will be drawn to.
+ * @param path is the current path the tree to draw to.
+ * @return the Rectangle enclosing the label portion that the last item in
+ * the path will be drawn to.
*/
public Rectangle getPathBounds(JTree tree, TreePath path)
{
- return null; // FIXME: not implemented
+ if (path != null)
+ {
+ Object cell = path.getLastPathComponent();
+ TreeModel mod = tree.getModel();
+ DefaultMutableTreeNode root = (DefaultMutableTreeNode) mod.getRoot();
+ if (!tree.isRootVisible()
+ && tree.isExpanded(new TreePath(root)))
+ root = root.getNextNode();
+
+ Point loc = getCellLocation(0, 0, tree, mod, cell, root);
+ return getCellBounds(loc.x, loc.y, cell);
+ }
+ return null;
}
-
-
+
/**
- * Creates a <code>TreePath</code> for the specified row.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @param row the index of the row, which should be a number
- * in the range <code>[0, getRowCount(tree) - 1]</code>.
- *
- * @return a <code>TreePath</code> for the specified row, or
- * <code>null</code> if <code>row</code> is outside
- * the valid range.
+ * Returns the path for passed in row. If row is not visible null is
+ * returned.
+ *
+ * @param tree is the current tree to return path for.
+ * @param row is the row number of the row to return.
+ * @return the path for passed in row. If row is not visible null is
+ * returned.
*/
public TreePath getPathForRow(JTree tree, int row)
{
- return null; // FIXME: not implemented
+ DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel())
+ .getRoot());
+ if (!tree.isRootVisible()
+ && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node)
+ .getPath())))
+ node = node.getNextNode();
+
+ for (int i = 0; i < row; i++)
+ node = getNextVisibleNode(node);
+
+ // in case nothing was found
+ if (node == null)
+ return null;
+
+ // something was found
+ return new TreePath(node.getPath());
}
-
-
+
/**
- * Determines in which row a <code>TreePath</code> is currently
- * being displayed.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @param path the path for which the caller wants to know
- * in which row it is being displayed.
- *
- * @return a number in the range <code>[0, getRowCount(tree)
- * - 1]</code> if the path is currently on display;
- * <code>-1</code> if the path is not shown to the
- * user.
+ * Returns the row that the last item identified in path is visible at. Will
+ * return -1 if any of the elments in the path are not currently visible.
+ *
+ * @param tree is the current tree to return the row for.
+ * @param path is the path used to find the row.
+ * @return the row that the last item identified in path is visible at. Will
+ * return -1 if any of the elments in the path are not currently
+ * visible.
*/
public int getRowForPath(JTree tree, TreePath path)
{
- return -1; // FIXME: not implemented
+ // FIXME: check visibility
+ // right now, just returns last element because
+ // expand/collapse is not implemented
+ return path.getPathCount() - 1;
}
-
-
+
/**
- * Counts how many rows are currently displayed.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @return the number of visible rows.
+ * Returns the number of rows that are being displayed.
+ *
+ * @param tree is the current tree to return the number of rows for.
+ * @return the number of rows being displayed.
*/
public int getRowCount(JTree tree)
{
- return 0; // FIXME: not implemented
+ DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree.getModel())
+ .getRoot());
+ if (!tree.isRootVisible()
+ && tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node)
+ .getPath())))
+ node = node.getNextNode();
+
+ int count = 0;
+
+ while (node != null)
+ {
+ count++;
+ node = getNextVisibleNode(node);
+ }
+
+ return count;
}
-
-
+
/**
- * Finds the path that is closest to the specified position.
- *
- * <p><img src="../doc-files/TreeUI-1.png" width="300" height="250"
- * alt="[A screen shot of a JTree]" />
- *
- * <p>As shown by the above illustration, the bounds of the
- * closest path do not necessarily need to contain the passed
- * location.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @param x the horizontal location, relative to the origin
- * of <code>tree</code>.
- *
- * @param y the vertical location, relative to the origin
- * of <code>tree</code>.
- *
- * @return the closest path, or <code>null</code> if the
- * tree is currenlty not displaying any paths at all.
- */
- public TreePath getClosestPathForLocation(JTree tree,
- int x, int y)
- {
- return null; // FIXME: not implemented
+ * Returns the path to the node that is closest to x,y. If there is nothing
+ * currently visible this will return null, otherwise it'll always return a
+ * valid path. If you need to test if the returned object is exactly at x,y
+ * you should get the bounds for the returned path and test x,y against that.
+ *
+ * @param tree the tree to search for the closest path
+ * @param x is the x coordinate of the location to search
+ * @param y is the y coordinate of the location to search
+ * @return the tree path closes to x,y.
+ */
+ public TreePath getClosestPathForLocation(JTree tree, int x, int y)
+ {
+ //FIXME: what if root is hidden? should not depend on (0,0)
+ // should start counting rows from where root is.
+
+ int row = Math.round(y / getRowHeight());
+ TreePath path = getPathForRow(tree, row);
+
+ // no row is visible at this node
+ while (row > 0 && path == null)
+ {
+ --row;
+ path = getPathForRow(tree, row);
+ }
+
+ return path;
}
-
-
+
/**
- * Determines whether the user is currently editing a tree cell.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @see #getEditingPath
+ * Returns true if the tree is being edited. The item that is being edited
+ * can be returned by getEditingPath().
+ *
+ * @param tree is the tree to check for editing.
+ * @return true if the tree is being edited.
*/
public boolean isEditing(JTree tree)
{
- return false; // FIXME: not implemented
+ // FIXME: not implemented
+ return false;
}
-
-
+
/**
- * Stops editing a tree cell, committing the entered value into the
- * tree&#x2019;s model. If no editing session is active, or if the
- * active editor does not agree to stopping, nothing happens. In
- * some look and feels, this action happens when the user has
- * pressed the enter key.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @return <code>false</code> if the editing still goes on because
- * the cell editor has objected to stopping the session;
- * <code>true</code> if editing has been stopped.
+ * Stops the current editing session. This has no effect if the tree is not
+ * being edited. Returns true if the editor allows the editing session to
+ * stop.
+ *
+ * @param tree is the tree to stop the editing on
+ * @return true if the editor allows the editing session to stop.
*/
public boolean stopEditing(JTree tree)
{
- return true; // FIXME: not implemented
+ // FIXME: not implemented
+ return false;
}
-
+
/**
- * Cancels editing a tree cell, discarding any entered value.
- * If no editing session is active, nothing happens. The cell
- * editor is not given an opportunity to veto the canceling.
- * In some look and feels, this action happens when the user has
- * pressed the escape key.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
+ * Cancels the current editing session.
+ *
+ * @param tree is the tree to cancel the editing session on.
*/
public void cancelEditing(JTree tree)
{
// FIXME: not implemented
}
-
-
+
/**
- * Starts a session to edit a tree cell. If the cell editor
- * rejects editing the cell, it will just be selected.
- *
- * @param tree the <code>JTree</code> for which this delegate
- * object provides the user interface.
- *
- * @param path the cell to edit.
+ * Selects the last item in path and tries to edit it. Editing will fail if
+ * the CellEditor won't allow it for the selected item.
+ *
+ * @param tree is the tree to edit on.
+ * @param path is the path in tree to edit on.
*/
public void startEditingAtPath(JTree tree, TreePath path)
{
// FIXME: not implemented
}
-
-
+
/**
- * Retrieves the tree cell that is currently being edited.
- *
- * @return the currently edited path, or <code>null</code>
- * if no editing session is currently active.
+ * Returns the path to the element that is being editted.
+ *
+ * @param tree is the tree to get the editing path from.
+ * @return the path that is being edited.
*/
public TreePath getEditingPath(JTree tree)
{
- return null; // FIXME: not implemented
+ // FIXME: not implemented
+ return null;
}
-
- public static ComponentUI createUI(JComponent c)
+
+ /**
+ * Invoked after the tree instance variable has been set, but before any
+ * default/listeners have been installed.
+ */
+ protected void prepareForUIInstall()
{
- return new BasicTreeUI();
+ // FIXME: not implemented
}
-
- int rightChildIndent;
- int leftChildIndent;
- int rowHeight;
- Color hashColor;
-
- protected void installDefaults(JTree tree)
+
+ /**
+ * Invoked from installUI after all the defaults/listeners have been
+ * installed.
+ */
+ protected void completeUIInstall()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Invoked from uninstallUI after all the defaults/listeners have been
+ * uninstalled.
+ */
+ protected void completeUIUninstall()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Installs the subcomponents of the tree, which is the renderer pane.
+ */
+ protected void installComponents()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Creates an instance of NodeDimensions that is able to determine the size
+ * of a given node in the tree.
+ *
+ * @return the NodeDimensions of a given node in the tree
+ */
+ protected AbstractLayoutCache.NodeDimensions createNodeDimensions()
+ {
+ // FIXME: not implemented
+ return null;
+ }
+
+ /**
+ * Creates a listener that is reponsible for the updates the UI based on how
+ * the tree changes.
+ *
+ * @return the PropertyChangeListener that is reposnsible for the updates
+ */
+ protected PropertyChangeListener createPropertyChangeListener()
+ {
+ return new PropertyChangeHandler();
+ }
+
+ /**
+ * Creates the listener responsible for updating the selection based on mouse
+ * events.
+ *
+ * @return the MouseListener responsible for updating.
+ */
+ protected MouseListener createMouseListener()
+ {
+ return new MouseHandler();
+ }
+
+ /**
+ * Creates the listener that is responsible for updating the display when
+ * focus is lost/grained.
+ *
+ * @return the FocusListener responsible for updating.
+ */
+ protected FocusListener createFocusListener()
+ {
+ return new FocusHandler();
+ }
+
+ /**
+ * Creates the listener reponsible for getting key events from the tree.
+ *
+ * @return the KeyListener responsible for getting key events.
+ */
+ protected KeyListener createKeyListener()
+ {
+ return new KeyHandler();
+ }
+
+ /**
+ * Creates the listener responsible for getting property change events from
+ * the selection model.
+ *
+ * @returns the PropertyChangeListener reponsible for getting property change
+ * events from the selection model.
+ */
+ protected PropertyChangeListener createSelectionModelPropertyChangeListener()
+ {
+ return new SelectionModelPropertyChangeHandler();
+ }
+
+ /**
+ * Creates the listener that updates the display based on selection change
+ * methods.
+ *
+ * @return the TreeSelectionListener responsible for updating.
+ */
+ protected TreeSelectionListener createTreeSelectionListener()
+ {
+ return new TreeSelectionHandler();
+ }
+
+ /**
+ * Creates a listener to handle events from the current editor
+ *
+ * @return the CellEditorListener that handles events from the current editor
+ */
+ protected CellEditorListener createCellEditorListener()
+ {
+ return new CellEditorHandler();
+ }
+
+ /**
+ * Creates and returns a new ComponentHandler. This is used for the large
+ * model to mark the validCachedPreferredSize as invalid when the component
+ * moves.
+ *
+ * @return a new ComponentHandler.
+ */
+ protected ComponentListener createComponentListener()
+ {
+ return new ComponentHandler();
+ }
+
+ /**
+ * Creates and returns the object responsible for updating the treestate when
+ * a nodes expanded state changes.
+ *
+ * @return the TreeExpansionListener responsible for updating the treestate
+ */
+ protected TreeExpansionListener createTreeExpansionListener()
+ {
+ return new TreeExpansionHandler();
+ }
+
+ /**
+ * Creates the object responsible for managing what is expanded, as well as
+ * the size of nodes.
+ *
+ * @return the object responsible for managing what is expanded.
+ */
+ protected AbstractLayoutCache createLayoutCache()
+ {
+ return new FixedHeightLayoutCache();
+ }
+
+ /**
+ * Returns the renderer pane that renderer components are placed in.
+ *
+ * @return the rendererpane that render components are placed in.
+ */
+ protected CellRendererPane createCellRendererPane()
+ {
+ return new CellRendererPane();
+ }
+
+ /**
+ * Creates a default cell editor.
+ *
+ * @return the default cell editor.
+ */
+ protected TreeCellEditor createDefaultCellEditor()
+ {
+ return new DefaultTreeCellEditor(tree,
+ (DefaultTreeCellRenderer) createDefaultCellRenderer(), cellEditor);
+ }
+
+ /**
+ * Returns the default cell renderer that is used to do the stamping of each
+ * node.
+ *
+ * @return the default cell renderer that is used to do the stamping of each
+ * node.
+ */
+ protected TreeCellRenderer createDefaultCellRenderer()
+ {
+ return new DefaultTreeCellRenderer();
+ }
+
+ /**
+ * Returns a listener that can update the tree when the model changes.
+ *
+ * @return a listener that can update the tree when the model changes.
+ */
+ protected TreeModelListener createTreeModelListener()
+ {
+ return new TreeModelHandler();
+ }
+
+ /**
+ * Uninstall all registered listeners
+ */
+ protected void uninstallListeners()
+ {
+ tree.removePropertyChangeListener(propertyChangeListener);
+ tree.removeFocusListener(focusListener);
+ tree.removeTreeSelectionListener(treeSelectionListener);
+ tree.removeMouseListener(mouseInputListener);
+ tree.removeKeyListener(keyListener);
+ tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
+ tree.removeComponentListener(componentListener);
+ tree.removeTreeExpansionListener(treeExpansionListener);
+
+ TreeCellEditor tce = tree.getCellEditor();
+ if (tce != null)
+ tce.removeCellEditorListener(cellEditorListener);
+ TreeModel tm = tree.getModel();
+ if (tm != null)
+ tm.removeTreeModelListener(treeModelListener);
+ }
+
+ /**
+ * Uninstall all keyboard actions.
+ */
+ protected void uninstallKeyboardActions()
+ {
+ }
+
+ /**
+ * Uninstall the rendererPane.
+ */
+ protected void uninstallComponents()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * The vertical element of legs between nodes starts at the bottom of the
+ * parent node by default. This method makes the leg start below that.
+ *
+ * @return the vertical leg buffer
+ */
+ protected int getVerticalLegBuffer()
+ {
+ // FIXME: not implemented
+ return 0;
+ }
+
+ /**
+ * The horizontal element of legs between nodes starts at the right of the
+ * left-hand side of the child node by default. This method makes the leg end
+ * before that.
+ *
+ * @return the horizontal leg buffer
+ */
+ protected int getHorizontalLegBuffer()
+ {
+ // FIXME: not implemented
+ return 0;
+ }
+
+ /**
+ * Make all the nodes that are expanded in JTree expanded in LayoutCache.
+ * This invokes update ExpandedDescendants with the root path.
+ */
+ protected void updateLayoutCacheExpandedNodes()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Updates the expanded state of all the descendants of the <code>path</code>
+ * by getting the expanded descendants from the tree and forwarding to the
+ * tree state.
+ *
+ * @param path the path used to update the expanded states
+ */
+ protected void updateExpandedDescendants(TreePath path)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Returns a path to the last child of <code>parent</code>
+ *
+ * @param parent is the topmost path to specified
+ * @return a path to the last child of parent
+ */
+ protected TreePath getLastChildPath(TreePath parent)
+ {
+ return ((TreePath) parent.getLastPathComponent());
+ }
+
+ /**
+ * Updates how much each depth should be offset by.
+ */
+ protected void updateDepthOffset()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Updates the cellEditor based on editability of the JTree that we're
+ * contained in. Ig the tree is editable but doesn't have a cellEditor, a
+ * basic one will be used.
+ */
+ protected void updateCellEditor()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Messaged from the tree we're in when the renderer has changed.
+ */
+ protected void updateRenderer()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Resets the treeState instance based on the tree we're providing the look
+ * and feel for.
+ */
+ protected void configureLayoutCache()
+ {
+ treeState = createLayoutCache();
+ }
+
+ /**
+ * Marks the cached size as being invalid, and messages the tree with
+ * <code>treeDidChange</code>.
+ */
+ protected void updateSize()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Updates the <code>preferredSize</code> instance variable, which is
+ * returned from <code>getPreferredSize()</code>. For left to right
+ * orientations, the size is determined from the current AbstractLayoutCache.
+ * For RTL orientations, the preferred size becomes the width minus the
+ * minimum x position.
+ */
+ protected void updateCachedPreferredSize()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Messaged from the VisibleTreeNode after it has been expanded.
+ *
+ * @param path is the path that has been expanded.
+ */
+ protected void pathWasExpanded(TreePath path)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Messaged from the VisibleTreeNode after it has collapsed
+ */
+ protected void pathWasCollapsed(TreePath path)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Install all defaults for the tree.
+ *
+ * @param tree is the JTree to install defaults for
+ */
+ protected void installDefaults(JTree tree)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
+
tree.setFont(defaults.getFont("Tree.font"));
tree.setForeground(defaults.getColor("Tree.foreground"));
tree.setBackground(defaults.getColor("Tree.background"));
tree.setOpaque(true);
-
- hashColor = defaults.getColor("Tree.hash");
+
rightChildIndent = defaults.getInt("Tree.rightChildIndent");
leftChildIndent = defaults.getInt("Tree.leftChildIndent");
- rowHeight = defaults.getInt("Tree.rowHeight");
+ setRowHeight(defaults.getInt("Tree.rowHeight"));
}
-
- protected void installKeyboardActions()
+
+ /**
+ * Install all keyboard actions for this
+ */
+ protected void installKeyboardActions()
{
}
-
- protected void installListeners()
+
+ /**
+ * Install all listeners for this
+ */
+ protected void installListeners()
{
+ tree.addPropertyChangeListener(propertyChangeListener);
+ tree.addFocusListener(focusListener);
+ tree.addTreeSelectionListener(treeSelectionListener);
+ tree.addMouseListener(mouseInputListener);
+ tree.addKeyListener(keyListener);
+ tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
+ tree.addComponentListener(componentListener);
+ cellEditor.addCellEditorListener(cellEditorListener);
+ tree.addTreeExpansionListener(treeExpansionListener);
+ treeModel.addTreeModelListener(treeModelListener);
}
-
+
+ /**
+ * Install the UI for the component
+ *
+ * @param c the component to install UI for
+ */
public void installUI(JComponent c)
{
+ super.installUI(c);
installDefaults((JTree) c);
+ tree = (JTree) c;
+ setModel(tree.getModel());
+ tree.setRootVisible(true);
+ tree.expandPath(new TreePath(tree.getModel().getRoot()));
+ treeSelectionModel = tree.getSelectionModel();
+ installListeners();
+ installKeyboardActions();
+ completeUIInstall();
}
-
-
- protected void uninstallDefaults(JTree tree)
+
+ /**
+ * Uninstall the defaults for the tree
+ *
+ * @param tree to uninstall defaults for
+ */
+ protected void uninstallDefaults(JTree tree)
{
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
tree.setFont(null);
tree.setForeground(null);
tree.setBackground(null);
-
tree.setCellRenderer(null);
}
-
+
+ /**
+ * Uninstall the UI for the component
+ *
+ * @param c the component to uninstall UI for
+ */
public void uninstallUI(JComponent c)
{
uninstallDefaults((JTree) c);
+ uninstallKeyboardActions();
+ uninstallListeners();
+ tree = null;
+ completeUIUninstall();
}
-
+
+ /**
+ * Paints the specified component appropriate for the look and feel. This
+ * method is invoked from the ComponentUI.update method when the specified
+ * component is being painted. Subclasses should override this method and use
+ * the specified Graphics object to render the content of the component.
+ *
+ * @param g the Graphics context in which to paint
+ * @param c the component being painted; this argument is often ignored, but
+ * might be used if the UI object is stateless and shared by multiple
+ * components
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ JTree tree = (JTree) c;
+ TreeModel mod = tree.getModel();
+ Object root = mod.getRoot();
+
+ if (!tree.isRootVisible())
+ tree.expandPath(new TreePath(root));
+
+ paintRecursive(g, 0, 0, 0, 0, tree, mod, root);
+
+ if (hasControlIcons())
+ paintControlIcons(g, 0, 0, 0, 0, tree, mod, root);
+ }
+
+ /**
+ * Ensures that the rows identified by beginRow through endRow are visible.
+ *
+ * @param beginRow is the first row
+ * @param endRow is the last row
+ */
+ protected void ensureRowsAreVisible(int beginRow, int endRow)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Sets the preferred minimum size.
+ *
+ * @param newSize is the new preferred minimum size.
+ */
+ public void setPreferredMinSize(Dimension newSize)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Gets the preferred minimum size.
+ *
+ * @returns the preferred minimum size.
+ */
+ public Dimension getPreferredMinSize()
+ {
+ // FIXME: not implemented
+ return null;
+ }
+
+ /**
+ * Returns the preferred size to properly display the tree, this is a cover
+ * method for getPreferredSize(c, false).
+ *
+ * @param c the component whose preferred size is being queried; this
+ * argument is often ignored but might be used if the UI object is
+ * stateless and shared by multiple components
+ * @return the preferred size
+ */
public Dimension getPreferredSize(JComponent c)
{
- return new Dimension(200,200);
+ return getPreferredSize(c, false);
}
-
- protected void paintLeaf(Graphics g, int x, int y, JTree tree, Object leaf)
- {
- Component c = tree.getCellRenderer().getTreeCellRendererComponent(tree,
- leaf,
- false, // selected
- false, // expanded
- true, // leaf
- 0, // row
- false // hasFocus
- );
- g.translate(x, y);
- c.paint(g);
- g.translate(-x, -y);
+
+ /**
+ * Returns the preferred size to represent the tree in c. If checkConsistancy
+ * is true, checkConsistancy is messaged first.
+ *
+ * @param c the component whose preferred size is being queried.
+ * @param checkConsistancy if true must check consistancy
+ * @return the preferred size
+ */
+ public Dimension getPreferredSize(JComponent c, boolean checkConsistancy)
+ {
+ // FIXME: checkConsistancy not implemented, c not used
+ TreeNode node = ((TreeNode) (tree.getModel())
+ .getRoot());
+ int maxWidth = 0;
+ int count = 0;
+ if (node != null)
+ {
+ maxWidth = (int) (getCellBounds(0, 0, node).getWidth());
+ while (node != null)
+ {
+ count++;
+ DefaultMutableTreeNode nextNode = getNextVisibleNode(
+ new DefaultMutableTreeNode(node));
+ if (nextNode != null)
+ maxWidth = Math.max(maxWidth, (int) (getCellBounds(0, 0, nextNode)
+ .getWidth()));
+ node = nextNode;
+ }
+ }
+ return new Dimension(maxWidth, (getRowHeight() * count));
}
-
- protected void paintNonLeaf(Graphics g, int x, int y, JTree tree, Object nonLeaf)
- {
- Component c = tree.getCellRenderer().getTreeCellRendererComponent(tree,
- nonLeaf,
- false, // selected
- false, // expanded
- false, // leaf
- 0, // row
- false // hasFocus
- );
- g.translate(x, y);
- c.paint(g);
- g.translate(-x, -y);
+
+ /**
+ * Returns the minimum size for this component. Which will be the min
+ * preferred size or (0,0).
+ *
+ * @param c the component whose min size is being queried.
+ * @returns the preferred size or null
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ // FIXME: not implemented
+ return getPreferredSize(c);
}
-
- protected int paintRecursive(Graphics g,
- int indentation,
- int descent,
- int childNumber,
- int depth,
- JTree tree,
- TreeModel mod,
- Object curr)
+
+ /**
+ * Returns the maximum size for the component, which will be the preferred
+ * size if the instance is currently in JTree or (0,0).
+ *
+ * @param c the component whose preferred size is being queried
+ * @return the max size or null
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ // FIXME: not implemented
+ return getPreferredSize(c);
+ }
+
+ /**
+ * Messages to stop the editing session. If the UI the receiver is providing
+ * the look and feel for returns true from
+ * <code>getInvokesStopCellEditing</code>, stopCellEditing will be invoked
+ * on the current editor. Then completeEditing will be messaged with false,
+ * true, false to cancel any lingering editing.
+ */
+ protected void completeEditing()
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Stops the editing session. If messageStop is true, the editor is messaged
+ * with stopEditing, if messageCancel is true the editor is messaged with
+ * cancelEditing. If messageTree is true, the treeModel is messaged with
+ * valueForPathChanged.
+ *
+ * @param messageStop message to stop editing
+ * @param messageCancel message to cancel editing
+ * @param messageTree message to treeModel
+ */
+ protected void completeEditing(boolean messageStop, boolean messageCancel,
+ boolean messageTree)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Will start editing for node if there is a cellEditor and shouldSelectCall
+ * returns true. This assumes that path is valid and visible.
+ *
+ * @param path is the path to start editing
+ * @param event is the MouseEvent performed on the path
+ * @return true if successful
+ */
+ protected boolean startEditing(TreePath path, MouseEvent event)
+ {
+ // FIXME: not implemented
+ return false;
+ }
+
+ /**
+ * If the <code>mouseX</code> and <code>mouseY</code> are in the expand
+ * or collapse region of the row, this will toggle the row.
+ *
+ * @param path the path we are concerned with
+ * @param mouseX is the cursor's x position
+ * @param mouseY is the cursor's y position
+ */
+ protected void checkForClickInExpandControl(TreePath path, int mouseX,
+ int mouseY)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Returns true if the <code>mouseX</code> and <code>mouseY</code> fall
+ * in the area of row that is used to expand/collpse the node and the node at
+ * row does not represent a leaf.
+ *
+ * @param path the path we are concerned with
+ * @param mouseX is the cursor's x position
+ * @param mouseY is the cursor's y position
+ * @return true if the <code>mouseX</code> and <code>mouseY</code> fall
+ * in the area of row that is used to expand/collpse the node and the
+ * node at row does not represent a leaf.
+ */
+ protected boolean isLocationInExpandControl(TreePath path, int mouseX,
+ int mouseY)
+ {
+ // FIXME: not implemented
+ return false;
+ }
+
+ /**
+ * Messaged when the user clicks the particular row, this invokes
+ * toggleExpandState.
+ *
+ * @param path the path we are concerned with
+ * @param mouseX is the cursor's x position
+ * @param mouseY is the cursor's y position
+ */
+ protected void handleExpandControlClick(TreePath path, int mouseX, int mouseY)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Expands path if it is not expanded, or collapses row if it is expanded. If
+ * expanding a path and JTree scroll on expand, ensureRowsAreVisible is
+ * invoked to scroll as many of the children to visible as possible (tries to
+ * scroll to last visible descendant of path).
+ *
+ * @param path the path we are concerned with
+ */
+ protected void toggleExpandState(TreePath path)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Returning true signifies a mouse event on the node should toggle the
+ * selection of only the row under the mouse.
+ *
+ * @param event is the MouseEvent performed on the row.
+ * @return true signifies a mouse event on the node should toggle the
+ * selection of only the row under the mouse.
+ */
+ protected boolean isToggleSelectionEvent(MouseEvent event)
+ {
+ // FIXME: not implemented
+ return false;
+ }
+
+ /**
+ * Returning true signifies a mouse event on the node should select from the
+ * anchor point.
+ *
+ * @param event is the MouseEvent performed on the node.
+ * @return true signifies a mouse event on the node should select from the
+ * anchor point.
+ */
+ protected boolean isMultiSelectEvent(MouseEvent event)
+ {
+ // FIXME: not implemented
+ return false;
+ }
+
+ /**
+ * Returning true indicates the row under the mouse should be toggled based
+ * on the event. This is invoked after checkForClickInExpandControl, implying
+ * the location is not in the expand (toggle) control.
+ *
+ * @param event is the MouseEvent performed on the row.
+ * @return true indicates the row under the mouse should be toggled based on
+ * the event.
+ */
+ protected boolean isToggleEvent(MouseEvent event)
+ {
+ // FIXME: not implemented
+ return false;
+ }
+
+ /**
+ * Messaged to update the selection based on a MouseEvent over a particular
+ * row. If the even is a toggle selection event, the row is either selected,
+ * or deselected. If the event identifies a multi selection event, the
+ * selection is updated from the anchor point. Otherwise, the row is
+ * selected, and if the even specified a toggle event the row is
+ * expanded/collapsed.
+ *
+ * @param path is the path selected for an event
+ * @param event is the MouseEvent performed on the path.
+ */
+ protected void selectPathForEvent(TreePath path, MouseEvent event)
+ {
+ // FIXME: not implemented
+ }
+
+ /**
+ * Returns true if the node at <code>row</code> is a leaf.
+ *
+ * @param row is the row we are concerned with.
+ * @return true if the node at <code>row</code> is a leaf.
+ */
+ protected boolean isLeaf(int row)
+ {
+ TreePath pathForRow = getPathForRow(tree, row);
+ if (pathForRow == null)
+ return true;
+
+ Object node = pathForRow.getLastPathComponent();
+
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).isLeaf();
+ else
+ return true;
+ }
+
+ /**
+ * Updates the preferred size when scrolling, if necessary.
+ */
+ public class ComponentHandler
+ extends ComponentAdapter
+ implements ActionListener
+ {
+ /**
+ * Timer used when inside a scrollpane and the scrollbar is adjusting
+ */
+ protected Timer timer;
+
+ /** ScrollBar that is being adjusted */
+ protected JScrollBar scrollBar;
+
+ /**
+ * Constructor
+ */
+ public ComponentHandler()
+ {
+ }
+
+ /**
+ * Invoked when the component's position changes.
+ *
+ * @param e the event that occurs when moving the component
+ */
+ public void componentMoved(ComponentEvent e)
+ {
+ }
+
+ /**
+ * Creats, if necessary, and starts a Timer to check if needed to resize
+ * the bounds
+ */
+ protected void startTimer()
+ {
+ }
+
+ /**
+ * Returns the JScrollPane housing the JTree, or null if one isn't found.
+ *
+ * @return JScrollPane housing the JTree, or null if one isn't found.
+ */
+ protected JScrollPane getScrollPane()
+ {
+ return null;
+ }
+
+ /**
+ * Public as a result of Timer. If the scrollBar is null, or not
+ * adjusting, this stops the timer and updates the sizing.
+ *
+ * @param ae is the action performed
+ */
+ public void actionPerformed(ActionEvent ae)
+ {
+ }
+ }// ComponentHandler
+
+ /**
+ * Listener responsible for getting cell editing events and updating the tree
+ * accordingly.
+ */
+ public class CellEditorHandler
+ implements CellEditorListener
+ {
+ /**
+ * Constructor
+ */
+ public CellEditorHandler()
+ {
+ }
+
+ /**
+ * Messaged when editing has stopped in the tree. Tells the listeners
+ * editing has stopped.
+ *
+ * @param e is the notification event
+ */
+ public void editingStopped(ChangeEvent e)
+ {
+ }
+
+ /**
+ * Messaged when editing has been canceled in the tree. This tells the
+ * listeners the editor has canceled editing.
+ *
+ * @param e is the notification event
+ */
+ public void editingCanceled(ChangeEvent e)
+ {
+ }
+ }// CellEditorHandler
+
+ /**
+ * Repaints the lead selection row when focus is lost/grained.
+ */
+ public class FocusHandler
+ implements FocusListener
+ {
+ /**
+ * Constructor
+ */
+ public FocusHandler()
+ {
+ }
+
+ /**
+ * Invoked when focus is activated on the tree we're in, redraws the lead
+ * row. Invoked when a component gains the keyboard focus.
+ *
+ * @param e is the focus event that is activated
+ */
+ public void focusGained(FocusEvent e)
+ {
+ }
+
+ /**
+ * Invoked when focus is deactivated on the tree we're in, redraws the
+ * lead row. Invoked when a component loses the keyboard focus.
+ *
+ * @param e is the focus event that is deactivated
+ */
+ public void focusLost(FocusEvent e)
+ {
+ }
+ }// FocusHandler
+
+ /**
+ * This is used to get multiple key down events to appropriately genereate
+ * events.
+ */
+ public class KeyHandler
+ extends KeyAdapter
+ {
+ /** Key code that is being generated for. */
+ protected Action repeatKeyAction;
+
+ /** Set to true while keyPressed is active */
+ protected boolean isKeyDown;
+
+ /**
+ * Constructor
+ */
+ public KeyHandler()
+ {
+ }
+
+ /**
+ * Invoked when a key has been typed. Moves the keyboard focus to the
+ * first element whose first letter matches the alphanumeric key pressed
+ * by the user. Subsequent same key presses move the keyboard focus to the
+ * next object that starts with the same letter.
+ *
+ * @param e the key typed
+ */
+ public void keyTyped(KeyEvent e)
+ {
+ }
+
+ /**
+ * Invoked when a key has been pressed.
+ *
+ * @param e the key pressed
+ */
+ public void keyPressed(KeyEvent e)
+ {
+ TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath();
+ DefaultMutableTreeNode last = null;
+ if (start != null)
+ last = (DefaultMutableTreeNode) start.getLastPathComponent();
+
+ if (last != null)
+ {
+ // DOWN, KP_DOWN
+ if (e.getKeyCode() == KeyEvent.VK_DOWN
+ || e.getKeyCode() == KeyEvent.VK_KP_DOWN)
+ {
+ DefaultMutableTreeNode next = (DefaultMutableTreeNode)
+ BasicTreeUI.this.getNextVisibleNode(last);
+ if (next != null)
+ {
+ TreePath newPath = new TreePath(next.getPath());
+ BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath);
+ if (e.isControlDown())
+ tree.setLeadSelectionPath(newPath);
+ else if (!next.isLeaf() && e.isShiftDown())
+ {
+ BasicTreeUI.this.tree.expandPath(newPath);
+ BasicTreeUI.this.tree.fireTreeExpanded(newPath);
+ }
+ }
+ }
+ // UP, KP_UP
+ else if (e.getKeyCode() == KeyEvent.VK_UP
+ || e.getKeyCode() == KeyEvent.VK_KP_UP)
+ {
+ DefaultMutableTreeNode prev = (DefaultMutableTreeNode)
+ BasicTreeUI.this.getPreviousVisibleNode(last);
+
+ if (prev != null)
+ {
+ TreePath newPath = new TreePath(prev.getPath());
+ BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
+ new TreePath(prev.getPath()));
+ if (e.isControlDown())
+ tree.setLeadSelectionPath(newPath);
+ else if (!prev.isLeaf() && e.isShiftDown())
+ {
+ BasicTreeUI.this.tree.expandPath(newPath);
+ BasicTreeUI.this.tree.fireTreeExpanded(newPath);
+ }
+ }
+ }
+ // LEFT, KP_LEFT
+ else if (e.getKeyCode() == KeyEvent.VK_LEFT
+ || e.getKeyCode() == KeyEvent.VK_KP_LEFT)
+ {
+ TreePath path = new TreePath(last.getPath());
+ DefaultMutableTreeNode p = (DefaultMutableTreeNode) last
+ .getParent();
+
+ if (!last.isLeaf() && BasicTreeUI.this.tree.isExpanded(path))
+ {
+ BasicTreeUI.this.tree.collapsePath(path);
+ BasicTreeUI.this.tree.fireTreeCollapsed(path);
+ }
+ else if (p != null)
+ BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
+ new TreePath(p.getPath()));
+ }
+ // RIGHT, KP_RIGHT
+ else if (e.getKeyCode() == KeyEvent.VK_RIGHT
+ || e.getKeyCode() == KeyEvent.VK_KP_RIGHT)
+ {
+ TreePath path = new TreePath(last.getPath());
+
+ if (!last.isLeaf() && BasicTreeUI.this.tree.isCollapsed(path))
+ {
+ BasicTreeUI.this.tree.expandPath(path);
+ BasicTreeUI.this.tree.fireTreeExpanded(path);
+ }
+ else
+ {
+ DefaultMutableTreeNode next = (DefaultMutableTreeNode)
+ BasicTreeUI.this.getNextVisibleNode(last);
+
+ if (next != null)
+ BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
+ new TreePath(next.getPath()));
+ }
+ }
+ // Enter
+ else if (e.getKeyCode() == KeyEvent.VK_ENTER)
+ {
+ TreePath path = new TreePath(last.getPath());
+ if (!last.isLeaf())
+ {
+ if (BasicTreeUI.this.tree.isExpanded(path))
+ {
+ BasicTreeUI.this.tree.collapsePath(path);
+ BasicTreeUI.this.tree.fireTreeCollapsed(path);
+ }
+ else
+ {
+ BasicTreeUI.this.tree.expandPath(path);
+ BasicTreeUI.this.tree.fireTreeExpanded(path);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Invoked when a key has been released
+ *
+ * @param e the key released
+ */
+ public void keyReleased(KeyEvent e)
+ {
+ }
+ }// KeyHandler
+
+ /**
+ * MouseListener is responsible for updating the selevtion based on mouse
+ * events.
+ */
+ public class MouseHandler
+ extends MouseAdapter
+ implements MouseMotionListener
+ {
+ /**
+ * Constructor
+ */
+ public MouseHandler()
+ {
+ }
+
+ /**
+ * Invoked when a mouse button has been pressed on a component.
+ *
+ * @param e is the mouse event that occured
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when a mouse button is pressed on a component and then dragged.
+ * MOUSE_DRAGGED events will continue to be delivered to the component
+ * where the drag originated until the mouse button is released
+ * (regardless of whether the mouse position is within the bounds of the
+ * component).
+ *
+ * @param e is the mouse event that occured
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when the mouse button has been moved on a component (with no
+ * buttons no down).
+ *
+ * @param e the mouse event that occured
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when a mouse button has been released on a component.
+ *
+ * @param e is the mouse event that occured
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ }
+ }// MouseHandler
+
+ /**
+ * MouseInputHandler handles passing all mouse events, including mouse motion
+ * events, until the mouse is released to the destination it is constructed
+ * with.
+ */
+ public class MouseInputHandler
+ implements MouseInputListener
+ {
+ /** Source that events are coming from */
+ protected Component source;
+
+ /** Destination that receives all events. */
+ protected Component destination;
+
+ /** Number of mouse clicks on a non-leaf */
+ private int clickCount = 0;
+
+ /** The last non-leaf cell that was clicked */
+ private Object lastClicked = null;
+
+ /**
+ * Constructor
+ *
+ * @param source that events are coming from
+ * @param destination that receives all events
+ * @param e is the event received
+ */
+ public MouseInputHandler(Component source, Component destination,
+ MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when the mouse button has been clicked (pressed and released)
+ * on a component.
+ *
+ * @param e mouse event that occured
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ Point click = e.getPoint();
+ int row = Math.round(click.y / BasicTreeUI.this.getRowHeight());
+ TreePath path = BasicTreeUI.this.getClosestPathForLocation(tree,
+ click.x, click.y);
+
+ if (path != null)
+ {
+ boolean inBounds = false;
+ boolean cntlClick = false;
+ Rectangle bounds = BasicTreeUI.this.getPathBounds(
+ BasicTreeUI.this.tree, path);
+
+ bounds.x -= rightChildIndent - 4;
+ bounds.width += rightChildIndent + 4;
+
+ if (bounds.contains(click.x, click.y))
+ inBounds = true;
+ else if (BasicTreeUI.this.hasControlIcons()
+ && (click.x < (bounds.x - rightChildIndent + 5) &&
+ click.x > (bounds.x - rightChildIndent - 5)))
+ cntlClick = true;
+
+ if ((inBounds || cntlClick)
+ && BasicTreeUI.this.tree.isVisible(path))
+ {
+ if (!cntlClick && !BasicTreeUI.this.isLeaf(row))
+ {
+ Object cell = path.getLastPathComponent();
+ if (lastClicked != null && lastClicked.equals(cell))
+ clickCount = 2;
+ else
+ {
+ lastClicked = cell;
+ clickCount = 1;
+ }
+ }
+
+ if (clickCount == 2 || cntlClick == true)
+ {
+ clickCount = 0;
+ lastClicked = null;
+ BasicTreeUI.this.tree.getSelectionModel().clearSelection();
+ if (BasicTreeUI.this.tree.isExpanded(path))
+ {
+ BasicTreeUI.this.tree.collapsePath(path);
+ BasicTreeUI.this.tree.fireTreeCollapsed(path);
+ }
+ else
+ {
+ BasicTreeUI.this.tree.expandPath(path);
+ BasicTreeUI.this.tree.fireTreeExpanded(path);
+ }
+ }
+
+ BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, path);
+ }
+ }
+ }
+
+ /**
+ * Invoked when a mouse button has been pressed on a component.
+ *
+ * @param e mouse event that occured
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when a mouse button has been released on a component.
+ *
+ * @param e mouse event that occured
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when the mouse enters a component.
+ *
+ * @param e mouse event that occured
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when the mouse exits a component.
+ *
+ * @param e mouse event that occured
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when a mouse button is pressed on a component and then dragged.
+ * MOUSE_DRAGGED events will continue to be delivered to the component
+ * where the drag originated until the mouse button is released
+ * (regardless of whether the mouse position is within the bounds of the
+ * component).
+ *
+ * @param e mouse event that occured
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ }
+
+ /**
+ * Invoked when the mouse cursor has been moved onto a component but no
+ * buttons have been pushed.
+ *
+ * @param e mouse event that occured
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+
+ /**
+ * Removes event from the source
+ */
+ protected void removeFromSource()
+ {
+ }
+ }// MouseInputHandler
+
+ /**
+ * Class responsible for getting size of node, method is forwarded to
+ * BasicTreeUI method. X location does not include insets, that is handled in
+ * getPathBounds.
+ */
+ public class NodeDimensionsHandler
+ extends AbstractLayoutCache.NodeDimensions
+ {
+ /**
+ * Constructor
+ */
+ public NodeDimensionsHandler()
+ {
+ }
+
+ /**
+ * Responsible for getting the size of a particular node.
+ *
+ * @param value the value to be represented
+ * @param row row being queried
+ * @param depth the depth of the row
+ * @param expanded true if row is expanded
+ * @param size a Rectangle containing the size needed to represent value
+ * @return containing the node dimensions, or null if node has no
+ * dimension
+ */
+ public Rectangle getNodeDimensions(Object value, int row, int depth,
+ boolean expanded, Rectangle size)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the amount to indent the given row
+ *
+ * @return amount to indent the given row.
+ */
+ protected int getRowX(int row, int depth)
+ {
+ return 0;
+ }
+ }// NodeDimensionsHandler
+
+ /**
+ * PropertyChangeListener for the tree. Updates the appropriate varaible, or
+ * TreeState, based on what changes.
+ */
+ public class PropertyChangeHandler
+ implements PropertyChangeListener
+ {
+
+ /**
+ * Constructor
+ */
+ public PropertyChangeHandler()
+ {
+ }
+
+ /**
+ * This method gets called when a bound property is changed.
+ *
+ * @param event A PropertyChangeEvent object describing the event source
+ * and the property that has changed.
+ */
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ }
+ }// PropertyChangeHandler
+
+ /**
+ * Listener on the TreeSelectionModel, resets the row selection if any of the
+ * properties of the model change.
+ */
+ public class SelectionModelPropertyChangeHandler
+ implements PropertyChangeListener
+ {
+
+ /**
+ * Constructor
+ */
+ public SelectionModelPropertyChangeHandler()
+ {
+ }
+
+ /**
+ * This method gets called when a bound property is changed.
+ *
+ * @param event A PropertyChangeEvent object describing the event source
+ * and the property that has changed.
+ */
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ }
+ }// SelectionModelPropertyChangeHandler
+
+ /**
+ * ActionListener that invokes cancelEditing when action performed.
+ */
+ public class TreeCancelEditingAction
+ extends AbstractAction
+ {
+
+ /**
+ * Constructor
+ */
+ public TreeCancelEditingAction()
+ {
+ }
+
+ /**
+ * Invoked when an action occurs.
+ *
+ * @param e event that occured
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
+ * Returns true if the action is enabled.
+ *
+ * @return true if the action is enabled, false otherwise
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+ }// TreeCancelEditingAction
+
+ /**
+ * Updates the TreeState in response to nodes expanding/collapsing.
+ */
+ public class TreeExpansionHandler
+ implements TreeExpansionListener
+ {
+
+ /**
+ * Constructor
+ */
+ public TreeExpansionHandler()
+ {
+ }
+
+ /**
+ * Called whenever an item in the tree has been expanded.
+ *
+ * @param event is the event that occured
+ */
+ public void treeExpanded(TreeExpansionEvent event)
+ {
+ BasicTreeUI.this.tree.repaint();
+ }
+
+ /**
+ * Called whenever an item in the tree has been collapsed.
+ *
+ * @param event is the event that occured
+ */
+ public void treeCollapsed(TreeExpansionEvent event)
+ {
+ BasicTreeUI.this.tree.repaint();
+ }
+ }// TreeExpansionHandler
+
+ /**
+ * TreeHomeAction is used to handle end/home actions. Scrolls either the
+ * first or last cell to be visible based on direction.
+ */
+ public class TreeHomeAction
+ extends AbstractAction
+ {
+
+ /** direction is either home or end */
+ protected int direction;
+
+ /**
+ * Constructor
+ *
+ * @param direction - it is home or end
+ * @param name is the name of the direction
+ */
+ public TreeHomeAction(int direction, String name)
+ {
+ }
+
+ /**
+ * Invoked when an action occurs.
+ *
+ * @param e is the event that occured
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
+ * Returns true if the action is enabled.
+ *
+ * @return true if the action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+ }// TreeHomeAction
+
+ /**
+ * TreeIncrementAction is used to handle up/down actions. Selection is moved
+ * up or down based on direction.
+ */
+ public class TreeIncrementAction
+ extends AbstractAction
+ {
+
+ /** Specifies the direction to adjust the selection by. */
+ protected int direction;
+
+ /**
+ * Constructor
+ *
+ * @param direction up or down
+ * @param name is the name of the direction
+ */
+ public TreeIncrementAction(int direction, String name)
+ {
+ }
+
+ /**
+ * Invoked when an action occurs.
+ *
+ * @param e is the event that occured
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
+ * Returns true if the action is enabled.
+ *
+ * @return true if the action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+ }// TreeIncrementAction
+
+ /**
+ * Forwards all TreeModel events to the TreeState.
+ */
+ public class TreeModelHandler
+ implements TreeModelListener
+ {
+ /**
+ * Constructor
+ */
+ public TreeModelHandler()
+ {
+ }
+
+ /**
+ * Invoked after a node (or a set of siblings) has changed in some way.
+ * The node(s) have not changed locations in the tree or altered their
+ * children arrays, but other attributes have changed and may affect
+ * presentation. Example: the name of a file has changed, but it is in the
+ * same location in the file system. To indicate the root has changed,
+ * childIndices and children will be null. Use e.getPath() to get the
+ * parent of the changed node(s). e.getChildIndices() returns the
+ * index(es) of the changed node(s).
+ *
+ * @param e is the event that occured
+ */
+ public void treeNodesChanged(TreeModelEvent e)
+ {
+ }
+
+ /**
+ * Invoked after nodes have been inserted into the tree. Use e.getPath()
+ * to get the parent of the new node(s). e.getChildIndices() returns the
+ * index(es) of the new node(s) in ascending order.
+ *
+ * @param e is the event that occured
+ */
+ public void treeNodesInserted(TreeModelEvent e)
+ {
+ }
+
+ /**
+ * Invoked after nodes have been removed from the tree. Note that if a
+ * subtree is removed from the tree, this method may only be invoked once
+ * for the root of the removed subtree, not once for each individual set
+ * of siblings removed. Use e.getPath() to get the former parent of the
+ * deleted node(s). e.getChildIndices() returns, in ascending order, the
+ * index(es) the node(s) had before being deleted.
+ *
+ * @param e is the event that occured
+ */
+ public void treeNodesRemoved(TreeModelEvent e)
+ {
+ }
+
+ /**
+ * Invoked after the tree has drastically changed structure from a given
+ * node down. If the path returned by e.getPath() is of length one and the
+ * first element does not identify the current root node the first element
+ * should become the new root of the tree. Use e.getPath() to get the path
+ * to the node. e.getChildIndices() returns null.
+ *
+ * @param e is the event that occured
+ */
+ public void treeStructureChanged(TreeModelEvent e)
+ {
+ }
+ }// TreeModelHandler
+
+ /**
+ * TreePageAction handles page up and page down events.
+ */
+ public class TreePageAction
+ extends AbstractAction
+ {
+ /** Specifies the direction to adjust the selection by. */
+ protected int direction;
+
+ /**
+ * Constructor
+ *
+ * @param direction up or down
+ * @param name is the name of the direction
+ */
+ public TreePageAction(int direction, String name)
+ {
+ }
+
+ /**
+ * Invoked when an action occurs.
+ *
+ * @param e is the event that occured
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
+ * Returns true if the action is enabled.
+ *
+ * @return true if the action is enabled.
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+ }// TreePageAction
+
+ /**
+ * Listens for changes in the selection model and updates the display
+ * accordingly.
+ */
+ public class TreeSelectionHandler
+ implements TreeSelectionListener
+ {
+ /**
+ * Constructor
+ */
+ public TreeSelectionHandler()
+ {
+ }
+
+ /**
+ * Messaged when the selection changes in the tree we're displaying for.
+ * Stops editing, messages super and displays the changed paths.
+ *
+ * @param event the event that characterizes the change.
+ */
+ public void valueChanged(TreeSelectionEvent event)
+ {
+ }
+ }// TreeSelectionHandler
+
+ /**
+ * For the first selected row expandedness will be toggled.
+ */
+ public class TreeToggleAction
+ extends AbstractAction
+ {
+ /**
+ * Constructor
+ *
+ * @param name is the name of <code>Action</code> field
+ */
+ public TreeToggleAction(String name)
+ {
+ }
+
+ /**
+ * Invoked when an action occurs.
+ *
+ * @param e the event that occured
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
+ * Returns true if the action is enabled.
+ *
+ * @return true if the action is enabled, false otherwise
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+ } // TreeToggleAction
+
+ /**
+ * TreeTraverseAction is the action used for left/right keys. Will toggle
+ * the expandedness of a node, as well as potentially incrementing the
+ * selection.
+ */
+ public class TreeTraverseAction
+ extends AbstractAction
+ {
+ /**
+ * Determines direction to traverse, 1 means expand, -1 means collapse.
+ */
+ protected int direction;
+
+ /**
+ * Constructor
+ *
+ * @param direction to traverse
+ * @param name is the name of the direction
+ */
+ public TreeTraverseAction(int direction, String name)
+ {
+ }
+
+ /**
+ * Invoked when an action occurs.
+ *
+ * @param e the event that occured
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+
+ /**
+ * Returns true if the action is enabled.
+ *
+ * @return true if the action is enabled, false otherwise
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+ } // TreeTraverseAction
+
+ /**
+ * Returns the cell bounds for painting selected cells
+ * Package private for use in inner classes.
+ *
+ * @param x is the x location of the cell
+ * @param y is the y location of the cell
+ * @param cell is the Object to get the bounds for
+ *
+ * @returns Rectangle that represents the cell bounds
+ */
+ Rectangle getCellBounds(int x, int y, Object cell)
+ {
+ if (cell != null)
+ {
+ String s = cell.toString();
+ Font f = tree.getFont();
+ FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());
+
+ if (s != null)
+ return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s) + 4,
+ fm.getHeight());
+ }
+ return new Rectangle(x, y, 0, 0);
+ }
+
+ /**
+ * Retrieves the location of some node, recursively starting at from
+ * some node.
+ * Package private for use in inner classes.
+ *
+ * @param x is the starting x position, offset
+ * @param y is the starting y position, offset
+ * @param tree is the tree to traverse
+ * @param mod is the TreeModel to use
+ * @param node is the node to get the location for
+ * @param startNode is the node to start searching from
+ *
+ * @return Point - the location of node
+ */
+ Point getCellLocation(int x, int y, JTree tree, TreeModel mod,
+ Object node, Object startNode)
+ {
+ int rowHeight = getRowHeight();
+ if (startNode == null || startNode.equals(node))
+ {
+ if (!tree.isRootVisible() && tree.isExpanded(new TreePath(mod.getRoot())))
+ return new Point(x + ((((DefaultMutableTreeNode) node).getLevel())
+ * rightChildIndent), y);
+
+ return new Point(x + ((((DefaultMutableTreeNode) node).getLevel() + 1)
+ * rightChildIndent), y);
+ }
+
+ if (!mod.isLeaf(startNode)
+ && tree.isExpanded(new TreePath(
+ ((DefaultMutableTreeNode) startNode).getPath())))
+ {
+ Object child = mod.getChild(startNode, 0);
+ if (child != null)
+ return getCellLocation(x, y + rowHeight, tree, mod,
+ node, child);
+ }
+
+ return getCellLocation(x, y + rowHeight, tree, mod, node,
+ getNextVisibleNode((DefaultMutableTreeNode) startNode));
+ }
+
+ /**
+ * Paints a node in the tree Package private for use in inner classes.
+ *
+ * @param g the Graphics context in which to paint
+ * @param x the x location of the node
+ * @param y the y location of the node
+ * @param tree the tree to draw on
+ * @param node the object to draw
+ */
+ void paintNode(Graphics g, int x, int y, JTree tree, Object node,
+ boolean isLeaf)
+ {
+ TreePath curr = new TreePath(((DefaultMutableTreeNode) node).getPath());
+ boolean selected = tree.isPathSelected(curr);
+ boolean expanded = false;
+ boolean hasIcons = false;
+
+ if (tree.isVisible(curr))
+ {
+ DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer) tree
+ .getCellRenderer();
+
+ if (!isLeaf)
+ expanded = tree.isExpanded(curr);
+
+ Icon icon = null;
+ if (!isLeaf && expanded)
+ icon = dtcr.getOpenIcon();
+ else if (!isLeaf && !expanded)
+ icon = dtcr.getClosedIcon();
+ else
+ icon = dtcr.getLeafIcon();
+
+ if (icon.getIconHeight() > -1 && icon.getIconWidth() > -1)
+ hasIcons = true;
+
+ Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
+ expanded, isLeaf, 0, false);
+
+ if (hasIcons)
+ {
+ if (selected)
+ {
+ Rectangle cell = getPathBounds(tree, curr);
+ g.setColor(dtcr.getBackgroundSelectionColor());
+ g.fillRect(cell.x + icon.getIconWidth()/2, cell.y, cell.width,
+ cell.height);
+
+ if (curr.equals(tree.getLeadSelectionPath()))
+ {
+ g.setColor(UIManager.getLookAndFeelDefaults().getColor(
+ "Tree.selectionBorderColor"));
+ g.drawRect(cell.x + icon.getIconWidth()/2, cell.y,
+ cell.width, cell.height);
+ }
+ }
+
+ g.translate(x, y);
+ c.paint(g);
+ g.translate(-x, -y);
+ }
+ else
+ rendererPane.paintComponent(g, c, c.getParent(),
+ getCellBounds(x, y, node));
+ }
+ }
+
+ /**
+ * Recursively paints all elements of the tree Package private for use in
+ * inner classes.
+ *
+ * @param g the Graphics context in which to paint
+ * @param indentation of the current object
+ * @param descent is the number of elements drawn
+ * @param childNumber is the index of the current child in the tree
+ * @param depth is the depth of the current object in the tree
+ * @param tree is the tree to draw to
+ * @param mod is the TreeModel we are using to draw
+ * @param curr is the current object to draw
+ *
+ * @return int - current descent of the tree
+ */
+ int paintRecursive(Graphics g, int indentation, int descent,
+ int childNumber, int depth, JTree tree, TreeModel mod, Object curr)
{
Rectangle clip = g.getClipBounds();
- if (indentation > clip.x + clip.width + rightChildIndent ||
- descent > clip.y + clip.height + rowHeight)
+ if (indentation > clip.x + clip.width + rightChildIndent
+ || descent > clip.y + clip.height + getRowHeight())
return descent;
-
-
- int halfHeight = rowHeight / 2;
+
+ int halfHeight = getRowHeight() / 2;
int halfWidth = rightChildIndent / 2;
int y0 = descent + halfHeight;
-
+ int heightOfLine = descent + halfHeight;
+ boolean isRootVisible = tree.isRootVisible();
+
if (mod.isLeaf(curr))
{
- paintLeaf(g, indentation, descent, tree, curr);
- descent += rowHeight;
+ paintNode(g, indentation + 4, descent, tree, curr, true);
+ descent += getRowHeight();
}
else
{
- if (depth > 0 || tree.isRootVisible())
+ if (depth > 0 || isRootVisible)
{
- paintNonLeaf(g, indentation, descent, tree, curr);
- descent += rowHeight;
+ paintNode(g, indentation + 4, descent, tree, curr, false);
+ descent += getRowHeight();
y0 += halfHeight;
}
+
int max = mod.getChildCount(curr);
- for (int i = 0; i < max; ++i)
+ if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)
+ .getPath())))
{
- g.setColor(hashColor);
- g.drawLine(indentation + halfWidth, descent + halfHeight,
- indentation + rightChildIndent, descent + halfHeight);
- descent = paintRecursive(g,
- indentation + rightChildIndent, descent,
- i, depth+1,
- tree, mod, mod.getChild(curr, i));
+ for (int i = 0; i < max; ++i)
+ {
+ int indent = indentation + rightChildIndent;
+ if (!isRootVisible && depth == 0)
+ indent = 0;
+ else if ((!isRootVisible && !curr.equals(mod.getRoot())) ||
+ isRootVisible)
+ {
+ g.setColor(getHashColor());
+ heightOfLine = descent + halfHeight;
+ g.drawLine(indentation + halfWidth, heightOfLine, indentation
+ + rightChildIndent, heightOfLine);
+ }
+
+ descent = paintRecursive(g, indent,
+ descent, i, depth + 1, tree, mod, mod.getChild(curr, i));
+ }
}
}
-
- int y1 = descent - halfHeight;
- if (y0 != y1)
+
+ if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)
+ .getPath())))
+ if (y0 != heightOfLine)
+ {
+ g.setColor(getHashColor());
+ g.drawLine(indentation + halfWidth, y0, indentation + halfWidth,
+ heightOfLine);
+ }
+
+ return descent;
+ }
+
+ /**
+ * Recursively paints all the control icons on the tree.
+ * Package private for use in inner classes.
+ *
+ * @param g the Graphics context in which to paint
+ * @param indentation of the current object
+ * @param descent is the number of elements drawn
+ * @param childNumber is the index of the current child in the tree
+ * @param depth is the depth of the current object in the tree
+ * @param tree is the tree to draw to
+ * @param mod is the TreeModel we are using to draw
+ * @param curr is the current object to draw
+ *
+ * @return int - current descent of the tree
+ */
+ int paintControlIcons(Graphics g, int indentation, int descent,
+ int childNumber, int depth, JTree tree, TreeModel mod, Object node)
+ {
+ int h = descent;
+ int rowHeight = getRowHeight();
+ Icon ei = UIManager.getLookAndFeelDefaults()
+ .getIcon("Tree.expandedIcon");
+ Icon ci = UIManager.getLookAndFeelDefaults()
+ .getIcon("Tree.collapsedIcon");
+ Rectangle clip = g.getClipBounds();
+ if (indentation > clip.x + clip.width + rightChildIndent
+ || descent > clip.y + clip.height + getRowHeight())
+ return descent;
+
+ if (mod.isLeaf(node))
+ descent += rowHeight;
+ else
{
- g.setColor(hashColor);
- g.drawLine(indentation + halfWidth, y0,
- indentation + halfWidth, y1);
+ if (depth > 0 || tree.isRootVisible())
+ descent += rowHeight;
+
+ int max = mod.getChildCount(node);
+ if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) node)
+ .getPath())))
+ {
+ if (!node.equals(mod.getRoot()))
+ ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h);
+
+ for (int i = 0; i < max; ++i)
+ {
+ int indent = indentation + rightChildIndent;
+ if (depth == 0 && !tree.isRootVisible())
+ indent = -1;
+
+ descent = paintControlIcons(g, indent,
+ descent, i, depth + 1, tree, mod, mod.getChild(node, i));
+ }
+ }
+ else if (!node.equals(mod.getRoot()))
+ ci.paintIcon(tree, g, indentation - rightChildIndent - 3,
+ descent - getRowHeight());
}
-
+
return descent;
}
-
- public void paint(Graphics g, JComponent c)
+
+ /**
+ * Returns true if the LookAndFeel implements the control icons
+ * Package private for use in inner classes.
+ *
+ * @return true if control icons are visible
+ */
+ boolean hasControlIcons()
{
- JTree tree = (JTree) c;
- TreeModel mod = tree.getModel();
- g.translate(10, 10);
- paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());
- g.translate(-10, -10);
+ if (UIManager.getLookAndFeelDefaults().
+ getIcon("Tree.expandedIcon") == null ||
+ UIManager.getLookAndFeelDefaults().
+ getIcon("Tree.collapsedIcon") == null)
+ return false;
+ return true;
+ }
+
+ /**
+ * Get next visible node in the tree.
+ * Package private for use in inner classes.
+ *
+ * @param the current node
+ * @return the next visible node in the JTree. Return null if there are no
+ * more.
+ */
+ DefaultMutableTreeNode getNextVisibleNode(DefaultMutableTreeNode node)
+ {
+ DefaultMutableTreeNode next = null;
+ TreePath current = null;
+
+ if (node != null)
+ next = node.getNextNode();
+
+ if (next != null)
+ {
+ current = new TreePath(next.getPath());
+ if (tree.isVisible(current))
+ return next;
+
+ while (next != null && !tree.isVisible(current))
+ {
+ next = next.getNextNode();
+
+ if (next != null)
+ current = new TreePath(next.getPath());
+ }
+ }
+ return next;
+ }
+
+ /**
+ * Get previous visible node in the tree.
+ * Package private for use in inner classes.
+ *
+ * @param the current node
+ * @return the next visible node in the JTree. Return null if there are no
+ * more.
+ */
+ DefaultMutableTreeNode getPreviousVisibleNode
+ (DefaultMutableTreeNode node)
+ {
+ DefaultMutableTreeNode prev = null;
+ TreePath current = null;
+
+ if (node != null)
+ prev = node.getPreviousNode();
+
+ if (prev != null)
+ {
+ current = new TreePath(prev.getPath());
+ if (tree.isVisible(current))
+ return prev;
+
+ while (prev != null && !tree.isVisible(current))
+ {
+ prev = prev.getPreviousNode();
+
+ if (prev != null)
+ current = new TreePath(prev.getPath());
+ }
+ }
+ return prev;
+ }
+
+ /**
+ * Selects the specified path in the tree depending on modes.
+ * Package private for use in inner classes.
+ *
+ * @param tree is the tree we are selecting the path in
+ * @param path is the path we are selecting
+ */
+ void selectPath(JTree tree, TreePath path)
+ {
+ if (path != null)
+ {
+ if (tree.isPathSelected(path))
+ tree.removeSelectionPath(path);
+ else if (tree.getSelectionModel().getSelectionMode()
+ == TreeSelectionModel.SINGLE_TREE_SELECTION)
+ {
+ tree.getSelectionModel().clearSelection();
+ tree.addSelectionPath(path);
+ tree.setLeadSelectionPath(path);
+ }
+ else if (tree.getSelectionModel().getSelectionMode()
+ == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION)
+ {
+ // TODO
+ }
+ else
+ {
+ tree.getSelectionModel().setSelectionMode(
+ TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ tree.addSelectionPath(path);
+ tree.setLeadSelectionPath(path);
+ }
+ }
}
-}
+} // BasicTreeUI \ No newline at end of file
diff --git a/javax/swing/plaf/basic/BasicViewportUI.java b/javax/swing/plaf/basic/BasicViewportUI.java
index 07d4ba3ed..8ce772bed 100644
--- a/javax/swing/plaf/basic/BasicViewportUI.java
+++ b/javax/swing/plaf/basic/BasicViewportUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/ComboPopup.java b/javax/swing/plaf/basic/ComboPopup.java
index 4cd518df5..8bdcc51b0 100644
--- a/javax/swing/plaf/basic/ComboPopup.java
+++ b/javax/swing/plaf/basic/ComboPopup.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/DefaultMenuLayout.java b/javax/swing/plaf/basic/DefaultMenuLayout.java
index d6ad950f0..9760e82a6 100644
--- a/javax/swing/plaf/basic/DefaultMenuLayout.java
+++ b/javax/swing/plaf/basic/DefaultMenuLayout.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/basic/package.html b/javax/swing/plaf/basic/package.html
index f65518cac..700c8cdbc 100644
--- a/javax/swing/plaf/basic/package.html
+++ b/javax/swing/plaf/basic/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.plaf.basic package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,7 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.plaf.basic</title></head>
<body>
-<p></p>
+<p>Provides a "basic" look and feel implementation.</p>
</body>
</html>
diff --git a/javax/swing/plaf/metal/DefaultMetalTheme.java b/javax/swing/plaf/metal/DefaultMetalTheme.java
index 7c91eaadc..673aec1e4 100644
--- a/javax/swing/plaf/metal/DefaultMetalTheme.java
+++ b/javax/swing/plaf/metal/DefaultMetalTheme.java
@@ -1,5 +1,5 @@
/* DefaultMetalTheme.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -43,6 +43,11 @@ import java.awt.Font;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
+/**
+ * The default theme for the {@link MetalLookAndFeel}.
+ *
+ * @see MetalLookAndFeel#setCurrentTheme(MetalTheme)
+ */
public class DefaultMetalTheme extends MetalTheme
{
private static final ColorUIResource PRIMARY1 =
@@ -71,71 +76,144 @@ public class DefaultMetalTheme extends MetalTheme
private static final FontUIResource WINDOW_TITLE_FONT =
new FontUIResource("Dialog", Font.BOLD, 12);
+ /**
+ * Creates a new instance of this theme.
+ */
public DefaultMetalTheme()
{
// Do nothing here.
}
+ /**
+ * Returns the name of the theme.
+ *
+ * @return <code>"Steel"</code>.
+ */
public String getName()
{
return "Steel";
}
+ /**
+ * Returns the first primary color for this theme.
+ *
+ * @return The first primary color.
+ */
protected ColorUIResource getPrimary1()
{
return PRIMARY1;
}
+ /**
+ * Returns the second primary color for this theme.
+ *
+ * @return The second primary color.
+ */
protected ColorUIResource getPrimary2()
{
return PRIMARY2;
}
+ /**
+ * Returns the third primary color for this theme.
+ *
+ * @return The third primary color.
+ */
protected ColorUIResource getPrimary3()
{
return PRIMARY3;
}
+ /**
+ * Returns the first secondary color for this theme.
+ *
+ * @return The first secondary color.
+ */
protected ColorUIResource getSecondary1()
{
return SECONDARY1;
}
+ /**
+ * Returns the second secondary color for this theme.
+ *
+ * @return The second secondary color.
+ */
protected ColorUIResource getSecondary2()
{
return SECONDARY2;
}
+ /**
+ * Returns the third secondary color for this theme.
+ *
+ * @return The third secondary color.
+ */
protected ColorUIResource getSecondary3()
{
return SECONDARY3;
}
+ /**
+ * Returns the font used for text on controls. In this case, the font is
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ *
+ * @return The font.
+ */
public FontUIResource getControlTextFont()
{
return CONTROL_TEXT_FONT;
}
-
+ /**
+ * Returns the font used for text in menus. In this case, the font is
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ *
+ * @return The font used for text in menus.
+ */
public FontUIResource getMenuTextFont()
{
return MENU_TEXT_FONT;
}
+ /**
+ * Returns the font used for sub text. In this case, the font is
+ * <code>FontUIResource("Dialog", Font.PLAIN, 10)</code>.
+ *
+ * @return The font used for sub text.
+ */
public FontUIResource getSubTextFont()
{
return SUB_TEXT_FONT;
}
+ /**
+ * Returns the font used for system text. In this case, the font is
+ * <code>FontUIResource("Dialog", Font.PLAIN, 12)</code>.
+ *
+ * @return The font used for system text.
+ */
public FontUIResource getSystemTextFont()
{
return SYSTEM_TEXT_FONT;
}
+ /**
+ * Returns the font used for user text. In this case, the font is
+ * <code>FontUIResource("Dialog", Font.PLAIN, 12)</code>.
+ *
+ * @return The font used for user text.
+ */
public FontUIResource getUserTextFont()
{
return USER_TEXT_FONT;
}
+ /**
+ * Returns the font used for window titles. In this case, the font is
+ * <code>FontUIResource("Dialog", Font.BOLD, 12)</code>.
+ *
+ * @return The font used for window titles.
+ */
public FontUIResource getWindowTitleFont()
{
return WINDOW_TITLE_FONT;
diff --git a/javax/swing/plaf/metal/MetalBorders.java b/javax/swing/plaf/metal/MetalBorders.java
index d5b467fa2..851324242 100644
--- a/javax/swing/plaf/metal/MetalBorders.java
+++ b/javax/swing/plaf/metal/MetalBorders.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,6 +46,9 @@ import java.awt.Insets;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.JButton;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
@@ -78,7 +81,7 @@ public class MetalBorders
/**
* The border that is drawn around Swing buttons.
*/
- public static class MetalButtonBorder
+ public static class ButtonBorder
extends AbstractBorder
implements UIResource
{
@@ -88,7 +91,7 @@ public class MetalBorders
/**
* Creates a new instance of ButtonBorder.
*/
- public MetalButtonBorder()
+ public ButtonBorder()
{
}
@@ -184,6 +187,168 @@ public class MetalBorders
}
/**
+ * A border used for {@link JMenu} and {@link JMenuItem} components.
+ */
+ public static class MenuItemBorder
+ extends AbstractBorder
+ implements UIResource
+ {
+ /** The border insets. */
+ protected static Insets borderInsets = new Insets(2, 2, 2, 2);
+
+ // TODO: find where the real colors come from
+ private static Color borderColorDark = new Color(102, 102, 153);
+ private static Color borderColorLight = new Color(255, 255, 255);
+
+ /**
+ * Creates a new border instance.
+ */
+ public MenuItemBorder()
+ {
+ }
+
+ /**
+ * Paints the border for the component. A border is painted only if the
+ * component is a selected {@link JMenu} or an armed {@link JMenuItem}.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate of the border area.
+ * @param y the y-coordinate of the border area.
+ * @param w the width of the border area.
+ * @param h the height of the border area.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ if (c instanceof JMenu) {
+ JMenu menu = (JMenu) c;
+ if (menu.isSelected())
+ {
+ g.setColor(borderColorDark);
+ g.drawLine(x, y, x, y + h);
+ g.drawLine(x, y, x + w, y);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + h);
+ g.setColor(borderColorLight);
+ g.drawLine(x + w - 1, y + 1, x + w - 1, y + h);
+ }
+ }
+ else if (c instanceof JMenuItem)
+ {
+ JMenuItem item = (JMenuItem) c;
+ if (item.isArmed())
+ {
+ g.setColor(borderColorDark);
+ g.drawLine(x, y, x + w, y);
+ g.setColor(borderColorLight);
+ g.drawLine(x, y + h - 1, x + w, y + h - 1);
+ }
+ }
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return borderInsets;
+ }
+
+ /**
+ * Populates <code>insets</code> with the border insets, then returns it.
+ *
+ * @param c the component (ignored).
+ * @param insets the object to populate with the border insets.
+ *
+ * @return The border insets.
+ *
+ * @throws NullPointerException if <code>insets</code> is <code>null</code>.
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ insets.left = borderInsets.left;
+ insets.top = borderInsets.top;
+ insets.bottom = borderInsets.bottom;
+ insets.right = borderInsets.right;
+ return insets;
+ }
+ }
+
+ /**
+ * A border used for {@link JMenuBar} components.
+ */
+ public static class MenuBarBorder
+ extends AbstractBorder
+ implements UIResource
+ {
+ /** The border insets. */
+ protected static Insets borderInsets = new Insets(1, 0, 1, 0);
+
+ // TODO: find where this color really comes from
+ private static Color borderColor = new Color(153, 153, 153);
+
+ /**
+ * Creates a new border instance.
+ */
+ public MenuBarBorder()
+ {
+ }
+
+ /**
+ * Paints the border for the component. A border is painted only if the
+ * component is a selected {@link JMenu} or an armed {@link JMenuItem}.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate of the border area.
+ * @param y the y-coordinate of the border area.
+ * @param w the width of the border area.
+ * @param h the height of the border area.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ g.setColor(borderColor);
+ g.drawLine(x, y + h - 1, x + w, y + h - 1);
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return borderInsets;
+ }
+
+ /**
+ * Populates <code>insets</code> with the border insets, then returns it.
+ *
+ * @param c the component (ignored).
+ * @param insets the object to populate with the border insets.
+ *
+ * @return The border insets.
+ *
+ * @throws NullPointerException if <code>insets</code> is <code>null</code>.
+ */
+ public Insets getBorderInsets(Component c, Insets insets)
+ {
+ insets.left = borderInsets.left;
+ insets.top = borderInsets.top;
+ insets.bottom = borderInsets.bottom;
+ insets.right = borderInsets.right;
+ return insets;
+ }
+ }
+
+ /**
* A border for JScrollPanes.
*/
public static class ScrollPaneBorder
@@ -404,7 +569,7 @@ public class MetalBorders
{
if (buttonBorder == null)
{
- Border outer = new MetalButtonBorder();
+ Border outer = new ButtonBorder();
Border inner = getMarginBorder();
buttonBorder = new BorderUIResource.CompoundBorderUIResource
(outer, inner);
@@ -421,7 +586,7 @@ public class MetalBorders
{
if (toolbarButtonBorder == null)
{
- Border outer = new MetalButtonBorder();
+ Border outer = new ButtonBorder();
Border inner = new RolloverMarginBorder();
toolbarButtonBorder = new BorderUIResource.CompoundBorderUIResource
(outer, inner);
diff --git a/javax/swing/plaf/metal/MetalButtonUI.java b/javax/swing/plaf/metal/MetalButtonUI.java
index 7b9130e0e..0dac5ec39 100644
--- a/javax/swing/plaf/metal/MetalButtonUI.java
+++ b/javax/swing/plaf/metal/MetalButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JToolBar;
@@ -56,18 +58,60 @@ public class MetalButtonUI
extends BasicButtonUI
{
- // FIXME: probably substitute with a Map in the future in the case
- // that this UI becomes stateful
-
/** The cached MetalButtonUI instance. */
private static MetalButtonUI instance = null;
+ /** The color for the focus border. */
+ protected Color focusColor;
+
+ /** The color that indicates a selected button. */
+ protected Color selectColor;
+
+ /** The color for disabled button labels. */
+ protected Color disabledTextColor;
+
/**
* Creates a new instance of MetalButtonUI.
*/
public MetalButtonUI()
{
super();
+ focusColor = getFocusColor();
+ selectColor = getSelectColor();
+ disabledTextColor = getDisabledTextColor();
+ }
+
+ /**
+ * Returns the color for the focus border.
+ *
+ * @return the color for the focus border
+ */
+ protected Color getFocusColor()
+ {
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ return def.getColor(getPropertyPrefix() + ".focus");
+ }
+
+ /**
+ * Returns the color that indicates a selected button.
+ *
+ * @return the color that indicates a selected button
+ */
+ protected Color getSelectColor()
+ {
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ return def.getColor(getPropertyPrefix() + ".select");
+ }
+
+ /**
+ * Returns the color for the text label of disabled buttons.
+ *
+ * @return the color for the text label of disabled buttons
+ */
+ protected Color getDisabledTextColor()
+ {
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ return def.getColor(getPropertyPrefix() + ".disabledText");
}
/**
diff --git a/javax/swing/plaf/metal/MetalCheckBoxIcon.java b/javax/swing/plaf/metal/MetalCheckBoxIcon.java
new file mode 100644
index 000000000..3f3c9ce58
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalCheckBoxIcon.java
@@ -0,0 +1,136 @@
+/* MetalCheckBoxIcon.java -- An icon for JCheckBoxes in the Metal L&F
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.plaf.UIResource;
+
+/**
+ * An {@link Icon} implementation for {@link JCheckBox}es in the
+ * Metal Look &amp; Feel.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class MetalCheckBoxIcon
+ implements Icon, UIResource, Serializable
+{
+
+ /** Used to paint the border of the icon. */
+ MetalBorders.ButtonBorder border;
+
+ /**
+ * Creates a new MetalCheckBoxIcon instance.
+ */
+ public MetalCheckBoxIcon()
+ {
+ border = new MetalBorders.ButtonBorder();
+ }
+
+ /**
+ * Draws the check in the CheckBox.
+ *
+ * @param c the component to draw on
+ * @param g the Graphics context to draw with
+ * @param x the X position
+ * @param y the Y position
+ */
+ protected void drawCheck(Component c, Graphics g, int x, int y)
+ {
+ g.setColor(Color.BLACK);
+ g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
+ g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
+ g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
+ g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
+ }
+
+ /**
+ * Returns the size (both X and Y) of the checkbox icon.
+ *
+ * @return the size of the checkbox icon
+ */
+ protected int getControlSize()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the width of the icon in pixels.
+ *
+ * @return the width of the icon in pixels
+ */
+ public int getIconWidth()
+ {
+ return getControlSize();
+ }
+
+ /**
+ * Returns the height of the icon in pixels.
+ *
+ * @return the height of the icon in pixels
+ */
+ public int getIconHeight()
+ {
+ return getControlSize();
+ }
+
+ /**
+ * Paints the icon. This first paints the border of the CheckBox and
+ * if the CheckBox is selected it calls {@link #drawCheck} to draw
+ * the check.
+ *
+ * @param c the Component to draw on (gets casted to JCheckBox)
+ * @param g the Graphics context to draw with
+ * @param x the X position
+ * @param y the Y position
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ border.paintBorder(c, g, x, y, getIconWidth(), getIconHeight());
+ JCheckBox cb = (JCheckBox) c;
+ if (cb.isSelected())
+ drawCheck(c, g, x, y);
+ }
+}
diff --git a/javax/swing/plaf/metal/MetalCheckBoxUI.java b/javax/swing/plaf/metal/MetalCheckBoxUI.java
index cc5ac73d7..d59e38c54 100644
--- a/javax/swing/plaf/metal/MetalCheckBoxUI.java
+++ b/javax/swing/plaf/metal/MetalCheckBoxUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalComboBoxIcon.java b/javax/swing/plaf/metal/MetalComboBoxIcon.java
new file mode 100644
index 000000000..ce4fa7d32
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalComboBoxIcon.java
@@ -0,0 +1,100 @@
+/* MetalComboBoxButton.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+
+/**
+ * An icon used by the {@link MetalComboBoxUI} class.
+ */
+public class MetalComboBoxIcon implements Icon, Serializable {
+
+ /**
+ * Creates a new icon.
+ */
+ public MetalComboBoxIcon()
+ {
+ // nothing required.
+ }
+
+ /**
+ * Returns the icon width, which for this icon is 10 pixels.
+ *
+ * @return <code>10</code>.
+ */
+ public int getIconWidth()
+ {
+ return 10;
+ }
+
+ /**
+ * Returns the icon height, which for this icon is 5 pixels.
+ *
+ * @return <code>5</code>.
+ */
+ public int getIconHeight()
+ {
+ return 5;
+ }
+
+ /**
+ * Paints the icon at the location (x, y).
+ *
+ * @param c the combo box (ignored here).
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // TODO: work out whether/how the icon changes with different component
+ // states (and also different metal themes)
+ Color savedColor = g.getColor();
+ g.setColor(Color.black);
+ for (int i = 0; i < 5; i++)
+ g.drawLine(x + i, y + i, x + 9 - i, y + i);
+ g.setColor(savedColor);
+ }
+
+}
diff --git a/javax/swing/plaf/metal/MetalComboBoxUI.java b/javax/swing/plaf/metal/MetalComboBoxUI.java
index 2e4ca5149..28c279d8e 100644
--- a/javax/swing/plaf/metal/MetalComboBoxUI.java
+++ b/javax/swing/plaf/metal/MetalComboBoxUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalDesktopIconUI.java b/javax/swing/plaf/metal/MetalDesktopIconUI.java
index 6ceedd0d6..00870545b 100644
--- a/javax/swing/plaf/metal/MetalDesktopIconUI.java
+++ b/javax/swing/plaf/metal/MetalDesktopIconUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalIconFactory.java b/javax/swing/plaf/metal/MetalIconFactory.java
new file mode 100644
index 000000000..2c21d2b02
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalIconFactory.java
@@ -0,0 +1,786 @@
+/* MetalIconFactory.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.io.Serializable;
+
+import javax.swing.Icon;
+import javax.swing.JRadioButton;
+import javax.swing.JSlider;
+import javax.swing.plaf.UIResource;
+
+/**
+ * Creates icons for the {@link MetalLookAndFeel}.
+ */
+public class MetalIconFactory implements Serializable
+{
+
+ /** A constant representing "dark". */
+ public static final boolean DARK = false;
+
+ /** A constant representing "light". */
+ public static final boolean LIGHT = true;
+
+ /**
+ * An icon representing a file (drawn as a piece of paper with the top-right
+ * corner turned down).
+ */
+ public static class FileIcon16 implements Icon, Serializable
+ {
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the location (x, y).
+ *
+ * @param c the component.
+ * @param g the graphics context.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // TODO: pick up appropriate UI colors
+ g.setColor(Color.black);
+ g.drawLine(x, y, x + 9, y);
+ g.drawLine(x, y + 1, x, y + 15);
+ g.drawLine(x, y + 15, x + 12, y + 15);
+ g.drawLine(x + 12, y + 15, x + 12, y + 6);
+ g.drawLine(x + 12, y + 6, x + 9, y);
+
+ g.drawLine(x + 7, y + 2, x + 11, y + 6);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+
+ g.setColor(new Color(204, 204, 255));
+ g.drawLine(x + 1, y + 1, x + 7, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + 14);
+ g.drawLine(x + 1, y + 14, x + 11, y + 14);
+ g.drawLine(x + 11, y + 14, x + 11, y + 7);
+ g.drawLine(x + 8, y + 2, x + 10, y + 4);
+ }
+
+ /**
+ * Returns the additional height (???).
+ *
+ * @return The additional height.
+ */
+ public int getAdditionalHeight()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return 0;
+ }
+
+ }
+
+ /**
+ * An icon representing a folder.
+ */
+ public static class FolderIcon16 implements Icon, Serializable
+ {
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth() {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the location (x, y).
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // TODO: pick up appropriate UI colors
+ g.setColor(Color.black);
+ g.drawLine(x, y + 3, x, y + 12);
+ g.drawLine(x, y + 12, x + 15, y + 12);
+ g.drawLine(x + 15, y + 12, x + 15, y + 2);
+ g.drawLine(x + 14, y + 3, x + 9, y + 3);
+ g.drawLine(x + 8, y + 2, x + 1, y + 2);
+ g.setColor(new Color(204, 204, 255));
+ g.fillRect(x + 2, y + 4, 7, 8);
+ g.fillRect(x + 9, y + 5, 6, 7);
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 9, y + 2, x + 14, y + 2);
+ g.setColor(new Color(50, 50, 120));
+ g.drawLine(x + 9, y + 1, x + 15, y + 1);
+ g.drawLine(x + 10, y, x + 15, y);
+ }
+
+ /**
+ * Returns the additional height (???).
+ *
+ * @return The additional height.
+ */
+ public int getAdditionalHeight()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return 0;
+ }
+
+ }
+
+ /**
+ * An {@link Icon} implementation for {@link JCheckBox}es in the
+ * Metal Look &amp; Feel.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+ static class RadioButtonIcon
+ implements Icon, UIResource, Serializable
+ {
+ /**
+ * Draws the check in the RadioButton.
+ *
+ * @param c the component to draw on
+ * @param g the Graphics context to draw with
+ */
+ protected void drawCheck(Component c, Graphics g)
+ {
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.fillRect(4, 3, 4, 6);
+ g.drawLine(3, 4, 3, 7);
+ g.drawLine(8, 4, 8, 7);
+ }
+
+ /**
+ * Returns the width of the icon in pixels.
+ *
+ * @return the width of the icon in pixels
+ */
+ public int getIconWidth()
+ {
+ return 13;
+ }
+
+ /**
+ * Returns the height of the icon in pixels.
+ *
+ * @return the height of the icon in pixels
+ */
+ public int getIconHeight()
+ {
+ return 13;
+ }
+
+ /**
+ * Paints the icon. This first paints the border of the RadioButton and
+ * if the CheckBox is selected it calls {@link #drawCheck} to draw
+ * the check.
+ *
+ * @param c the Component to draw on (gets casted to JCheckBox)
+ * @param g the Graphics context to draw with
+ * @param x the X position
+ * @param y the Y position
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color dark = MetalLookAndFeel.getControlDarkShadow();
+ Color light = MetalLookAndFeel.getWhite();
+ g.translate(x, y);
+
+ // The light 'circle'
+ g.setColor(light);
+ g.drawLine(4, 1, 10, 1);
+ g.drawLine(2, 2, 3, 2);
+ g.drawLine(8, 2, 11, 2);
+ g.drawLine(2, 3, 2, 3);
+ g.drawLine(11, 2, 11, 9);
+ g.drawLine(1, 4, 1, 7);
+ g.drawLine(12, 4, 12, 7);
+ g.drawLine(2, 8, 2, 11);
+ g.drawLine(11, 8, 11, 9);
+ g.drawLine(10, 10, 10, 10);
+ g.drawLine(2, 11, 9, 11);
+ g.drawLine(4, 12, 7, 12);
+
+ // The dark 'circle'
+ g.setColor(dark);
+ g.drawLine(4, 0, 7, 0);
+ g.drawLine(2, 1, 3, 1);
+ g.drawLine(8, 1, 9, 1);
+ g.drawLine(1, 2, 1, 3);
+ g.drawLine(10, 2, 10, 3);
+ g.drawLine(0, 4, 0, 7);
+ g.drawLine(11, 4, 11, 7);
+ g.drawLine(1, 8, 1, 9);
+ g.drawLine(10, 8, 10, 9);
+ g.drawLine(2, 10, 3, 10);
+ g.drawLine(8, 10, 9, 10);
+ g.drawLine(4, 11, 7, 11);
+
+ JRadioButton rb = (JRadioButton) c;
+ if (rb.isSelected())
+ drawCheck(c, g);
+
+ g.translate(-x, -y);
+ }
+ }
+
+ /**
+ * The icon used to display the thumb control on a horizontally oriented
+ * {@link JSlider} component.
+ */
+ private static class HorizontalSliderThumbIcon
+ implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public HorizontalSliderThumbIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 15;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon, taking into account whether or not the component has
+ * the focus.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ boolean focus = false;
+ if (c != null)
+ focus = c.hasFocus();
+ // TODO: pick up the colors from the look and feel
+
+ // draw the outline
+ g.setColor(Color.black);
+ g.drawLine(x + 1, y, x + 13, y);
+ g.drawLine(x + 14, y + 1, x + 14, y + 7);
+ g.drawLine(x + 14, y + 8, x + 7, y + 15);
+ g.drawLine(x + 6, y + 14, x, y + 8);
+ g.drawLine(x, y + 7, x, y + 1);
+
+ // fill the icon
+ g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium
+ g.fillRect(x + 2, y + 2, 12, 7);
+ g.drawLine(x + 2, y + 9, x + 12, y + 9);
+ g.drawLine(x + 3, y + 10, x + 11, y + 10);
+ g.drawLine(x + 4, y + 11, x + 10, y + 11);
+ g.drawLine(x + 5, y + 12, x + 9, y + 12);
+ g.drawLine(x + 6, y + 13, x + 8, y + 13);
+ g.drawLine(x + 7, y + 14, x + 7, y + 14);
+
+ // draw highlights
+ g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 10, y + 2, x + 10, y + 2);
+
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
+
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 10, y + 6, x + 10, y + 6);
+
+ // draw dots
+ g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
+
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 9, y + 5, x + 9, y + 5);
+
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 11, y + 7, x + 11, y + 7);
+
+ }
+ }
+
+ /**
+ * The icon used to display the thumb control on a horizontally oriented
+ * {@link JSlider} component.
+ */
+ private static class VerticalSliderThumbIcon implements Icon, Serializable
+ {
+ /**
+ * Creates a new instance.
+ */
+ public VerticalSliderThumbIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 15;
+ }
+
+ /**
+ * Paints the icon taking into account whether the slider control has the
+ * focus or not.
+ *
+ * @param c the slider (must be a non-<code>null</code> instance of
+ * {@link JSlider}.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ boolean focus = false;
+ if (c != null)
+ focus = c.hasFocus();
+ // TODO: pick up the colors from the look and feel
+
+ // draw the outline
+ g.setColor(Color.black);
+ g.drawLine(x + 1, y, x + 7, y);
+ g.drawLine(x + 8, y, x + 15, y + 7);
+ g.drawLine(x + 14, y + 8, x + 8, y + 14);
+ g.drawLine(x + 8, y + 14, x + 1, y + 14);
+ g.drawLine(x, y + 13, x, y + 1);
+
+ // fill the icon
+ g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium
+ g.fillRect(x + 2, y + 2, 7, 12);
+ g.drawLine(x + 9, y + 2, x + 9, y + 12);
+ g.drawLine(x + 10, y + 3, x + 10, y + 11);
+ g.drawLine(x + 11, y + 4, x + 11, y + 10);
+ g.drawLine(x + 12, y + 5, x + 12, y + 9);
+ g.drawLine(x + 13, y + 6, x + 13, y + 8);
+ g.drawLine(x + 14, y + 7, x + 14, y + 7);
+
+ // draw highlights
+ g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light
+ g.drawLine(x + 1, y + 1, x + 8, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 13);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 2, y + 10, x + 2, y + 10);
+
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 4, y + 8, x + 4, y + 8);
+
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 6, y + 10, x + 6, y + 10);
+
+ // draw dots
+ g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 3, y + 11, x + 3, y + 11);
+
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
+
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 7, y + 11, x + 7, y + 11);
+ }
+ }
+
+ /**
+ * A tree control icon. This icon can be in one of two states: expanded and
+ * collapsed.
+ */
+ public static class TreeControlIcon implements Icon, Serializable
+ {
+
+ /** ???. */
+ protected boolean isLight;
+
+ /** A flag that controls whether or not the icon is collapsed. */
+ private boolean collapsed;
+
+ /**
+ * Creates a new icon.
+ *
+ * @param isCollapsed a flag that controls whether the icon is in the
+ * collapsed state or the expanded state.
+ */
+ public TreeControlIcon(boolean isCollapsed)
+ {
+ collapsed = isCollapsed;
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 18;
+ }
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 18;
+ }
+
+ /**
+ * Paints the icon at the location (x, y).
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ x = x + 5;
+ y = y + 5;
+ if (collapsed)
+ {
+ // TODO: pick up appropriate UI colors
+ g.setColor(Color.black);
+ g.drawLine(x + 2, y, x + 5, y);
+ g.drawLine(x + 6, y + 1, x + 7, y + 2);
+ g.fillRect(x + 7, y + 3, 5, 2);
+ g.drawLine(x + 7, y + 5, x + 6, y + 6);
+ g.drawLine(x + 1, y + 1, x + 1, y + 1);
+ g.drawLine(x, y + 2, x, y + 5);
+ g.drawLine(x + 1, y + 6, x + 1, y + 6);
+ g.drawLine(x + 2, y + 7, x + 5, y + 7);
+ g.fillRect(x + 3, y + 3, 2, 2);
+
+ g.setColor(new Color(204, 204, 255));
+ g.drawLine(x + 3, y + 2, x + 4, y + 2);
+ g.drawLine(x + 2, y + 3, x + 2, y + 4);
+ g.drawLine(x + 3, y + 5, x + 3, y + 5);
+ g.drawLine(x + 5, y + 3, x + 5, y + 3);
+
+ g.setColor(new Color(153, 153, 204));
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 2, y + 5, x + 2, y + 5);
+ g.drawLine(x + 2, y + 6, x + 5, y + 6);
+ g.drawLine(x + 5, y + 2, x + 5, y + 2);
+ g.drawLine(x + 6, y + 2, x + 6, y + 5);
+
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 2, y + 1, x + 5, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 5);
+ }
+ else
+ {
+ // TODO: pick up appropriate UI colors
+ g.setColor(Color.black);
+ g.drawLine(x + 2, y, x + 5, y);
+ g.drawLine(x + 6, y + 1, x + 7, y + 2);
+ g.drawLine(x + 7, y + 2, x + 7, y + 5);
+ g.fillRect(x + 3, y + 7, 2, 5);
+ g.drawLine(x + 7, y + 5, x + 6, y + 6);
+ g.drawLine(x + 1, y + 1, x + 1, y + 1);
+ g.drawLine(x, y + 2, x, y + 5);
+ g.drawLine(x + 1, y + 6, x + 1, y + 6);
+ g.drawLine(x + 2, y + 7, x + 5, y + 7);
+ g.fillRect(x + 3, y + 3, 2, 2);
+
+ g.setColor(new Color(204, 204, 255));
+ g.drawLine(x + 3, y + 2, x + 4, y + 2);
+ g.drawLine(x + 2, y + 3, x + 2, y + 4);
+ g.drawLine(x + 3, y + 5, x + 3, y + 5);
+ g.drawLine(x + 5, y + 3, x + 5, y + 3);
+
+ g.setColor(new Color(153, 153, 204));
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 2, y + 5, x + 2, y + 5);
+ g.drawLine(x + 2, y + 6, x + 5, y + 6);
+ g.drawLine(x + 5, y + 2, x + 5, y + 2);
+ g.drawLine(x + 6, y + 2, x + 6, y + 5);
+
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 2, y + 1, x + 5, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 5);
+ }
+ }
+
+ /**
+ * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintMe(Component c, Graphics g, int x, int y)
+ {
+ paintIcon(c, g, x, y);
+ }
+ }
+
+ /**
+ * A tree folder icon.
+ */
+ public static class TreeFolderIcon extends FolderIcon16
+ {
+ /**
+ * Creates a new instance.
+ */
+ public TreeFolderIcon()
+ {
+ }
+
+ /**
+ * Returns the additional height (???).
+ *
+ * @return The additional height.
+ */
+ public int getAdditionalHeight()
+ {
+ return 2;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * A tree leaf icon.
+ */
+ public static class TreeLeafIcon extends FileIcon16
+ {
+ /**
+ * Creates a new instance.
+ */
+ public TreeLeafIcon()
+ {
+ }
+
+ /**
+ * Returns the additional height (???).
+ *
+ * @return The additional height.
+ */
+ public int getAdditionalHeight()
+ {
+ return 4;
+ }
+
+ /**
+ * Returns the shift (???).
+ *
+ * @return The shift.
+ */
+ public int getShift()
+ {
+ return 2;
+ }
+ }
+
+ /** The cached RadioButtonIcon instance. */
+ private static RadioButtonIcon radioButtonIcon;
+
+ /**
+ * Creates a new instance. All the methods are static, so creating an
+ * instance isn't necessary.
+ */
+ public MetalIconFactory()
+ {
+ }
+
+ /**
+ * Returns an icon for RadioButtons in the Metal L&amp;F.
+ *
+ * @return an icon for RadioButtons in the Metal L&amp;F
+ */
+ public static Icon getRadioButtonIcon()
+ {
+ if (radioButtonIcon == null)
+ radioButtonIcon = new RadioButtonIcon();
+ return radioButtonIcon;
+ }
+
+ /**
+ * Returns the icon used to display the thumb for a horizontally oriented
+ * {@link JSlider}.
+ *
+ * @return The icon.
+ */
+ public static Icon getHorizontalSliderThumbIcon()
+ {
+ return new HorizontalSliderThumbIcon();
+ }
+
+ /**
+ * Returns the icon used to display the thumb for a vertically oriented
+ * {@link JSlider}.
+ *
+ * @return The icon.
+ */
+ public static Icon getVerticalSliderThumbIcon()
+ {
+ return new VerticalSliderThumbIcon();
+ }
+
+ /**
+ * Creates and returns a new tree folder icon.
+ *
+ * @return A new tree folder icon.
+ */
+ public static Icon getTreeFolderIcon()
+ {
+ return new TreeFolderIcon();
+ }
+
+ /**
+ * Creates and returns a new tree leaf icon.
+ *
+ * @return A new tree leaf icon.
+ */
+ public static Icon getTreeLeafIcon()
+ {
+ return new TreeLeafIcon();
+ }
+
+ /**
+ * Creates and returns a tree control icon.
+ *
+ * @param isCollapsed a flag that controls whether the icon is in the
+ * collapsed or expanded state.
+ *
+ * @return A tree control icon.
+ */
+ public static Icon getTreeControlIcon(boolean isCollapsed)
+ {
+ return new TreeControlIcon(isCollapsed);
+ }
+
+}
diff --git a/javax/swing/plaf/metal/MetalInternalFrameUI.java b/javax/swing/plaf/metal/MetalInternalFrameUI.java
index f2f8e3600..14143512e 100644
--- a/javax/swing/plaf/metal/MetalInternalFrameUI.java
+++ b/javax/swing/plaf/metal/MetalInternalFrameUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalLabelUI.java b/javax/swing/plaf/metal/MetalLabelUI.java
index 12aa7b116..cdd861227 100644
--- a/javax/swing/plaf/metal/MetalLabelUI.java
+++ b/javax/swing/plaf/metal/MetalLabelUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java
index 77f683516..373fb0593 100644
--- a/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,49 +39,96 @@ exception statement from your version. */
package javax.swing.plaf.metal;
import java.awt.Color;
+import java.awt.Font;
import java.awt.Insets;
+import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
+import javax.swing.plaf.IconUIResource;
+import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
+/**
+ * A custom look and feel that is designed to look similar across different
+ * operating systems.
+ */
public class MetalLookAndFeel extends BasicLookAndFeel
{
private static final long serialVersionUID = 6680646159193457980L;
+
+ /** The current theme. */
private static MetalTheme theme;
+
+ /** The look and feel defaults. */
private UIDefaults LAF_defaults;
+ /**
+ * Creates a new instance of the Metal look and feel.
+ */
public MetalLookAndFeel()
{
createDefaultTheme();
}
+ /**
+ * Sets the current theme to a new instance of {@link DefaultMetalTheme}.
+ */
protected void createDefaultTheme()
{
setCurrentTheme(new DefaultMetalTheme());
}
+ /**
+ * Returns <code>false</code> to indicate that this look and feel does not
+ * attempt to emulate the look and feel of native applications on the host
+ * platform.
+ *
+ * @return <code>false</code>.
+ */
public boolean isNativeLookAndFeel()
{
- return true;
+ return false;
}
+ /**
+ * Returns <code>true</code> to indicate that this look and feel is supported
+ * on all platforms.
+ *
+ * @return <code>true</code>.
+ */
public boolean isSupportedLookAndFeel()
{
return true;
}
+ /**
+ * Returns a string describing the look and feel. In this case, the method
+ * returns "Metal look and feel".
+ *
+ * @return A string describing the look and feel.
+ */
public String getDescription()
{
return "Metal look and feel";
}
+ /**
+ * Returns the look and feel identifier.
+ *
+ * @return "MetalLookAndFeel".
+ */
public String getID()
{
return "MetalLookAndFeel";
}
+ /**
+ * Returns the look and feel name.
+ *
+ * @return "MetalLookAndFeel".
+ */
public String getName()
{
return "MetalLookAndFeel";
@@ -90,225 +137,474 @@ public class MetalLookAndFeel extends BasicLookAndFeel
public UIDefaults getDefaults()
{
if (LAF_defaults == null)
- LAF_defaults = super.getDefaults();
+ {
+ LAF_defaults = super.getDefaults();
- // add custom theme entries to the table
- theme.addCustomEntriesToTable(LAF_defaults);
+ // add custom theme entries to the table
+ theme.addCustomEntriesToTable(LAF_defaults);
+ }
// Returns the default values for this look and feel.
return LAF_defaults;
}
+ /**
+ * Returns the accelerator foreground color from the installed theme.
+ *
+ * @return The accelerator foreground color.
+ */
public static ColorUIResource getAcceleratorForeground()
{
return theme.getAcceleratorForeground();
}
+ /**
+ * Returns the accelerator selected foreground color from the installed
+ * theme.
+ *
+ * @return The accelerator selected foreground color.
+ */
public static ColorUIResource getAcceleratorSelectedForeground()
{
return theme.getAcceleratorSelectedForeground();
}
+ /**
+ * Returns the color black from the installed theme.
+ *
+ * @return The color black.
+ */
public static ColorUIResource getBlack()
{
return theme.getBlack();
}
+ /**
+ * Returns the control color from the installed theme.
+ *
+ * @return The control color.
+ */
public static ColorUIResource getControl()
{
return theme.getControl();
}
+ /**
+ * Returns the color used for dark shadows on controls, from the installed
+ * theme.
+ *
+ * @return The color used for dark shadows on controls.
+ */
public static ColorUIResource getControlDarkShadow()
{
return theme.getControlDarkShadow();
}
+ /**
+ * Returns the color used for disabled controls, from the installed theme.
+ *
+ * @return The color used for disabled controls.
+ */
public static ColorUIResource getControlDisabled()
{
return theme.getControlDisabled();
}
+ /**
+ * Returns the color used to draw highlights for controls, from the installed
+ * theme.
+ *
+ * @return The color used to draw highlights for controls.
+ */
public static ColorUIResource getControlHighlight()
{
return theme.getControlHighlight();
}
+ /**
+ * Returns the color used to display control info, from the installed
+ * theme.
+ *
+ * @return The color used to display control info.
+ */
public static ColorUIResource getControlInfo()
{
return theme.getControlInfo();
}
+ /**
+ * Returns the color used to draw shadows for controls, from the installed
+ * theme.
+ *
+ * @return The color used to draw shadows for controls.
+ */
public static ColorUIResource getControlShadow()
{
return theme.getControlShadow();
}
+ /**
+ * Returns the color used for text on controls, from the installed theme.
+ *
+ * @return The color used for text on controls.
+ */
public static ColorUIResource getControlTextColor()
{
return theme.getControlTextColor();
}
+ /**
+ * Returns the font used for text on controls, from the installed theme.
+ *
+ * @return The font used for text on controls.
+ */
public static FontUIResource getControlTextFont()
{
return theme.getControlTextFont();
}
+ /**
+ * Returns the color used for the desktop background, from the installed
+ * theme.
+ *
+ * @return The color used for the desktop background.
+ */
public static ColorUIResource getDesktopColor()
{
return theme.getDesktopColor();
}
+ /**
+ * Returns the color used to draw focus highlights, from the installed
+ * theme.
+ *
+ * @return The color used to draw focus highlights.
+ */
public static ColorUIResource getFocusColor()
{
return theme.getFocusColor();
}
+ /**
+ * Returns the color used to draw highlighted text, from the installed
+ * theme.
+ *
+ * @return The color used to draw highlighted text.
+ */
public static ColorUIResource getHighlightedTextColor()
{
return theme.getHighlightedTextColor();
}
+ /**
+ * Returns the color used to draw text on inactive controls, from the
+ * installed theme.
+ *
+ * @return The color used to draw text on inactive controls.
+ */
public static ColorUIResource getInactiveControlTextColor()
{
return theme.getInactiveControlTextColor();
}
+ /**
+ * Returns the color used to draw inactive system text, from the installed
+ * theme.
+ *
+ * @return The color used to draw inactive system text.
+ */
public static ColorUIResource getInactiveSystemTextColor()
{
return theme.getInactiveSystemTextColor();
}
+ /**
+ * Returns the background color for menu items, from the installed theme.
+ *
+ * @return The background color for menu items.
+ *
+ * @see #getMenuSelectedBackground()
+ */
public static ColorUIResource getMenuBackground()
{
return theme.getMenuBackground();
}
+ /**
+ * Returns the foreground color for disabled menu items, from the installed
+ * theme.
+ *
+ * @return The foreground color for disabled menu items.
+ *
+ * @see #getMenuForeground()
+ */
public static ColorUIResource getMenuDisabledForeground()
{
return theme.getMenuDisabledForeground();
}
+ /**
+ * Returns the foreground color for menu items, from the installed theme.
+ *
+ * @return The foreground color for menu items.
+ *
+ * @see #getMenuDisabledForeground()
+ * @see #getMenuSelectedForeground()
+ */
public static ColorUIResource getMenuForeground()
{
return theme.getMenuForeground();
}
+ /**
+ * Returns the background color for selected menu items, from the installed
+ * theme.
+ *
+ * @return The background color for selected menu items.
+ *
+ * @see #getMenuBackground()
+ */
public static ColorUIResource getMenuSelectedBackground()
{
return theme.getMenuSelectedBackground();
}
+ /**
+ * Returns the foreground color for selected menu items, from the installed
+ * theme.
+ *
+ * @return The foreground color for selected menu items.
+ *
+ * @see #getMenuForeground()
+ */
public static ColorUIResource getMenuSelectedForeground()
{
return theme.getMenuSelectedForeground();
}
+ /**
+ * Returns the font used for text in menus, from the installed theme.
+ *
+ * @return The font used for text in menus.
+ */
public static FontUIResource getMenuTextFont()
{
return theme.getMenuTextFont();
}
+ /**
+ * Returns the primary color for controls, from the installed theme.
+ *
+ * @return The primary color for controls.
+ */
public static ColorUIResource getPrimaryControl()
{
return theme.getPrimaryControl();
}
+ /**
+ * Returns the primary color for the dark shadow on controls, from the
+ * installed theme.
+ *
+ * @return The primary color for the dark shadow on controls.
+ */
public static ColorUIResource getPrimaryControlDarkShadow()
{
return theme.getPrimaryControlDarkShadow();
}
+ /**
+ * Returns the primary color for the highlight on controls, from the
+ * installed theme.
+ *
+ * @return The primary color for the highlight on controls.
+ */
public static ColorUIResource getPrimaryControlHighlight()
{
return theme.getPrimaryControlHighlight();
}
+ /**
+ * Returns the primary color for the information on controls, from the
+ * installed theme.
+ *
+ * @return The primary color for the information on controls.
+ */
public static ColorUIResource getPrimaryControlInfo()
{
return theme.getPrimaryControlInfo();
}
+ /**
+ * Returns the primary color for the shadow on controls, from the installed
+ * theme.
+ *
+ * @return The primary color for the shadow on controls.
+ */
public static ColorUIResource getPrimaryControlShadow()
{
return theme.getPrimaryControlShadow();
}
+ /**
+ * Returns the background color for separators, from the installed theme.
+ *
+ * @return The background color for separators.
+ */
public static ColorUIResource getSeparatorBackground()
{
return theme.getSeparatorBackground();
}
+ /**
+ * Returns the foreground color for separators, from the installed theme.
+ *
+ * @return The foreground color for separators.
+ */
public static ColorUIResource getSeparatorForeground()
{
return theme.getSeparatorForeground();
}
+ /**
+ * Returns the font used for sub text, from the installed theme.
+ *
+ * @return The font used for sub text.
+ */
public static FontUIResource getSubTextFont()
{
return theme.getSubTextFont();
}
+ /**
+ * Returns the color used for system text, from the installed theme.
+ *
+ * @return The color used for system text.
+ */
public static ColorUIResource getSystemTextColor()
{
return theme.getSystemTextColor();
}
+ /**
+ * Returns the font used for system text, from the installed theme.
+ *
+ * @return The font used for system text.
+ */
public static FontUIResource getSystemTextFont()
{
return theme.getSystemTextFont();
}
+ /**
+ * Returns the color used to highlight text, from the installed theme.
+ *
+ * @return The color used to highlight text.
+ */
public static ColorUIResource getTextHighlightColor()
{
return theme.getTextHighlightColor();
}
+ /**
+ * Returns the color used to display user text, from the installed theme.
+ *
+ * @return The color used to display user text.
+ */
public static ColorUIResource getUserTextColor()
{
return theme.getUserTextColor();
}
+ /**
+ * Returns the font used for user text, obtained from the current theme.
+ *
+ * @return The font used for user text.
+ */
public static FontUIResource getUserTextFont()
{
return theme.getUserTextFont();
}
+ /**
+ * Returns the color used for white, from the installed theme.
+ *
+ * @return The color used for white.
+ */
public static ColorUIResource getWhite()
{
return theme.getWhite();
}
+ /**
+ * Returns the window background color, from the installed theme.
+ *
+ * @return The window background color.
+ */
public static ColorUIResource getWindowBackground()
{
return theme.getWindowBackground();
}
+ /**
+ * Returns the window title background color, from the installed theme.
+ *
+ * @return The window title background color.
+ */
public static ColorUIResource getWindowTitleBackground()
{
return theme.getWindowTitleBackground();
}
+ /**
+ * Returns the window title font from the current theme.
+ *
+ * @return The window title font.
+ *
+ * @see MetalTheme
+ */
public static FontUIResource getWindowTitleFont()
{
return theme.getWindowTitleFont();
}
+ /**
+ * Returns the window title foreground color, from the installed theme.
+ *
+ * @return The window title foreground color.
+ */
public static ColorUIResource getWindowTitleForeground()
{
return theme.getWindowTitleForeground();
}
+ /**
+ * Returns the background color for an inactive window title, from the
+ * installed theme.
+ *
+ * @return The background color for an inactive window title.
+ */
public static ColorUIResource getWindowTitleInactiveBackground()
{
return theme.getWindowTitleInactiveBackground();
}
+ /**
+ * Returns the foreground color for an inactive window title, from the
+ * installed theme.
+ *
+ * @return The foreground color for an inactive window title.
+ */
public static ColorUIResource getWindowTitleInactiveForeground()
{
return theme.getWindowTitleInactiveForeground();
}
+ /**
+ * Sets the current theme for the look and feel.
+ *
+ * @param theme the theme.
+ */
public static void setCurrentTheme(MetalTheme theme)
{
MetalLookAndFeel.theme = theme;
@@ -417,7 +713,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
* </tr><tr>
* <td>Button.background</td><td>0xcccccc</td>
* </tr><tr>
- * <td>Button.border</td><td>{@link MetalBorders.ButtonBorder}</td>
+ * <td>Button.border</td><td>{@link MetalBorders#getButtonBorder()}</td>
* </tr><tr>
* <td>Button.font</td><td>{@link #getControlTextFont}</td>
* </tr><tr>
@@ -476,6 +772,9 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Button.select", new ColorUIResource(getPrimaryControlShadow()),
"Button.shadow", new ColorUIResource(getPrimaryControlShadow()),
"CheckBox.background", new ColorUIResource(getControl()),
+ "CheckBox.icon",
+ new UIDefaults.ProxyLazyValue
+ ("javax.swing.plaf.metal.MetalCheckBoxIcon"),
"CheckBoxMenuItem.background", new ColorUIResource(getControl()),
"ToolBar.background", new ColorUIResource(getControl()),
"Panel.background", new ColorUIResource(getControl()),
@@ -489,11 +788,28 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Label.disabledForeground", new ColorUIResource(getControlDisabled()),
"Label.foreground", new ColorUIResource(getSystemTextColor()),
"Menu.background", new ColorUIResource(getControl()),
+ "Menu.border", new MetalBorders.MenuItemBorder(),
+ "Menu.borderPainted", Boolean.TRUE,
"Menu.font", getControlTextFont(),
+ "Menu.selectionBackground", getMenuSelectedBackground(),
+ "Menu.selectionForeground", getMenuSelectedForeground(),
"MenuBar.background", new ColorUIResource(getControl()),
+ "MenuBar.border", new MetalBorders.MenuBarBorder(),
"MenuBar.font", getControlTextFont(),
"MenuItem.background", new ColorUIResource(getControl()),
+ "MenuItem.border", new MetalBorders.MenuItemBorder(),
"MenuItem.font", getControlTextFont(),
+ "MenuItem.selectionBackground", getMenuSelectedBackground(),
+ "MenuItem.selectionForeground", getMenuSelectedForeground(),
+ "Panel.background", new ColorUIResource(getControl()),
+ "RadioButton.icon",
+ new UIDefaults.LazyValue()
+ {
+ public Object createValue(UIDefaults def)
+ {
+ return MetalIconFactory.getRadioButtonIcon();
+ }
+ },
"ScrollBar.background", new ColorUIResource(getControl()),
"ScrollBar.shadow", new ColorUIResource(getControlShadow()),
"ScrollBar.thumb", new ColorUIResource(getPrimaryControlShadow()),
@@ -501,6 +817,53 @@ public class MetalLookAndFeel extends BasicLookAndFeel
new ColorUIResource(getPrimaryControlDarkShadow()),
"ScrollBar.thumbHighlight",
new ColorUIResource(getPrimaryControl()),
+
+ "SplitPane.darkShadow",
+ new ColorUIResource(getControlDarkShadow()),
+ "SplitPane.highlight",
+ new ColorUIResource(getControlHighlight()),
+
+ "Slider.focusInsets", new InsetsUIResource(0, 0, 0, 0),
+ "Slider.horizontalThumbIcon",
+ MetalIconFactory.getHorizontalSliderThumbIcon(),
+ "Slider.verticalThumbIcon",
+ MetalIconFactory.getVerticalSliderThumbIcon(),
+ "Slider.trackWidth", new Integer(7),
+ "Slider.majorTickLength", new Integer(6),
+
+ "ToggleButton.background", new ColorUIResource(getControl()),
+ "ToggleButton.border", MetalBorders.getButtonBorder(),
+ "ToggleButton.darkShadow", new ColorUIResource(getControlDarkShadow()),
+ "ToggleButton.disabledText", new ColorUIResource(getControlDisabled()),
+ "ToggleButton.focus", new ColorUIResource(getFocusColor()),
+ "ToggleButton.font", getControlTextFont(),
+ "ToggleButton.foreground", new ColorUIResource(getSystemTextColor()),
+ "ToggleButton.highlight", new ColorUIResource(getControlHighlight()),
+ "ToggleButton.light", new ColorUIResource(getControlHighlight()),
+ "ToggleButton.margin", new Insets(2, 14, 2, 14),
+ "ToggleButton.select", new ColorUIResource(getPrimaryControlShadow()),
+ "ToggleButton.shadow", new ColorUIResource(getPrimaryControlShadow()),
+
+ "Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
+ "Tree.closedIcon", MetalIconFactory.getTreeFolderIcon(),
+ "Tree.leafIcon", MetalIconFactory.getTreeLeafIcon(),
+ "Tree.collapsedIcon", MetalIconFactory.getTreeControlIcon(true),
+ "Tree.expandedIcon", MetalIconFactory.getTreeControlIcon(false),
+ "Tree.font", new FontUIResource(new Font("Helvetica", Font.PLAIN, 12)),
+ "Tree.background", new ColorUIResource(Color.white),
+ "Tree.foreground", new ColorUIResource(new Color(204, 204, 255)),
+ "Tree.hash", new ColorUIResource(new Color(204, 204, 255)),
+ "Tree.leftChildIndent", new Integer(7),
+ "Tree.rightChildIndent", new Integer(13),
+ "Tree.rowHeight", new Integer(20),
+ "Tree.scrollsOnExpand", Boolean.TRUE,
+ "Tree.selectionBackground", new ColorUIResource(new Color(204, 204, 255)),
+ "Tree.nonSelectionBackground", new ColorUIResource(Color.white),
+ "Tree.selectionBorderColor", new ColorUIResource(new Color(102, 102, 153)),
+ "Tree.selectionForeground", new ColorUIResource(Color.black),
+ "Tree.textBackground", new ColorUIResource(new Color(204, 204, 255)),
+ "Tree.textForeground", new ColorUIResource(Color.black),
+ "Tree.selectionForeground", new ColorUIResource(Color.black),
"PopupMenu.border", new MetalBorders.PopupMenuBorder()
};
defaults.putDefaults(myDefaults);
diff --git a/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java b/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
index 0892c56e4..ec9bf2b55 100644
--- a/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
+++ b/javax/swing/plaf/metal/MetalPopupMenuSeparatorUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalProgressBarUI.java b/javax/swing/plaf/metal/MetalProgressBarUI.java
index 04ca52f71..96d1988fd 100644
--- a/javax/swing/plaf/metal/MetalProgressBarUI.java
+++ b/javax/swing/plaf/metal/MetalProgressBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalRadioButtonUI.java b/javax/swing/plaf/metal/MetalRadioButtonUI.java
index b4ff10bd5..a668f914e 100644
--- a/javax/swing/plaf/metal/MetalRadioButtonUI.java
+++ b/javax/swing/plaf/metal/MetalRadioButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalRootPaneUI.java b/javax/swing/plaf/metal/MetalRootPaneUI.java
index 5306b6182..4196a4e47 100644
--- a/javax/swing/plaf/metal/MetalRootPaneUI.java
+++ b/javax/swing/plaf/metal/MetalRootPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalScrollBarUI.java b/javax/swing/plaf/metal/MetalScrollBarUI.java
index 17ac88bc7..526dfb50a 100644
--- a/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -129,28 +129,9 @@ public class MetalScrollBarUI
thumbBounds.y + thumbBounds.height);
// draw the pattern
- int xOff = 0;
- for (int y = thumbBounds.y + 4;
- y < (thumbBounds.y + thumbBounds.height - 4); y++)
- {
- // set color alternating with every line
- if ((y % 2) == 0)
- g.setColor(thumbHighlightColor);
- else
- g.setColor(thumbDarkShadowColor);
-
- for (int x = thumbBounds.x + 3 + (xOff);
- x < (thumbBounds.x + thumbBounds.width - 3); x = x + 4)
- {
- g.drawLine(x, y, x, y);
- }
-
- // increase x offset
- xOff++;
- if (xOff > 3)
- xOff = 0;
-
- }
+ MetalUtils.fillMetalPattern(g, thumbBounds.x + 3, thumbBounds.y + 3,
+ thumbBounds.width - 6, thumbBounds.height - 6,
+ thumbHighlightColor, thumbDarkShadowColor);
}
/**
diff --git a/javax/swing/plaf/metal/MetalScrollPaneUI.java b/javax/swing/plaf/metal/MetalScrollPaneUI.java
index 6220ea9e2..3e1198b39 100644
--- a/javax/swing/plaf/metal/MetalScrollPaneUI.java
+++ b/javax/swing/plaf/metal/MetalScrollPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalSeparatorUI.java b/javax/swing/plaf/metal/MetalSeparatorUI.java
index e6c36b4e4..6e78ccb70 100644
--- a/javax/swing/plaf/metal/MetalSeparatorUI.java
+++ b/javax/swing/plaf/metal/MetalSeparatorUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalSliderUI.java b/javax/swing/plaf/metal/MetalSliderUI.java
index fafd21d3e..4b52c4b00 100644
--- a/javax/swing/plaf/metal/MetalSliderUI.java
+++ b/javax/swing/plaf/metal/MetalSliderUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,25 +38,72 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeListener;
import java.util.HashMap;
+import javax.swing.Icon;
import javax.swing.JComponent;
+import javax.swing.JSlider;
+import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.plaf.basic.BasicSliderUI;
+/**
+ * A UI delegate for the {@link JSlider} component.
+ */
public class MetalSliderUI
extends BasicSliderUI
{
+ // TODO: find a use for this
+ protected static Color thumbColor;
+
+ // TODO: find a use for this
+ protected static Color highlightColor;
+
+ // TODO: find a use for this
+ protected static Color darkShadowColor;
+
+ /** The track width. */
+ protected static int trackWidth = UIManager.getInt("Slider.trackWidth");
+
+ /** The length of the major tick marks. */
+ protected static int tickLength = UIManager.getInt("Slider.majorTickLength");
+
+ /** The icon used for the thumb control of horizontally oriented sliders. */
+ protected static Icon horizThumbIcon = UIManager.getIcon(
+ "Slider.horizontalThumbIcon");
+
+ /** The icon used for the thumb control of vertically oriented sliders. */
+ protected static Icon vertThumbIcon = UIManager.getIcon(
+ "Slider.verticalThumbIcon");
+ /** The gap between the track and the tick marks. */
+ protected final int TICK_BUFFER = 4;
+
+ /**
+ * A flag that controls whether or not the track is filled up to the value
+ * of the slider.
+ */
+ protected boolean filledSlider;
+
+ /** A key to look up the filledSlider setting in the {@link UIManager}. */
+ protected final String SLIDER_FILL = "JSlider.isFilled";
+
/** The UI instances for MetalSliderUIs */
private static HashMap instances;
/**
- * Constructs a new instance of MetalSliderUI.
+ * Constructs a new instance.
*/
public MetalSliderUI()
{
super(null);
+ filledSlider = UIManager.getBoolean(SLIDER_FILL);
}
/**
@@ -71,17 +118,225 @@ public class MetalSliderUI
if (instances == null)
instances = new HashMap();
-
Object o = instances.get(component);
MetalSliderUI instance;
if (o == null)
{
- instance = new MetalSliderUI();
- instances.put(component, instance);
+ instance = new MetalSliderUI();
+ instances.put(component, instance);
}
else
instance = (MetalSliderUI) o;
return instance;
}
+
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ Boolean b = (Boolean) c.getClientProperty(SLIDER_FILL);
+ if (b != null)
+ filledSlider = b.booleanValue();
+ }
+
+ /**
+ * Paints the thumb icon for the slider.
+ *
+ * @param g the graphics device.
+ */
+ public void paintThumb(Graphics g)
+ {
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ horizThumbIcon.paintIcon(slider, g, thumbRect.x, thumbRect.y);
+ else
+ vertThumbIcon.paintIcon(slider, g, thumbRect.x, thumbRect.y);
+ }
+
+ /**
+ * Creates a property change listener for the slider.
+ *
+ * @param slider the slider.
+ */
+ protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
+ {
+ // TODO: try to figure out why it might be necessary to override this
+ // method as is done in Sun's implementation
+ return super.createPropertyChangeListener(slider);
+ }
+
+ /**
+ * Paints the track along which the thumb control moves.
+ *
+ * @param g the graphics device.
+ */
+ public void paintTrack(Graphics g)
+ {
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ {
+ if (filledSlider)
+ {
+ // TODO: fill the track
+ }
+ BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y
+ + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1,
+ getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray,
+ Color.white);
+ }
+ else
+ {
+ if (filledSlider)
+ {
+ // TODO: fill the track
+ }
+ BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width
+ - getTrackWidth()) / 2, trackRect.y, getTrackWidth(),
+ trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray,
+ Color.white);
+ }
+ }
+
+ /**
+ * Draws the focus rectangle for the slider. The Metal look and feel
+ * indicates that the {@link JSlider} has the focus by changing the color of
+ * the thumb control - this is handled elsewhere and so this method is empty
+ * (it overrides the method in the {@link BasicSliderUI} class to prevent
+ * a default focus highlight from being drawn).
+ *
+ * @param g the graphics device.
+ */
+ public void paintFocus(Graphics g)
+ {
+ // do nothing as focus is shown by different color on thumb control
+ }
+
+ /**
+ * Returns the size of the thumb icon.
+ *
+ * @return The size of the thumb icon.
+ */
+ protected Dimension getThumbSize()
+ {
+ if (slider.getOrientation() == JSlider.HORIZONTAL)
+ return new Dimension(horizThumbIcon.getIconWidth(),
+ horizThumbIcon.getIconHeight());
+ else
+ return new Dimension(vertThumbIcon.getIconWidth(),
+ vertThumbIcon.getIconHeight());
+ }
+
+ /**
+ * Returns the length of the major tick marks.
+ *
+ * @return The length of the major tick marks.
+ */
+ public int getTickLength()
+ {
+ return tickLength + TICK_BUFFER;
+ }
+
+ /**
+ * Returns the track width.
+ *
+ * @return The track width.
+ */
+ protected int getTrackWidth()
+ {
+ return trackWidth;
+ }
+
+ /**
+ * Returns the track length.
+ *
+ * @return The track length.
+ */
+ protected int getTrackLength()
+ {
+ return (slider.getOrientation() == JSlider.HORIZONTAL
+ ? tickRect.width : tickRect.height);
+ }
+
+ /**
+ * Returns the thumb overhang.
+ *
+ * @return The thumb overhang.
+ */
+ protected int getThumbOverhang()
+ {
+ // TODO: figure out what this is used for
+ return 0;
+ }
+
+ protected void scrollDueToClickInTrack(int dir)
+ {
+ super.scrollDueToClickInTrack(dir);
+ }
+
+ /**
+ * Paints the minor ticks for a slider with a horizontal orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param x the x value for the tick.
+ */
+ protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds,
+ int x)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ // TODO: get color from UIManager...
+ g.setColor(new Color(153, 153, 204));
+ g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength / 2);
+ }
+
+ /**
+ * Paints the major ticks for a slider with a horizontal orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param x the x value for the tick.
+ */
+ protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds,
+ int x)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ // TODO: get color from UIManager...
+ g.setColor(new Color(153, 153, 204));
+ g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength);
+ }
+
+ /**
+ * Paints the minor ticks for a slider with a vertical orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param y the y value for the tick.
+ */
+ protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds,
+ int y)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ // TODO: get color from UIManager...
+ g.setColor(new Color(153, 153, 204));
+ g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength / 2, y);
+ }
+
+ /**
+ * Paints the major ticks for a slider with a vertical orientation.
+ *
+ * @param g the graphics device.
+ * @param tickBounds the tick bounds.
+ * @param y the y value for the tick.
+ */
+ protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds,
+ int y)
+ {
+ // Note the incoming 'g' has a translation in place to get us to the
+ // start of the tick rect already...
+ // TODO: get color from UIManager...
+ g.setColor(new Color(153, 153, 204));
+ g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength, y);
+ }
+
}
diff --git a/javax/swing/plaf/metal/MetalSplitPaneDivider.java b/javax/swing/plaf/metal/MetalSplitPaneDivider.java
new file mode 100644
index 000000000..60e9c0559
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalSplitPaneDivider.java
@@ -0,0 +1,84 @@
+/* MetalSplitPaneDivider.java
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
+
+/**
+ * The divider that is used by the MetalSplitPaneUI.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ *
+ */
+class MetalSplitPaneDivider extends BasicSplitPaneDivider
+{
+ /** The dark color in the pattern. */
+ Color dark;
+
+ /** The light color in the pattern. */
+ Color light;
+
+ /**
+ * Creates a new instance of MetalSplitPaneDivider.
+ *
+ * @param ui the <code>MetalSplitPaneUI</code> that uses this divider
+ */
+ public MetalSplitPaneDivider(MetalSplitPaneUI ui, Color light, Color dark)
+ {
+ super(ui);
+ this.light = light;
+ this.dark = dark;
+ }
+
+ /**
+ * Paints the divider.
+ *
+ * @param g the <code>Graphics</code> context to use for painting
+ */
+ public void paint(Graphics g)
+ {
+ //super.paint(g);
+ Dimension s = getSize();
+ MetalUtils.fillMetalPattern(g, 2, 2, s.width - 4, s.height - 4,
+ light, dark);
+ }
+}
diff --git a/javax/swing/plaf/metal/MetalSplitPaneUI.java b/javax/swing/plaf/metal/MetalSplitPaneUI.java
index eda17f508..b7ea8984b 100644
--- a/javax/swing/plaf/metal/MetalSplitPaneUI.java
+++ b/javax/swing/plaf/metal/MetalSplitPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,11 +38,15 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
import java.util.HashMap;
import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSplitPaneUI;
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
public class MetalSplitPaneUI
extends BasicSplitPaneUI
@@ -83,4 +87,20 @@ public class MetalSplitPaneUI
return instance;
}
+
+ /**
+ * Returns the divider that is used by the <code>JSplitPane</code>.
+ *
+ * The divider returned by this method is a {@link BasicSplitPaneDivider}
+ * that is drawn using the Metal look.
+ *
+ * @return the default divider to use for <code>JSplitPane</code>s.
+ */
+ public BasicSplitPaneDivider createDefaultDivider()
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ Color light = defaults.getColor("SplitPane.highlight");
+ Color dark = defaults.getColor("SplitPane.darkShadow");
+ return new MetalSplitPaneDivider(this, light, dark);
+ }
}
diff --git a/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/javax/swing/plaf/metal/MetalTabbedPaneUI.java
index 524fc5253..bf50f9172 100644
--- a/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+++ b/javax/swing/plaf/metal/MetalTabbedPaneUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalTextFieldUI.java b/javax/swing/plaf/metal/MetalTextFieldUI.java
index d2e9ea529..d6e50e122 100644
--- a/javax/swing/plaf/metal/MetalTextFieldUI.java
+++ b/javax/swing/plaf/metal/MetalTextFieldUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalTheme.java b/javax/swing/plaf/metal/MetalTheme.java
index 970f83095..d5131af2e 100644
--- a/javax/swing/plaf/metal/MetalTheme.java
+++ b/javax/swing/plaf/metal/MetalTheme.java
@@ -1,5 +1,5 @@
/* MetalTheme.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -45,215 +45,532 @@ import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
+/**
+ * The base class for themes used by the {@link MetalLookAndFeel}. A default
+ * theme ({@link DefaultMetalTheme}) is provided, or you can create and use
+ * your own.
+ *
+ * @see MetalLookAndFeel#setCurrentTheme(MetalTheme)
+ */
public abstract class MetalTheme
{
private ColorUIResource BLACK = new ColorUIResource(Color.BLACK);
private ColorUIResource WHITE = new ColorUIResource(Color.WHITE);
+ /**
+ * Default constructor.
+ */
public MetalTheme()
{
// Do nothing here.
}
+ /**
+ * Returns the name of the theme.
+ *
+ * @return The name of the theme.
+ */
public abstract String getName();
+ /**
+ * Adds custom entries to the UI defaults table. This method is empty.
+ *
+ * @param table the table.
+ */
public void addCustomEntriesToTable(UIDefaults table)
{
// Do nothing here.
- // This method needs to be overloaded to actuall do something.
+ // This method needs to be overridden to actually do something.
+ // It is called from MetalLookAndFeel.getDefaults().
}
+ /**
+ * Returns the accelerator foreground color. The default implementation
+ * returns the color from {@link #getPrimary1()}.
+ *
+ * @return The accelerator foreground color.
+ */
public ColorUIResource getAcceleratorForeground()
{
return getPrimary1();
}
+ /**
+ * Returns the accelerator selected foreground color. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The accelerator selected foreground color.
+ */
public ColorUIResource getAcceleratorSelectedForeground()
{
return getBlack();
}
+ /**
+ * Returns the control color. The default implementation returns the color
+ * from {@link #getSecondary3()}.
+ *
+ * @return The control color.
+ */
public ColorUIResource getControl()
{
return getSecondary3();
}
+ /**
+ * Returns the color used for dark shadows on controls. The default
+ * implementation returns the color from {@link #getSecondary1()}.
+ *
+ * @return The color used for dark shadows on controls.
+ */
public ColorUIResource getControlDarkShadow()
{
return getSecondary1();
}
+ /**
+ * Returns the color used for disabled controls. The default implementation
+ * returns the color from {@link #getSecondary1()}.
+ *
+ * @return The color used for disabled controls.
+ */
public ColorUIResource getControlDisabled()
{
return getSecondary2();
}
+ /**
+ * Returns the color used to draw highlights for controls. The default
+ * implementation returns the color from {@link #getWhite()}.
+ *
+ * @return The color used to draw highlights for controls.
+ */
public ColorUIResource getControlHighlight()
{
return getWhite();
}
+ /**
+ * Returns the color used to display control info. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The color used to display control info.
+ */
public ColorUIResource getControlInfo()
{
return getBlack();
}
+ /**
+ * Returns the color used to draw shadows for controls. The default
+ * implementation returns the color from {@link #getSecondary2()}.
+ *
+ * @return The color used to draw shadows for controls.
+ */
public ColorUIResource getControlShadow()
{
return getSecondary2();
}
+ /**
+ * Returns the color used for text on controls. The default implementation
+ * returns the color from {@link #getControlInfo()}.
+ *
+ * @return The color used for text on controls.
+ */
public ColorUIResource getControlTextColor()
{
return getControlInfo();
}
+ /**
+ * Returns the color used for the desktop background. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The color used for the desktop background.
+ */
public ColorUIResource getDesktopColor()
{
return getPrimary2();
}
+ /**
+ * Returns the color used to draw focus highlights. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The color used to draw focus highlights.
+ */
public ColorUIResource getFocusColor()
{
return getPrimary2();
}
+ /**
+ * Returns the color used to draw highlighted text. The default
+ * implementation returns the color from {@link #getHighlightedTextColor()}.
+ *
+ * @return The color used to draw highlighted text.
+ */
public ColorUIResource getHighlightedTextColor()
{
return getControlTextColor();
}
+ /**
+ * Returns the color used to draw text on inactive controls. The default
+ * implementation returns the color from {@link #getControlDisabled()}.
+ *
+ * @return The color used to draw text on inactive controls.
+ */
public ColorUIResource getInactiveControlTextColor()
{
return getControlDisabled();
}
+ /**
+ * Returns the color used to draw inactive system text. The default
+ * implementation returns the color from {@link #getSecondary2()}.
+ *
+ * @return The color used to draw inactive system text.
+ */
public ColorUIResource getInactiveSystemTextColor()
{
return getSecondary2();
}
+ /**
+ * Returns the background color for menu items. The default implementation
+ * returns the color from {@link #getSecondary3()}.
+ *
+ * @return The background color for menu items.
+ *
+ * @see #getMenuSelectedBackground()
+ */
public ColorUIResource getMenuBackground()
{
return getSecondary3();
}
+ /**
+ * Returns the foreground color for disabled menu items. The default
+ * implementation returns the color from {@link #getSecondary2()}.
+ *
+ * @return The foreground color for disabled menu items.
+ *
+ * @see #getMenuForeground()
+ */
public ColorUIResource getMenuDisabledForeground()
{
- return getSecondary3();
+ return getSecondary2();
}
+ /**
+ * Returns the foreground color for menu items. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The foreground color for menu items.
+ *
+ * @see #getMenuDisabledForeground()
+ * @see #getMenuSelectedForeground()
+ */
public ColorUIResource getMenuForeground()
{
return getBlack();
}
+ /**
+ * Returns the background color for selected menu items. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The background color for selected menu items.
+ *
+ * @see #getMenuBackground()
+ */
public ColorUIResource getMenuSelectedBackground()
{
return getPrimary2();
}
+ /**
+ * Returns the foreground color for selected menu items. The default
+ * implementation returns the value from {@link #getBlack()}.
+ *
+ * @return The foreground color for selected menu items.
+ *
+ * @see #getMenuForeground()
+ */
public ColorUIResource getMenuSelectedForeground()
{
return getBlack();
}
+ /**
+ * Returns the primary color for controls. The default implementation
+ * returns the color from {@link #getPrimary3()}.
+ *
+ * @return The primary color for controls.
+ */
public ColorUIResource getPrimaryControl()
{
return getPrimary3();
}
+ /**
+ * Returns the primary color for the dark shadow on controls. The default
+ * implementation returns the color from {@link #getPrimary1()}.
+ *
+ * @return The primary color for the dark shadow on controls.
+ */
public ColorUIResource getPrimaryControlDarkShadow()
{
return getPrimary1();
}
+ /**
+ * Returns the primary color for the highlight on controls. The default
+ * implementation returns the color from {@link #getWhite()}.
+ *
+ * @return The primary color for the highlight on controls.
+ */
public ColorUIResource getPrimaryControlHighlight()
{
return getWhite();
}
+ /**
+ * Returns the primary color for the information on controls. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The primary color for the information on controls.
+ */
public ColorUIResource getPrimaryControlInfo()
{
return getBlack();
}
+ /**
+ * Returns the primary color for the shadow on controls. The default
+ * implementation returns the color from {@link #getPrimary2()}.
+ *
+ * @return The primary color for the shadow on controls.
+ */
public ColorUIResource getPrimaryControlShadow()
{
return getPrimary2();
}
+ /**
+ * Returns the background color for separators. The default implementation
+ * returns the color from {@link #getWhite()}.
+ *
+ * @return The background color for separators.
+ */
public ColorUIResource getSeparatorBackground()
{
return getWhite();
}
+ /**
+ * Returns the foreground color for separators. The default implementation
+ * returns the value from {@link #getPrimary1()}.
+ *
+ * @return The foreground color for separators.
+ */
public ColorUIResource getSeparatorForeground()
{
return getPrimary1();
}
+ /**
+ * Returns the color used for system text. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The color used for system text.
+ */
public ColorUIResource getSystemTextColor()
{
return getBlack();
}
+ /**
+ * Returns the color used to highlight text. The default implementation
+ * returns the color from {@link #getPrimary3()}.
+ *
+ * @return The color used to highlight text.
+ */
public ColorUIResource getTextHighlightColor()
{
return getPrimary3();
}
+ /**
+ * Returns the color used to display user text. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The color used to display user text.
+ */
public ColorUIResource getUserTextColor()
{
return getBlack();
}
+ /**
+ * Returns the window background color. The default implementation returns
+ * the color from {@link #getWhite()}.
+ *
+ * @return The window background color.
+ */
public ColorUIResource getWindowBackground()
{
return getWhite();
}
+ /**
+ * Returns the window title background color. The default implementation
+ * returns the color from {@link #getPrimary3()}.
+ *
+ * @return The window title background color.
+ */
public ColorUIResource getWindowTitleBackground()
{
return getPrimary3();
}
+ /**
+ * Returns the window title foreground color. The default implementation
+ * returns the color from {@link #getBlack()}.
+ *
+ * @return The window title foreground color.
+ */
public ColorUIResource getWindowTitleForeground()
{
return getBlack();
}
+ /**
+ * Returns the background color for an inactive window title. The default
+ * implementation returns the color from {@link #getSecondary3()}.
+ *
+ * @return The background color for an inactive window title.
+ */
public ColorUIResource getWindowTitleInactiveBackground()
{
return getSecondary3();
}
+ /**
+ * Returns the foreground color for an inactive window title. The default
+ * implementation returns the color from {@link #getBlack()}.
+ *
+ * @return The foreground color for an inactive window title.
+ */
public ColorUIResource getWindowTitleInactiveForeground()
{
return getBlack();
}
+ /**
+ * Returns the color used for black.
+ *
+ * @return The color used for black.
+ */
protected ColorUIResource getBlack()
{
return BLACK;
}
+ /**
+ * Returns the color used for white.
+ *
+ * @return The color used for white.
+ */
protected ColorUIResource getWhite()
{
return WHITE;
}
+ /**
+ * Returns the first primary color for this theme.
+ *
+ * @return The first primary color.
+ */
protected abstract ColorUIResource getPrimary1();
+
+ /**
+ * Returns the second primary color for this theme.
+ *
+ * @return The second primary color.
+ */
protected abstract ColorUIResource getPrimary2();
+
+ /**
+ * Returns the third primary color for this theme.
+ *
+ * @return The third primary color.
+ */
protected abstract ColorUIResource getPrimary3();
+
+ /**
+ * Returns the first secondary color for this theme.
+ *
+ * @return The first secondary color.
+ */
protected abstract ColorUIResource getSecondary1();
+
+ /**
+ * Returns the second secondary color for this theme.
+ *
+ * @return The second secondary color.
+ */
protected abstract ColorUIResource getSecondary2();
+
+ /**
+ * Returns the third secondary color for this theme.
+ *
+ * @return The third secondary color.
+ */
protected abstract ColorUIResource getSecondary3();
+ /**
+ * Returns the font used for text on controls.
+ *
+ * @return The font used for text on controls.
+ */
public abstract FontUIResource getControlTextFont();
+
+ /**
+ * Returns the font used for text in menus.
+ *
+ * @return The font used for text in menus.
+ */
public abstract FontUIResource getMenuTextFont();
+
+ /**
+ * Returns the font used for sub text.
+ *
+ * @return The font used for sub text.
+ */
public abstract FontUIResource getSubTextFont();
+
+ /**
+ * Returns the font used for system text.
+ *
+ * @return The font used for system text.
+ */
public abstract FontUIResource getSystemTextFont();
+
+ /**
+ * Returns the font used for user text.
+ *
+ * @return The font used for user text.
+ */
public abstract FontUIResource getUserTextFont();
+
+ /**
+ * Returns the font used for window titles.
+ *
+ * @return The font used for window titles.
+ */
public abstract FontUIResource getWindowTitleFont();
+
}
diff --git a/javax/swing/plaf/metal/MetalToggleButtonUI.java b/javax/swing/plaf/metal/MetalToggleButtonUI.java
index 84af36a5e..be6d0c39e 100644
--- a/javax/swing/plaf/metal/MetalToggleButtonUI.java
+++ b/javax/swing/plaf/metal/MetalToggleButtonUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,7 +38,11 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+
import javax.swing.JComponent;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToggleButtonUI;
@@ -46,7 +50,15 @@ public class MetalToggleButtonUI
extends BasicToggleButtonUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
+ /** The color for the focus border. */
+ protected Color focusColor;
+
+ /** The color that indicates a selected button. */
+ protected Color selectColor;
+
+ /** The color for disabled button labels. */
+ protected Color disabledTextColor;
+
/** The shared UI instance for MetalToggleButtonUIs */
private static MetalToggleButtonUI instance = null;
@@ -56,6 +68,43 @@ public class MetalToggleButtonUI
public MetalToggleButtonUI()
{
super();
+ focusColor = getFocusColor();
+ selectColor = getSelectColor();
+ disabledTextColor = getDisabledTextColor();
+ }
+
+
+ /**
+ * Returns the color for the focus border.
+ *
+ * @return the color for the focus border
+ */
+ protected Color getFocusColor()
+ {
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ return def.getColor(getPropertyPrefix() + ".focus");
+ }
+
+ /**
+ * Returns the color that indicates a selected button.
+ *
+ * @return the color that indicates a selected button
+ */
+ protected Color getSelectColor()
+ {
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ return def.getColor(getPropertyPrefix() + ".select");
+ }
+
+ /**
+ * Returns the color for the text label of disabled buttons.
+ *
+ * @return the color for the text label of disabled buttons
+ */
+ protected Color getDisabledTextColor()
+ {
+ UIDefaults def = UIManager.getLookAndFeelDefaults();
+ return def.getColor(getPropertyPrefix() + ".disabledText");
}
/**
diff --git a/javax/swing/plaf/metal/MetalToolBarUI.java b/javax/swing/plaf/metal/MetalToolBarUI.java
index 299a4c0a4..39af0011a 100644
--- a/javax/swing/plaf/metal/MetalToolBarUI.java
+++ b/javax/swing/plaf/metal/MetalToolBarUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalToolTipUI.java b/javax/swing/plaf/metal/MetalToolTipUI.java
index 303b6294a..c88b6534a 100644
--- a/javax/swing/plaf/metal/MetalToolTipUI.java
+++ b/javax/swing/plaf/metal/MetalToolTipUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/plaf/metal/MetalTreeUI.java b/javax/swing/plaf/metal/MetalTreeUI.java
index a420204b5..d85d61c24 100644
--- a/javax/swing/plaf/metal/MetalTreeUI.java
+++ b/javax/swing/plaf/metal/MetalTreeUI.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTreeUI;
@@ -46,9 +48,8 @@ public class MetalTreeUI
extends BasicTreeUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for MetalTreeUIs */
- private static MetalTreeUI instance = null;
+ /** The UI instances for MetalTreeUIs */
+ private static HashMap instances = null;
/**
* Constructs a new instance of MetalTreeUI.
@@ -67,8 +68,19 @@ public class MetalTreeUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalTreeUI();
+ if (instances == null)
+ instances = new HashMap();
+
+ Object o = instances.get(component);
+ MetalTreeUI instance;
+ if (o == null)
+ {
+ instance = new MetalTreeUI();
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalTreeUI) o;
+
return instance;
}
}
diff --git a/javax/swing/plaf/metal/MetalUtils.java b/javax/swing/plaf/metal/MetalUtils.java
new file mode 100644
index 000000000..a342ee02b
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalUtils.java
@@ -0,0 +1,87 @@
+/* Metaltils.java
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.metal;
+
+import java.awt.Color;
+import java.awt.Graphics;
+
+/**
+ * Some utility and helper methods for the Metal Look &amp; Feel.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+class MetalUtils
+{
+
+ /**
+ * Fills a rectangle with the typical Metal pattern.
+ *
+ * @param g the <code>Graphics</code> context to use
+ * @param x the X coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param y the Y coordinate of the upper left corner of the rectangle to
+ * fill
+ * @param w the width of the rectangle to fill
+ * @param w the height of the rectangle to fill
+ * @param light the light color to use
+ * @param dark the dark color to use
+ */
+ static void fillMetalPattern(Graphics g, int x, int y, int w, int h,
+ Color light, Color dark)
+ {
+ int xOff = 0;
+ for (int mY = y; mY < (y + h); mY++)
+ {
+ // set color alternating with every line
+ if ((mY % 2) == 0)
+ g.setColor(light);
+ else
+ g.setColor(dark);
+
+ for (int mX = x + (xOff); mX < (x + w); mX += 4)
+ {
+ g.drawLine(mX, mY, mX, mY);
+ }
+
+ // increase x offset
+ xOff++;
+ if (xOff > 3)
+ xOff = 0;
+ }
+ }
+}
diff --git a/javax/swing/plaf/metal/package.html b/javax/swing/plaf/metal/package.html
index 3d125027a..2ea787bb5 100644
--- a/javax/swing/plaf/metal/package.html
+++ b/javax/swing/plaf/metal/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.plaf.metal package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,7 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.plaf.metal</title></head>
<body>
-<p></p>
+<p>Provides a cross-platform look and feel known as "Metal".</p>
</body>
</html>
diff --git a/javax/swing/plaf/package.html b/javax/swing/plaf/package.html
index e4b247aea..c266074f0 100644
--- a/javax/swing/plaf/package.html
+++ b/javax/swing/plaf/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.plaf package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.plaf</title></head>
<body>
-<p></p>
+<p>A base package for the "pluggable look and feel" (plaf) mechanism used by
+the <code>javax.swing</code> classes.</p>
</body>
</html>
diff --git a/javax/swing/table/AbstractTableModel.java b/javax/swing/table/AbstractTableModel.java
index 076487f53..3e9f6e9b3 100644
--- a/javax/swing/table/AbstractTableModel.java
+++ b/javax/swing/table/AbstractTableModel.java
@@ -1,5 +1,5 @@
/* AbstractTableModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,7 +46,8 @@ import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
/**
- * AbstractTableModel
+ * A base class that can be used to create implementations of the
+ * {@link TableModel} interface.
*
* @author Andrew Selkirk
*/
@@ -55,58 +56,60 @@ public abstract class AbstractTableModel implements TableModel, Serializable
static final long serialVersionUID = -5798593159423650347L;
/**
- * listenerList
+ * Storage for the listeners registered with this model.
*/
protected EventListenerList listenerList = new EventListenerList();
/**
- * Constructor AbstractTableModel
+ * Creates a default instance.
*/
public AbstractTableModel()
{
- // TODO
+ // no setup required here
}
/**
- * Get the name of the column for this index. If you do not override
- * this methode, you'll get something like: 0, A; 1, B; ...; AA; AB;
- * ...
+ * Returns the name of the specified column. This method generates default
+ * names in a sequence (starting with column 0): A, B, C, ..., Z, AA, AB,
+ * AC, ..., AZ, BA, BB, BC, and so on. Subclasses may override this method
+ * to allow column names to be specified on some other basis.
*
- * @param columnIndex The index of the column.
+ * @param columnIndex the column index.
*
* @return The name of the column.
*/
- public String getColumnName (int columnIndex)
+ public String getColumnName(int columnIndex)
{
- int index = columnIndex + 1;
StringBuffer buffer = new StringBuffer();
-
- while (index > 0)
+ while (columnIndex >= 0)
{
- buffer.insert (0, (char) ('A' + ((index - 1) % 26)));
- index = (index - 1) / 26;
+ buffer.insert (0, (char) ('A' + columnIndex % 26));
+ columnIndex = columnIndex / 26 - 1;
}
-
- // Return column name.
return buffer.toString();
}
/**
- * Return the index of the given name.
+ * Return the index of the specified column, or <code>-1</code> if there is
+ * no column with the specified name.
*
- * @param columnName The name of the column.
+ * @param columnName the name of the column (<code>null</code> not permitted).
*
* @return The index of the column, -1 if not found.
+ *
+ * @see #getColumnName(int)
+ * @throws NullPointerException if <code>columnName</code> is
+ * <code>null</code>.
*/
- public int findColumn (String columnName)
+ public int findColumn(String columnName)
{
int count = getColumnCount();
for (int index = 0; index < count; index++)
{
- String name = getColumnName (index);
+ String name = getColumnName(index);
- if (name.equals (columnName))
+ if (columnName.equals(name))
return index;
}
@@ -115,142 +118,162 @@ public abstract class AbstractTableModel implements TableModel, Serializable
}
/**
- * Returns the class of a comlumn.
- *
- * @param columnIndex The index of the column.
- *
- * @return The class type of the column.
+ * Returns the <code>Class</code> for all <code>Object</code> instances
+ * in the specified column.
+ *
+ * @param columnIndex the column index.
+ *
+ * @return The class.
*/
- public Class getColumnClass (int columnIndex)
+ public Class getColumnClass(int columnIndex)
{
return Object.class;
}
/**
- * Tells whether a cell is editable.
+ * Returns <code>true</code> if the specified cell is editable, and
+ * <code>false</code> if it is not. This implementation returns
+ * <code>false</code> for all arguments, subclasses should override the
+ * method if necessary.
*
- * @param rowIndex The row of the cell.
- * @param columnIndex The index of the cell.
+ * @param rowIndex the row index of the cell.
+ * @param columnIndex the column index of the cell.
*
- * @return True if cell is editable.
+ * @return <code>false</code>.
*/
- public boolean isCellEditable (int rowIndex, int columnIndex)
+ public boolean isCellEditable(int rowIndex, int columnIndex)
{
return false;
}
/**
- * Sets a cell to a value.
+ * Sets the value of the given cell. This implementation ignores all
+ * arguments and does nothing, subclasses should override the
+ * method if necessary.
*
- * @param value New value of cell.
- * @param rowIndex The row of the cell.
- * @param columnIndex The column of the cell.
+ * @param value the new value (<code>null</code> permitted).
+ * @param rowIndex the row index of the cell.
+ * @param columnIndex the column index of the cell.
*/
- public void setValueAt (Object value, int rowIndex, int columnIndex)
+ public void setValueAt(Object value, int rowIndex, int columnIndex)
{
// Do nothing...
}
/**
- * Add a TableModelListener.
+ * Adds a listener to the table model. The listener will receive notification
+ * of all changes to the table model.
*
- * @param listener The listener to add.
+ * @param listener the listener.
*/
- public void addTableModelListener (TableModelListener listener)
+ public void addTableModelListener(TableModelListener listener)
{
- listenerList.add (TableModelListener.class, listener);
+ listenerList.add(TableModelListener.class, listener);
}
/**
- * Removes a TableModelListener.
+ * Removes a listener from the table model so that it will no longer receive
+ * notification of changes to the table model.
*
- * @param listener The listener to remove.
+ * @param listener the listener to remove.
*/
- public void removeTableModelListener (TableModelListener listener)
+ public void removeTableModelListener(TableModelListener listener)
{
- listenerList.remove (TableModelListener.class, listener);
+ listenerList.remove(TableModelListener.class, listener);
}
/**
- * Return all registered TableModelListener objects.
+ * Returns an array containing the listeners that have been added to the
+ * table model.
*
- * @return Array of TableModelListener objects.
+ * @return Array of {@link TableModelListener} objects.
*
* @since 1.4
*/
public TableModelListener[] getTableModelListeners()
{
return (TableModelListener[])
- listenerList.getListeners (TableModelListener.class);
+ listenerList.getListeners(TableModelListener.class);
}
/**
- * fireTableDataChanged
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that the table data has changed.
*/
public void fireTableDataChanged()
{
- fireTableChanged (new TableModelEvent (this));
+ fireTableChanged(new TableModelEvent(this, 0, Integer.MAX_VALUE));
}
/**
- * fireTableStructureChanged
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that the table structure has changed.
*/
public void fireTableStructureChanged()
{
- fireTableChanged (new TableModelEvent (this, TableModelEvent.HEADER_ROW));
+ fireTableChanged(new TableModelEvent(this, TableModelEvent.HEADER_ROW));
}
/**
- * fireTableRowsInserted
- * @param value0 TODO
- * @param value1 TODO
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that some rows have been inserted into the model.
+ *
+ * @param firstRow the index of the first row.
+ * @param lastRow the index of the last row.
*/
public void fireTableRowsInserted (int firstRow, int lastRow)
{
- fireTableChanged (new TableModelEvent (this, firstRow, lastRow,
- TableModelEvent.ALL_COLUMNS,
- TableModelEvent.INSERT));
+ fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
+ TableModelEvent.ALL_COLUMNS,
+ TableModelEvent.INSERT));
}
/**
- * fireTableRowsUpdated
- * @param value0 TODO
- * @param value1 TODO
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that some rows have been updated.
+ *
+ * @param firstRow the index of the first row.
+ * @param lastRow the index of the last row.
*/
public void fireTableRowsUpdated (int firstRow, int lastRow)
{
- fireTableChanged (new TableModelEvent (this, firstRow, lastRow,
- TableModelEvent.ALL_COLUMNS,
- TableModelEvent.UPDATE));
+ fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
+ TableModelEvent.ALL_COLUMNS,
+ TableModelEvent.UPDATE));
}
/**
- * fireTableRowsDeleted
- * @param value0 TODO
- * @param value1 TODO
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that some rows have been deleted from the model.
+ *
+ * @param firstRow the index of the first row.
+ * @param lastRow the index of the last row.
*/
public void fireTableRowsDeleted(int firstRow, int lastRow)
{
- fireTableChanged (new TableModelEvent (this, firstRow, lastRow,
- TableModelEvent.ALL_COLUMNS,
- TableModelEvent.DELETE));
+ fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
+ TableModelEvent.ALL_COLUMNS,
+ TableModelEvent.DELETE));
}
/**
- * fireTableCellUpdated
- * @param value0 TODO
- * @param value1 TODO
+ * Sends a {@link TableModelEvent} to all registered listeners to inform
+ * them that a single cell has been updated.
+ *
+ * @param row the row index.
+ * @param column the column index.
*/
public void fireTableCellUpdated (int row, int column)
{
- fireTableChanged (new TableModelEvent (this, row, row, column));
+ fireTableChanged(new TableModelEvent(this, row, row, column));
}
/**
- * fireTableChanged
- * @param value0 TODO
+ * Sends the specified event to all registered listeners.
+ *
+ * @param event the event to send.
*/
- public void fireTableChanged (TableModelEvent event)
+ public void fireTableChanged(TableModelEvent event)
{
int index;
TableModelListener listener;
@@ -264,12 +287,15 @@ public abstract class AbstractTableModel implements TableModel, Serializable
}
/**
- * getListeners
- * @param value0 TODO
- * @return EventListener[]
+ * Returns an array of listeners of the given type that are registered with
+ * this model.
+ *
+ * @param listenerType the listener class.
+ *
+ * @return An array of listeners (possibly empty).
*/
- public EventListener[] getListeners (Class listenerType)
+ public EventListener[] getListeners(Class listenerType)
{
- return listenerList.getListeners (listenerType);
+ return listenerList.getListeners(listenerType);
}
}
diff --git a/javax/swing/table/DefaultTableCellRenderer.java b/javax/swing/table/DefaultTableCellRenderer.java
index 1dadf81b5..02e9fd7dc 100644
--- a/javax/swing/table/DefaultTableCellRenderer.java
+++ b/javax/swing/table/DefaultTableCellRenderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/table/DefaultTableColumnModel.java b/javax/swing/table/DefaultTableColumnModel.java
index 3a8b1a3bf..10871770d 100644
--- a/javax/swing/table/DefaultTableColumnModel.java
+++ b/javax/swing/table/DefaultTableColumnModel.java
@@ -1,5 +1,5 @@
/* DefaultTableColumnModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -119,9 +119,11 @@ public class DefaultTableColumnModel
*/
public void addColumn(TableColumn col)
{
+ if (col == null)
+ throw new IllegalArgumentException("Null 'col' argument.");
tableColumns.add(col);
invalidateWidthCache();
- fireColumnAdded(new TableColumnModelEvent(this,0,tableColumns.size()));
+ fireColumnAdded(new TableColumnModelEvent(this, 0, tableColumns.size() - 1));
}
/**
@@ -132,8 +134,10 @@ public class DefaultTableColumnModel
*/
public void removeColumn(TableColumn col)
{
- int index = getColumnIndex(col);
- fireColumnRemoved(new TableColumnModelEvent(this,index,0));
+ int index = this.tableColumns.indexOf(col);
+ if (index < 0)
+ return;
+ fireColumnRemoved(new TableColumnModelEvent(this, index, 0));
tableColumns.remove(col);
invalidateWidthCache();
}
@@ -147,10 +151,14 @@ public class DefaultTableColumnModel
*/
public void moveColumn(int i, int j)
{
- Object tmp = tableColumns.get(i);
- tableColumns.set(i, tableColumns.get(j));
- tableColumns.set(j, tmp);
- fireColumnAdded(new TableColumnModelEvent(this,i,j));
+ int columnCount = getColumnCount();
+ if (i < 0 || i >= columnCount)
+ throw new IllegalArgumentException("Index 'i' out of range.");
+ if (j < 0 || j >= columnCount)
+ throw new IllegalArgumentException("Index 'j' out of range.");
+ Object column = tableColumns.remove(i);
+ tableColumns.add(j, column);
+ fireColumnAdded(new TableColumnModelEvent(this, i, j));
}
/**
@@ -182,14 +190,27 @@ public class DefaultTableColumnModel
}
/**
- * getColumnIndex returns index of the specified column
+ * Returns the index of the {@link TableColumn} with the given identifier.
*
- * @param identifier identifier of the column
- * @return int index of the given column
+ * @param identifier the identifier (<code>null</code> not permitted).
+ *
+ * @return The index of the {@link TableColumn} with the given identifier.
+ *
+ * @throws IllegalArgumentException if <code>identifier</code> is
+ * <code>null</code> or there is no column with that identifier.
*/
public int getColumnIndex(Object identifier)
{
- return tableColumns.indexOf(identifier, 0);
+ if (identifier == null)
+ throw new IllegalArgumentException("Null identifier.");
+ int columnCount = tableColumns.size();
+ for (int i = 0; i < columnCount; i++)
+ {
+ TableColumn tc = (TableColumn) tableColumns.get(i);
+ if (identifier.equals(tc.getIdentifier()))
+ return i;
+ }
+ throw new IllegalArgumentException("No TableColumn with that identifier.");
}
/**
diff --git a/javax/swing/table/DefaultTableModel.java b/javax/swing/table/DefaultTableModel.java
index aab420201..6844f2a27 100644
--- a/javax/swing/table/DefaultTableModel.java
+++ b/javax/swing/table/DefaultTableModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -61,7 +61,7 @@ public class DefaultTableModel extends AbstractTableModel
protected Vector dataVector;
/**
- * columnIdentifiers
+ * Storage for the column identifiers.
*/
protected Vector columnIdentifiers;
@@ -160,7 +160,7 @@ public class DefaultTableModel extends AbstractTableModel
/**
* Returns the vector containing the row data for the table.
*
- * @returns The data vector.
+ * @return The data vector.
*/
public Vector getDataVector()
{
@@ -181,11 +181,11 @@ public class DefaultTableModel extends AbstractTableModel
*/
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());
- }
+ if (data == null)
+ dataVector = new Vector();
+ else
+ dataVector = data;
+ setColumnIdentifiers(columnNames);
}
/**
@@ -281,7 +281,7 @@ public class DefaultTableModel extends AbstractTableModel
* If <code>rowCount</code> is greater than the current number of rows in
* the table, new (empty) rows are added.
*
- * @param the row count.
+ * @param rowCount the row count.
*/
public void setRowCount(int rowCount)
{
@@ -319,7 +319,7 @@ public class DefaultTableModel extends AbstractTableModel
}
if (columnIdentifiers != null)
columnIdentifiers.setSize(columnCount);
- fireTableDataChanged();
+ fireTableStructureChanged();
}
/**
@@ -385,7 +385,7 @@ public class DefaultTableModel extends AbstractTableModel
((Vector) dataVector.get(i)).add(columnData == null ? null : columnData[i]);
}
columnIdentifiers.add(columnName);
- fireTableDataChanged();
+ fireTableStructureChanged();
}
/**
@@ -395,9 +395,10 @@ public class DefaultTableModel extends AbstractTableModel
* @param rowData the row data (<code>null</code> permitted).
*/
public void addRow(Vector rowData) {
+ int rowIndex = dataVector.size();
dataVector.add(rowData);
newRowsAdded(new TableModelEvent(
- this, dataVector.size(), dataVector.size(), -1, TableModelEvent.INSERT)
+ this, rowIndex, rowIndex, -1, TableModelEvent.INSERT)
);
}
@@ -450,7 +451,9 @@ public class DefaultTableModel extends AbstractTableModel
{
dataVector.insertElementAt(removed.get(i), toIndex);
}
- fireTableDataChanged();
+ int firstRow = Math.min(startIndex, toIndex);
+ int lastRow = Math.max(endIndex, toIndex + (endIndex - startIndex));
+ fireTableRowsUpdated(firstRow, lastRow);
}
/**
@@ -465,8 +468,9 @@ public class DefaultTableModel extends AbstractTableModel
}
/**
- * getRowCount
- * @returns int
+ * Returns the number of rows in the model.
+ *
+ * @return The row count.
*/
public int getRowCount() {
return dataVector.size();
@@ -486,7 +490,7 @@ public class DefaultTableModel extends AbstractTableModel
*
* @param column the column index.
*
- * @returns The column name.
+ * @return The column name.
*/
public String getColumnName(int column) {
String result = "";
@@ -502,6 +506,8 @@ public class DefaultTableModel extends AbstractTableModel
else
result = super.getColumnName(column);
}
+ else
+ result = super.getColumnName(column);
}
return result;
}
@@ -514,7 +520,7 @@ public class DefaultTableModel extends AbstractTableModel
* @param row the row index.
* @param column the column index.
*
- * @returns <code>true</code> in all cases.
+ * @return <code>true</code> in all cases.
*/
public boolean isCellEditable(int row, int column) {
return true;
@@ -526,8 +532,8 @@ public class DefaultTableModel extends AbstractTableModel
* @param row the row index.
* @param column the column index.
*
- * @returns The value (<code>Object</code>, possibly <code>null</code>) at
- * the specified cell in the table.
+ * @return The value (<code>Object</code>, possibly <code>null</code>) at
+ * the specified cell in the table.
*/
public Object getValueAt(int row, int column) {
return ((Vector) dataVector.get(row)).get(column);
@@ -551,8 +557,8 @@ public class DefaultTableModel extends AbstractTableModel
*
* @param data the data array (<code>null</code> permitted).
*
- * @returns A vector (or <code>null</code> if the data array
- * is <code>null</code>).
+ * @return A vector (or <code>null</code> if the data array
+ * is <code>null</code>).
*/
protected static Vector convertToVector(Object[] data) {
if (data == null)
@@ -566,10 +572,10 @@ public class DefaultTableModel extends AbstractTableModel
/**
* Converts the data array to a <code>Vector</code> of rows.
*
- * @param the data array (<code>null</code> permitted).
+ * @param data the data array (<code>null</code> permitted).
*
- * @returns A vector (or <code>null</code> if the data array
- * is <code>null</code>.
+ * @return A vector (or <code>null</code> if the data array
+ * is <code>null</code>.
*/
protected static Vector convertToVector(Object[][] data) {
if (data == null)
diff --git a/javax/swing/table/JTableHeader.java b/javax/swing/table/JTableHeader.java
index 0f538ed24..45586da20 100644
--- a/javax/swing/table/JTableHeader.java
+++ b/javax/swing/table/JTableHeader.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -356,11 +356,21 @@ public class JTableHeader extends JComponent
TableCellRenderer cellRenderer;
+ /**
+ * Creates a new default instance.
+ */
public JTableHeader()
{
this(null);
}
+ /**
+ * Creates a new header. If <code>cm</code> is <code>null</code>, a new
+ * table column model is created by calling
+ * {@link #createDefaultColumnModel()}.
+ *
+ * @param cm the table column model (<code>null</code> permitted).
+ */
public JTableHeader(TableColumnModel cm)
{
accessibleContext = new AccessibleJTableHeader();
@@ -377,6 +387,11 @@ public class JTableHeader extends JComponent
updateUI();
}
+ /**
+ * Creates a default table column model.
+ *
+ * @return A default table column model.
+ */
protected TableColumnModel createDefaultColumnModel()
{
return new DefaultTableColumnModel();
@@ -572,16 +587,31 @@ public class JTableHeader extends JComponent
updateTableInRealTime = u;
}
+ /**
+ * Creates a default renderer.
+ *
+ * @return A default renderer.
+ */
protected TableCellRenderer createDefaultRenderer()
{
return new DefaultTableCellRenderer();
}
-
+
+ /**
+ * Returns the default table cell renderer.
+ *
+ * @return The default table cell renderer.
+ */
public TableCellRenderer getDefaultRenderer()
{
return cellRenderer;
}
+ /**
+ * Sets the default table cell renderer.
+ *
+ * @param cellRenderer the renderer.
+ */
public void setDefaultRenderer(TableCellRenderer cellRenderer)
{
this.cellRenderer = cellRenderer;
@@ -621,6 +651,13 @@ public class JTableHeader extends JComponent
setUI((TableHeaderUI) UIManager.getUI(this));
}
+ /**
+ * Returns the index of the column at the specified point.
+ *
+ * @param point the point.
+ *
+ * @return The column index, or -1.
+ */
public int columnAtPoint(Point point)
{
if (getBounds().contains(point))
diff --git a/javax/swing/table/TableCellEditor.java b/javax/swing/table/TableCellEditor.java
index d83812c1a..b355311dc 100644
--- a/javax/swing/table/TableCellEditor.java
+++ b/javax/swing/table/TableCellEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/table/TableCellRenderer.java b/javax/swing/table/TableCellRenderer.java
index 580226b3f..639b4b9ad 100644
--- a/javax/swing/table/TableCellRenderer.java
+++ b/javax/swing/table/TableCellRenderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/table/TableColumn.java b/javax/swing/table/TableColumn.java
index c2de7f0e1..9c36bb05a 100644
--- a/javax/swing/table/TableColumn.java
+++ b/javax/swing/table/TableColumn.java
@@ -1,5 +1,5 @@
/* TableColumn.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,13 +38,16 @@ exception statement from your version. */
package javax.swing.table;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
import javax.swing.event.SwingPropertyChangeSupport;
/**
- * TableColumn
+ * Represents the attributes of a column in a table, including the column index,
+ * width, minimum width, preferred width and maximum width.
+ *
* @author Andrew Selkirk
* @version 1.0
*/
@@ -54,52 +57,53 @@ public class TableColumn
static final long serialVersionUID = -6113660025878112608L;
/**
- * COLUMN_WIDTH_PROPERTY
+ * The name for the <code>columnWidth</code> property. Note that the typo
+ * in the name value is deliberate, to match the specification.
*/
public static final String COLUMN_WIDTH_PROPERTY = "columWidth";
/**
- * HEADER_VALUE_PROPERTY
+ * The name for the <code>headerValue</code> property.
*/
public static final String HEADER_VALUE_PROPERTY = "headerValue";
/**
- * HEADER_RENDERER_PROPERTY
+ * The name for the <code>headerRenderer</code> property.
*/
public static final String HEADER_RENDERER_PROPERTY = "headerRenderer";
/**
- * CELL_RENDERER_PROPERTY
+ * The name for the <code>cellRenderer</code> property.
*/
public static final String CELL_RENDERER_PROPERTY = "cellRenderer";
/**
- * modelIndex
+ * The index of the corresponding column in the table model.
*/
protected int modelIndex;
/**
- * identifier
+ * The identifier for the column.
*/
protected Object identifier;
/**
- * width
+ * The width.
*/
protected int width;
/**
- * minWidth
+ * The minimum width.
*/
protected int minWidth = 15;
/**
- * preferredWidth
+ * The preferred width.
*/
private int preferredWidth;
/**
- * maxWidth
+ * The maximum width.
*/
protected int maxWidth = Integer.MAX_VALUE;
@@ -109,7 +113,7 @@ public class TableColumn
protected TableCellRenderer headerRenderer;
/**
- * headerValue
+ * The header value.
*/
protected Object headerValue;
@@ -142,7 +146,8 @@ public class TableColumn
new SwingPropertyChangeSupport(this);
/**
- * Constructor TableColumn
+ * Creates a new <code>TableColumn</code> that maps to column 0 in the
+ * related table model. The default width is <code>75</code> units.
*/
public TableColumn()
{
@@ -150,7 +155,8 @@ public class TableColumn
}
/**
- * Constructor TableColumn
+ * Creates a new <code>TableColumn</code> that maps to the specified column
+ * in the related table model. The default width is <code>75</code> units.
*
* @param modelIndex the index of the column in the model
*/
@@ -160,7 +166,8 @@ public class TableColumn
}
/**
- * Constructor TableColumn
+ * Creates a new <code>TableColumn</code> that maps to the specified column
+ * in the related table model, and has the specified <code>width</code>.
*
* @param modelIndex the index of the column in the model
* @param width the width
@@ -171,12 +178,14 @@ public class TableColumn
}
/**
- * Constructor TableColumn
+ * Creates a new <code>TableColumn</code> that maps to the specified column
+ * in the related table model, and has the specified <code>width</code>,
+ * <code>cellRenderer</code> and <code>cellEditor</code>.
*
* @param modelIndex the index of the column in the model
* @param width the width
- * @param cellRenderer the cell renderer
- * @param cellEditor the cell editor
+ * @param cellRenderer the cell renderer (<code>null</code> permitted).
+ * @param cellEditor the cell editor (<code>null</code> permitted).
*/
public TableColumn(int modelIndex, int width,
TableCellRenderer cellRenderer, TableCellEditor cellEditor)
@@ -230,9 +239,10 @@ public class TableColumn
}
/**
- * setModelIndex
+ * Sets the index of the column in the related {@link TableModel} that this
+ * <code>TableColumn</code> maps to.
*
- * @param modelIndex the index to set
+ * @param modelIndex the column index in the model.
*/
public void setModelIndex(int modelIndex)
{
@@ -240,7 +250,8 @@ public class TableColumn
}
/**
- * getModelIndex
+ * Returns the index of the column in the related {@link TableModel} that
+ * this <code>TableColumn</code> maps to.
*
* @return the model index
*/
@@ -250,7 +261,7 @@ public class TableColumn
}
/**
- * setIdentifier
+ * Sets the identifier for the column.
*
* @param identifier the identifier
*/
@@ -260,9 +271,11 @@ public class TableColumn
}
/**
- * getIdentifier
+ * Returns the identifier for the column, or {@link #getHeaderValue()} if the
+ * identifier is <code>null</code>.
*
- * @return the identifier
+ * @return The identifier (or {@link #getHeaderValue()} if the identifier is
+ * <code>null</code>).
*/
public Object getIdentifier()
{
@@ -272,7 +285,9 @@ public class TableColumn
}
/**
- * setHeaderValue
+ * Sets the header value and sends a {@link PropertyChangeEvent} to all
+ * registered listeners. The header value property uses the name
+ * {@link #HEADER_VALUE_PROPERTY}.
*
* @param headerValue the value of the header
*/
@@ -287,7 +302,7 @@ public class TableColumn
}
/**
- * getHeaderValue
+ * Returns the header value.
*
* @return the value of the header
*/
@@ -299,7 +314,7 @@ public class TableColumn
/**
* setHeaderRenderer
*
- * @param headerRenderer the renderer to se
+ * @param renderer the renderer to use
*/
public void setHeaderRenderer(TableCellRenderer renderer)
{
@@ -322,9 +337,10 @@ public class TableColumn
}
/**
- * setCellRenderer
+ * Sets the renderer for cells in this column and sends a
+ * {@link PropertyChangeEvent} to all registered listeners.
*
- * @param cellRenderer the cell renderer
+ * @param renderer the cell renderer (<code>null</code> permitted).
*/
public void setCellRenderer(TableCellRenderer renderer)
{
@@ -338,9 +354,9 @@ public class TableColumn
}
/**
- * getCellRenderer
+ * Returns the renderer for the table cells in this column.
*
- * @return the cell renderer
+ * @return The cell renderer.
*/
public TableCellRenderer getCellRenderer()
{
@@ -425,9 +441,10 @@ public class TableColumn
}
/**
- * setMinWidth
+ * Sets the minimum width for the column and, if necessary, updates the
+ * <code>width</code> and <code>preferredWidth</code>.
*
- * @param minWidth the minium width
+ * @param minWidth the minimum width
*/
public void setMinWidth(int minWidth)
{
@@ -437,9 +454,9 @@ public class TableColumn
}
/**
- * getMinWidth
+ * Returns the <code>TableColumn</code>'s minimum width.
*
- * @return the minimum width
+ * @return The minimum width.
*/
public int getMinWidth()
{
@@ -447,7 +464,8 @@ public class TableColumn
}
/**
- * setMaxWidth
+ * Sets the maximum width and, if necessary, updates the <code>width</code>
+ * and <code>preferredWidth</code>.
*
* @param maxWidth the maximum width
*/
@@ -459,8 +477,9 @@ public class TableColumn
}
/**
- * getMaxWidth
- * @return the maximim width
+ * Returns the maximum width.
+ *
+ * @return The maximum width.
*/
public int getMaxWidth()
{
@@ -498,8 +517,7 @@ public class TableColumn
}
/**
- * disableResizedPosting
- *
+ * This method is empty, unused and deprecated.
* @deprecated 1.3
*/
public void disableResizedPosting()
@@ -508,8 +526,7 @@ public class TableColumn
}
/**
- * enableResizedPosting
- *
+ * This method is empty, unused and deprecated.
* @deprecated 1.3
*/
public void enableResizedPosting()
@@ -518,8 +535,9 @@ public class TableColumn
}
/**
- * addPropertyChangeListener
- * @param listener the listener to all
+ * Adds a property change listener.
+ *
+ * @param listener the listener to add
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
{
@@ -536,6 +554,7 @@ public class TableColumn
}
/**
+ * Returns the property change listeners for this <code>TableColumn</code>.
* @since 1.4
*/
public PropertyChangeListener[] getPropertyChangeListeners()
diff --git a/javax/swing/table/TableColumnModel.java b/javax/swing/table/TableColumnModel.java
index 1c036d8a1..76a145604 100644
--- a/javax/swing/table/TableColumnModel.java
+++ b/javax/swing/table/TableColumnModel.java
@@ -1,5 +1,5 @@
/* TableColumnModel.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,29 +40,39 @@ package javax.swing.table;
import java.util.Enumeration;
+import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.TableColumnModelListener;
/**
- * TableColumnModel public interface
+ * The interface used by {@link JTable} to access the columns in the table
+ * view.
+ *
* @author Andrew Selkirk
*/
public interface TableColumnModel
{
/**
- * addColumn
- * @param column TableColumn
+ * Adds a column to the model.
+ *
+ * @param column the new column (<code>null</code> not permitted).
+ *
+ * @throws IllegalArgumentException if <code>column</code> is
+ * <code>null</code>.
*/
void addColumn(TableColumn column);
/**
- * removeColumn
+ * Removes a column from the model. If <code>column</code> is not defined
+ * in the model, this method does nothing.
+ *
* @param column TableColumn
*/
void removeColumn(TableColumn column);
/**
- * moveColumn
+ * Moves a column.
+ *
* @param columnIndex Index of column to move
* @param newIndex New index of column
*/
@@ -75,8 +85,9 @@ public interface TableColumnModel
void setColumnMargin(int margin);
/**
- * getColumnCount
- * @return Column count
+ * Returns the number of columns in the model.
+ *
+ * @return The column count
*/
int getColumnCount();
@@ -87,20 +98,30 @@ public interface TableColumnModel
Enumeration getColumns();
/**
- * getColumnIndex
- * @param columnIdentifier Column id
+ * Returns the index of the {@link TableColumn} with the given identifier.
+ *
+ * @param identifier the identifier (<code>null</code> not permitted).
+ *
+ * @return The index of the {@link TableColumn} with the given identifier.
+ *
+ * @throws IllegalArgumentException if <code>identifier</code> is
+ * <code>null</code> or there is no column with that identifier.
*/
int getColumnIndex(Object columnIdentifier);
/**
- * getColumn
- * @param columnIndex Index of column
+ * Returns the <code>TableColumn</code> at the specified index.
+ *
+ * @param columnIndex the column index.
+ *
+ * @return The table column.
*/
TableColumn getColumn(int columnIndex);
/**
- * getColumnMargin
- * @return Column margin
+ * Returns the column margin.
+ *
+ * @return The column margin.
*/
int getColumnMargin();
diff --git a/javax/swing/table/TableModel.java b/javax/swing/table/TableModel.java
index 591ce4342..016ae171d 100644
--- a/javax/swing/table/TableModel.java
+++ b/javax/swing/table/TableModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,8 +42,8 @@ import javax.swing.event.TableModelListener;
/**
* A <code>TableModel</code> is a two dimensional data structure that
* can store arbitrary <code>Object</code> instances, usually for the
- * purpose of display in a {@link JTable} component. Individual objects
- * can be accessed by specifying the row index and column index for
+ * purpose of display in a {@link javax.swing.JTable} component. Individual
+ * objects can be accessed by specifying the row index and column index for
* the object. Each column in the model has a name associated with it.
* <p>
* The {@link DefaultTableModel} class provides one implementation of
diff --git a/javax/swing/table/package.html b/javax/swing/table/package.html
index 93c6de184..84e6f1aa3 100644
--- a/javax/swing/table/package.html
+++ b/javax/swing/table/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.table package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.table</title></head>
<body>
-<p></p>
+<p>Interfaces and classes that support the {@link javax.swing.JTable}
+component.</p>
</body>
</html>
diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java
index efeb85db6..58d85732b 100644
--- a/javax/swing/text/AbstractDocument.java
+++ b/javax/swing/text/AbstractDocument.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -108,16 +108,7 @@ public abstract class AbstractDocument
public Position createPosition(final int offset) throws BadLocationException
{
- if (offset < 0 || offset > getLength())
- throw new BadLocationException(getText(0, getLength()), offset);
-
- return new Position()
- {
- public int getOffset()
- {
- return offset;
- }
- };
+ return content.createPosition(offset);
}
protected void fireChangedUpdate(DocumentEvent event)
@@ -847,15 +838,28 @@ public abstract class AbstractDocument
public class LeafElement extends AbstractElement
{
private static final long serialVersionUID = 5115368706941283802L;
- int start;
- int end;
+
+ /** Manages the start offset of this element. */
+ Position startPos;
+
+ /** Manages the end offset of this element. */
+ Position endPos;
public LeafElement(Element parent, AttributeSet attributes, int start,
int end)
{
super(parent, attributes);
- this.start = start;
- this.end = end;
+ try
+ {
+ startPos = parent.getDocument().createPosition(start);
+ endPos = parent.getDocument().createPosition(end);
+ }
+ catch (BadLocationException ex)
+ {
+ throw new AssertionError("BadLocationException must not be thrown "
+ + "here. start=" + start + ", end=" + end
+ + ", length=" + getLength());
+ }
}
public Enumeration children()
@@ -885,7 +889,7 @@ public abstract class AbstractDocument
public int getEndOffset()
{
- return end;
+ return endPos.getOffset();
}
public String getName()
@@ -895,7 +899,7 @@ public abstract class AbstractDocument
public int getStartOffset()
{
- return start;
+ return startPos.getOffset();
}
public boolean isLeaf()
diff --git a/javax/swing/text/AttributeSet.java b/javax/swing/text/AttributeSet.java
index 68d36bcf4..87e7b98af 100644
--- a/javax/swing/text/AttributeSet.java
+++ b/javax/swing/text/AttributeSet.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/BadLocationException.java b/javax/swing/text/BadLocationException.java
index 01463d139..e1a2ebcc6 100644
--- a/javax/swing/text/BadLocationException.java
+++ b/javax/swing/text/BadLocationException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/BoxView.java b/javax/swing/text/BoxView.java
new file mode 100644
index 000000000..79a3123bf
--- /dev/null
+++ b/javax/swing/text/BoxView.java
@@ -0,0 +1,87 @@
+/* BoxView.java -- An composite view
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Graphics;
+import java.awt.Shape;
+
+// TODO: Implement this class.
+public class BoxView
+ extends CompositeView
+{
+
+ /**
+ * Creates a new <code>BoxView</code> for the given
+ * <code>Element</code>.
+ *
+ * @param element the element that is rendered by this BoxView
+ */
+ public BoxView(Element element)
+ {
+ super(element);
+ }
+
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ // TODO: Implement me.
+ }
+
+
+ /**
+ * Returns the preferred span of the content managed by this
+ * <code>View</code> along the specified <code>axis</code>.
+ *
+ * @param axis the axis
+ *
+ * @return the preferred span of this <code>View</code>.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ // TODO: Implement me.
+ return 0F;
+ }
+}
diff --git a/javax/swing/text/Caret.java b/javax/swing/text/Caret.java
index 62263a62a..46072ef19 100644
--- a/javax/swing/text/Caret.java
+++ b/javax/swing/text/Caret.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/ChangedCharSetException.java b/javax/swing/text/ChangedCharSetException.java
index bf592a65a..7fba29a30 100644
--- a/javax/swing/text/ChangedCharSetException.java
+++ b/javax/swing/text/ChangedCharSetException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/ComponentView.java b/javax/swing/text/ComponentView.java
index 0305a7174..744d537ae 100644
--- a/javax/swing/text/ComponentView.java
+++ b/javax/swing/text/ComponentView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/CompositeView.java b/javax/swing/text/CompositeView.java
new file mode 100644
index 000000000..3dc46fc8e
--- /dev/null
+++ b/javax/swing/text/CompositeView.java
@@ -0,0 +1,84 @@
+/* CompositeView.java -- An abstract view that manages child views
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Shape;
+
+// TODO: Implement this class.
+public abstract class CompositeView
+ extends View
+{
+
+ /**
+ * Creates a new <code>CompositeView</code> for the given
+ * <code>Element</code>.
+ *
+ * @param element the element that is rendered by this CompositeView
+ */
+ public CompositeView(Element element)
+ {
+ super(element);
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ // Implement me.
+ return null;
+ }
+}
diff --git a/javax/swing/text/DateFormatter.java b/javax/swing/text/DateFormatter.java
new file mode 100644
index 000000000..869f9a090
--- /dev/null
+++ b/javax/swing/text/DateFormatter.java
@@ -0,0 +1,85 @@
+/* DateFormatter.java --
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.text;
+
+import java.text.DateFormat;
+
+/**
+ * <code>DateFormatter</code> is an {@link InternationalFormatter}
+ * that implements value to string and string to value conversion via
+ * an instance of {@link DateFormat}.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class DateFormatter extends InternationalFormatter
+{
+
+ /** The serialVersoinUID. */
+ private static final long serialVersionUID = 5423279572591848797L;
+
+ /**
+ * Creates a new instance using the default {@link DateFormat} object
+ * returned by {@link DateFormat#getDateInstance()}.
+ */
+ public DateFormatter()
+ {
+ this(DateFormat.getDateInstance());
+ }
+
+ /**
+ * Creates a new instance of <code>DateFormatter</code> using the
+ * specified <code>DateFormat</code>
+ *
+ * @param format the <code>DateFormat</code> to use
+ */
+ public DateFormatter(DateFormat format)
+ {
+ super();
+ setFormat(format);
+ }
+
+ /**
+ * Sets the format that is used by this <code>DateFormatter</code>.
+ *
+ * @param format the <code>DateFormat</code> to use
+ */
+ public void setFormat(DateFormat format)
+ {
+ super.setFormat(format);
+ }
+}
diff --git a/javax/swing/text/DefaultCaret.java b/javax/swing/text/DefaultCaret.java
index e4d51946f..b57b36563 100644
--- a/javax/swing/text/DefaultCaret.java
+++ b/javax/swing/text/DefaultCaret.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/DefaultEditorKit.java b/javax/swing/text/DefaultEditorKit.java
index 891731f36..aa2fbe850 100644
--- a/javax/swing/text/DefaultEditorKit.java
+++ b/javax/swing/text/DefaultEditorKit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -92,6 +92,16 @@ public class DefaultEditorKit extends EditorKit
}
}
+ /**
+ * This action is executed as default action when a KEY_TYPED
+ * event is received and no keymap entry exists for that. The purpose
+ * of this action is to filter out a couple of characters. This includes
+ * the control characters and characters with the ALT-modifier.
+ *
+ * If an event does not get filtered, it is inserted into the document
+ * of the text component. If there is some text selected in the text component,
+ * this text will be replaced.
+ */
public static class DefaultKeyTypedAction
extends TextAction
{
@@ -102,6 +112,13 @@ public class DefaultEditorKit extends EditorKit
public void actionPerformed(ActionEvent event)
{
+ // first we filter the following events:
+ // - control characters
+ // - key events with the ALT modifier (FIXME: filter that too!)
+ char c = event.getActionCommand().charAt(0);
+ if (Character.isISOControl(c))
+ return;
+
JTextComponent t = getTextComponent(event);
if (t != null)
{
@@ -119,6 +136,11 @@ public class DefaultEditorKit extends EditorKit
}
}
+ /**
+ * This action inserts a newline character into the document
+ * of the text component. This is typically triggered by hitting
+ * ENTER on the keyboard.
+ */
public static class InsertBreakAction
extends TextAction
{
@@ -129,6 +151,8 @@ public class DefaultEditorKit extends EditorKit
public void actionPerformed(ActionEvent event)
{
+ JTextComponent t = getTextComponent(event);
+ t.replaceSelection("\n");
}
}
diff --git a/javax/swing/text/DefaultFormatter.java b/javax/swing/text/DefaultFormatter.java
new file mode 100644
index 000000000..c97d90703
--- /dev/null
+++ b/javax/swing/text/DefaultFormatter.java
@@ -0,0 +1,429 @@
+/* DefaultFormatter.java --
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.text;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.text.ParseException;
+
+import javax.swing.JFormattedTextField;
+
+/**
+ * The <code>DefaultFormatter</code> is a concrete formatter for use in
+ * {@link JFormattedTextField}s.
+ *
+ * It can format arbitrary values by invoking
+ * their {@link Object#toString} method.
+ *
+ * In order to convert a String back to
+ * a value, the value class must provide a single argument constructor that
+ * takes a String object as argument value. If no such constructor is found,
+ * the String itself is passed back by #stringToValue.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class DefaultFormatter
+ extends JFormattedTextField.AbstractFormatter
+ implements Cloneable, Serializable
+{
+
+ /**
+ * A {@link DocumentFilter} that intercepts modification of the
+ * JFormattedTextField's Document and commits the value depending
+ * on the value of the <code>commitsOnValidEdit</code> property.
+ *
+ */
+ // FIXME: Handle allowsInvalid and overwriteMode properties
+ private class FormatterDocumentFilter
+ extends DocumentFilter
+ {
+ /**
+ * Invoked when text is removed from a text component.
+ *
+ * @param bypass the FilterBypass to use to mutate the document
+ * @param offset the start position of the modification
+ * @param length the length of the removed text
+ *
+ * @throws BadLocationException if offset or lenght are invalid in
+ * the Document
+ */
+ public void remove(DocumentFilter.FilterBypass bypass, int offset,
+ int length)
+ throws BadLocationException
+ {
+ super.remove(bypass, offset, length);
+ checkValidInput();
+ commitIfAllowed();
+ }
+
+ /**
+ * Invoked when text is inserted into a text component.
+ *
+ * @param bypass the FilterBypass to use to mutate the document
+ * @param offset the start position of the modification
+ * @param text the inserted text
+ * @param attributes the attributes of the inserted text
+ *
+ * @throws BadLocationException if offset or lenght are invalid in
+ * the Document
+ */
+ public void insertString(DocumentFilter.FilterBypass bypass, int offset,
+ String text, AttributeSet attributes)
+ throws BadLocationException
+ {
+ if (overwriteMode == true)
+ replace(bypass, offset, text.length(), text, attributes);
+ else
+ super.insertString(bypass, offset, text, attributes);
+ checkValidInput();
+ commitIfAllowed();
+ }
+
+ /**
+ * Invoked when text is replaced in a text component.
+ *
+ * @param bypass the FilterBypass to use to mutate the document
+ * @param offset the start position of the modification
+ * @param length the length of the removed text
+ * @param text the inserted text
+ * @param attributes the attributes of the inserted text
+ *
+ * @throws BadLocationException if offset or lenght are invalid in
+ * the Document
+ */
+ public void replace(DocumentFilter.FilterBypass bypass, int offset,
+ int length, String text, AttributeSet attributes)
+ throws BadLocationException
+ {
+ super.replace(bypass, offset, length, text, attributes);
+ checkValidInput();
+ commitIfAllowed();
+ }
+
+ /**
+ * Commits the value to the JTextTextField if the property
+ * <code>commitsOnValidEdit</code> is set to <code>true</code>.
+ */
+ private void commitIfAllowed()
+ {
+ if (commitsOnValidEdit == true)
+ try
+ {
+ getFormattedTextField().commitEdit();
+ }
+ catch (ParseException ex)
+ {
+ // ignore invalid edits
+ }
+ }
+
+ /**
+ * Checks if the value in the input field is valid. If the
+ * property allowsInvalid is set to <code>false</code>, then
+ * the string in the input field is not allowed to be entered.
+ *
+ * @param doc the document of the input field
+ * @param value the current (old) value of the input field
+ */
+ private void checkValidInput()
+ {
+ JFormattedTextField ftf = getFormattedTextField();
+ try
+ {
+ Object newval = stringToValue(ftf.getText());
+ }
+ catch (ParseException ex)
+ {
+ if (!allowsInvalid)
+ {
+ // roll back the input if invalid edits are not allowed
+ try
+ {
+ ftf.setText(valueToString(ftf.getValue()));
+ }
+ catch (ParseException pe)
+ {
+ // if that happens, something serious must be wrong
+ throw new AssertionError("values must be parseable");
+ }
+ }
+ }
+ }
+ }
+
+ /** The serialVersoinUID. */
+ private static final long serialVersionUID = -7369196326612908900L;
+
+ /**
+ * Indicates if the value should be committed after every
+ * valid modification of the Document.
+ */
+ boolean commitsOnValidEdit;
+
+ /**
+ * If <code>true</code> newly inserted characters overwrite existing
+ * values, otherwise insertion is done the normal way.
+ */
+ boolean overwriteMode;
+
+ /**
+ * If <code>true</code> invalid edits are allowed for a limited
+ * time.
+ */
+ boolean allowsInvalid;
+
+ /**
+ * The class that is used for values.
+ */
+ Class valueClass;
+
+ /**
+ * Creates a new instance of <code>DefaultFormatter</code>.
+ */
+ public DefaultFormatter()
+ {
+ commitsOnValidEdit = true;
+ overwriteMode = true;
+ allowsInvalid = true;
+ valueClass = Object.class;
+ }
+
+ /**
+ * Installs the formatter on the specified {@link JFormattedTextField}.
+ *
+ * This method does the following things:
+ * <ul>
+ * <li>Display the value of #valueToString in the
+ * <code>JFormattedTextField</code></li>
+ * <li>Install the Actions from #getActions on the <code>JTextField</code>
+ * </li>
+ * <li>Install the DocumentFilter returned by #getDocumentFilter</li>
+ * <li>Install the NavigationFilter returned by #getNavigationFilter</li>
+ * </ul>
+ *
+ * This method is typically not overridden by subclasses. Instead override
+ * one of the mentioned methods in order to customize behaviour.
+ *
+ * @param ftf the {@link JFormattedTextField} in which this formatter
+ * is installed
+ */
+ public void install(JFormattedTextField ftf)
+ {
+ super.install(ftf);
+ }
+
+ /**
+ * Returns <code>true</code> if the value should be committed after
+ * each valid modification of the input field, <code>false</code> if
+ * it should never be committed by this formatter.
+ *
+ * @return the state of the <code>commitsOnValidEdit</code> property
+ *
+ * @see #setCommitsOnValidEdit
+ */
+ public boolean getCommitsOnValidEdit()
+ {
+ return commitsOnValidEdit;
+ }
+
+ /**
+ * Sets the value of the <code>commitsOnValidEdit</code> property.
+ *
+ * @param commitsOnValidEdit the new state of the
+ * <code>commitsOnValidEdit</code> property
+ *
+ * @see #getCommitsOnValidEdit
+ */
+ public void setCommitsOnValidEdit(boolean commitsOnValidEdit)
+ {
+ this.commitsOnValidEdit = commitsOnValidEdit;
+ }
+
+ /**
+ * Returns the value of the <code>overwriteMode</code> property.
+ * If that is set to <code>true</code> then newly inserted characters
+ * overwrite existing values, otherwise the characters are inserted like
+ * normal. The default is <code>true</code>.
+ *
+ * @return the value of the <code>overwriteMode</code> property
+ */
+ public boolean getOverwriteMode()
+ {
+ return overwriteMode;
+ }
+
+ /**
+ * Sets the value of the <code>overwriteMode</code> property.
+ *
+ * If that is set to <code>true</code> then newly inserted characters
+ * overwrite existing values, otherwise the characters are inserted like
+ * normal. The default is <code>true</code>.
+ *
+ * @param overwriteMode the new value for the <code>overwriteMode</code>
+ * property
+ */
+ public void setOverwriteMode(boolean overwriteMode)
+ {
+ this.overwriteMode = overwriteMode;
+ }
+
+ /**
+ * Returns whether or not invalid edits are allowed or not. If invalid
+ * edits are allowed, the JFormattedTextField may temporarily contain invalid
+ * characters.
+ *
+ * @return the value of the allowsInvalid property
+ */
+ public boolean getAllowsInvalid()
+ {
+ return allowsInvalid;
+ }
+
+ /**
+ * Sets the value of the <code>allowsInvalid</code> property.
+ *
+ * @param allowsInvalid the new value for the property
+ *
+ * @see #getAllowsInvalid()
+ */
+ public void setAllowsInvalid(boolean allowsInvalid)
+ {
+ this.allowsInvalid = allowsInvalid;
+ }
+
+ /**
+ * Returns the class that is used for values. When Strings are converted
+ * back to values, this class is used to create new value objects.
+ *
+ * @return the class that is used for values
+ */
+ public Class getValueClass()
+ {
+ return valueClass;
+ }
+
+ /**
+ * Sets the class that is used for values.
+ *
+ * @param valueClass the class that is used for values
+ *
+ * @see #getValueClass()
+ */
+ public void setValueClass(Class valueClass)
+ {
+ this.valueClass = valueClass;
+ }
+
+ /**
+ * Converts a String (from the JFormattedTextField input) to a value.
+ * In order to achieve this, the formatter tries to instantiate an object
+ * of the class returned by #getValueClass() using a single argument
+ * constructor that takes a String argument. If such a constructor cannot
+ * be found, the String itself is returned.
+ *
+ * @param string the string to convert
+ *
+ * @return the value for the string
+ *
+ * @throws ParseException if the string cannot be converted into
+ * a value object (e.g. invalid input)
+ */
+ public Object stringToValue(String string)
+ throws ParseException
+ {
+ Object value = string;
+ Class valueClass = getValueClass();
+ if (valueClass == null)
+ valueClass = getFormattedTextField().getValue().getClass();
+ if (valueClass != null)
+ try
+ {
+ Constructor constr = valueClass.getConstructor
+ (new Class[]{String.class});
+ value = constr.newInstance(new Object[]{ string });
+ }
+ catch (NoSuchMethodException ex)
+ {
+ // leave value as string
+ }
+ catch (Exception ex)
+ {
+ throw new ParseException(string, 0);
+ }
+ return value;
+ }
+
+ /**
+ * Converts a value object into a String. This is done by invoking the
+ * {@link Object#toString()} method on the value.
+ *
+ * @param value the value to be converted
+ *
+ * @return the string representation of the value
+ *
+ * @throws ParseException if the value cannot be converted
+ */
+ public String valueToString(Object value)
+ throws ParseException
+ {
+ return value.toString();
+ }
+
+ /**
+ * Creates and returns a clone of this DefaultFormatter.
+ *
+ * @return a clone of this object
+ *
+ * @throws CloneNotSupportedException not thrown here
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ return super.clone();
+ }
+
+ /**
+ * Returns the DocumentFilter that is used to restrict input.
+ *
+ * @return the DocumentFilter that is used to restrict input
+ */
+ protected DocumentFilter getDocumentFilter()
+ {
+ return new FormatterDocumentFilter();
+ }
+}
diff --git a/javax/swing/text/DefaultHighlighter.java b/javax/swing/text/DefaultHighlighter.java
index 8d0491b66..c8d874caa 100644
--- a/javax/swing/text/DefaultHighlighter.java
+++ b/javax/swing/text/DefaultHighlighter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/DefaultStyledDocument.java b/javax/swing/text/DefaultStyledDocument.java
index 7b72ab246..14bb038a6 100644
--- a/javax/swing/text/DefaultStyledDocument.java
+++ b/javax/swing/text/DefaultStyledDocument.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -42,42 +42,174 @@ import java.awt.Color;
import java.awt.Font;
import java.io.Serializable;
+import javax.swing.event.DocumentEvent;
+
/**
+ * The default implementation of {@link StyledDocument}.
+ *
+ * The document is modeled as an {@link Element} tree, which has
+ * a {@link SecionElement} as single root, which has one or more
+ * {@link AbstractDocument.BranchElement}s as paragraph nodes
+ * and each paragraph node having one or more
+ * {@link AbstractDocument.LeafElement}s as content nodes.
+ *
* @author Michael Koch (konqueror@gmx.de)
+ * @author Roman Kennke (roman@kennke.org)
*/
public class DefaultStyledDocument extends AbstractDocument
implements StyledDocument
{
+ /**
+ * Performs all <em>structural</code> changes to the <code>Element</code>
+ * hierarchy.
+ */
public class ElementBuffer
implements Serializable
{
+ /** The root element of the hierarchy. */
private Element root;
-
+
+ /** Holds the offset for structural changes. */
+ private int offset;
+
+ /** Holds the length of structural changes. */
+ private int length;
+
+ /**
+ * Creates a new <code>ElementBuffer</code> for the specified
+ * <code>root</code> element.
+ *
+ * @param root the root element for this <code>ElementBuffer</code>
+ */
public ElementBuffer(Element root)
{
this.root = root;
}
+ /**
+ * Returns the root element of this <code>ElementBuffer</code>.
+ *
+ * @return the root element of this <code>ElementBuffer</code>
+ */
public Element getRootElement()
{
return root;
}
+
+ /**
+ * Modifies the element structure so that the specified interval starts
+ * and ends at an element boundary. Content and paragraph elements
+ * are split and created as necessary.
+ *
+ * This also updates the <code>DefaultDocumentEvent</code> to reflect the
+ * structural changes.
+ *
+ * The bulk work is delegated to {@link #changeUpdate()}.
+ *
+ * @param offset the start index of the interval to be changed
+ * @param length the length of the interval to be changed
+ * @param ev the <code>DefaultDocumentEvent</code> describing the change
+ */
+ public void change(int offset, int length, DefaultDocumentEvent ev)
+ {
+ this.offset = offset;
+ this.length = length;
+ changeUpdate();
+ }
+
+ /**
+ * Performs the actual work for {@link #change}.
+ * The elements at the interval boundaries are split up (if necessary)
+ * so that the interval boundaries are located at element boundaries.
+ */
+ protected void changeUpdate()
+ {
+ // Split up the element at the start offset if necessary.
+ Element el = getCharacterElement(offset);
+ split(el, offset);
+
+ int endOffset = offset + length;
+ el = getCharacterElement(endOffset);
+ split(el, endOffset);
+ }
+
+ /**
+ * Splits an element if <code>offset</code> is not alread at its boundary.
+ *
+ * @param el the Element to possibly split
+ * @param offset the offset at which to possibly split
+ */
+ void split(Element el, int offset)
+ {
+ if (el instanceof AbstractElement)
+ {
+ AbstractElement ael = (AbstractElement) el;
+ int startOffset = ael.getStartOffset();
+ int endOffset = ael.getEndOffset();
+ int len = endOffset - startOffset;
+ if (startOffset != offset && endOffset != offset)
+ {
+ Element paragraph = ael.getParentElement();
+ if (paragraph instanceof BranchElement)
+ {
+ BranchElement par = (BranchElement) paragraph;
+ Element child1 = createLeafElement(par, ael, startOffset,
+ offset);
+ Element child2 = createLeafElement(par, ael, offset,
+ endOffset);
+ int index = par.getElementIndex(startOffset);
+ par.replace(index, 1, new Element[]{ child1, child2 });
+ }
+ else
+ throw new AssertionError("paragraph elements are expected to "
+ + "be instances of "
+ + "javax.swing.text.AbstractDocument.BranchElement");
+ }
+ }
+ else
+ throw new AssertionError("content elements are expected to be "
+ + "instances of "
+ + "javax.swing.text.AbstractDocument.AbstractElement");
+ }
}
-
+
+ /**
+ * The default size to use for new content buffers.
+ */
public static final int BUFFER_SIZE_DEFAULT = 4096;
+ /**
+ * The <code>EditorBuffer</code> that is used to manage to
+ * <code>Element</code> hierarchy.
+ */
protected DefaultStyledDocument.ElementBuffer buffer;
-
+
+ /**
+ * Creates a new <code>DefaultStyledDocument</code>.
+ */
public DefaultStyledDocument()
{
this(new GapContent(BUFFER_SIZE_DEFAULT), new StyleContext());
}
+ /**
+ * Creates a new <code>DefaultStyledDocument</code> that uses the
+ * specified {@link StyleContext}.
+ *
+ * @param context the <code>StyleContext</code> to use
+ */
public DefaultStyledDocument(StyleContext context)
{
this(new GapContent(BUFFER_SIZE_DEFAULT), context);
}
+ /**
+ * Creates a new <code>DefaultStyledDocument</code> that uses the
+ * specified {@link StyleContext} and {@link Content} buffer.
+ *
+ * @param content the <code>Content</code> buffer to use
+ * @param context the <code>StyleContext</code> to use
+ */
public DefaultStyledDocument(AbstractDocument.Content content,
StyleContext context)
{
@@ -86,15 +218,38 @@ public class DefaultStyledDocument extends AbstractDocument
setLogicalStyle(0, context.getStyle(StyleContext.DEFAULT_STYLE));
}
+ /**
+ * Adds a style into the style hierarchy. Unspecified style attributes
+ * can be resolved in the <code>parent</code> style, if one is specified.
+ *
+ * While it is legal to add nameless styles (<code>nm == null</code),
+ * you must be aware that the client application is then responsible
+ * for managing the style hierarchy, since unnamed styles cannot be
+ * looked up by their name.
+ *
+ * @param nm the name of the style or <code>null</code> if the style should
+ * be unnamed
+ * @param parent the parent in which unspecified style attributes are
+ * resolved, or <code>null</code> if that is not necessary
+ *
+ * @return the newly created <code>Style</code>
+ */
public Style addStyle(String nm, Style parent)
{
StyleContext context = (StyleContext) getAttributeContext();
return context.addStyle(nm, parent);
}
-
+
+ /**
+ * Create the default root element for this kind of <code>Document</code>.
+ *
+ * @return the default root element for this kind of <code>Document</code>
+ */
protected AbstractDocument.AbstractElement createDefaultRoot()
{
Element[] tmp;
+ // FIXME: Create a SecionElement here instead of a BranchElement.
+ // Use createBranchElement() and createLeafElement instead.
BranchElement section = new BranchElement(null, null);
BranchElement paragraph = new BranchElement(section, null);
@@ -109,7 +264,17 @@ public class DefaultStyledDocument extends AbstractDocument
return section;
}
-
+
+ /**
+ * Returns the <code>Element</code> that corresponds to the character
+ * at the specified position.
+ *
+ * @param position the position of which we query the corresponding
+ * <code>Element</code>
+ *
+ * @return the <code>Element</code> that corresponds to the character
+ * at the specified position
+ */
public Element getCharacterElement(int position)
{
Element element = getDefaultRootElement();
@@ -122,63 +287,172 @@ public class DefaultStyledDocument extends AbstractDocument
return element;
}
-
+
+ /**
+ * Extracts a background color from a set of attributes.
+ *
+ * @param attributes the attributes from which to get a background color
+ *
+ * @return the background color that correspond to the attributes
+ */
public Color getBackground(AttributeSet attributes)
{
StyleContext context = (StyleContext) getAttributeContext();
return context.getBackground(attributes);
}
-
+
+ /**
+ * Returns the default root element.
+ *
+ * @return the default root element
+ */
public Element getDefaultRootElement()
{
return buffer.getRootElement();
}
-
+
+ /**
+ * Extracts a font from a set of attributes.
+ *
+ * @param attributes the attributes from which to get a font
+ *
+ * @return the font that correspond to the attributes
+ */
public Font getFont(AttributeSet attributes)
{
StyleContext context = (StyleContext) getAttributeContext();
return context.getFont(attributes);
}
+ /**
+ * Extracts a foreground color from a set of attributes.
+ *
+ * @param attributes the attributes from which to get a foreground color
+ *
+ * @return the foreground color that correspond to the attributes
+ */
public Color getForeground(AttributeSet attributes)
{
StyleContext context = (StyleContext) getAttributeContext();
return context.getForeground(attributes);
}
-
+
+ /**
+ * Returns the logical <code>Style</code> for the specified position.
+ *
+ * @param position the position from which to query to logical style
+ *
+ * @return the logical <code>Style</code> for the specified position
+ */
public Style getLogicalStyle(int position)
{
Element paragraph = getParagraphElement(position);
AttributeSet attributes = paragraph.getAttributes();
return (Style) attributes.getResolveParent();
}
-
+
+ /**
+ * Returns the paragraph element for the specified position.
+ *
+ * @param position the position for which to query the paragraph element
+ *
+ * @return the paragraph element for the specified position
+ */
public Element getParagraphElement(int position)
{
Element element = getCharacterElement(position);
return element.getParentElement();
}
+ /**
+ * Looks up and returns a named <code>Style</code>.
+ *
+ * @param nm the name of the <code>Style</code>
+ *
+ * @return the found <code>Style</code> of <code>null</code> if no such
+ * <code>Style</code> exists
+ */
public Style getStyle(String nm)
{
StyleContext context = (StyleContext) getAttributeContext();
return context.getStyle(nm);
}
+ /**
+ * Removes a named <code>Style</code> from the style hierarchy.
+ *
+ * @param nm the name of the <code>Style</code> to be removed
+ */
public void removeStyle(String nm)
{
StyleContext context = (StyleContext) getAttributeContext();
context.removeStyle(nm);
}
+ /**
+ * Sets text attributes for the fragment specified by <code>offset</code>
+ * and <code>length</code>.
+ *
+ * @param offset the start offset of the fragment
+ * @param length the length of the fragment
+ * @param attribute the text attributes to set
+ * @param replace if <code>true</code>, the attributes of the current
+ * selection are overridden, otherwise they are merged
+ */
public void setCharacterAttributes(int offset, int length,
AttributeSet attributes,
boolean replace)
{
- // FIXME: Implement me.
- throw new Error("not implemented");
+ DefaultDocumentEvent ev =
+ new DefaultDocumentEvent(offset, length,
+ DocumentEvent.EventType.CHANGE);
+
+ // Modify the element structure so that the interval begins at an element
+ // start and ends at an element end.
+ buffer.change(offset, length, ev);
+
+ Element root = getDefaultRootElement();
+ // Visit all paragraph elements within the specified interval
+ int paragraphCount = root.getElementCount();
+ for (int pindex = 0; pindex < paragraphCount; pindex++)
+ {
+ Element paragraph = root.getElement(pindex);
+ // Skip paragraphs that lie outside the interval.
+ if ((paragraph.getStartOffset() > offset + length)
+ || (paragraph.getEndOffset() < offset))
+ continue;
+
+ // Visit content elements within this paragraph
+ int contentCount = paragraph.getElementCount();
+ for (int cindex = 0; cindex < contentCount; cindex++)
+ {
+ Element content = paragraph.getElement(cindex);
+ // Skip content that lies outside the interval.
+ if ((content.getStartOffset() > offset + length)
+ || (content.getEndOffset() < offset))
+ continue;
+
+ if (content instanceof AbstractElement)
+ {
+ AbstractElement el = (AbstractElement) content;
+ if (replace)
+ el.removeAttributes(el);
+ el.addAttributes(attributes);
+ }
+ else
+ throw new AssertionError("content elements are expected to be"
+ + "instances of "
+ + "javax.swing.text.AbstractDocument.AbstractElement");
+ }
+ }
}
+ /**
+ * Sets the logical style for the paragraph at the specified position.
+ *
+ * @param position the position at which the logical style is added
+ * @param style the style to set for the current paragraph
+ */
public void setLogicalStyle(int position, Style style)
{
Element el = getParagraphElement(position);
@@ -192,6 +466,15 @@ public class DefaultStyledDocument extends AbstractDocument
+ "instances of javax.swing.text.AbstractDocument.AbstractElement");
}
+ /**
+ * Sets text attributes for the paragraph at the specified fragment.
+ *
+ * @param offset the beginning of the fragment
+ * @param length the length of the fragment
+ * @param attribute the text attributes to set
+ * @param replace if <code>true</code>, the attributes of the current
+ * selection are overridden, otherwise they are merged
+ */
public void setParagraphAttributes(int offset, int length,
AttributeSet attributes,
boolean replace)
diff --git a/javax/swing/text/Document.java b/javax/swing/text/Document.java
index d299f68a2..f23767f58 100644
--- a/javax/swing/text/Document.java
+++ b/javax/swing/text/Document.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/DocumentFilter.java b/javax/swing/text/DocumentFilter.java
index ff96d0729..f86f41ca6 100644
--- a/javax/swing/text/DocumentFilter.java
+++ b/javax/swing/text/DocumentFilter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/EditorKit.java b/javax/swing/text/EditorKit.java
index 5d89a11ba..bd51a866f 100644
--- a/javax/swing/text/EditorKit.java
+++ b/javax/swing/text/EditorKit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/Element.java b/javax/swing/text/Element.java
index 9f6161264..eb53ee9d3 100644
--- a/javax/swing/text/Element.java
+++ b/javax/swing/text/Element.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/FieldView.java b/javax/swing/text/FieldView.java
index e81a19fe5..4d5c51ceb 100644
--- a/javax/swing/text/FieldView.java
+++ b/javax/swing/text/FieldView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/FlowView.java b/javax/swing/text/FlowView.java
new file mode 100644
index 000000000..cf139341b
--- /dev/null
+++ b/javax/swing/text/FlowView.java
@@ -0,0 +1,56 @@
+/* FlowView.java -- A composite View
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+// TODO: Implement this class.
+public class FlowView
+ extends BoxView
+{
+
+ /**
+ * Creates a new <code>FlowView</code> for the given
+ * <code>Element</code>.
+ *
+ * @param element the element that is rendered by this FlowView
+ */
+ public FlowView(Element element)
+ {
+ super(element);
+ }
+}
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
index 111617e94..94084800c 100644
--- a/javax/swing/text/GapContent.java
+++ b/javax/swing/text/GapContent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -39,6 +39,9 @@ exception statement from your version. */
package javax.swing.text;
import java.io.Serializable;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.ListIterator;
import javax.swing.undo.UndoableEdit;
@@ -57,6 +60,67 @@ import javax.swing.undo.UndoableEdit;
public class GapContent
implements AbstractDocument.Content, Serializable
{
+
+ /**
+ * A {@link Position} implementation for <code>GapContent</code>.
+ */
+ class GapContentPosition implements Position, Comparable
+ {
+
+ /** The index within the buffer array. */
+ int mark;
+
+ /**
+ * Creates a new GapContentPosition object.
+ *
+ * @param mark the mark of this Position
+ */
+ GapContentPosition(int mark)
+ {
+ this.mark = mark;
+ }
+
+ /**
+ * Comparable interface implementation. This is used to store all
+ * positions in an ordered fashion.
+ *
+ * @param o the object to be compared to this
+ *
+ * @return a negative integer if this is less than <code>o</code>, zero
+ * if both are equal or a positive integer if this is greater
+ * than <code>o</code>
+ *
+ * @throws ClassCastException if <code>o</code> is not a GapContentPosition
+ * or Integer object
+ */
+ public int compareTo(Object o)
+ {
+ if (o instanceof Integer)
+ {
+ int otherMark = ((Integer) o).intValue();
+ return mark - otherMark;
+ }
+ else
+ {
+ GapContentPosition other = (GapContentPosition) o;
+ return mark - other.mark;
+ }
+ }
+
+ /**
+ * Returns the current offset of this Position within the content.
+ *
+ * @return the current offset of this Position within the content.
+ */
+ public int getOffset()
+ {
+ if (mark <= gapStart)
+ return mark;
+ else
+ return mark - (gapEnd - gapStart);
+ }
+ }
+
private static final long serialVersionUID = 8374645204155842629L;
/**
@@ -81,6 +145,12 @@ public class GapContent
int gapEnd;
/**
+ * The positions generated by this GapContent. They are kept in an
+ * ordered fashion, so they can be looked up easily.
+ */
+ LinkedList positions;
+
+ /**
* Creates a new GapContent object.
*/
public GapContent()
@@ -99,6 +169,7 @@ public class GapContent
gapStart = 0;
gapEnd = size - 1;
buffer[size - 1] = '\n';
+ positions = new LinkedList();
}
/**
@@ -288,15 +359,24 @@ public class GapContent
*/
public Position createPosition(final int offset) throws BadLocationException
{
- return new Position()
- {
- int off = offset;
-
- public int getOffset()
- {
- return off;
- }
- };
+ if (offset < 0 || offset > length())
+ throw new BadLocationException("The offset was out of the bounds of this"
+ + " buffer", offset);
+
+ // We store the actual array index in the GapContentPosition. The real
+ // offset is then calculated in the GapContentPosition.
+ int mark = offset;
+ if (offset > gapStart)
+ mark += gapEnd - gapStart;
+ GapContentPosition pos = new GapContentPosition(mark);
+
+ // Add this into our list in a sorted fashion.
+ int index = Collections.binarySearch(positions, pos);
+ if (index < 0)
+ index = -(index + 1);
+ positions.add(index, pos);
+
+ return pos;
}
/**
@@ -309,12 +389,25 @@ public class GapContent
*/
protected void shiftEnd(int newSize)
{
+ int delta = (gapEnd - gapStart) - newSize;
char[] newBuf = (char[]) allocateArray(length() + newSize);
System.arraycopy(buffer, 0, newBuf, 0, gapStart);
System.arraycopy(buffer, gapEnd, newBuf, gapStart + newSize,
buffer.length - gapEnd);
gapEnd = gapStart + newSize;
buffer = newBuf;
+
+ // Update the marks after the gapEnd.
+ int index = Collections.binarySearch(positions, new Integer(gapEnd));
+ if (index < 0)
+ {
+ index = -(index + 1);
+ }
+ for (ListIterator i = positions.listIterator(index); i.hasNext();)
+ {
+ GapContentPosition p = (GapContentPosition) i.next();
+ p.mark += delta;
+ }
}
/**
@@ -326,6 +419,22 @@ public class GapContent
{
int newGapEnd = newGapStart + (gapEnd - gapStart);
+
+ // Update the positions between newGapEnd and (old) gapEnd. The marks
+ // must be shifted by (gapEnd - newGapEnd).
+ int index1 = Collections.binarySearch(positions, new Integer(gapEnd));
+ int index2 = Collections.binarySearch(positions, new Integer(newGapEnd));
+ int i1 = Math.min(index1, index2);
+ int i2 = Math.max(index1, index2);
+ for (ListIterator i = positions.listIterator(i1); i.hasNext();)
+ {
+ if (i.nextIndex() > i2)
+ break;
+
+ GapContentPosition p = (GapContentPosition) i.next();
+ p.mark += gapEnd - newGapEnd;
+ }
+
if (newGapStart == gapStart)
return;
else if (newGapStart < gapStart)
@@ -353,4 +462,28 @@ public class GapContent
{
return buffer;
}
+
+ /**
+ * Replaces a portion of the storage with the specified items.
+ *
+ * @param position the position at which to remove items
+ * @param rmSize the number of items to remove
+ * @param addItems the items to add at location
+ * @param addSize the number of items to add
+ */
+ protected void replace(int position, int rmSize, Object addItems,
+ int addSize)
+ {
+ // Remove content
+ shiftGap(position);
+ gapEnd += rmSize;
+
+ // If gap is too small, enlarge the gap.
+ if ((gapEnd - gapStart) < addSize)
+ shiftEnd(addSize);
+
+ // Add new items to the buffer.
+ System.arraycopy(addItems, 0, buffer, gapStart, addSize);
+ gapStart += addSize;
+ }
}
diff --git a/javax/swing/text/GlyphView.java b/javax/swing/text/GlyphView.java
new file mode 100644
index 000000000..f96a918ca
--- /dev/null
+++ b/javax/swing/text/GlyphView.java
@@ -0,0 +1,111 @@
+/* GlyphView.java -- A view to render styled text
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Graphics;
+import java.awt.Shape;
+
+// TODO: Implement this class.
+public class GlyphView
+ extends View
+{
+
+ /**
+ * Creates a new <code>GlyphView</code> for the given <code>Element</code>.
+ *
+ * @param element the element that is rendered by this GlyphView
+ */
+ public GlyphView(Element element)
+ {
+ super(element);
+ }
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ // TODO: Implement me.
+ }
+
+
+ /**
+ * Returns the preferred span of the content managed by this
+ * <code>View</code> along the specified <code>axis</code>.
+ *
+ * @param axis the axis
+ *
+ * @return the preferred span of this <code>View</code>.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ // TODO: Implement me.
+ return 0F;
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ // Implement me.
+ return null;
+ }
+}
diff --git a/javax/swing/text/Highlighter.java b/javax/swing/text/Highlighter.java
index affec9b7a..91f3b7903 100644
--- a/javax/swing/text/Highlighter.java
+++ b/javax/swing/text/Highlighter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/IconView.java b/javax/swing/text/IconView.java
new file mode 100644
index 000000000..4bbebdb52
--- /dev/null
+++ b/javax/swing/text/IconView.java
@@ -0,0 +1,110 @@
+/* IconView.java -- A view to render icons
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+import java.awt.Graphics;
+import java.awt.Shape;
+
+// TODO: Implement this class.
+public class IconView
+ extends View
+{
+
+ /**
+ * Creates a new <code>IconView</code> for the given <code>Element</code>.
+ *
+ * @param element the element that is rendered by this IconView
+ */
+ public IconView(Element element)
+ {
+ super(element);
+ }
+
+ /**
+ * Renders the <code>Element</code> that is associated with this
+ * <code>View</code>.
+ *
+ * @param g the <code>Graphics</code> context to render to
+ * @param a the allocated region for the <code>Element</code>
+ */
+ public void paint(Graphics g, Shape a)
+ {
+ // TODO: Implement me.
+ }
+
+ /**
+ * Returns the preferred span of the content managed by this
+ * <code>View</code> along the specified <code>axis</code>.
+ *
+ * @param axis the axis
+ *
+ * @return the preferred span of this <code>View</code>.
+ */
+ public float getPreferredSpan(int axis)
+ {
+ // TODO: Implement me.
+ return 0F;
+ }
+
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException
+ {
+ // Implement me.
+ return null;
+ }
+}
diff --git a/javax/swing/text/InternationalFormatter.java b/javax/swing/text/InternationalFormatter.java
new file mode 100644
index 000000000..cedaf59fe
--- /dev/null
+++ b/javax/swing/text/InternationalFormatter.java
@@ -0,0 +1,354 @@
+/* InternationalFormatter.java --
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.text;
+
+import java.text.AttributedCharacterIterator;
+import java.text.Format;
+import java.text.ParseException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.swing.Action;
+import javax.swing.JFormattedTextField;
+
+/**
+ * This extends {@link DefaultFormatter} so that the value to string
+ * conversion is done via a {@link Format} object. This allows
+ * various additional formats to be handled by JFormattedField.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class InternationalFormatter
+ extends DefaultFormatter
+{
+
+ /** The serialVersoinUID. */
+ private static final long serialVersionUID = 6941977820906408656L;
+
+ /** The format that handles value to string conversion. */
+ Format format;
+
+ /** The minimal permissable value. */
+ Comparable minimum;
+
+ /** The maximal permissable value. */
+ Comparable maximum;
+
+ /**
+ * Creates a new InternationalFormatter with no Format specified.
+ */
+ public InternationalFormatter()
+ {
+ super();
+ minimum = null;
+ maximum = null;
+ format = null;
+ }
+
+ /**
+ * Creates a new InternationalFormatter that uses the specified
+ * Format object for value to string conversion.
+ *
+ * @param format the Format object to use for value to string conversion
+ */
+ public InternationalFormatter(Format format)
+ {
+ this();
+ setFormat(format);
+ }
+
+ /**
+ * Sets the Format object that is used to convert values to strings.
+ *
+ * @param format the Format to use for value to string conversion
+ *
+ * @see Format
+ */
+ public void setFormat(Format format)
+ {
+ this.format = format;
+ }
+
+ /**
+ * Returns the currently used Format object that is used to format
+ * the JFormattedField.
+ *
+ * @return the current Format
+ */
+ public Format getFormat()
+ {
+ return format;
+ }
+
+ /**
+ * Sets the minimum value that is allowed by this Formatter. The minimum
+ * value is given as an object that implements the {@link Comparable}
+ * interface.
+ *
+ * If <code>minValue</code> is null, then the Formatter has no restrictions
+ * at the lower end.
+ *
+ * If value class is not yet specified and <code>minValue</code> is not
+ * null, then <code>valueClass</code> is set to the class of the minimum
+ * value.
+ *
+ * @param minValue the minimum permissable value
+ *
+ * @see Comparable
+ */
+ public void setMinimum(Comparable minValue)
+ {
+ minimum = minValue;
+ if (valueClass == null && minValue != null)
+ valueClass = minValue.getClass();
+ }
+
+ /**
+ * Returns the minimal value that is allowed by this Formatter.
+ *
+ * A <code>null</code> value means that there is no restriction.
+ *
+ * @return the minimal value that is allowed by this Formatter or
+ * <code>null</code> if there is no restriction
+ */
+ public Comparable getMinimum()
+ {
+ return minimum;
+ }
+
+ /**
+ * Sets the maximum value that is allowed by this Formatter. The maximum
+ * value is given as an object that implements the {@link Comparable}
+ * interface.
+ *
+ * If <code>maxValue</code> is null, then the Formatter has no restrictions
+ * at the upper end.
+ *
+ * If value class is not yet specified and <code>maxValue</code> is not
+ * null, then <code>valueClass</code> is set to the class of the maximum
+ * value.
+ *
+ * @param maxValue the maximum permissable value
+ *
+ * @see Comparable
+ */
+ public void setMaximum(Comparable maxValue)
+ {
+ maximum = maxValue;
+ if (valueClass == null && maxValue != null)
+ valueClass = maxValue.getClass();
+ }
+
+ /**
+ * Returns the maximal value that is allowed by this Formatter.
+ *
+ * A <code>null</code> value means that there is no restriction.
+ *
+ * @return the maximal value that is allowed by this Formatter or
+ * <code>null</code> if there is no restriction
+ */
+ public Comparable getMaximum()
+ {
+ return maximum;
+ }
+
+ /**
+ * Installs the formatter on the specified {@link JFormattedTextField}.
+ *
+ * This method does the following things:
+ * <ul>
+ * <li>Display the value of #valueToString in the
+ * <code>JFormattedTextField</code></li>
+ * <li>Install the Actions from #getActions on the <code>JTextField</code>
+ * </li>
+ * <li>Install the DocumentFilter returned by #getDocumentFilter</li>
+ * <li>Install the NavigationFilter returned by #getNavigationFilter</li>
+ * </ul>
+ *
+ * This method is typically not overridden by subclasses. Instead override
+ * one of the mentioned methods in order to customize behaviour.
+ *
+ * @param ftf the {@link JFormattedTextField} in which this formatter
+ * is installed
+ */
+ public void install(JFormattedTextField ftf)
+ {
+ super.install(ftf);
+ }
+
+ /**
+ * Converts a value object into a String. This is done by invoking
+ * {@link Format#format(Object)} on the specified <code>Format</code> object.
+ * If no format is set, then {@link DefaultFormatter#valueToString(Object)}
+ * is called as a fallback.
+ *
+ * @param value the value to be converted
+ *
+ * @return the string representation of the value
+ *
+ * @throws ParseException if the value cannot be converted
+ */
+ public String valueToString(Object value)
+ throws ParseException
+ {
+ if (format != null)
+ return format.format(value);
+ else
+ return super.valueToString(value);
+ }
+
+ /**
+ * Converts a String (from the JFormattedTextField input) to a value.
+ * This is achieved by invoking {@link Format#parseObject(String)} on
+ * the specified <code>Format</code> object.
+ *
+ * This implementation differs slightly from {@link DefaultFormatter},
+ * it does:
+ * <ol>
+ * <li>Convert the string to an <code>Object</code> using the
+ * <code>Formatter</code>.</li>
+ * <li>If a <code>valueClass</code> has been set, this object is passed to
+ * {@link DefaultFormatter#stringToValue(String)} so that the value
+ * has the correct type. This may or may not work correctly, depending on
+ * the implementation of toString() in the value class and if the class
+ * implements a constructor that takes one String as argument.</li>
+ * <li>If no {@link ParseException} has been thrown so far, we check if the
+ * value exceeds either <code>minimum</code> or <code>maximum</code> if
+ * one of those has been specified and throw a <code>ParseException</code>
+ * if it does.</li>
+ * <li>Return the value.</li>
+ * </ol>
+ *
+ * If no format has been specified, then
+ * {@link DefaultFormatter#stringToValue(String)} is invoked as fallback.
+ *
+ * @param string the string to convert
+ *
+ * @return the value for the string
+ *
+ * @throws ParseException if the string cannot be converted into
+ * a value object (e.g. invalid input)
+ */
+ public Object stringToValue(String string)
+ throws ParseException
+ {
+ if (format != null)
+ {
+ Object o = format.parseObject(string);
+
+ // If a value class has been set, call super in order to get
+ // the class right. That is what the JDK API docs suggest, so we do
+ // it that way.
+ if (valueClass != null)
+ o = super.stringToValue(o.toString());
+
+ // Check for minimum and maximum bounds
+ if (minimum != null && minimum.compareTo(o) > 0)
+ throw new ParseException("The value may not be less than the"
+ + " specified minimum", 0);
+ if (maximum != null && minimum.compareTo(o) < 0)
+ throw new ParseException("The value may not be greater than the"
+ + " specified maximum", 0);
+ return o;
+ }
+ else
+ return super.stringToValue(string);
+ }
+
+ /**
+ * Returns the {@link Format.Field} constants that are associated with
+ * the specified position in the text.
+ *
+ * If <code>offset</code> is not a valid location in the input field,
+ * an empty array of fields is returned.
+ *
+ * @param offset the position in the text from which we want to fetch
+ * the fields constants
+ *
+ * @return the field values associated with the specified position in
+ * the text
+ */
+ public Format.Field[] getFields(int offset)
+ {
+ // TODO: don't know if this is correct
+ AttributedCharacterIterator aci = format.formatToCharacterIterator
+ (getFormattedTextField().getValue());
+ aci.setIndex(offset);
+ Map atts = aci.getAttributes();
+ Set keys = atts.keySet();
+ Format.Field[] fields = new Format.Field[keys.size()];
+ int index = 0;
+ for (Iterator i = keys.iterator(); i.hasNext(); index++)
+ fields[index] = (Format.Field) i.next();
+ return fields;
+ }
+
+ /**
+ * This creates and returns a clone of this Formatter.
+ *
+ * @return a clone of this formatter
+ *
+ * @throws CloneNotSupportedException not thrown here, since cloning is
+ * supported
+ * XXX - FIXME - Whole method disabled as workaround for gcj bug #22060.
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ // TODO: it has to be considered, if we should return a deep or shallow
+ // clone here. for now we return a shallow clone
+ Object clone = super.clone();
+ return clone;
+ }
+ */
+
+ /**
+ * Returns the Actions that are supported by this Formatter.
+ *
+ * @specnote the JDK API docs say here: <cite>If
+ * <code>getSupportsIncrement</code> returns true, this returns two
+ * Actions suitable for incrementing/decrementing the value.</cite>
+ * The questsion is, which method <code>getSupportsIncrement</code>?
+ * There is no such method in the whole API! So we just call
+ * super.getActions here.
+ */
+ public Action[] getActions()
+ {
+ return super.getActions();
+ }
+}
diff --git a/javax/swing/text/JTextComponent.java b/javax/swing/text/JTextComponent.java
index 0e0256d3b..b3fad7912 100644
--- a/javax/swing/text/JTextComponent.java
+++ b/javax/swing/text/JTextComponent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -54,6 +54,8 @@ import java.awt.event.ActionListener;
import java.awt.event.InputMethodListener;
import java.awt.event.KeyEvent;
import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -94,7 +96,6 @@ public abstract class JTextComponent extends JComponent
/**
* Constructor AccessibleJTextComponent
- * @param component TODO
*/
public AccessibleJTextComponent()
{
@@ -320,7 +321,9 @@ public abstract class JTextComponent extends JComponent
*/
public void actionPerformed(ActionEvent ev)
{
- caret.setVisible(!caret.isVisible());
+ Caret c = caret;
+ if (c != null)
+ c.setVisible(!c.isVisible());
}
/**
@@ -329,11 +332,15 @@ public abstract class JTextComponent extends JComponent
public void update()
{
stop();
- setDelay(caret.getBlinkRate());
- if (editable)
- start();
- else
- caret.setVisible(false);
+ Caret c = caret;
+ if (c != null)
+ {
+ setDelay(c.getBlinkRate());
+ if (editable)
+ start();
+ else
+ c.setVisible(false);
+ }
}
}
@@ -704,8 +711,8 @@ public abstract class JTextComponent extends JComponent
* @return A Keymap associated with the provided name, or
* <code>null</code> if no such Keymap exists
*
- * @see #addKeymap()
- * @see #removeKeymap()
+ * @see #addKeymap
+ * @see #removeKeymap
* @see #keymaps
*/
public static Keymap getKeymap(String n)
@@ -720,7 +727,7 @@ public abstract class JTextComponent extends JComponent
*
* @return The keymap removed from the global table
*
- * @see #addKeymap()
+ * @see #addKeymap
* @see #getKeymap()
* @see #keymaps
*/
@@ -743,7 +750,7 @@ public abstract class JTextComponent extends JComponent
*
* @return The newly created Keymap
*
- * @see #removeKeymap()
+ * @see #removeKeymap
* @see #getKeymap()
* @see #keymaps
*/
@@ -761,7 +768,7 @@ public abstract class JTextComponent extends JComponent
*
* @return The component's current Keymap
*
- * @see #setKeymap()
+ * @see #setKeymap
* @see #keymap
*/
public Keymap getKeymap()
@@ -893,8 +900,8 @@ public abstract class JTextComponent extends JComponent
* @param actions The set of actions to resolve binding names against
*
* @see Action#NAME
- * @see Action#getValue()
- * @see KeyBinding#ActionName
+ * @see Action#getValue
+ * @see KeyBinding#actionName
*/
public static void loadKeymap(Keymap map,
JTextComponent.KeyBinding[] bindings,
@@ -913,12 +920,12 @@ public abstract class JTextComponent extends JComponent
* editor can run. Equivalent to calling
* <code>getUI().getEditorKit().getActions()</code>. This set of Actions
* is a reasonable value to provide as a parameter to {@link
- * #loadKeymap()}, when resolving a set of {@link #KeyBinding} objects
+ * #loadKeymap}, when resolving a set of {@link KeyBinding} objects
* against this component.
*
* @return The set of available Actions on this component's {@link EditorKit}
*
- * @see TextUI#getEditorKit()
+ * @see TextUI#getEditorKit
* @see EditorKit#getActions()
*/
public Action[] getActions()
@@ -926,15 +933,16 @@ public abstract class JTextComponent extends JComponent
return getUI().getEditorKit(this).getActions();
}
- // This is package-private to avoid an accessor method.
+ // These are package-private to avoid an accessor method.
Document doc;
- private Caret caret;
+ Caret caret;
+ boolean editable;
+
private Highlighter highlighter;
private Color caretColor;
private Color disabledTextColor;
private Color selectedTextColor;
private Color selectionColor;
- private boolean editable;
private Insets margin;
private boolean dragEnabled;
@@ -1113,7 +1121,7 @@ public abstract class JTextComponent extends JComponent
/**
* This method sets the label's UI delegate.
*
- * @param ui The label's UI delegate.
+ * @param newUI The label's UI delegate.
*/
public void setUI(TextUI newUI)
{
@@ -1351,7 +1359,7 @@ public abstract class JTextComponent extends JComponent
/**
* Selects the text from the given postion to the selection end position.
*
- * @param end the start positon of the selected text.
+ * @param start the start positon of the selected text.
*/
public void setSelectionStart(int start)
{
@@ -1382,7 +1390,7 @@ public abstract class JTextComponent extends JComponent
* Selects a part of the content of the text component.
*
* @param start the start position of the selected text
- * @param ent the end position of the selected text
+ * @param end the end position of the selected text
*/
public void select(int start, int end)
{
@@ -1611,4 +1619,55 @@ public abstract class JTextComponent extends JComponent
{
navigationFilter = filter;
}
+
+ /**
+ * Read and set the content this component. If not overridden, the
+ * method reads the component content as a plain text.
+ *
+ * The second parameter of this method describes the input stream. It can
+ * be String, URL, File and so on. If not null, this object is added to
+ * the properties of the associated document under the key
+ * {@link Document#StreamDescriptionProperty}.
+ *
+ * @param input an input stream to read from.
+ * @param streamDescription an object, describing the stream.
+ *
+ * @throws IOException if the reader throws it.
+ *
+ * @see #getDocument()
+ * @see Document#getProperty(Object)
+ */
+ public void read(Reader input, Object streamDescription)
+ throws IOException
+ {
+ if (streamDescription != null)
+ {
+ Document d = getDocument();
+ if (d != null)
+ d.putProperty(Document.StreamDescriptionProperty, streamDescription);
+ }
+
+ StringBuffer b = new StringBuffer();
+ int c;
+
+ // Read till -1 (EOF).
+ while ((c = input.read()) >= 0)
+ b.append((char) c);
+
+ setText(b.toString());
+ }
+
+ /**
+ * Write the content of this component to the given stream. If not
+ * overridden, the method writes the component content as a plain text.
+ *
+ * @param output the writer to write into.
+ *
+ * @throws IOException if the writer throws it.
+ */
+ public void write(Writer output)
+ throws IOException
+ {
+ output.write(getText());
+ }
}
diff --git a/javax/swing/text/Keymap.java b/javax/swing/text/Keymap.java
index 8c1dd8bcc..c3f61d88e 100644
--- a/javax/swing/text/Keymap.java
+++ b/javax/swing/text/Keymap.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/LabelView.java b/javax/swing/text/LabelView.java
new file mode 100644
index 000000000..a10391613
--- /dev/null
+++ b/javax/swing/text/LabelView.java
@@ -0,0 +1,54 @@
+/* LabelView.java -- A view to render styled text
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+// TODO: Implement this class.
+public class LabelView
+ extends GlyphView
+{
+ /**
+ * Creates a new <code>GlyphView</code> for the given <code>Element</code>.
+ *
+ * @param element the element that is rendered by this GlyphView
+ */
+ public LabelView(Element element)
+ {
+ super(element);
+ }
+}
diff --git a/javax/swing/text/LayeredHighlighter.java b/javax/swing/text/LayeredHighlighter.java
index 0b063e5a1..dcaf1c504 100644
--- a/javax/swing/text/LayeredHighlighter.java
+++ b/javax/swing/text/LayeredHighlighter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/MutableAttributeSet.java b/javax/swing/text/MutableAttributeSet.java
index d8cb62a7b..2fe9ad50f 100644
--- a/javax/swing/text/MutableAttributeSet.java
+++ b/javax/swing/text/MutableAttributeSet.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/NavigationFilter.java b/javax/swing/text/NavigationFilter.java
index cdf9e77b7..45f58f9e2 100644
--- a/javax/swing/text/NavigationFilter.java
+++ b/javax/swing/text/NavigationFilter.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/ParagraphView.java b/javax/swing/text/ParagraphView.java
new file mode 100644
index 000000000..44338a1e4
--- /dev/null
+++ b/javax/swing/text/ParagraphView.java
@@ -0,0 +1,56 @@
+/* ParagraphView.java -- A composite View
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text;
+
+// TODO: Implement this class.
+public class ParagraphView
+ extends FlowView
+{
+
+ /**
+ * Creates a new <code>ParagraphView</code> for the given
+ * <code>Element</code>.
+ *
+ * @param element the element that is rendered by this ParagraphView
+ */
+ public ParagraphView(Element element)
+ {
+ super(element);
+ }
+}
diff --git a/javax/swing/text/PasswordView.java b/javax/swing/text/PasswordView.java
index ad18350e9..229fd2b50 100644
--- a/javax/swing/text/PasswordView.java
+++ b/javax/swing/text/PasswordView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/PlainDocument.java b/javax/swing/text/PlainDocument.java
index 352df7a88..71070e92d 100644
--- a/javax/swing/text/PlainDocument.java
+++ b/javax/swing/text/PlainDocument.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -135,22 +135,6 @@ public class PlainDocument extends AbstractDocument
start, end - len);
rootElement.replace(i1, i2 - i1, new Element[]{ newEl });
}
- else
- {
- // otherwise only adjust indices of the element
- LeafElement el1 = (LeafElement) rootElement.getElement(i1);
- el1.end -= len;
- }
-
- // reindex remaining elements
- for (int i = rootElement.getElementIndex(p0) + 1;
- i < rootElement.getElementCount(); i++)
- {
- LeafElement el = (LeafElement) rootElement.getElement(i);
- el.start -= len;
- el.end -= len;
- }
-
}
public Element getDefaultRootElement()
diff --git a/javax/swing/text/PlainView.java b/javax/swing/text/PlainView.java
index c9e064362..5d1fab000 100644
--- a/javax/swing/text/PlainView.java
+++ b/javax/swing/text/PlainView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/Position.java b/javax/swing/text/Position.java
index 2fe2bd347..a9d3d09d7 100644
--- a/javax/swing/text/Position.java
+++ b/javax/swing/text/Position.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/Segment.java b/javax/swing/text/Segment.java
index 3b1d9e7aa..92d850016 100644
--- a/javax/swing/text/Segment.java
+++ b/javax/swing/text/Segment.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/SimpleAttributeSet.java b/javax/swing/text/SimpleAttributeSet.java
index c3b7b0820..3ef5db61d 100644
--- a/javax/swing/text/SimpleAttributeSet.java
+++ b/javax/swing/text/SimpleAttributeSet.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/StringContent.java b/javax/swing/text/StringContent.java
index c0e688a8d..bedf480d4 100644
--- a/javax/swing/text/StringContent.java
+++ b/javax/swing/text/StringContent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/Style.java b/javax/swing/text/Style.java
index d8553c02c..851ac0219 100644
--- a/javax/swing/text/Style.java
+++ b/javax/swing/text/Style.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/StyleConstants.java b/javax/swing/text/StyleConstants.java
index e9019b1a9..3f973f226 100644
--- a/javax/swing/text/StyleConstants.java
+++ b/javax/swing/text/StyleConstants.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/StyleContext.java b/javax/swing/text/StyleContext.java
index 86ccc112c..ae11622ff 100644
--- a/javax/swing/text/StyleContext.java
+++ b/javax/swing/text/StyleContext.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -380,9 +380,17 @@ public class StyleContext
// FIXME: also not sure if these tables ought to be static (singletons),
// shared across all StyleContexts. I think so, but it's not clear in
// docs. revert to non-shared if you think it matters.
-
+
+ /**
+ * The name of the default style.
+ */
public static final String DEFAULT_STYLE = "default";
+ /**
+ * The default style for this style context.
+ */
+ NamedStyle defaultStyle = new NamedStyle(DEFAULT_STYLE, null);
+
static Hashtable sharedAttributeSets = new Hashtable();
static Hashtable sharedFonts = new Hashtable();
@@ -392,10 +400,15 @@ public class StyleContext
EventListenerList listenerList;
Hashtable styleTable;
+ /**
+ * Creates a new instance of the style context. Add the default style
+ * to the style table.
+ */
public StyleContext()
{
listenerList = new EventListenerList();
styleTable = new Hashtable();
+ styleTable.put(DEFAULT_STYLE, defaultStyle);
}
protected SmallAttributeSet createSmallAttributeSet(AttributeSet a)
@@ -436,11 +449,25 @@ public class StyleContext
styleTable.remove(name);
}
+ /**
+ * Get the style from the style table. If the passed name
+ * matches {@link #DEFAULT_STYLE}, returns the default style.
+ * Otherwise returns the previously defined style of
+ * <code>null</code> if the style with the given name is not defined.
+ *
+ * @param name the name of the style.
+ *
+ * @return the style with the given name or null if no such defined.
+ */
public Style getStyle(String name)
{
return (Style) styleTable.get(name);
}
-
+
+ /**
+ * Get the names of the style. The returned enumeration always
+ * contains at least one member, the default style.
+ */
public Enumeration getStyleNames()
{
return styleTable.keys();
diff --git a/javax/swing/text/StyledDocument.java b/javax/swing/text/StyledDocument.java
index 26b10ca22..ea277540f 100644
--- a/javax/swing/text/StyledDocument.java
+++ b/javax/swing/text/StyledDocument.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/StyledEditorKit.java b/javax/swing/text/StyledEditorKit.java
index 148ebd32b..4dfbf9103 100644
--- a/javax/swing/text/StyledEditorKit.java
+++ b/javax/swing/text/StyledEditorKit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -46,458 +46,660 @@ import java.io.Serializable;
import javax.swing.Action;
import javax.swing.JEditorPane;
+import javax.swing.JTextPane;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
/**
- * StyledEditorKit
+ * An {@link EditorKit} that supports editing styled text.
*
* @author Andrew Selkirk
+ * @author Roman Kennke (roman@kennke.org)
*/
public class StyledEditorKit extends DefaultEditorKit
{
+ /** The serialVersionUID. */
private static final long serialVersionUID = 7002391892985555948L;
/**
- * UnderlineAction
+ * Toggles the underline attribute for the selected text.
*/
public static class UnderlineAction extends StyledEditorKit.StyledTextAction
{
/**
- * Constructor UnderlineAction
+ * Creates an instance of <code>UnderlineAction</code>.
*/
public UnderlineAction()
{
- super("TODO");
- // TODO
+ super("TODO"); // TODO: Figure out name for this action.
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ JEditorPane editor = getEditor(event);
+ StyledDocument doc = getStyledDocument(editor);
+ Element el = doc.getCharacterElement(editor.getSelectionStart());
+ boolean isUnderline = StyleConstants.isUnderline(el.getAttributes());
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setUnderline(atts, ! isUnderline);
+ setCharacterAttributes(editor, atts, false);
}
}
/**
- * ItalicAction
+ * Toggles the italic attribute for the selected text.
*/
public static class ItalicAction extends StyledEditorKit.StyledTextAction
{
/**
- * Constructor ItalicAction
+ * Creates an instance of <code>ItalicAction</code>.
*/
public ItalicAction()
{
- super("TODO");
- // TODO
+ super("TODO"); // TODO: Figure out correct name of this Action.
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ JEditorPane editor = getEditor(event);
+ StyledDocument doc = getStyledDocument(editor);
+ Element el = doc.getCharacterElement(editor.getSelectionStart());
+ boolean isItalic = StyleConstants.isItalic(el.getAttributes());
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setItalic(atts, ! isItalic);
+ setCharacterAttributes(editor, atts, false);
}
}
/**
- * BoldAction
+ * Toggles the bold attribute for the selected text.
*/
public static class BoldAction extends StyledEditorKit.StyledTextAction
{
/**
- * Constructor BoldAction
+ * Creates an instance of <code>BoldAction</code>.
*/
public BoldAction()
{
- super("TODO");
- // TODO
+ super("TODO"); // TODO: Figure out correct name of this Action.
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ JEditorPane editor = getEditor(event);
+ StyledDocument doc = getStyledDocument(editor);
+ Element el = doc.getCharacterElement(editor.getSelectionStart());
+ boolean isBold = StyleConstants.isBold(el.getAttributes());
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setItalic(atts, ! isBold);
+ setCharacterAttributes(editor, atts, false);
}
}
/**
- * AlignmentAction
+ * Sets the alignment attribute on the selected text.
*/
public static class AlignmentAction extends StyledEditorKit.StyledTextAction
{
/**
- * a
+ * The aligment to set.
*/
private int a;
/**
- * Constructor AlignmentAction
- * @param nm TODO
- * @param a TODO
+ * Creates a new instance of <code>AlignmentAction</code> to set the
+ * alignment to <code>a</code>.
+ *
+ * @param nm the name of the Action
+ * @param a the alignment to set
*/
public AlignmentAction(String nm, int a)
{
- super("TODO");
- // TODO
+ super(nm);
+ this.a = a;
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setAlignment(atts, a);
+ setParagraphAttributes(getEditor(event), atts, false);
}
}
/**
- * ForegroundAction
+ * Sets the foreground color attribute on the selected text.
*/
public static class ForegroundAction extends StyledEditorKit.StyledTextAction
{
/**
- * fg
+ * The foreground color to set.
*/
private Color fg;
/**
- * Constructor ForegroundAction
- * @param nm TODO
- * @param fg TODO
+ * Creates a new instance of <code>ForegroundAction</code> to set the
+ * foreground color to <code>fg</code>.
+ *
+ * @param nm the name of the Action
+ * @param fg the foreground color to set
*/
public ForegroundAction(String nm, Color fg)
{
- super("TODO");
- // TODO
+ super(nm);
+ this.fg = fg;
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setForeground(atts, fg);
+ setCharacterAttributes(getEditor(event), atts, false);
}
}
/**
- * FontSizeAction
+ * Sets the font size attribute on the selected text.
*/
public static class FontSizeAction extends StyledEditorKit.StyledTextAction
{
/**
- * size
+ * The font size to set.
*/
private int size;
/**
- * Constructor FontSizeAction
- * @param nm TODO
- * @param size TODO
+ * Creates a new instance of <code>FontSizeAction</code> to set the
+ * font size to <code>size</code>.
+ *
+ * @param nm the name of the Action
+ * @param size the font size to set
*/
public FontSizeAction(String nm, int size)
{
- super("TODO");
- // TODO
+ super(nm);
+ this.size = size;
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setFontSize(atts, size);
+ setCharacterAttributes(getEditor(event), atts, false);
}
}
/**
- * FontFamilyAction
+ * Sets the font family attribute on the selected text.
*/
public static class FontFamilyAction extends StyledEditorKit.StyledTextAction
{
/**
- * family
+ * The font family to set.
*/
private String family;
/**
- * Constructor FontFamilyAction
- * @param nm TODO
- * @param family TODO
+ * Creates a new instance of <code>FontFamilyAction</code> to set the
+ * font family to <code>family</code>.
+ *
+ * @param nm the name of the Action
+ * @param family the font family to set
*/
public FontFamilyAction(String nm, String family)
{
- super("TODO");
- // TODO
+ super(nm);
+ this.family = family;
}
/**
- * actionPerformed
- * @param event TODO
+ * Performs the action.
+ *
+ * @param event the <code>ActionEvent</code> that describes the action
*/
public void actionPerformed(ActionEvent event)
{
- // TODO
+ SimpleAttributeSet atts = new SimpleAttributeSet();
+ StyleConstants.setFontFamily(atts, family);
+ setCharacterAttributes(getEditor(event), atts, false);
}
}
/**
- * StyledTextAction
+ * The abstract superclass of all styled TextActions. This class
+ * provides some useful methods to manipulate the text attributes.
*/
public abstract static class StyledTextAction extends TextAction
{
/**
- * Constructor StyledTextAction
- * @param nm TODO
+ * Creates a new instance of <code>StyledTextAction</code>.
+ *
+ * @param nm the name of the <code>StyledTextAction</code>
*/
public StyledTextAction(String nm)
{
super(nm);
- // TODO
}
/**
- * getEditor
- * @param event TODO
- * @returns JEditorPane
+ * Returns the <code>JEditorPane</code> component from which the
+ * <code>ActionEvent</code> originated.
+ *
+ * @param event the <code>ActionEvent</code>
+ * @return the <code>JEditorPane</code> component from which the
+ * <code>ActionEvent</code> originated
*/
protected final JEditorPane getEditor(ActionEvent event)
{
- return null; // TODO
+ return (JEditorPane) getTextComponent(event);
}
/**
- * setCharacterAttributes
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
+ * Sets the specified character attributes on the currently selected
+ * text of <code>editor</code>. If <code>editor</code> does not have
+ * a selection, then the attributes are used as input attributes
+ * for newly inserted content.
+ *
+ * @param editor the <code>JEditorPane</code> component
+ * @param atts the text attributes to set
+ * @param replace if <code>true</code> the current attributes of the
+ * selection are replaces, otherwise they are merged
*/
- protected final void setCharacterAttributes(JEditorPane value0,
- AttributeSet value1,
- boolean value2)
+ protected final void setCharacterAttributes(JEditorPane editor,
+ AttributeSet atts,
+ boolean replace)
{
- // TODO
+ Document doc = editor.getDocument();
+ if (doc instanceof StyledDocument)
+ {
+ StyledDocument styleDoc = (StyledDocument) editor.getDocument();
+ EditorKit kit = editor.getEditorKit();
+ if (!(kit instanceof StyledEditorKit))
+ {
+ StyledEditorKit styleKit = (StyledEditorKit) kit;
+ int start = editor.getSelectionStart();
+ int end = editor.getSelectionEnd();
+ int dot = editor.getCaret().getDot();
+ if (start == dot && end == dot)
+ {
+ // If there is no selection, then we only update the
+ // input attributes.
+ MutableAttributeSet inputAttributes =
+ styleKit.getInputAttributes();
+ inputAttributes.addAttributes(atts);
+ }
+ else
+ styleDoc.setCharacterAttributes(start, end, atts, replace);
+ }
+ else
+ throw new AssertionError("The EditorKit for StyledTextActions "
+ + "is expected to be a StyledEditorKit");
+ }
+ else
+ throw new AssertionError("The Document for StyledTextActions is "
+ + "expected to be a StyledDocument.");
}
/**
- * getStyledDocument
- * @param value0 TODO
- * @returns StyledDocument
+ * Returns the {@link StyledDocument} that is used by <code>editor</code>.
+ *
+ * @param editor the <code>JEditorPane</code> from which to get the
+ * <code>StyledDocument</code>
+ *
+ * @return the {@link StyledDocument} that is used by <code>editor</code>
*/
- protected final StyledDocument getStyledDocument(JEditorPane value0)
+ protected final StyledDocument getStyledDocument(JEditorPane editor)
{
- return null; // TODO
+ Document doc = editor.getDocument();
+ if (!(doc instanceof StyledDocument))
+ throw new AssertionError("The Document for StyledEditorKits is "
+ + "expected to be a StyledDocument.");
+
+ return (StyledDocument) doc;
}
/**
- * getStyledEditorKit
- * @param value0 TODO
- * @returns StyledEditorKit
+ * Returns the {@link StyledEditorKit} that is used by <code>editor</code>.
+ *
+ * @param editor the <code>JEditorPane</code> from which to get the
+ * <code>StyledEditorKit</code>
+ *
+ * @return the {@link StyledEditorKit} that is used by <code>editor</code>
*/
- protected final StyledEditorKit getStyledEditorKit(JEditorPane value0)
+ protected final StyledEditorKit getStyledEditorKit(JEditorPane editor)
{
- return null; // TODO
+ EditorKit kit = editor.getEditorKit();
+ if (!(kit instanceof StyledEditorKit))
+ throw new AssertionError("The EditorKit for StyledDocuments is "
+ + "expected to be a StyledEditorKit.");
+
+ return (StyledEditorKit) kit;
}
/**
- * setParagraphAttributes
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
+ * Sets the specified character attributes on the paragraph that
+ * contains the currently selected
+ * text of <code>editor</code>. If <code>editor</code> does not have
+ * a selection, then the attributes are set on the paragraph that
+ * contains the current caret position.
+ *
+ * @param editor the <code>JEditorPane</code> component
+ * @param atts the text attributes to set
+ * @param replace if <code>true</code> the current attributes of the
+ * selection are replaces, otherwise they are merged
*/
- protected final void setParagraphAttributes(JEditorPane value0,
- AttributeSet value1,
- boolean value2)
+ protected final void setParagraphAttributes(JEditorPane editor,
+ AttributeSet atts,
+ boolean replace)
{
- // TODO
+ Document doc = editor.getDocument();
+ if (doc instanceof StyledDocument)
+ {
+ StyledDocument styleDoc = (StyledDocument) editor.getDocument();
+ EditorKit kit = editor.getEditorKit();
+ if (!(kit instanceof StyledEditorKit))
+ {
+ StyledEditorKit styleKit = (StyledEditorKit) kit;
+ int start = editor.getSelectionStart();
+ int end = editor.getSelectionEnd();
+ int dot = editor.getCaret().getDot();
+ if (start == dot && end == dot)
+ {
+ // If there is no selection, then we only update the
+ // input attributes.
+ MutableAttributeSet inputAttributes =
+ styleKit.getInputAttributes();
+ inputAttributes.addAttributes(atts);
+ }
+ else
+ styleDoc.setParagraphAttributes(start, end, atts, replace);
+ }
+ else
+ throw new AssertionError("The EditorKit for StyledTextActions "
+ + "is expected to be a StyledEditorKit");
+ }
+ else
+ throw new AssertionError("The Document for StyledTextActions is "
+ + "expected to be a StyledDocument.");
}
}
/**
- * StyledViewFactory
+ * A {@link ViewFactory} that is able to create {@link View}s for
+ * the <code>Element</code>s that are supported by
+ * <code>StyledEditorKit</code>, namely the following types of Elements:
+ *
+ * <ul>
+ * <li>{@link AbstractDocument.ContentElementName}</li>
+ * <li>{@link AbstractDocument.ParagraphElementName}</li>
+ * <li>{@link AbstractDocument.SectionElementName}</li>
+ * <li>{@link StyleContext.ComponentElementName}</li>
+ * <li>{@link StyleContext.IconElementName}</li>
+ * </ul>
*/
static class StyledViewFactory
implements ViewFactory
{
/**
- * Constructor StyledViewFactory
- */
- StyledViewFactory()
- {
- // TODO
- }
-
- /**
- * create
- * @param value0 TODO
- * @returns View
+ * Creates a {@link View} for the specified <code>Element</code>.
+ *
+ * @param element the <code>Element</code> to create a <code>View</code>
+ * for
+ * @return the <code>View</code> for the specified <code>Element</code>
+ * or <code>null</code> if the type of <code>element</code> is
+ * not supported
*/
- public View create(Element value0)
+ public View create(Element element)
{
- return null; // TODO
+ String name = element.getName();
+ View view = null;
+ if (name.equals(AbstractDocument.ContentElementName))
+ view = new LabelView(element);
+ else if (name.equals(AbstractDocument.ParagraphElementName))
+ view = new ParagraphView(element);
+ else if (name.equals(AbstractDocument.SectionElementName))
+ view = new BoxView(element);
+ else if (name.equals(StyleConstants.ComponentElementName))
+ view = new ComponentView(element);
+ else if (name.equals(StyleConstants.IconElementName))
+ view = new IconView(element);
+
+ return view;
}
}
/**
- * AttributeTracker
+ * Keeps track of the caret position and updates the currentRun
+ * <code>Element</code> and the <code>inputAttributes</code>.
*/
- class AttributeTracker
- implements CaretListener, PropertyChangeListener, Serializable
+ class CaretTracker
+ implements CaretListener
{
/**
- * Constructor AttributeTracker
- * @param value0 TODO
- */
- AttributeTracker(StyledEditorKit value0)
- {
- // TODO
- }
-
- /**
- * updateInputAttributes
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
+ * Notifies an update of the caret position.
+ *
+ * @param ev the event for the caret update
*/
- void updateInputAttributes(int value0, int value1, JTextComponent value2)
+ public void caretUpdate(CaretEvent ev)
{
- // TODO
- }
-
- /**
- * propertyChange
- * @param value0 TODO
- */
- public void propertyChange(PropertyChangeEvent value0)
- {
- // TODO
- }
-
- /**
- * caretUpdate
- * @param value0 TODO
- */
- public void caretUpdate(CaretEvent value0)
- {
- // TODO
+ Object source = ev.getSource();
+ if (!(source instanceof JTextComponent))
+ throw new AssertionError("CaretEvents are expected to come from a"
+ + "JTextComponent.");
+
+ JTextComponent text = (JTextComponent) source;
+ Document doc = text.getDocument();
+ if (!(doc instanceof StyledDocument))
+ throw new AssertionError("The Document used by StyledEditorKits is"
+ + "expected to be a StyledDocument");
+
+ StyledDocument styleDoc = (StyledDocument) doc;
+ currentRun = styleDoc.getCharacterElement(ev.getDot());
+ createInputAttributes(currentRun, inputAttributes);
}
}
/**
- * currentRun
+ * Stores the <code>Element</code> at the current caret position. This
+ * is updated by {@link CaretTracker}.
*/
Element currentRun;
/**
- * currentParagraph
+ * The current input attributes. This is updated by {@link CaretTracker}.
*/
- Element currentParagraph;
+ MutableAttributeSet inputAttributes;
/**
- * inputAttributes
+ * The CaretTracker that keeps track of the current input attributes, and
+ * the current character run Element.
*/
- MutableAttributeSet inputAttributes;
+ CaretTracker caretTracker;
+
+ /**
+ * The ViewFactory for StyledEditorKits.
+ */
+ StyledViewFactory viewFactory;
/**
- * Constructor StyledEditorKit
+ * Creates a new instance of <code>StyledEditorKit</code>.
*/
public StyledEditorKit()
{
- // TODO
+ inputAttributes = new SimpleAttributeSet();
}
/**
- * clone
- * @returns Object
+ * Creates an exact copy of this <code>StyledEditorKit</code>.
+ *
+ * @return an exact copy of this <code>StyledEditorKit</code>
*/
public Object clone()
{
- return null; // TODO
+ StyledEditorKit clone = (StyledEditorKit) super.clone();
+ // FIXME: Investigate which fields must be copied.
+ return clone;
}
/**
- * getActions
- * @returns Action[]
+ * Returns the <code>Action</code>s supported by this {@link EditorKit}.
+ * This includes the {@link BoldAction}, {@link ItalicAction} and
+ * {@link UnderlineAction} as well as the <code>Action</code>s supported
+ * by {@link DefaultEditorKit}.
+ *
+ * The other <code>Action</code>s of <code>StyledEditorKit</code> are not
+ * returned here, since they require a parameter and thus custom
+ * instantiation.
+ *
+ * @return the <code>Action</code>s supported by this {@link EditorKit}
*/
public Action[] getActions()
{
- return null; // TODO
+ Action[] actions1 = super.getActions();
+ Action[] myActions = new Action[] { new BoldAction(), new ItalicAction(),
+ new UnderlineAction() };
+ return TextAction.augmentList(actions1, myActions);
}
/**
- * getInputAttributes
- * @returns MutableAttributeSet
+ * Returns the current input attributes. These are automatically set on
+ * any newly inserted content, if not specified otherwise.
+ *
+ * @return the current input attributes
*/
public MutableAttributeSet getInputAttributes()
{
- return null; // TODO
+ return inputAttributes;
}
/**
- * getCharacterAttributeRun
- * @returns Element
+ * Returns the {@link Element} that represents the character run at the
+ * current caret position.
+ *
+ * @return the {@link Element} that represents the character run at the
+ * current caret position
*/
public Element getCharacterAttributeRun()
{
- return null; // TODO
+ return currentRun;
}
/**
- * createDefaultDocument
- * @returns Document
+ * Creates the default {@link Document} supported by this
+ * <code>EditorKit</code>. This is an instance of
+ * {@link DefaultStyledDocument} in this case but may be overridden by
+ * subclasses.
+ *
+ * @return an instance of <code>DefaultStyledDocument</code>
*/
public Document createDefaultDocument()
{
- return null; // TODO
+ return new DefaultStyledDocument();
}
/**
- * install
- * @param component TODO
+ * Installs this <code>EditorKit</code> on the specified {@link JEditorPane}.
+ * This basically involves setting up required listeners on the
+ * <code>JEditorPane</code>.
+ *
+ * @param component the <code>JEditorPane</code> to install this
+ * <code>EditorKit</code> on
*/
public void install(JEditorPane component)
{
- // TODO
+ CaretTracker tracker = new CaretTracker();
+ component.addCaretListener(tracker);
}
/**
- * deinstall
- * @param component TODO
+ * Deinstalls this <code>EditorKit</code> from the specified
+ * {@link JEditorPane}. This basically involves removing all listeners from
+ * <code>JEditorPane</code> that have been set up by this
+ * <code>EditorKit</code>.
+ *
+ * @param component the <code>JEditorPane</code> from which to deinstall this
+ * <code>EditorKit</code>
*/
public void deinstall(JEditorPane component)
{
- // TODO
+ CaretTracker t = caretTracker;
+ if (t != null)
+ component.removeCaretListener(t);
+ caretTracker = null;
}
/**
- * getViewFactory
- * @returns ViewFactory
+ * Returns a {@link ViewFactory} that is able to create {@link View}s
+ * for {@link Element}s that are supported by this <code>EditorKit</code>,
+ * namely the following types of <code>Element</code>s:
+ *
+ * <ul>
+ * <li>{@link AbstractDocument.ContentElementName}</li>
+ * <li>{@link AbstractDocument.ParagraphElementName}</li>
+ * <li>{@link AbstractDocument.SectionElementName}</li>
+ * <li>{@link StyleContext.ComponentElementName}</li>
+ * <li>{@link StyleContext.IconElementName}</li>
+ * </ul>
+ *
+ * @return a {@link ViewFactory} that is able to create {@link View}s
+ * for {@link Element}s that are supported by this <code>EditorKit</code>
*/
public ViewFactory getViewFactory()
{
- return null; // TODO
+ if (viewFactory == null)
+ viewFactory = new StyledViewFactory();
+ return viewFactory;
}
/**
- * createInputAttributes
- * @param element TODO
- * @param set TODO
+ * Copies the text attributes from <code>element</code> to <code>set</code>.
+ * This is called everytime when the caret position changes to keep
+ * track of the current input attributes. The attributes in <code>set</code>
+ * are cleaned before adding the attributes of <code>element</code>.
+ *
+ * This method filters out attributes for element names, <code>Icon</code>s
+ * and <code>Component</code>s.
+ *
+ * @param element the <code>Element</code> from which to copy the text
+ * attributes
+ * @param set the inputAttributes to copy the attributes to
*/
- protected void createInputAttributes(Element element, MutableAttributeSet set)
+ protected void createInputAttributes(Element element,
+ MutableAttributeSet set)
{
- // TODO
+ AttributeSet atts = element.getAttributes();
+ set.removeAttributes(set);
+ // FIXME: Filter out component, icon and element name attributes.
+ set.addAttributes(atts);
}
}
diff --git a/javax/swing/text/TabExpander.java b/javax/swing/text/TabExpander.java
index 56940f552..d70dd4604 100644
--- a/javax/swing/text/TabExpander.java
+++ b/javax/swing/text/TabExpander.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/TabSet.java b/javax/swing/text/TabSet.java
index 58ae65ef0..146f545aa 100644
--- a/javax/swing/text/TabSet.java
+++ b/javax/swing/text/TabSet.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/TabStop.java b/javax/swing/text/TabStop.java
index 2c95a63e4..032da8bca 100644
--- a/javax/swing/text/TabStop.java
+++ b/javax/swing/text/TabStop.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/TabableView.java b/javax/swing/text/TabableView.java
index 9d244be19..2a96ea94d 100644
--- a/javax/swing/text/TabableView.java
+++ b/javax/swing/text/TabableView.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/TextAction.java b/javax/swing/text/TextAction.java
index 0191a2dc4..8588e3cd2 100644
--- a/javax/swing/text/TextAction.java
+++ b/javax/swing/text/TextAction.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/Utilities.java b/javax/swing/text/Utilities.java
index 79047014d..d40408ddc 100644
--- a/javax/swing/text/Utilities.java
+++ b/javax/swing/text/Utilities.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/View.java b/javax/swing/text/View.java
index 760e3b0ae..7b6ce24b4 100644
--- a/javax/swing/text/View.java
+++ b/javax/swing/text/View.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -459,5 +459,58 @@ public abstract class View implements SwingConstants
if (ec != null)
preferenceChanged(this, true, true);
}
-}
+ /**
+ * Maps a position in the document into the coordinate space of the View.
+ * The output rectangle usually reflects the font height but has a width
+ * of zero.
+ *
+ * @param pos the position of the character in the model
+ * @param a the area that is occupied by the view
+ * @param bias either {@link Position.Bias.Forward} or
+ * {@link Position.Bias.Backward} depending on the preferred
+ * direction bias. If <code>null</code> this defaults to
+ * <code>Position.Bias.Forward</code>
+ *
+ * @return a rectangle that gives the location of the document position
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>pos</code> is invalid
+ * @throws IllegalArgumentException if b is not one of the above listed
+ * valid values
+ */
+ public abstract Shape modelToView(int pos, Shape a, Position.Bias b)
+ throws BadLocationException;
+
+ /**
+ * Maps a region in the document into the coordinate space of the View.
+ *
+ * @param p1 the beginning position inside the document
+ * @param b1 the direction bias for the beginning position
+ * @param p2 the end position inside the document
+ * @param b2 the direction bias for the end position
+ * @param a the area that is occupied by the view
+ *
+ * @return a rectangle that gives the span of the document region
+ * inside the view coordinate space
+ *
+ * @throws BadLocationException if <code>p1</code> or <code>p2</code> are
+ * invalid
+ * @throws IllegalArgumentException if b1 or b2 is not one of the above
+ * listed valid values
+ */
+ public Shape modelToView(int p1, Position.Bias b1,
+ int p2, Position.Bias b2, Shape a)
+ throws BadLocationException
+ {
+ if (b1 != Position.Bias.Forward && b1 != Position.Bias.Backward)
+ throw new IllegalArgumentException
+ ("b1 must be either Position.Bias.Forward or Position.Bias.Backward");
+ if (b2 != Position.Bias.Forward && b2 != Position.Bias.Backward)
+ throw new IllegalArgumentException
+ ("b2 must be either Position.Bias.Forward or Position.Bias.Backward");
+ Shape s1 = modelToView(p1, a, b1);
+ Shape s2 = modelToView(p2, a, b2);
+ return s1.getBounds().union(s2.getBounds());
+ }
+}
diff --git a/javax/swing/text/ViewFactory.java b/javax/swing/text/ViewFactory.java
index c9cc4b792..079488017 100644
--- a/javax/swing/text/ViewFactory.java
+++ b/javax/swing/text/ViewFactory.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/HTML.java b/javax/swing/text/html/HTML.java
index 06e0ef403..3c03a63a4 100644
--- a/javax/swing/text/html/HTML.java
+++ b/javax/swing/text/html/HTML.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -965,6 +965,21 @@ public class HTML
final int flags;
/**
+ * Create the unitialised instance of HTML.Tag.
+ *
+ * The {@link #breaksFlow()}, {@link #isBlock()}
+ * and {@link #isPreformatted()} will always return false.
+ * The {@link #toString()} will return <code>null</code>.
+ *
+ * @since 1.3
+ */
+ public Tag()
+ {
+ name = null;
+ flags = 0;
+ }
+
+ /**
* Creates a new Tag with the specified id, and with causesBreak
* and isBlock set to false.
*/
diff --git a/javax/swing/text/html/HTMLDocument.java b/javax/swing/text/html/HTMLDocument.java
index 45c87c7b7..a95e496ec 100644
--- a/javax/swing/text/html/HTMLDocument.java
+++ b/javax/swing/text/html/HTMLDocument.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/HTMLEditorKit.java b/javax/swing/text/html/HTMLEditorKit.java
index 742eab36e..c0182fe6a 100644
--- a/javax/swing/text/html/HTMLEditorKit.java
+++ b/javax/swing/text/html/HTMLEditorKit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,19 +38,25 @@ exception statement from your version. */
package javax.swing.text.html;
+import java.io.IOException;
import java.io.Reader;
+import java.io.Serializable;
import javax.swing.text.BadLocationException;
import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.StyledEditorKit;
/**
* This class is NOT implemented. This file currently holds only
* declarations of the two enclosing classes, necessary for testing
* the implemented javax.swing.text.html.parser package.
+ *
* @author No authorship is taken, implement the class and be!
* TODO: replace this header after implementing the class.
*/
public class HTMLEditorKit
+ extends StyledEditorKit
+ implements Serializable, Cloneable
{
/**
* The abstract HTML parser declaration.
@@ -70,7 +76,7 @@ public class HTMLEditorKit
public abstract void parse(Reader reader, ParserCallback callback,
boolean ignoreCharSet
)
- throws java.io.IOException;
+ throws IOException;
}
/**
@@ -118,8 +124,8 @@ public class HTMLEditorKit
* The method is called when the HTML closing tag ((like &lt;/table&gt;)
* is found or if the parser concludes that the one should be present
* in the current position.
- * @param The tag being handled
- * @position the tag position in the text being parsed.
+ * @param tag The tag being handled
+ * @param position the tag position in the text being parsed.
*/
public void handleEndTag(HTML.Tag tag, int position)
{
@@ -153,7 +159,7 @@ public class HTMLEditorKit
* is found or if the parser concludes that the one should be present
* in the current position.
* @param tag The tag being handled
- * @param position The tag position in the text bein parsed
+ * @param position The tag position in the text being parsed
*/
public void handleStartTag(HTML.Tag tag, MutableAttributeSet attributes,
int position
@@ -170,4 +176,75 @@ public class HTMLEditorKit
{
}
}
-}
+
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 8751997116710384592L;
+
+ /**
+ * Default cascading stylesheed file ("default.css").
+ */
+ public static final String DEFAULT_CSS = "default.css";
+
+ /**
+ * The <b>bold</b> action identifier.
+ */
+ public static final String BOLD_ACTION = "html-bold-action";
+
+ /**
+ * The <i>italic</i> action identifier.
+ */
+ public static final String ITALIC_ACTION = "html-italic-action";
+
+ /**
+ * The <font color="#FF0000">color</font> action indentifier
+ * (passing the color as an argument).
+ */
+ public static final String COLOR_ACTION = "html-color-action";
+
+ /**
+ * The <font size="+1">increase</font> font action identifier.
+ */
+ public static final String FONT_CHANGE_BIGGER = "html-font-bigger";
+
+ /**
+ * The <font size="-1">decrease</font> font action identifier.
+ */
+ public static final String FONT_CHANGE_SMALLER = "html-font-smaller";
+
+ /**
+ * Align images at the bottom.
+ */
+ public static final String IMG_ALIGN_BOTTOM = "html-image-align-bottom";
+
+ /**
+ * Align images at the middle.
+ */
+ public static final String IMG_ALIGN_MIDDLE = "html-image-align-middle";
+
+ /**
+ * Align images at the top.
+ */
+ public static final String IMG_ALIGN_TOP = "html-image-align-top";
+
+ /**
+ * Align images at the border.
+ */
+ public static final String IMG_BORDER = "html-image-border";
+
+ /**
+ * The "logical style" action identifier, passing that style as parameter.
+ */
+ public static final String LOGICAL_STYLE_ACTION = "html-logical-style-action";
+
+ /**
+ * The "ident paragraph left" action.
+ */
+ public static final String PARA_INDENT_LEFT = "html-para-indent-left";
+
+ /**
+ * The "ident paragraph right" action.
+ */
+ public static final String PARA_INDENT_RIGHT = "html-para-indent-right";
+} \ No newline at end of file
diff --git a/javax/swing/text/html/HTMLFrameHyperlinkEvent.java b/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
index 82de2a803..dc0ab10a8 100644
--- a/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
+++ b/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/package.html b/javax/swing/text/html/package.html
index 622c4fcc1..c7e774428 100644
--- a/javax/swing/text/html/package.html
+++ b/javax/swing/text/html/package.html
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/parser/AttributeList.java b/javax/swing/text/html/parser/AttributeList.java
index c74f35953..5bca0bfa7 100644
--- a/javax/swing/text/html/parser/AttributeList.java
+++ b/javax/swing/text/html/parser/AttributeList.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/parser/ContentModel.java b/javax/swing/text/html/parser/ContentModel.java
index 7c8ff35a2..deb7b1602 100644
--- a/javax/swing/text/html/parser/ContentModel.java
+++ b/javax/swing/text/html/parser/ContentModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/parser/DTD.java b/javax/swing/text/html/parser/DTD.java
index 270c8158f..f17ca011e 100644
--- a/javax/swing/text/html/parser/DTD.java
+++ b/javax/swing/text/html/parser/DTD.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -62,7 +62,8 @@ import java.util.Vector;
* <p>
* If you need more information about SGML DTD documents,
* the author suggests to read SGML tutorial on
- * {@link http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html}.
+ * <a href="http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html"
+ * >http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html</a>.
* We also recommend Goldfarb C.F (1991) <i>The SGML Handbook</i>,
* Oxford University Press, 688 p, ISBN: 0198537379.
* </p>
@@ -402,7 +403,7 @@ public class DTD
* placed to the field
* {@link javax.swing.text.html.parser.AttributeList#next },
* creating a linked list.
- * @return
+ * @return The attributes.
*/
protected AttributeList defAttributeList(String name, int type, int modifier,
String default_value,
@@ -541,7 +542,7 @@ public class DTD
* The unknown elements are automatically defined and added
* to the element table.
* @param elements
- * @return
+ * @return The bit set.
*/
private BitSet bitSet(String[] elements)
{
diff --git a/javax/swing/text/html/parser/DTDConstants.java b/javax/swing/text/html/parser/DTDConstants.java
index 29218c25d..75e7afb4d 100644
--- a/javax/swing/text/html/parser/DTDConstants.java
+++ b/javax/swing/text/html/parser/DTDConstants.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,14 +40,16 @@ package javax.swing.text.html.parser;
/**
* <p>This class defines the SGML basic types, used for describing HTML 4.01
- * at {@link http://www.w3.org/TR/html4/types.html }. Not all constants,
+ * at <a href="http://www.w3.org/TR/html4/types.html"
+ * >http://www.w3.org/TR/html4/types.html</a>. Not all constants,
* defined here, are actually used in HTML 4.01 SGML specification. Some others
* are defined just as part of the required implementation.
* </p>
* <p>
* If you need more information about SGML DTD documents,
* the author suggests to read SGML tutorial on
- * {@link http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html}.
+ * <a href="http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html"
+ * >http://www.w3.org/TR/WD-html40-970708/intro/sgmltut.html</a>.
* We also recommend Goldfarb C.F (1991) <i>The SGML Handbook</i>,
* Oxford University Press, 688 p, ISBN: 0198537379.
* </p>
diff --git a/javax/swing/text/html/parser/DocumentParser.java b/javax/swing/text/html/parser/DocumentParser.java
index f210d4f88..164297f18 100644
--- a/javax/swing/text/html/parser/DocumentParser.java
+++ b/javax/swing/text/html/parser/DocumentParser.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -167,7 +167,7 @@ public class DocumentParser
* to get a default DTD; you must either refer to the implementation -
* specific packages, write your own DTD or obtain the working instance
* of parser in other way, for example, by calling
- * {@link javax.swing.text.html.HTMLEditorKit#getParser() }.
+ * {@link javax.swing.text.html.HTMLEditorKit#getParser()}.
* @param a_dtd a DTD to use.
*/
public DocumentParser(DTD a_dtd)
@@ -180,18 +180,18 @@ public class DocumentParser
* Parses the HTML document, calling methods of the provided
* callback. This method must be multithread - safe.
* @param reader The reader to read the HTML document from
- * @param callback The callback that is notifyed about the presence
+ * @param aCallback The callback that is notifyed about the presence
* of HTML elements in the document.
* @param ignoreCharSet If thrue, any charset changes during parsing
* are ignored.
* @throws java.io.IOException
*/
- public void parse(Reader reader, HTMLEditorKit.ParserCallback a_callback,
+ public void parse(Reader reader, HTMLEditorKit.ParserCallback aCallback,
boolean ignoreCharSet
)
throws IOException
{
- callBack = a_callback;
+ callBack = aCallback;
gnu.parse(reader);
callBack.handleEndOfLineString(gnu.getEndOfLineSequence());
@@ -230,7 +230,7 @@ public class DocumentParser
* The method is called when the HTML closing tag ((like &lt;/table&gt;)
* is found or if the parser concludes that the one should be present
* in the current position.
- * @param The tag being handled
+ * @param tag The tag being handled
*/
protected void handleEndTag(TagElement tag)
{
@@ -245,7 +245,7 @@ public class DocumentParser
* The method is called when the HTML opening tag ((like &lt;table&gt;)
* is found or if the parser concludes that the one should be present
* in the current position.
- * @param The tag being handled
+ * @param tag The tag being handled
*/
protected void handleStartTag(TagElement tag)
{
diff --git a/javax/swing/text/html/parser/Element.java b/javax/swing/text/html/parser/Element.java
index 4f39fbef0..098983c69 100644
--- a/javax/swing/text/html/parser/Element.java
+++ b/javax/swing/text/html/parser/Element.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -225,7 +225,7 @@ public final class Element
/**
* Get all attributes of this document as an attribute list.
- * @return
+ * @return The attribute list.
*/
public AttributeList getAttributes()
{
diff --git a/javax/swing/text/html/parser/Entity.java b/javax/swing/text/html/parser/Entity.java
index ba79552c7..766984f9c 100644
--- a/javax/swing/text/html/parser/Entity.java
+++ b/javax/swing/text/html/parser/Entity.java
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/parser/Parser.java b/javax/swing/text/html/parser/Parser.java
index 7202f6b5b..7ff6853da 100644
--- a/javax/swing/text/html/parser/Parser.java
+++ b/javax/swing/text/html/parser/Parser.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -327,7 +327,7 @@ public class Parser
* Handle the tag with no content, like &lt;br&gt;. The method is
* called for the elements that, in accordance with the current DTD,
* has an empty content.
- * @param The tag being handled.
+ * @param tag The tag being handled.
* @throws javax.swing.text.ChangedCharSetException
*/
protected void handleEmptyTag(TagElement tag)
@@ -339,7 +339,7 @@ public class Parser
* The method is called when the HTML closing tag ((like &lt;/table&gt;)
* is found or if the parser concludes that the one should be present
* in the current position.
- * @param The tag being handled
+ * @param tag The tag being handled
*/
protected void handleEndTag(TagElement tag)
{
@@ -354,7 +354,7 @@ public class Parser
* The method is called when the HTML opening tag ((like &lt;table&gt;)
* is found or if the parser concludes that the one should be present
* in the current position.
- * @param The tag being handled
+ * @param tag The tag being handled
*/
protected void handleStartTag(TagElement tag)
{
@@ -383,7 +383,7 @@ public class Parser
* both title starting and closing tags are already behind.
* The passed argument contains the concatenation of all
* title text sections.
- * @param The title text.
+ * @param title The title text.
*/
protected void handleTitle(char[] title)
{
@@ -402,7 +402,7 @@ public class Parser
/**
* Constructs the tag from the given element.
- * @param the tag base {@link javax.swing.text.html.parser.Element}
+ * @param element the tag base {@link javax.swing.text.html.parser.Element}
* @param isSupposed true if the tag is not actually present in the
* html input, but the parser supposes that it should to occur in
* the current location.
@@ -427,7 +427,7 @@ public class Parser
* is found or if the parser concludes that the one should be present
* in the current position. The method is called immediately before
* calling the handleStartTag.
- * @param The tag
+ * @param tag The tag
*/
protected void startTag(TagElement tag)
throws ChangedCharSetException
diff --git a/javax/swing/text/html/parser/ParserDelegator.java b/javax/swing/text/html/parser/ParserDelegator.java
index 30f77ca7c..e5d2db4df 100644
--- a/javax/swing/text/html/parser/ParserDelegator.java
+++ b/javax/swing/text/html/parser/ParserDelegator.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -113,7 +113,9 @@ public class ParserDelegator
DTD getDTD()
{
- return dtd;
+ // Accessing the inherited gnu.javax.swing.text.html.parser.support.Parser
+ // field. super. is a workaround, required to support JDK1.3's javac.
+ return super.dtd;
}
}
@@ -141,7 +143,7 @@ public class ParserDelegator
* Parses the HTML document, calling methods of the provided
* callback. This method must be multithread - safe.
* @param reader The reader to read the HTML document from
- * @param callback The callback that is notifyed about the presence
+ * @param a_callback The callback that is notifyed about the presence
* of HTML elements in the document.
* @param ignoreCharSet If thrue, any charset changes during parsing
* are ignored.
@@ -189,7 +191,7 @@ public class ParserDelegator
* all subsequent calls to the parse(...) . If you need to specify
* your DTD locally, simply {@link javax.swing.text.html.parser.Parser}
* instead.
- * @param dtd The DTD that will be used to parse documents by this class.
+ * @param a_dtd The DTD that will be used to parse documents by this class.
* @param name The name of this DTD.
* @return No standard is specified on which instance of DTD must be
* returned by this method, and it is recommended to leave the returned
diff --git a/javax/swing/text/html/parser/TagElement.java b/javax/swing/text/html/parser/TagElement.java
index ab9465261..4558b15eb 100644
--- a/javax/swing/text/html/parser/TagElement.java
+++ b/javax/swing/text/html/parser/TagElement.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/html/parser/package.html b/javax/swing/text/html/parser/package.html
index d9cceb01c..5d5157fb2 100644
--- a/javax/swing/text/html/parser/package.html
+++ b/javax/swing/text/html/parser/package.html
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/package.html b/javax/swing/text/package.html
index 9e5bebb9f..50043b6c4 100644
--- a/javax/swing/text/package.html
+++ b/javax/swing/text/package.html
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/ControlWordToken.java b/javax/swing/text/rtf/ControlWordToken.java
index 043cae412..7008f0fd4 100644
--- a/javax/swing/text/rtf/ControlWordToken.java
+++ b/javax/swing/text/rtf/ControlWordToken.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/RTFEditorKit.java b/javax/swing/text/rtf/RTFEditorKit.java
index 8a6e88a84..b2ebe3dd1 100644
--- a/javax/swing/text/rtf/RTFEditorKit.java
+++ b/javax/swing/text/rtf/RTFEditorKit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/RTFParseException.java b/javax/swing/text/rtf/RTFParseException.java
index dba51d2e0..2a9c64f05 100644
--- a/javax/swing/text/rtf/RTFParseException.java
+++ b/javax/swing/text/rtf/RTFParseException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/RTFParser.java b/javax/swing/text/rtf/RTFParser.java
index fe837fbff..4f0f967c1 100644
--- a/javax/swing/text/rtf/RTFParser.java
+++ b/javax/swing/text/rtf/RTFParser.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/RTFScanner.java b/javax/swing/text/rtf/RTFScanner.java
index d964a4347..3cdd6e8e0 100644
--- a/javax/swing/text/rtf/RTFScanner.java
+++ b/javax/swing/text/rtf/RTFScanner.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/TextToken.java b/javax/swing/text/rtf/TextToken.java
index e326792cc..2d6d527d1 100644
--- a/javax/swing/text/rtf/TextToken.java
+++ b/javax/swing/text/rtf/TextToken.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/text/rtf/Token.java b/javax/swing/text/rtf/Token.java
index a7a955269..7d5adaaf0 100644
--- a/javax/swing/text/rtf/Token.java
+++ b/javax/swing/text/rtf/Token.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/AbstractLayoutCache.java b/javax/swing/tree/AbstractLayoutCache.java
index 6fb75f77f..adece101d 100644
--- a/javax/swing/tree/AbstractLayoutCache.java
+++ b/javax/swing/tree/AbstractLayoutCache.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -48,7 +48,8 @@ import javax.swing.event.TreeModelEvent;
*
* @author Andrew Selkirk
*/
-public abstract class AbstractLayoutCache implements RowMapper
+public abstract class AbstractLayoutCache
+ implements RowMapper
{
/**
* class NodeDimensions
@@ -74,8 +75,7 @@ public abstract class AbstractLayoutCache implements RowMapper
* @return Rectangle
*/
public abstract Rectangle getNodeDimensions(Object value0, int value1,
- int value2, boolean value3,
- Rectangle value4);
+ int value2, boolean value3, Rectangle value4);
}
/**
@@ -108,7 +108,7 @@ public abstract class AbstractLayoutCache implements RowMapper
*/
public AbstractLayoutCache()
{
- // Do nothing here.
+ // Do nothing here.
}
/**
@@ -134,27 +134,31 @@ public abstract class AbstractLayoutCache implements RowMapper
/**
* getNodeDimensions
*
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- * @param value3 TODO
- * @param value4 TODO
+ * @param value TODO
+ * @param row TODO
+ * @param depth TODO
+ * @param expanded TODO
+ * @param bounds TODO
*
* @return Rectangle
*/
- protected Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4)
+ protected Rectangle getNodeDimensions(Object value, int row, int depth,
+ boolean expanded, Rectangle bounds)
{
- return null; // TODO
+ if (bounds == null)
+ return new Rectangle();
+ return null;
+ // TODO
}
/**
* Sets the model that provides the tree data.
*
- * @param the model
+ * @param model the model
*/
public void setModel(TreeModel model)
{
- treeModel = model;
+ treeModel = model;
}
/**
@@ -314,7 +318,7 @@ public abstract class AbstractLayoutCache implements RowMapper
*
* @return int
*/
- public abstract int getVisibleChildCount(TreePath value0);
+ public abstract int getVisibleChildCount(TreePath path);
/**
* setExpandedState
diff --git a/javax/swing/tree/DefaultMutableTreeNode.java b/javax/swing/tree/DefaultMutableTreeNode.java
index de34ee072..e709e2a04 100644
--- a/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/javax/swing/tree/DefaultMutableTreeNode.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -45,14 +45,19 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.NoSuchElementException;
import java.util.Stack;
import java.util.Vector;
+
/**
* DefaultMutableTreeNode
*
* @author Andrew Selkirk
+ * @author Robert Schuster (robertschuster@fsfe.org)
*/
public class DefaultMutableTreeNode
implements Cloneable, MutableTreeNode, Serializable
@@ -232,7 +237,7 @@ public class DefaultMutableTreeNode
* Inserts given child node at the given index.
*
* @param node the child node
- * @param value the index.
+ * @param index the index.
*/
public void insert(MutableTreeNode node, int index)
{
@@ -353,7 +358,7 @@ public class DefaultMutableTreeNode
*/
public void removeFromParent()
{
- // FIXME: IS this implementation really correct ?
+ parent.remove(this);
parent = null;
}
@@ -389,7 +394,7 @@ public class DefaultMutableTreeNode
/**
* isNodeDescendant
*
- * @param node0 TODO
+ * @param node TODO
*
* @return boolean
*/
@@ -656,7 +661,7 @@ public class DefaultMutableTreeNode
*/
public Enumeration preorderEnumeration()
{
- return null; // TODO: Implement me.
+ return new PreorderEnumeration(this);
}
/**
@@ -666,7 +671,7 @@ public class DefaultMutableTreeNode
*/
public Enumeration postorderEnumeration()
{
- return null; // TODO: Implement me.
+ return new PostorderEnumeration(this);
}
/**
@@ -676,7 +681,7 @@ public class DefaultMutableTreeNode
*/
public Enumeration breadthFirstEnumeration()
{
- return null; // TODO: Implement me.
+ return new BreadthFirstEnumeration(this);
}
/**
@@ -913,6 +918,7 @@ public class DefaultMutableTreeNode
if (parent == null)
return null;
+ // TODO: Fix implementation.
return null;
//return parent.getChildAfter(this);
}
@@ -926,7 +932,8 @@ public class DefaultMutableTreeNode
{
if (parent == null)
return null;
-
+
+ // TODO: Fix implementation.
return null;
//return parent.getChildBefore(this);
}
@@ -951,4 +958,155 @@ public class DefaultMutableTreeNode
return count;
}
+
+ /** Provides an enumeration of a tree in breadth-first traversal
+ * order.
+ */
+ static class BreadthFirstEnumeration implements Enumeration
+ {
+
+ LinkedList queue = new LinkedList();
+
+ BreadthFirstEnumeration(TreeNode node)
+ {
+ queue.add(node);
+ }
+
+ public boolean hasMoreElements()
+ {
+ return !queue.isEmpty();
+ }
+
+ public Object nextElement()
+ {
+ if(queue.isEmpty())
+ throw new NoSuchElementException("No more elements left.");
+
+ TreeNode node = (TreeNode) queue.removeFirst();
+
+ Enumeration children = node.children();
+ while (children.hasMoreElements())
+ queue.add(children.nextElement());
+
+ return node;
+ }
+ }
+
+ /** Provides an enumeration of a tree traversing it
+ * preordered.
+ */
+ static class PreorderEnumeration implements Enumeration
+ {
+ TreeNode next;
+
+ Stack childrenEnums = new Stack();
+
+ PreorderEnumeration(TreeNode node)
+ {
+ next = node;
+ childrenEnums.push(node.children());
+ }
+
+ public boolean hasMoreElements()
+ {
+ return next != null;
+ }
+
+ public Object nextElement()
+ {
+ if( next == null )
+ throw new NoSuchElementException("No more elements left.");
+
+ Object current = next;
+
+ Enumeration children = (Enumeration) childrenEnums.peek();
+
+ // Retrieves the next element.
+ next = traverse(children);
+
+ return current;
+ }
+
+ private TreeNode traverse(Enumeration children)
+ {
+ // If more children are available step down.
+ if( children.hasMoreElements() )
+ {
+ TreeNode child = (TreeNode) children.nextElement();
+ childrenEnums.push(child.children());
+
+ return child;
+ }
+
+ // If no children are left, we return to a higher level.
+ childrenEnums.pop();
+
+ // If there are no more levels left, there is no next
+ // element to return.
+ if ( childrenEnums.isEmpty() )
+ return null;
+ else
+ {
+ return traverse((Enumeration) childrenEnums.peek());
+ }
+ }
+ }
+
+ /** Provides an enumeration of a tree traversing it
+ * postordered (= depth-first).
+ */
+ static class PostorderEnumeration implements Enumeration
+ {
+
+ Stack nodes = new Stack();
+ Stack childrenEnums = new Stack();
+
+ PostorderEnumeration(TreeNode node)
+ {
+ nodes.push(node);
+ childrenEnums.push(node.children());
+ }
+
+ public boolean hasMoreElements()
+ {
+ return !nodes.isEmpty();
+ }
+
+ public Object nextElement()
+ {
+ if( nodes.isEmpty() )
+ throw new NoSuchElementException("No more elements left!");
+
+ Enumeration children = (Enumeration) childrenEnums.peek();
+
+ return traverse(children);
+ }
+
+ private Object traverse(Enumeration children)
+ {
+ if ( children.hasMoreElements() )
+ {
+ TreeNode node = (TreeNode) children.nextElement();
+ nodes.push(node);
+
+ Enumeration newChildren = node.children();
+ childrenEnums.push(newChildren);
+
+ return traverse(newChildren);
+ }
+ else
+ {
+ childrenEnums.pop();
+
+ // Returns the node whose children
+ // have all been visited. (= postorder)
+ Object next = nodes.peek();
+ nodes.pop();
+
+ return next;
+ }
+ }
+
+ }
+
}
diff --git a/javax/swing/tree/DefaultTreeCellEditor.java b/javax/swing/tree/DefaultTreeCellEditor.java
index af280201b..e509d2c18 100644
--- a/javax/swing/tree/DefaultTreeCellEditor.java
+++ b/javax/swing/tree/DefaultTreeCellEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index beae3840b..0f1792161 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -1,6 +1,6 @@
-/* DefaultTreeCellRenderer.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
-
+/* DefaultTreeCellRenderer.java
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -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.tree;
import java.awt.Color;
@@ -54,15 +53,16 @@ import javax.swing.plaf.UIResource;
/**
* DefaultTreeCellRenderer
+ *
* @author Andrew Selkirk
*/
public class DefaultTreeCellRenderer
- extends JLabel
- implements TreeCellRenderer
+ extends JLabel
+ implements TreeCellRenderer
{
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Variables --------------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
/**
* selected
@@ -118,380 +118,475 @@ public class DefaultTreeCellRenderer
* borderSelectionColor
*/
protected Color borderSelectionColor;
+
-
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Initialization ---------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
/**
* Constructor DefaultTreeCellRenderer
*/
- public DefaultTreeCellRenderer() {
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- setLeafIcon(getDefaultLeafIcon());
- setOpenIcon(getDefaultOpenIcon());
- setClosedIcon(getDefaultClosedIcon());
-
- setTextNonSelectionColor(defaults.getColor("Tree.textForeground"));
- setTextSelectionColor(defaults.getColor("Tree.selectionForeground"));
- setBackgroundNonSelectionColor(defaults.getColor("Tree.textBackground"));
- setBackgroundSelectionColor(defaults.getColor("Tree.selectionBackground"));
- setBorderSelectionColor(defaults.getColor("Tree.selectionBorderColor"));
+ public DefaultTreeCellRenderer()
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ setLeafIcon(getDefaultLeafIcon());
+ setOpenIcon(getDefaultOpenIcon());
+ setClosedIcon(getDefaultClosedIcon());
+
+ setTextNonSelectionColor(defaults.getColor("Tree.textForeground"));
+ setTextSelectionColor(defaults.getColor("Tree.selectionForeground"));
+ setBackgroundNonSelectionColor(defaults
+ .getColor("Tree.nonSelectionBackground"));
+ setBackgroundSelectionColor(defaults
+ .getColor("Tree.selectionBackground"));
+ setBorderSelectionColor(defaults
+ .getColor("Tree.selectionBorderColor"));
}
-
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Methods ----------------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
/**
* getDefaultOpenIcon
+ *
* @returns Icon
*/
- public Icon getDefaultOpenIcon() {
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon");
+ public Icon getDefaultOpenIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon");
}
/**
* getDefaultClosedIcon
+ *
* @returns Icon
*/
- public Icon getDefaultClosedIcon() {
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
+ public Icon getDefaultClosedIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
}
/**
* getDefaultLeafIcon
+ *
* @returns Icon
*/
- public Icon getDefaultLeafIcon() {
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
+ public Icon getDefaultLeafIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
}
/**
* setOpenIcon
- * @param value0 TODO
+ *
+ * @param i the icon.
*/
- public void setOpenIcon(Icon i) {
- openIcon = i;
+ public void setOpenIcon(Icon i)
+ {
+ openIcon = i;
}
/**
* getOpenIcon
+ *
* @returns Icon
*/
- public Icon getOpenIcon() {
- return openIcon;
- }
+ public Icon getOpenIcon()
+ {
+ return openIcon;
+ }
/**
* setClosedIcon
- * @param value0 TODO
+ *
+ * @param i the icon.
*/
- public void setClosedIcon(Icon i) {
- closedIcon = i;
- }
+ public void setClosedIcon(Icon i)
+ {
+ closedIcon = i;
+ }
/**
* getClosedIcon
+ *
* @returns Icon
*/
- public Icon getClosedIcon() {
- return closedIcon;
- }
+ public Icon getClosedIcon()
+ {
+ return closedIcon;
+ }
/**
* setLeafIcon
- * @param value0 TODO
+ *
+ * @param i the icon.
*/
- public void setLeafIcon(Icon i) {
- leafIcon = i;
+ public void setLeafIcon(Icon i)
+ {
+ leafIcon = i;
}
/**
* getLeafIcon
+ *
* @returns Icon
*/
- public Icon getLeafIcon() {
- return leafIcon;
+ public Icon getLeafIcon()
+ {
+ return leafIcon;
}
/**
* setTextSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setTextSelectionColor(Color c) {
- textSelectionColor = c;
+ public void setTextSelectionColor(Color c)
+ {
+ textSelectionColor = c;
}
/**
* getTextSelectionColor
+ *
* @returns Color
*/
- public Color getTextSelectionColor() {
- return textSelectionColor;
+ public Color getTextSelectionColor()
+ {
+ return textSelectionColor;
}
/**
* setTextNonSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setTextNonSelectionColor(Color c) {
- textNonSelectionColor = c;
+ public void setTextNonSelectionColor(Color c)
+ {
+ textNonSelectionColor = c;
}
/**
* getTextNonSelectionColor
+ *
* @returns Color
*/
- public Color getTextNonSelectionColor() {
- return textNonSelectionColor;
+ public Color getTextNonSelectionColor()
+ {
+ return textNonSelectionColor;
}
/**
* setBackgroundSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setBackgroundSelectionColor(Color c) {
- backgroundSelectionColor = c;
+ public void setBackgroundSelectionColor(Color c)
+ {
+ backgroundSelectionColor = c;
}
/**
* getBackgroundSelectionColor
+ *
* @returns Color
*/
- public Color getBackgroundSelectionColor() {
- return backgroundSelectionColor;
+ public Color getBackgroundSelectionColor()
+ {
+ return backgroundSelectionColor;
}
/**
* setBackgroundNonSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setBackgroundNonSelectionColor(Color c) {
- backgroundNonSelectionColor = c;
+ public void setBackgroundNonSelectionColor(Color c)
+ {
+ backgroundNonSelectionColor = c;
}
/**
* getBackgroundNonSelectionColor
+ *
* @returns Color
*/
- public Color getBackgroundNonSelectionColor() {
- return backgroundNonSelectionColor;
+ public Color getBackgroundNonSelectionColor()
+ {
+ return backgroundNonSelectionColor;
}
/**
* setBorderSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setBorderSelectionColor(Color c) {
- borderSelectionColor = c;
+ public void setBorderSelectionColor(Color c)
+ {
+ borderSelectionColor = c;
}
/**
* getBorderSelectionColor
+ *
* @returns Color
*/
- public Color getBorderSelectionColor() {
- return borderSelectionColor;
+ public Color getBorderSelectionColor()
+ {
+ return borderSelectionColor;
}
/**
* setFont
- * @param value0 TODO
- */
- public void setFont(Font f) {
- if (f != null && f instanceof UIResource)
- f = null;
- super.setFont(f);
+ *
+ * @param f the font.
+ */
+ public void setFont(Font f)
+ {
+ if (f != null && f instanceof UIResource)
+ f = null;
+ super.setFont(f);
}
/**
* setBackground
- * @param value0 TODO
- */
- public void setBackground(Color c) {
- if (c != null && c instanceof UIResource)
- c = null;
- super.setBackground(c);
+ *
+ * @param c the color.
+ */
+ public void setBackground(Color c)
+ {
+ if (c != null && c instanceof UIResource)
+ c = null;
+ super.setBackground(c);
}
/**
* getTreeCellRendererComponent
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- * @param value3 TODO
- * @param value4 TODO
- * @param value5 TODO
- * @param value6 TODO
+ *
+ * @param tree TODO
+ * @param val TODO
+ * @param selected TODO
+ * @param expanded TODO
+ * @param leaf TODO
+ * @param row TODO
+ * @param hasFocus TODO
* @returns Component
*/
- public Component getTreeCellRendererComponent(JTree tree,
- Object val,
- boolean selected,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus) {
- this.selected = selected;
- this.hasFocus = hasFocus;
-
- if (leaf)
- setIcon(getLeafIcon());
- else if (expanded)
- setIcon(getOpenIcon());
- else
- setIcon(getClosedIcon());
-
- setText(val.toString());
- setHorizontalAlignment(LEFT);
- setVerticalAlignment(TOP);
-
- return this;
+ public Component getTreeCellRendererComponent(JTree tree, Object val,
+ boolean selected, boolean expanded, boolean leaf, int row,
+ boolean hasFocus)
+ {
+ if (leaf)
+ setIcon(getLeafIcon());
+ else if (expanded)
+ setIcon(getOpenIcon());
+ else
+ setIcon(getClosedIcon());
+
+ setText(val.toString());
+ this.selected = selected;
+ this.hasFocus = hasFocus;
+ setHorizontalAlignment(LEFT);
+ setOpaque(true);
+ setVerticalAlignment(TOP);
+ setEnabled(true);
+ super.setFont(UIManager.getLookAndFeelDefaults().getFont("Tree.font"));
+
+ if (selected)
+ {
+ super.setBackground(getBackgroundSelectionColor());
+ setForeground(getTextSelectionColor());
+ }
+ else
+ {
+ super.setBackground(getBackgroundNonSelectionColor());
+ setForeground(getTextNonSelectionColor());
+ }
+
+ return this;
+ }
+
+ /**
+ * getFont
+ *
+ * @return the current Font
+ */
+ public Font getFont()
+ {
+ return super.getFont();
}
/**
* paint
- * @param value0 TODO
+ *
+ * @param g the graphics device.
*/
- public void paint(Graphics g) {
- super.paint(g);
+ public void paint(Graphics g)
+ {
+ super.paint(g);
}
/**
* getPreferredSize
+ *
* @returns Dimension
*/
- public Dimension getPreferredSize() {
+ public Dimension getPreferredSize()
+ {
return null; // TODO
} // getPreferredSize()
/**
* validate
*/
- public void validate() {
- // TODO
+ public void validate()
+ {
+ // Overridden for performance reasons.
} // validate()
/**
* revalidate
*/
- public void revalidate() {
- // TODO
+ public void revalidate()
+ {
+ // Overridden for performance reasons.
} // revalidate()
/**
* repaint
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
* @param value3 TODO
* @param value4 TODO
*/
- public void repaint(long value0, int value1, int value2, int value3, int value4) {
- // TODO
+ public void repaint(long value0, int value1, int value2, int value3,
+ int value4)
+ {
+ // Overridden for performance reasons.
} // repaint()
/**
* repaint
+ *
* @param value0 TODO
*/
- public void repaint(Rectangle value0) {
- // TODO
+ public void repaint(Rectangle value0)
+ {
+ // Overridden for performance reasons.
} // repaint()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- protected void firePropertyChange(String value0, Object value1, Object value2) {
- // TODO
+ protected void firePropertyChange(String value0, Object value1,
+ Object value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, byte value1, byte value2) {
- // TODO
+ public void firePropertyChange(String value0, byte value1, byte value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, char value1, char value2) {
- // TODO
+ public void firePropertyChange(String value0, char value1, char value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, short value1, short value2) {
- // TODO
+ public void firePropertyChange(String value0, short value1, short value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, int value1, int value2) {
- // TODO
+ public void firePropertyChange(String value0, int value1, int value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, long value1, long value2) {
- // TODO
+ public void firePropertyChange(String value0, long value1, long value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, float value1, float value2) {
- // TODO
+ public void firePropertyChange(String value0, float value1, float value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
+ *
* @param value0 TODO
* @param value1 TODO
* @param value2 TODO
*/
- public void firePropertyChange(String value0, double value1, double value2) {
- // TODO
+ public void firePropertyChange(String value0, double value1, double value2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
/**
* firePropertyChange
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- */
- public void firePropertyChange(String value0, boolean value1, boolean value2) {
- // TODO
+ *
+ * @param name the property name.
+ * @param v1 the old value.
+ * @param v2 the new value.
+ */
+ public void firePropertyChange(String name, boolean v1, boolean v2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
-
} // DefaultTreeCellRenderer
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index 2e34a3522..e4291e130 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -47,405 +47,409 @@ import java.util.EventListener;
import javax.swing.event.EventListenerList;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
+import javax.swing.tree.DefaultMutableTreeNode;
/**
* DefaultTreeModel
* @author Andrew Selkirk
*/
public class DefaultTreeModel
- implements Serializable, TreeModel
+ implements Serializable, TreeModel
{
- static final long serialVersionUID = -2621068368932566998L;
-
- /**
- * root
- */
- protected TreeNode root = null;
-
- /**
- * listenerList
- */
- protected EventListenerList listenerList = new EventListenerList();
-
- /**
- * asksAllowsChildren
- */
- protected boolean asksAllowsChildren;
-
- /**
- * Constructor DefaultTreeModel
- * @param value0 TODO
- */
- public DefaultTreeModel(TreeNode root)
- {
- setRoot(root);
- }
-
- /**
- * Constructor DefaultTreeModel
- * @param value0 TODO
- * @param value1 TODO
- */
- public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
- {
- setRoot(root);
- this.asksAllowsChildren = asksAllowsChildren;
- }
-
- /**
- * writeObject
- * @param value0 TODO
- * @exception IOException TODO
- */
- private void writeObject(ObjectOutputStream value0) throws IOException
- {
- // TODO
- }
-
- /**
- * readObject
- * @param value0 TODO
- * @exception IOException TODO
- * @exception ClassNotFoundException TODO
- */
- private void readObject(ObjectInputStream value0)
- throws IOException, ClassNotFoundException
- {
- // TODO
- }
-
- /**
- * asksAllowsChildren
- * @return boolean
- */
- public boolean asksAllowsChildren()
- {
- return asksAllowsChildren;
- }
-
- /**
- * setAsksAllowsChildren
- * @param value0 TODO
- */
- public void setAsksAllowsChildren(boolean value)
- {
- asksAllowsChildren = value; // TODO
- }
-
- /**
- * setRoot
- * @param value0 TODO
- */
- public void setRoot(TreeNode root)
- {
- // Sanity Check
- if (root == null)
- {
- throw new IllegalArgumentException("null root");
- }
- // Set new root
- this.root = root;
-
- // TODO
- }
-
- /**
- * getRoot
- * @return Object
- */
- public Object getRoot()
- {
- return root;
- }
-
- /**
- * getIndexOfChild
- * @param value0 TODO
- * @param value1 TODO
- * @return int
- */
- public int getIndexOfChild(Object parent, Object child)
- {
- return 0; // TODO
- }
-
- /**
- * getChild
- * @param value0 TODO
- * @param value1 TODO
- * @return Object
- */
- public Object getChild(Object node, int idx)
- {
- if (node instanceof TreeNode)
- return ((TreeNode)node).getChildAt(idx);
- else
- return null;
- }
-
- /**
- * getChildCount
- * @param value0 TODO
- * @return int
- */
- public int getChildCount(Object node)
- {
- if (node instanceof TreeNode)
- return ((TreeNode)node).getChildCount();
- else
- return 0;
- }
-
- /**
- * isLeaf
- * @param value0 TODO
- * @return boolean
- */
- public boolean isLeaf(Object node)
- {
- if (node instanceof TreeNode)
- return ((TreeNode)node).isLeaf();
- else
- return true;
- }
-
- /**
- * reload
- */
- public void reload()
- {
- // TODO
- }
-
- /**
- * reload
- * @param value0 TODO
- */
- public void reload(TreeNode value0)
- {
- // TODO
- }
-
- /**
- * valueForPathChanged
- * @param value0 TODO
- * @param value1 TODO
- */
- public void valueForPathChanged(TreePath value0, Object value1)
- {
- // TODO
- }
-
- /**
- * insertNodeInto
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- */
- public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1,
- int value2)
- {
- // TODO
- }
-
- /**
- * removeNodeFromParent
- * @param value0 TODO
- */
- public void removeNodeFromParent(MutableTreeNode value0)
- {
- // TODO
- }
-
- /**
- * nodeChanged
- * @param value0 TODO
- */
- public void nodeChanged(TreeNode value0)
- {
- // TODO
- }
-
- /**
- * nodesWereInserted
- * @param value0 TODO
- * @param value1 TODO
- */
- public void nodesWereInserted(TreeNode value0, int[] value1)
- {
- // TODO
- }
-
- /**
- * nodesWereRemoved
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- */
- public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2)
- {
- // TODO
- }
-
- /**
- * nodesChanged
- * @param value0 TODO
- * @param value1 TODO
- */
- public void nodesChanged(TreeNode value0, int[] value1)
- {
- // TODO
- }
-
- /**
- * nodeStructureChanged
- * @param value0 TODO
- */
- public void nodeStructureChanged(TreeNode value0)
- {
- // TODO
- }
-
- /**
- * getPathToRoot
- * @param value0 TODO
- * @return TreeNode[]
- */
- public TreeNode[] getPathToRoot(TreeNode value0)
- {
- return null; // TODO
- }
-
- /**
- * getPathToRoot
- * @param value0 TODO
- * @param value1 TODO
- * @return TreeNode[]
- */
- protected TreeNode[] getPathToRoot(TreeNode value0, int value1)
- {
- return null; // TODO
- }
-
- /**
- * Registers a listere to the model.
- *
- * @param listener the listener to add
- */
- public void addTreeModelListener(TreeModelListener listener)
- {
- listenerList.add(TreeModelListener.class, listener);
- }
-
- /**
- * Removes a listener from the model.
- *
- * @param listener the listener to remove
- */
- public void removeTreeModelListener(TreeModelListener listener)
- {
- listenerList.remove(TreeModelListener.class, listener);
- }
-
- /**
- * Returns all registered <code>TreeModelListener</code> listeners.
- *
- * @return an array of listeners.
- *
- * @since 1.4
- */
- public TreeModelListener[] getTreeModelListeners()
- {
- return (TreeModelListener[]) listenerList.getListeners(TreeModelListener.class);
- }
-
- /**
- * fireTreeNodesChanged
- *
- * @param source the node being changed
- * @param path the path to the root node
- * @param childIndices the indices of the changed elements
- * @param children the changed elements
- */
- protected void fireTreeNodesChanged(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event =
- new TreeModelEvent(source, path, childIndices, children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeNodesChanged(event);
- }
-
- /**
- * fireTreeNodesInserted
- *
- * @param source the node where new nodes got inserted
- * @param path the path to the root node
- * @param childIndices the indices of the new elements
- * @param children the new elements
- */
- protected void fireTreeNodesInserted(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event =
- new TreeModelEvent(source, path, childIndices, children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeNodesInserted(event);
- }
-
- /**
- * fireTreeNodesRemoved
- *
- * @param source the node where nodes got removed-
- * @param path the path to the root node
- * @param childIndices the indices of the removed elements
- * @param children the removed elements
- */
- protected void fireTreeNodesRemoved(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event =
- new TreeModelEvent(source, path, childIndices, children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeNodesRemoved(event);
- }
-
- /**
- * fireTreeStructureChanged
- *
- * @param source the node where the model has changed
- * @param path the path to the root node
- * @param childIndices the indices of the affected elements
- * @param children the affected elements
- */
- protected void fireTreeStructureChanged(Object source, Object[] path,
- int[] childIndices, Object[] children)
- {
- TreeModelEvent event =
- new TreeModelEvent(source, path, childIndices, children);
- TreeModelListener[] listeners = getTreeModelListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].treeStructureChanged(event);
- }
-
- /**
- * Returns the registered listeners of a given type.
- *
- * @param listenerType the listener type to return
- *
- * @return an array of listeners
- *
- * @since 1.3
- */
- public EventListener[] getListeners(Class listenerType)
- {
- return listenerList.getListeners(listenerType);
- }
+ static final long serialVersionUID = -2621068368932566998L;
+
+ /**
+ * root
+ */
+ protected TreeNode root = null;
+
+ /**
+ * listenerList
+ */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * asksAllowsChildren
+ */
+ protected boolean asksAllowsChildren;
+
+ /**
+ * Constructor DefaultTreeModel
+ * @param root the tree root.
+ */
+ public DefaultTreeModel(TreeNode root)
+ {
+ if (root == null)
+ root = new DefaultMutableTreeNode();
+ setRoot(root);
+ }
+
+ /**
+ * Constructor DefaultTreeModel
+ * @param root the tree root.
+ * @param asksAllowsChildren TODO
+ */
+ public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
+ {
+ setRoot(root);
+ this.asksAllowsChildren = asksAllowsChildren;
+ }
+
+ /**
+ * writeObject
+ * @param obj the object.
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream obj) throws IOException
+ {
+ // TODO
+ }
+
+ /**
+ * readObject
+ * @param value0 TODO
+ * @exception IOException TODO
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream value0) throws IOException,
+ ClassNotFoundException
+ {
+ // TODO
+ }
+
+ /**
+ * asksAllowsChildren
+ * @return boolean
+ */
+ public boolean asksAllowsChildren()
+ {
+ return asksAllowsChildren;
+ }
+
+ /**
+ * setAsksAllowsChildren
+ * @param value TODO
+ */
+ public void setAsksAllowsChildren(boolean value)
+ {
+ asksAllowsChildren = value; // TODO
+ }
+
+ /**
+ * setRoot
+ * @param root the root node.
+ */
+ public void setRoot(TreeNode root)
+ {
+ // Sanity Check
+ if (root == null)
+ {
+ throw new IllegalArgumentException("null root");
+ }
+ // Set new root
+ this.root = root;
+
+ // TODO
+ }
+
+ /**
+ * getRoot
+ * @return Object
+ */
+ public Object getRoot()
+ {
+ return root;
+ }
+
+ /**
+ * getIndexOfChild
+ * @param parent TODO
+ * @param child TODO
+ * @return int
+ */
+ public int getIndexOfChild(Object parent, Object child)
+ {
+ return 0; // TODO
+ }
+
+ /**
+ * getChild
+ * @param node TODO
+ * @param idx TODO
+ * @return Object
+ */
+ public Object getChild(Object node, int idx)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildAt(idx);
+ else
+ return null;
+ }
+
+ /**
+ * getChildCount
+ * @param node TODO
+ * @return int
+ */
+ public int getChildCount(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildCount();
+ else
+ return 0;
+ }
+
+ /**
+ * isLeaf
+ * @param node TODO
+ * @return boolean
+ */
+ public boolean isLeaf(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).isLeaf();
+ else
+ return true;
+ }
+
+ /**
+ * reload
+ */
+ public void reload()
+ {
+ // TODO
+ }
+
+ /**
+ * reload
+ * @param value0 TODO
+ */
+ public void reload(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * valueForPathChanged
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void valueForPathChanged(TreePath value0, Object value1)
+ {
+ // TODO
+ }
+
+ /**
+ * insertNodeInto
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1,
+ int value2)
+ {
+ // TODO
+ }
+
+ /**
+ * removeNodeFromParent
+ * @param value0 TODO
+ */
+ public void removeNodeFromParent(MutableTreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * nodeChanged
+ * @param value0 TODO
+ */
+ public void nodeChanged(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesWereInserted
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void nodesWereInserted(TreeNode value0, int[] value1)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesWereRemoved
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesChanged
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void nodesChanged(TreeNode value0, int[] value1)
+ {
+ // TODO
+ }
+
+ /**
+ * nodeStructureChanged
+ * @param value0 TODO
+ */
+ public void nodeStructureChanged(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * getPathToRoot
+ * @param value0 TODO
+ * @return TreeNode[]
+ */
+ public TreeNode[] getPathToRoot(TreeNode value0)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * getPathToRoot
+ * @param value0 TODO
+ * @param value1 TODO
+ * @return TreeNode[]
+ */
+ protected TreeNode[] getPathToRoot(TreeNode value0, int value1)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Registers a listere to the model.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeModelListener(TreeModelListener listener)
+ {
+ listenerList.add(TreeModelListener.class, listener);
+ }
+
+ /**
+ * Removes a listener from the model.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeModelListener(TreeModelListener listener)
+ {
+ listenerList.remove(TreeModelListener.class, listener);
+ }
+
+ /**
+ * Returns all registered <code>TreeModelListener</code> listeners.
+ *
+ * @return an array of listeners.
+ *
+ * @since 1.4
+ */
+ public TreeModelListener[] getTreeModelListeners()
+ {
+ return (TreeModelListener[]) listenerList
+ .getListeners(TreeModelListener.class);
+ }
+
+ /**
+ * fireTreeNodesChanged
+ *
+ * @param source the node being changed
+ * @param path the path to the root node
+ * @param childIndices the indices of the changed elements
+ * @param children the changed elements
+ */
+ protected void fireTreeNodesChanged(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesChanged(event);
+ }
+
+ /**
+ * fireTreeNodesInserted
+ *
+ * @param source the node where new nodes got inserted
+ * @param path the path to the root node
+ * @param childIndices the indices of the new elements
+ * @param children the new elements
+ */
+ protected void fireTreeNodesInserted(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesInserted(event);
+ }
+
+ /**
+ * fireTreeNodesRemoved
+ *
+ * @param source the node where nodes got removed-
+ * @param path the path to the root node
+ * @param childIndices the indices of the removed elements
+ * @param children the removed elements
+ */
+ protected void fireTreeNodesRemoved(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesRemoved(event);
+ }
+
+ /**
+ * fireTreeStructureChanged
+ *
+ * @param source the node where the model has changed
+ * @param path the path to the root node
+ * @param childIndices the indices of the affected elements
+ * @param children the affected elements
+ */
+ protected void fireTreeStructureChanged(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeStructureChanged(event);
+ }
+
+ /**
+ * Returns the registered listeners of a given type.
+ *
+ * @param listenerType the listener type to return
+ *
+ * @return an array of listeners
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
}
diff --git a/javax/swing/tree/DefaultTreeSelectionModel.java b/javax/swing/tree/DefaultTreeSelectionModel.java
index d53de53aa..de27dad04 100644
--- a/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -1,6 +1,6 @@
-/* DefaultTreeSelectionModel.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
-
+/* DefaultTreeSelectionModel.java
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -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.tree;
import java.beans.PropertyChangeListener;
@@ -54,593 +53,702 @@ import javax.swing.event.TreeSelectionListener;
/**
* DefaultTreeSelectionModel
+ *
* @author Andrew Selkirk
*/
public class DefaultTreeSelectionModel
- implements Cloneable, Serializable, TreeSelectionModel
+ implements Cloneable, Serializable, TreeSelectionModel
{
- static final long serialVersionUID = 3288129636638950196L;
-
- /**
- * SELECTION_MODE_PROPERTY
- */
- public static final String SELECTION_MODE_PROPERTY = "selectionMode";
-
- /**
- * Our Swing property change support.
- */
- protected SwingPropertyChangeSupport changeSupport;
-
- /**
- * The current selection.
- */
- protected TreePath[] selection;
-
- /**
- * Our TreeSelectionListeners.
- */
- protected EventListenerList listenerList;
-
- /**
- * The current RowMapper.
- */
- protected transient RowMapper rowMapper;
-
- /**
- * The current listSelectionModel.
- */
- protected DefaultListSelectionModel listSelectionModel;
-
- /**
- * The current selection mode.
- */
- protected int selectionMode;
-
- /**
- * The path that has been added last.
- */
- protected TreePath leadPath;
-
- /**
- * The index of the last added path.
- */
- protected int leadIndex;
-
- /**
- * The row of the last added path according to the RowMapper.
- */
- protected int leadRow;
-
- /**
- * Constructs a new DefaultTreeSelectionModel.
- */
- public DefaultTreeSelectionModel()
- {
- setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
- listenerList = new EventListenerList();
- }
-
- /**
- * Creates a clone of this DefaultTreeSelectionModel with the same
- * selection.
- *
- * @exception CloneNotSupportedException should not be thrown here
- *
- * @return a clone of this DefaultTreeSelectionModel
- */
- public Object clone() throws CloneNotSupportedException
- {
- return null; // TODO
- }
-
- /**
- * Returns a string that shows this object's properties.
- *
- * @return a string that shows this object's properties
- */
- public String toString()
- {
- return null; // TODO
- }
-
- /**
- * writeObject
- * @param value0 TODO
- * @exception IOException TODO
- */
- private void writeObject(ObjectOutputStream value0) throws IOException
- {
- // TODO
- }
-
- /**
- * readObject
- * @param value0 TODO
- * @exception IOException TODO
- * @exception ClassNotFoundException TODO
- */
- private void readObject(ObjectInputStream value0)
- throws IOException, ClassNotFoundException
- {
- // TODO
- }
-
- /**
- * Sets the RowMapper that should be used to map between paths and their
- * rows.
- *
- * @param rowMapper the RowMapper to set
- *
- * @see {@link RowMapper
- */
- public void setRowMapper(RowMapper value0)
- {
- // TODO
- }
-
- /**
- * Returns the RowMapper that is currently used to map between paths and
- * their rows.
- *
- * @return the current RowMapper
- *
- * @see {@link RowMapper
- */
- public RowMapper getRowMapper()
- {
- return rowMapper;
- }
-
- /**
- * Sets the current selection mode. Possible values are
- * {@link #SINGLE_TREE_SELECTION}, {@link CONTIGUOUS_TREE_SELECTION}
- * and {@link #DISCONTIGUOUS_TREE_SELECTION}.
- *
- * @param mode the selection mode to be set
- *
- * @see {@link #getSelectionMode}
- * @see {@link #SINGLE_TREE_SELECTION}
- * @see {@link #CONTIGUOUS_TREE_SELECTION}
- * @see {@link #DISCONTIGUOUS_TREE_SELECTION}
- */
- public void setSelectionMode(int mode)
- {
- selectionMode = mode;
- }
-
- /**
- * Returns the current selection mode.
- *
- * @return the current selection mode
- *
- * @see {@link #setSelectionMode}
- * @see {@link #SINGLE_TREE_SELECTION}
- * @see {@link #CONTIGUOUS_TREE_SELECTION}
- * @see {@link #DISCONTIGUOUS_TREE_SELECTION}
- */
- public int getSelectionMode()
- {
- return selectionMode;
- }
-
- /**
- * Sets this path as the only selection.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param path the path to set as selection
- */
- public void setSelectionPath(TreePath path)
- {
- selection = new TreePath[] { path };
- }
-
- /**
- * Sets the paths as selection. This method checks for duplicates and
- * removes them.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param paths the paths to set as selection
- */
- public void setSelectionPaths(TreePath[] value0)
- {
- // TODO
- }
-
- /**
- * Adds a path to the list of selected paths. This method checks if the
- * path is already selected and doesn't add the same path twice.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param path the path to add to the selection
- */
- public void addSelectionPath(TreePath value0)
- {
- // TODO
- }
-
- /**
- * Adds the paths to the list of selected paths. This method checks if the
- * paths are already selected and doesn't add the same path twice.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param paths the paths to add to the selection
- */
- public void addSelectionPaths(TreePath[] value0)
- {
- // TODO
- }
-
- /**
- * Removes the path from the selection.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param path the path to remove
- */
- public void removeSelectionPath(TreePath value0)
- {
- // TODO
- }
-
- /**
- * Removes the paths from the selection.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param paths the path to remove
- */
- public void removeSelectionPaths(TreePath[] value0)
- {
- // TODO
- }
-
- /**
- * Returns the first path in the selection. This is especially useful
- * when the selectionMode is {@link #SINGLE_TREE_SELECTION}.
- *
- * @return the first path in the selection
- */
- public TreePath getSelectionPath()
- {
- if ((selection == null) || (selection.length == 0))
- return null;
- else
- return selection[0];
- }
-
- /**
- * Returns the complete selection.
- *
- * @return the complete selection
- */
- public TreePath[] getSelectionPaths()
- {
- return selection;
- }
-
- /**
- * Returns the number of paths in the selection.
- *
- * @return the number of paths in the selection
- */
- public int getSelectionCount()
- {
- if (selection == null)
- return 0;
- else
- return selection.length;
- }
-
- /**
- * Checks if a given path is in the selection.
- *
- * @param path the path to check
- *
- * @return <code>true</code> if the path is in the selection,
- * <code>false</code> otherwise
- */
- public boolean isPathSelected(TreePath value0)
- {
- return false; // TODO
- }
-
- /**
- * Checks if the selection is empty.
- *
- * @return <code>true</code> if the selection is empty,
- * <code>false</code> otherwise
- */
- public boolean isSelectionEmpty()
- {
- return ((selection == null) || (selection.length == 0));
- }
-
- /**
- * Removes all paths from the selection.
- */
- public void clearSelection()
- {
- // TODO
- }
-
- /**
- * Adds a <code>TreeSelectionListener</code> object to this model.
- *
- * @param listener the listener to add
- */
- public void addTreeSelectionListener(TreeSelectionListener listener)
- {
- listenerList.add(TreeSelectionListener.class, listener);
- }
-
- /**
- * Removes a <code>TreeSelectionListener</code> object from this model.
- *
- * @param listener the listener to remove
- */
- public void removeTreeSelectionListener(TreeSelectionListener listener)
- {
- listenerList.remove(TreeSelectionListener.class, listener);
- }
-
- /**
- * Returns all <code>TreeSelectionListener</code> added to this model.
- *
- * @return an array of listeners
- *
- * @since 1.4
- */
- public TreeSelectionListener[] getTreeSelectionListeners()
- {
- return (TreeSelectionListener[]) listenerList.getListeners(TreeSelectionListener.class);
- }
-
- /**
- * fireValueChanged
- *
- * @param event the event to fire.
- */
- protected void fireValueChanged(TreeSelectionEvent event)
- {
- TreeSelectionListener[] listeners = getTreeSelectionListeners();
-
- for (int i = listeners.length - 1; i >= 0; --i)
- listeners[i].valueChanged(event);
- }
-
- /**
- * Returns all added listeners of a special type.
- *
- * @param listenerType the listener type
- *
- * @return an array of listeners
- *
- * @since 1.3
- */
- public EventListener[] getListeners(Class listenerType)
- {
- return listenerList.getListeners(listenerType);
- }
-
- /**
- * Returns the currently selected rows.
- *
- * @return the currently selected rows
- */
- public int[] getSelectionRows()
- {
- if (rowMapper == null)
- return null;
- else
- return rowMapper.getRowsForPaths(selection);
- }
-
- /**
- * Returns the smallest row index from the selection.
- *
- * @return the smallest row index from the selection
- */
- public int getMinSelectionRow()
- {
- if ((rowMapper == null) || (selection == null) || (selection.length == 0))
- return -1;
- else {
- int[] rows = rowMapper.getRowsForPaths(selection);
- int minRow = Integer.MAX_VALUE;
- for (int index = 0; index < rows.length; index++)
- minRow = Math.min(minRow, rows[index]);
- return minRow;
- }
- }
-
- /**
- * Returns the largest row index from the selection.
- *
- * @return the largest row index from the selection
- */
- public int getMaxSelectionRow()
- {
- if ((rowMapper == null) || (selection == null) || (selection.length == 0))
- return -1;
- else {
- int[] rows = rowMapper.getRowsForPaths(selection);
- int maxRow = -1;
- for (int index = 0; index < rows.length; index++)
- maxRow = Math.max(maxRow, rows[index]);
- return maxRow;
- }
- }
-
- /**
- * Checks if a particular row is selected.
- *
- * @param row the index of the row to check
- *
- * @return <code>true</code> if the row is in this selection,
- * <code>false</code> otherwise
- */
- public boolean isRowSelected(int value0)
- {
- return false; // TODO
- }
-
- /**
- * Updates the mappings from TreePaths to row indices.
- */
- public void resetRowSelection()
- {
- // TODO
- }
-
- /**
- * getLeadSelectionRow
- * @return int
- */
- public int getLeadSelectionRow()
- {
- if ((rowMapper == null) || (leadPath == null))
- return -1;
- else
- return rowMapper.getRowsForPaths(new TreePath[]{ leadPath })[0];
- }
-
- /**
- * getLeadSelectionPath
- * @return TreePath
- */
- public TreePath getLeadSelectionPath()
- {
- return leadPath;
- }
-
- /**
- * Adds a <code>PropertyChangeListener</code> object to this model.
- *
- * @param listener the listener to add.
- */
- public void addPropertyChangeListener(PropertyChangeListener listener)
- {
- changeSupport.addPropertyChangeListener(listener);
- }
-
- /**
- * Removes a <code>PropertyChangeListener</code> object from this model.
- *
- * @param listener the listener to remove.
- */
- public void removePropertyChangeListener(PropertyChangeListener listener)
- {
- changeSupport.removePropertyChangeListener(listener);
- }
-
- /**
- * Returns all added <code>PropertyChangeListener</code> objects.
- *
- * @return an array of listeners.
- *
- * @since 1.4
- */
- public PropertyChangeListener[] getPropertyChangeListeners()
- {
- return changeSupport.getPropertyChangeListeners();
- }
-
- /**
- * Makes sure the currently selected paths are valid according to the
- * current selectionMode.
- *
- * If the selectionMode is set to {@link CONTIGUOUS_TREE_SELECTION}
- * and the selection isn't contiguous then the selection is reset to
- * the first set of contguous paths.
- *
- * If the selectionMode is set to {@link SINGLE_TREE_SELECTION}
- * and the selection has more than one path, the selection is reset to
- * the contain only the first path.
- */
- protected void insureRowContinuity()
- {
- // TODO
- }
-
- /**
- * Returns <code>true</code> if the paths are contiguous or we
- * have no RowMapper assigned.
- *
- * @param paths the paths to check for continuity
- * @return <code>true</code> if the paths are contiguous or we
- * have no RowMapper assigned
- */
- protected boolean arePathsContiguous(TreePath[] value0)
- {
- return false; // TODO
- }
-
- /**
- * Checks if the paths can be added. This returns <code>true</code> if:
- * <ul>
- * <li><code>paths</code> is <code>null</code> or empty</li>
- * <li>we have no RowMapper assigned</li>
- * <li>nothing is currently selected</li>
- * <li>selectionMode is {@link DISCONTIGUOUS_TREE_SELECTION</li>
- * <li>adding the paths to the selection still results in a contiguous set
- * of paths</li>
- *
- * @param paths the paths to check
- *
- * @return <code>true</code> if the paths can be added with respect to the
- * selectionMode
- */
- protected boolean canPathsBeAdded(TreePath[] value0)
- {
- return false; // TODO
- }
-
- /**
- * Checks if the paths can be removed without breaking the continuity of
- * the selection according to selectionMode.
- *
- * @param paths the paths to check
- * @return <code>true</code> if the paths can be removed with respect to the
- * selectionMode
- */
- protected boolean canPathsBeRemoved(TreePath[] value0)
- {
- return false; // TODO
- }
-
- /**
- * notifyPathChange
- * @param value0 TODO
- * @param value1 TODO
- */
- protected void notifyPathChange(Vector value0, TreePath value1)
- {
- // TODO
- }
-
- /**
- * Updates the lead index instance field.
- */
- protected void updateLeadIndex()
- {
- // TODO
- }
-
- /**
- * Deprecated and not used.
- */
- protected void insureUniqueness()
- {
- // TODO
- }
+ static final long serialVersionUID = 3288129636638950196L;
+
+ /**
+ * SELECTION_MODE_PROPERTY
+ */
+ public static final String SELECTION_MODE_PROPERTY = "selectionMode";
+
+ /**
+ * Our Swing property change support.
+ */
+ protected SwingPropertyChangeSupport changeSupport;
+
+ /**
+ * The current selection.
+ */
+ protected TreePath[] selection;
+
+ /**
+ * Our TreeSelectionListeners.
+ */
+ protected EventListenerList listenerList;
+
+ /**
+ * The current RowMapper.
+ */
+ protected transient RowMapper rowMapper;
+
+ /**
+ * The current listSelectionModel.
+ */
+ protected DefaultListSelectionModel listSelectionModel;
+
+ /**
+ * The current selection mode.
+ */
+ protected int selectionMode;
+
+ /**
+ * The path that has been added last.
+ */
+ protected TreePath leadPath;
+
+ /**
+ * The index of the last added path.
+ */
+ protected int leadIndex;
+
+ /**
+ * The row of the last added path according to the RowMapper.
+ */
+ protected int leadRow;
+
+ /**
+ * Constructs a new DefaultTreeSelectionModel.
+ */
+ public DefaultTreeSelectionModel()
+ {
+ setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
+ listenerList = new EventListenerList();
+ }
+
+ /**
+ * Creates a clone of this DefaultTreeSelectionModel with the same
+ * selection.
+ *
+ * @exception CloneNotSupportedException should not be thrown here
+ *
+ * @return a clone of this DefaultTreeSelectionModel
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Returns a string that shows this object's properties.
+ *
+ * @return a string that shows this object's properties
+ */
+ public String toString()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * writeObject
+ *
+ * @param value0 TODO
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream value0) throws IOException
+ {
+ // TODO
+ }
+
+ /**
+ * readObject
+ *
+ * @param value0 TODO
+ * @exception IOException TODO
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream value0) throws IOException,
+ ClassNotFoundException
+ {
+ // TODO
+ }
+
+ /**
+ * Sets the RowMapper that should be used to map between paths and their
+ * rows.
+ *
+ * @param rowMapper the RowMapper to set
+ *
+ * @see RowMapper
+ */
+ public void setRowMapper(RowMapper rowMapper)
+ {
+ // TODO
+ }
+
+ /**
+ * Returns the RowMapper that is currently used to map between paths and
+ * their rows.
+ *
+ * @return the current RowMapper
+ *
+ * @see RowMapper
+ */
+ public RowMapper getRowMapper()
+ {
+ return rowMapper;
+ }
+
+ /**
+ * Sets the current selection mode. Possible values are
+ * {@link #SINGLE_TREE_SELECTION}, {@link #CONTIGUOUS_TREE_SELECTION} and
+ * {@link #DISCONTIGUOUS_TREE_SELECTION}.
+ *
+ * @param mode the selection mode to be set
+ *
+ * @see #getSelectionMode
+ * @see #SINGLE_TREE_SELECTION
+ * @see #CONTIGUOUS_TREE_SELECTION
+ * @see #DISCONTIGUOUS_TREE_SELECTION
+ */
+ public void setSelectionMode(int mode)
+ {
+ selectionMode = mode;
+ }
+
+ /**
+ * Returns the current selection mode.
+ *
+ * @return the current selection mode
+ *
+ * @see #setSelectionMode
+ * @see #SINGLE_TREE_SELECTION
+ * @see #CONTIGUOUS_TREE_SELECTION
+ * @see #DISCONTIGUOUS_TREE_SELECTION
+ */
+ public int getSelectionMode()
+ {
+ return selectionMode;
+ }
+
+ /**
+ * Sets this path as the only selection.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param path the path to set as selection
+ */
+ public void setSelectionPath(TreePath path)
+ {
+ selection = new TreePath[] {
+ path };
+ }
+
+ /**
+ * Sets the paths as selection. This method checks for duplicates and
+ * removes them.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param paths the paths to set as selection
+ */
+ public void setSelectionPaths(TreePath[] paths)
+ {
+ // TODO
+ }
+
+ /**
+ * Adds a path to the list of selected paths. This method checks if the path
+ * is already selected and doesn't add the same path twice.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param path the path to add to the selection
+ */
+ public void addSelectionPath(TreePath path)
+ {
+ if (!isPathSelected(path))
+ {
+ if (isSelectionEmpty())
+ setSelectionPath(path);
+ else
+ {
+ TreePath[] temp = new TreePath[selection.length + 1];
+ System.arraycopy(selection, 0, temp, 0, selection.length);
+ temp[temp.length - 1] = path;
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+ }
+ leadPath = path;
+ fireValueChanged(new TreeSelectionEvent(this, path, true,
+ leadPath, path));
+ }
+ }
+
+ /**
+ * Adds the paths to the list of selected paths. This method checks if the
+ * paths are already selected and doesn't add the same path twice.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param paths the paths to add to the selection
+ */
+ public void addSelectionPaths(TreePath[] paths)
+ {
+ if (paths != null)
+ {
+ TreePath v0 = null;
+ for (int i = 0; i < paths.length; i++)
+ {
+ v0 = paths[i];
+ if (!isPathSelected(v0))
+ {
+ if (isSelectionEmpty())
+ setSelectionPath(v0);
+ else
+ {
+ TreePath[] temp = new TreePath[selection.length + 1];
+ System.arraycopy(selection, 0, temp, 0,
+ selection.length);
+ temp[temp.length - 1] = v0;
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+ }
+ leadPath = paths[paths.length - 1];
+ fireValueChanged(new TreeSelectionEvent(this, v0, true,
+ leadPath, paths[0]));
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the path from the selection.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param path the path to remove
+ */
+ public void removeSelectionPath(TreePath path)
+ {
+ int index = -1;
+ if (isPathSelected(path))
+ {
+ for (int i = 0; i < selection.length; i++)
+ {
+ if (selection[i].equals(path))
+ {
+ index = i;
+ break;
+ }
+ }
+ TreePath[] temp = new TreePath[selection.length - 1];
+ System.arraycopy(selection, 0, temp, 0, index);
+ System.arraycopy(selection, index + 1, temp, index,
+ selection.length - index - 1);
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+
+ fireValueChanged(new TreeSelectionEvent(this, path, false,
+ leadPath, path));
+ }
+ }
+
+ /**
+ * Removes the paths from the selection.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param paths the paths to remove
+ */
+ public void removeSelectionPaths(TreePath[] paths)
+ {
+ if (paths != null)
+ {
+ int index = -1;
+ TreePath v0 = null;
+ for (int i = 0; i < paths.length; i++)
+ {
+ v0 = paths[i];
+ if (isPathSelected(v0))
+ {
+ for (int x = 0; x < selection.length; x++)
+ {
+ if (selection[i].equals(v0))
+ {
+ index = x;
+ break;
+ }
+ }
+ TreePath[] temp = new TreePath[selection.length - 1];
+ System.arraycopy(selection, 0, temp, 0, index);
+ System.arraycopy(selection, index + 1, temp, index,
+ selection.length - index - 1);
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+
+ fireValueChanged(new TreeSelectionEvent(this, v0, false,
+ leadPath, paths[0]));
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the first path in the selection. This is especially useful when
+ * the selectionMode is {@link #SINGLE_TREE_SELECTION}.
+ *
+ * @return the first path in the selection
+ */
+ public TreePath getSelectionPath()
+ {
+ if ((selection == null) || (selection.length == 0))
+ return null;
+ else
+ return selection[0];
+ }
+
+ /**
+ * Returns the complete selection.
+ *
+ * @return the complete selection
+ */
+ public TreePath[] getSelectionPaths()
+ {
+ return selection;
+ }
+
+ /**
+ * Returns the number of paths in the selection.
+ *
+ * @return the number of paths in the selection
+ */
+ public int getSelectionCount()
+ {
+ if (selection == null)
+ return 0;
+ else
+ return selection.length;
+ }
+
+ /**
+ * Checks if a given path is in the selection.
+ *
+ * @param path the path to check
+ *
+ * @return <code>true</code> if the path is in the selection,
+ * <code>false</code> otherwise
+ */
+ public boolean isPathSelected(TreePath path)
+ {
+ if (selection == null)
+ return false;
+
+ for (int i = 0; i < selection.length; i++)
+ {
+ if (selection[i].equals(path))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if the selection is empty.
+ *
+ * @return <code>true</code> if the selection is empty, <code>false</code>
+ * otherwise
+ */
+ public boolean isSelectionEmpty()
+ {
+ return ((selection == null) || (selection.length == 0));
+ }
+
+ /**
+ * Removes all paths from the selection.
+ */
+ public void clearSelection()
+ {
+ leadPath = null;
+ selection = null;
+ }
+
+ /**
+ * Adds a <code>TreeSelectionListener</code> object to this model.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeSelectionListener(TreeSelectionListener listener)
+ {
+ listenerList.add(TreeSelectionListener.class, listener);
+ }
+
+ /**
+ * Removes a <code>TreeSelectionListener</code> object from this model.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeSelectionListener(TreeSelectionListener listener)
+ {
+ listenerList.remove(TreeSelectionListener.class, listener);
+ }
+
+ /**
+ * Returns all <code>TreeSelectionListener</code> added to this model.
+ *
+ * @return an array of listeners
+ *
+ * @since 1.4
+ */
+ public TreeSelectionListener[] getTreeSelectionListeners()
+ {
+ return (TreeSelectionListener[])
+ getListeners(TreeSelectionListener.class);
+ }
+
+ /**
+ * fireValueChanged
+ *
+ * @param event the event to fire.
+ */
+ protected void fireValueChanged(TreeSelectionEvent event)
+ {
+ TreeSelectionListener[] listeners = getTreeSelectionListeners();
+
+ for (int i = 0; i < listeners.length; ++i)
+ listeners[i].valueChanged(event);
+ }
+
+ /**
+ * Returns all added listeners of a special type.
+ *
+ * @param listenerType the listener type
+ *
+ * @return an array of listeners
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
+
+ /**
+ * Returns the currently selected rows.
+ *
+ * @return the currently selected rows
+ */
+ public int[] getSelectionRows()
+ {
+ if (rowMapper == null)
+ return null;
+ else
+ return rowMapper.getRowsForPaths(selection);
+ }
+
+ /**
+ * Returns the smallest row index from the selection.
+ *
+ * @return the smallest row index from the selection
+ */
+ public int getMinSelectionRow()
+ {
+ if ((rowMapper == null) || (selection == null)
+ || (selection.length == 0))
+ return -1;
+ else
+ {
+ int[] rows = rowMapper.getRowsForPaths(selection);
+ int minRow = Integer.MAX_VALUE;
+ for (int index = 0; index < rows.length; index++)
+ minRow = Math.min(minRow, rows[index]);
+ return minRow;
+ }
+ }
+
+ /**
+ * Returns the largest row index from the selection.
+ *
+ * @return the largest row index from the selection
+ */
+ public int getMaxSelectionRow()
+ {
+ if ((rowMapper == null) || (selection == null)
+ || (selection.length == 0))
+ return -1;
+ else
+ {
+ int[] rows = rowMapper.getRowsForPaths(selection);
+ int maxRow = -1;
+ for (int index = 0; index < rows.length; index++)
+ maxRow = Math.max(maxRow, rows[index]);
+ return maxRow;
+ }
+ }
+
+ /**
+ * Checks if a particular row is selected.
+ *
+ * @param row the index of the row to check
+ *
+ * @return <code>true</code> if the row is in this selection,
+ * <code>false</code> otherwise
+ */
+ public boolean isRowSelected(int row)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * Updates the mappings from TreePaths to row indices.
+ */
+ public void resetRowSelection()
+ {
+ // TODO
+ }
+
+ /**
+ * getLeadSelectionRow
+ *
+ * @return int
+ */
+ public int getLeadSelectionRow()
+ {
+ if ((rowMapper == null) || (leadPath == null))
+ return -1;
+ else
+ return rowMapper.getRowsForPaths(new TreePath[] {
+ leadPath })[0];
+ }
+
+ /**
+ * getLeadSelectionPath
+ *
+ * @return TreePath
+ */
+ public TreePath getLeadSelectionPath()
+ {
+ return leadPath;
+ }
+
+ /**
+ * Adds a <code>PropertyChangeListener</code> object to this model.
+ *
+ * @param listener the listener to add.
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * Removes a <code>PropertyChangeListener</code> object from this model.
+ *
+ * @param listener the listener to remove.
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Returns all added <code>PropertyChangeListener</code> objects.
+ *
+ * @return an array of listeners.
+ *
+ * @since 1.4
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ return changeSupport.getPropertyChangeListeners();
+ }
+
+ /**
+ * Makes sure the currently selected paths are valid according to the
+ * current selectionMode.
+ *
+ * If the selectionMode is set to {@link #CONTIGUOUS_TREE_SELECTION} and the
+ * selection isn't contiguous then the selection is reset to the first set
+ * of contguous paths.
+ *
+ * If the selectionMode is set to {@link #SINGLE_TREE_SELECTION} and the
+ * selection has more than one path, the selection is reset to the contain
+ * only the first path.
+ */
+ protected void insureRowContinuity()
+ {
+ // TODO
+ }
+
+ /**
+ * Returns <code>true</code> if the paths are contiguous or we have no
+ * RowMapper assigned.
+ *
+ * @param paths the paths to check for continuity
+ * @return <code>true</code> if the paths are contiguous or we have no
+ * RowMapper assigned
+ */
+ protected boolean arePathsContiguous(TreePath[] paths)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * Checks if the paths can be added. This returns <code>true</code> if:
+ * <ul>
+ * <li><code>paths</code> is <code>null</code> or empty</li>
+ * <li>we have no RowMapper assigned</li>
+ * <li>nothing is currently selected</li>
+ * <li>selectionMode is {@link #DISCONTIGUOUS_TREE_SELECTION}</li>
+ * <li>adding the paths to the selection still results in a contiguous set
+ * of paths</li>
+ *
+ * @param paths the paths to check
+ *
+ * @return <code>true</code> if the paths can be added with respect to the
+ * selectionMode
+ */
+ protected boolean canPathsBeAdded(TreePath[] paths)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * Checks if the paths can be removed without breaking the continuity of the
+ * selection according to selectionMode.
+ *
+ * @param paths the paths to check
+ * @return <code>true</code> if the paths can be removed with respect to
+ * the selectionMode
+ */
+ protected boolean canPathsBeRemoved(TreePath[] paths)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * notifyPathChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ protected void notifyPathChange(Vector value0, TreePath value1)
+ {
+ // TODO
+ }
+
+ /**
+ * Updates the lead index instance field.
+ */
+ protected void updateLeadIndex()
+ {
+ // TODO
+ }
+
+ /**
+ * Deprecated and not used.
+ */
+ protected void insureUniqueness()
+ {
+ // TODO
+ }
}
diff --git a/javax/swing/tree/ExpandVetoException.java b/javax/swing/tree/ExpandVetoException.java
index 5edf09a11..1c8827c8a 100644
--- a/javax/swing/tree/ExpandVetoException.java
+++ b/javax/swing/tree/ExpandVetoException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/FixedHeightLayoutCache.java b/javax/swing/tree/FixedHeightLayoutCache.java
index 5cb6d3a2a..535417ec3 100644
--- a/javax/swing/tree/FixedHeightLayoutCache.java
+++ b/javax/swing/tree/FixedHeightLayoutCache.java
@@ -1,5 +1,5 @@
/* FixedHeightLayoutCache.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -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.tree;
import java.awt.Rectangle;
@@ -45,192 +44,201 @@ import javax.swing.event.TreeModelEvent;
/**
* FixedHeightLayoutCache
+ *
* @author Andrew Selkirk
*/
-public class FixedHeightLayoutCache extends AbstractLayoutCache {
+public class FixedHeightLayoutCache
+ extends AbstractLayoutCache
+{
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Variables --------------------------------------------------
- //-------------------------------------------------------------
-
+ // -------------------------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Initialization ---------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
/**
* Constructor FixedHeightLayoutCache
*/
- public FixedHeightLayoutCache() {
+ public FixedHeightLayoutCache()
+ {
// TODO
} // FixedHeightLayoutCache()
-
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * setModel
- * @param value0 TODO
- */
- public void setModel(TreeModel value0) {
- // TODO
- } // setModel()
-
- /**
- * setRootVisible
- * @param value0 TODO
- */
- public void setRootVisible(boolean value0) {
- // TODO
- } // setRootVisible()
-
- /**
- * setRowHeight
- * @param value0 TODO
- */
- public void setRowHeight(int value0) {
- // TODO
- } // setRowHeight()
+ // -------------------------------------------------------------
/**
* getRowCount
+ *
* @returns int
*/
- public int getRowCount() {
+ public int getRowCount()
+ {
return 0; // TODO
} // getRowCount()
/**
* invalidatePathBounds
+ *
* @param value0 TODO
*/
- public void invalidatePathBounds(TreePath value0) {
+ public void invalidatePathBounds(TreePath value0)
+ {
// TODO
} // invalidatePathBounds()
/**
* invalidateSizes
*/
- public void invalidateSizes() {
+ public void invalidateSizes()
+ {
// TODO
} // invalidateSizes()
/**
* isExpanded
+ *
* @param value0 TODO
* @returns boolean
*/
- public boolean isExpanded(TreePath value0) {
+ public boolean isExpanded(TreePath value0)
+ {
return false; // TODO
} // isExpanded()
/**
* getBounds
+ *
* @param value0 TODO
* @param value1 TODO
* @returns Rectangle
*/
- public Rectangle getBounds(TreePath value0, Rectangle value1) {
+ public Rectangle getBounds(TreePath value0, Rectangle value1)
+ {
return null; // TODO
} // getBounds()
/**
* getPathForRow
- * @param value0 TODO
+ *
+ * @param row TODO
* @returns TreePath
*/
- public TreePath getPathForRow(int value0) {
- return null; // TODO
+ public TreePath getPathForRow(int row)
+ {
+ //TODO
+ return null;
} // getPathForRow()
/**
* getRowForPath
+ *
* @param value0 TODO
* @returns int
*/
- public int getRowForPath(TreePath value0) {
- return 0; // TODO
+ public int getRowForPath(TreePath value0)
+ {
+ return 0;
} // getRowForPath()
/**
* getPathClosestTo
+ *
* @param value0 TODO
* @param value1 TODO
* @returns TreePath
*/
- public TreePath getPathClosestTo(int value0, int value1) {
+ public TreePath getPathClosestTo(int value0, int value1)
+ {
return null; // TODO
} // getPathClosestTo()
/**
* getVisibleChildCount
+ *
* @param value0 TODO
* @returns int
*/
- public int getVisibleChildCount(TreePath value0) {
+ public int getVisibleChildCount(TreePath value0)
+ {
return 0; // TODO
} // getVisibleChildCount()
/**
* getVisiblePathsFrom
+ *
* @param value0 TODO
* @returns Enumeration
*/
- public Enumeration getVisiblePathsFrom(TreePath value0) {
+ public Enumeration getVisiblePathsFrom(TreePath value0)
+ {
return null; // TODO
} // getVisiblePathsFrom()
/**
* setExpandedState
+ *
* @param value0 TODO
* @param value1 TODO
*/
- public void setExpandedState(TreePath value0, boolean value1) {
+ public void setExpandedState(TreePath value0, boolean value1)
+ {
// TODO
} // setExpandedState()
/**
* getExpandedState
+ *
* @param value0 TODO
* @returns boolean
*/
- public boolean getExpandedState(TreePath value0) {
+ public boolean getExpandedState(TreePath value0)
+ {
return false; // TODO
} // getExpandedState()
/**
* treeNodesChanged
+ *
* @param value0 TODO
*/
- public void treeNodesChanged(TreeModelEvent value0) {
+ public void treeNodesChanged(TreeModelEvent value0)
+ {
// TODO
} // treeNodesChanged()
/**
* treeNodesInserted
+ *
* @param value0 TODO
*/
- public void treeNodesInserted(TreeModelEvent value0) {
+ public void treeNodesInserted(TreeModelEvent value0)
+ {
// TODO
} // treeNodesInserted()
/**
* treeNodesRemoved
+ *
* @param value0 TODO
*/
- public void treeNodesRemoved(TreeModelEvent value0) {
+ public void treeNodesRemoved(TreeModelEvent value0)
+ {
// TODO
} // treeNodesRemoved()
/**
* treeStructureChanged
+ *
* @param value0 TODO
*/
- public void treeStructureChanged(TreeModelEvent value0) {
+ public void treeStructureChanged(TreeModelEvent value0)
+ {
// TODO
} // treeStructureChanged()
-
} // FixedHeightLayoutCache
diff --git a/javax/swing/tree/MutableTreeNode.java b/javax/swing/tree/MutableTreeNode.java
index 1f0c943aa..9f0ff4ded 100644
--- a/javax/swing/tree/MutableTreeNode.java
+++ b/javax/swing/tree/MutableTreeNode.java
@@ -1,5 +1,5 @@
/* MutableTreeNode.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -61,7 +61,7 @@ public interface MutableTreeNode extends TreeNode
*
* @param index the index
*
- * @see #add(MutableTreeNode,int)
+ * @see #insert(MutableTreeNode,int)
* @see #remove(MutableTreeNode)
* @see #removeFromParent()
*/
@@ -72,7 +72,7 @@ public interface MutableTreeNode extends TreeNode
*
* @param node the node to remove
*
- * @see #add(MutableTreeNode,int)
+ * @see #insert(MutableTreeNode,int)
* @see #remove(int)
* @see #removeFromParent()
*/
@@ -98,7 +98,7 @@ public interface MutableTreeNode extends TreeNode
*
* @param parent the parent
*
- * @see insert(MutableTreeNode,int)
+ * @see #insert(MutableTreeNode,int)
*/
void setParent(MutableTreeNode parent);
}
diff --git a/javax/swing/tree/RowMapper.java b/javax/swing/tree/RowMapper.java
index ea3122a46..690efb77e 100644
--- a/javax/swing/tree/RowMapper.java
+++ b/javax/swing/tree/RowMapper.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/TreeCellEditor.java b/javax/swing/tree/TreeCellEditor.java
index 4b4357a16..691cbc163 100644
--- a/javax/swing/tree/TreeCellEditor.java
+++ b/javax/swing/tree/TreeCellEditor.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/TreeCellRenderer.java b/javax/swing/tree/TreeCellRenderer.java
index ebd173efa..ebbe3fa91 100644
--- a/javax/swing/tree/TreeCellRenderer.java
+++ b/javax/swing/tree/TreeCellRenderer.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/TreeModel.java b/javax/swing/tree/TreeModel.java
index 00bd88b4c..759aaac58 100644
--- a/javax/swing/tree/TreeModel.java
+++ b/javax/swing/tree/TreeModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/TreeNode.java b/javax/swing/tree/TreeNode.java
index d7967f0ef..fb8f880f2 100644
--- a/javax/swing/tree/TreeNode.java
+++ b/javax/swing/tree/TreeNode.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/TreePath.java b/javax/swing/tree/TreePath.java
index 7c16fc21e..37ec632c9 100644
--- a/javax/swing/tree/TreePath.java
+++ b/javax/swing/tree/TreePath.java
@@ -1,5 +1,5 @@
/* TreePath.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -38,13 +38,14 @@ exception statement from your version. */
package javax.swing.tree;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.util.Arrays;
/**
- * TreePath
+ * A <code>TreePath</code> represents a sequence of tree elements that form
+ * a path starting from the root of a tree. A tree element can be represented
+ * by any {@link Object}.
+ *
* @author Andrew Selkirk
*/
public class TreePath implements Serializable
@@ -58,39 +59,48 @@ public class TreePath implements Serializable
/**
- * Constructor TreePath
- * @param path TODO
+ * Creates a path from the list of objects representing tree elements. The
+ * incoming array is copied so that subsequent changes do not affect this
+ * tree path.
+ *
+ * @param path the elements in the path (<code>null</code> not permitted).
+ *
+ * @throws IllegalArgumentException if <code>path</code> is <code>null</code>.
*/
public TreePath(Object[] path)
{
- // Create Path
+ if (path == null)
+ throw new IllegalArgumentException("Null 'path' not permitted.");
this.path = new Object[path.length];
System.arraycopy(path, 0, this.path, 0, path.length);
}
/**
- * Constructor TreePath
- * @param element TODO
+ * Creates a new path from a single element.
+ *
+ * @param element the element (<code>null</code> not permitted).
+ *
+ * @throws IllegalArgumentException if <code>element</code> is
+ * <code>null</code>.
*/
public TreePath(Object element)
{
- // Create Path
path = new Object[1];
path[0] = element;
}
/**
- * Constructor TreePath
- * @param path TODO
- * @param element TODO
+ * Creates a new tree path by adding the specified <code>element</code> to
+ * the <code>path</code>.
+ *
+ * @param path a tree path.
+ * @param element a path element.
*/
protected TreePath(TreePath path, Object element)
{
- // Variables
- Object[] treepath;
-
- // Get Tree Path
- treepath = path.getPath();
+ if (element == null)
+ throw new NullPointerException("Null 'element' argument.");
+ Object[] treepath = path.getPath();
// Create Tree Path
this.path = new Object[treepath.length + 1];
@@ -99,9 +109,11 @@ public class TreePath implements Serializable
}
/**
- * Constructor TreePath
- * @param path TODO
- * @param length TODO
+ * Creates a new tree path using the first <code>length</code> elements
+ * from the given array.
+ *
+ * @param path the path elements.
+ * @param length the path length.
*/
protected TreePath(Object[] path, int length)
{
@@ -111,7 +123,7 @@ public class TreePath implements Serializable
}
/**
- * Constructor TreePath
+ * Default constructor.
*/
protected TreePath()
{
@@ -120,8 +132,9 @@ public class TreePath implements Serializable
/**
- * hashCode
- * @returns int
+ * Returns a hashcode for the path.
+ *
+ * @return A hashcode.
*/
public int hashCode()
{
@@ -129,30 +142,33 @@ public class TreePath implements Serializable
}
/**
- * equals
- * @param object TODO
- * @returns boolean
+ * Tests this path for equality with an arbitrary object. An object is
+ * considered equal to this path if and only if:
+ * <ul>
+ * <li>the object is not <code>null</code>;</li>
+ * <li>the object is an instanceof {@link TreePath};</li>
+ * <li>the object contains the same elements in the same order as this
+ * {@link TreePath};</li>
+ * </ul>
+ *
+ * @param object the object (<code>null</code> permitted).
+ *
+ * @returns <code>true</code> if <code>obj</code> is equal to this tree path,
+ * and <code>false</code> otherwise.
*/
public boolean equals(Object object)
{
- // Variables
- Object[] treepath;
- int index;
+ Object[] treepath;
+ int index;
- // Check for TreePath
if (object instanceof TreePath)
{
- // Get Path Elements
treepath = ((TreePath) object).getPath();
-
- // Check length
if (treepath.length != path.length)
return false;
-
- // Check Elements
for (index = 0; index < path.length; index++)
{
- if (treepath[index] != path[index])
+ if (!treepath[index].equals(path[index]))
return false;
}
@@ -165,49 +181,32 @@ public class TreePath implements Serializable
}
/**
- * toString
- * @returns String
+ * Returns a string representation of this path.
+ *
+ * @return A string representation of this path.
*/
public String toString()
{
- return null; // TODO
+ if (path.length == 1)
+ return String.valueOf(path[0]);
+ else
+ return Arrays.asList(path).toString();
}
/**
- * writeObject
- * @param value0 TODO
- * @exception IOException TODO
- */
- private void writeObject(ObjectOutputStream value0)
- throws IOException
- {
- // TODO
- }
-
- /**
- * readObject
- * @param value0 TODO
- * @exception IOException TODO
- * @exception ClassNotFoundException TODO
- */
- private void readObject(ObjectInputStream value0)
- throws IOException, ClassNotFoundException
- {
- // TODO
- }
-
- /**
- * getPath
- * @returns Object[]
+ * Returns an array containing the path elements.
+ *
+ * @returns An array containing the path elements.
*/
public Object[] getPath()
{
- return path;
+ return (Object[]) path.clone();
}
/**
- * getLastPathComponent
- * @returns Object
+ * Returns the last object in the path.
+ *
+ * @return The last object in the path.
*/
public Object getLastPathComponent()
{
@@ -215,8 +214,9 @@ public class TreePath implements Serializable
}
/**
- * getPathCount
- * @returns int
+ * Returns the number of elements in the path.
+ *
+ * @returns The number of elements in the path.
*/
public int getPathCount()
{
@@ -224,57 +224,55 @@ public class TreePath implements Serializable
}
/**
- * getPathComponent
- * @param position TODO
- * @returns Object
+ * Returns the element at the specified position in the path.
+ *
+ * @param position the element position (<code>0 &lt N - 1</code>, where
+ * <code>N</code> is the number of elements in the path).
+ *
+ * @return The element at the specified position.
+ *
+ * @throws IllegalArgumentException if <code>position</code> is outside the
+ * valid range.
*/
public Object getPathComponent(int position)
{
+ if (position < 0 || position >= getPathCount())
+ throw new IllegalArgumentException("Invalid position: " + position);
return path[position];
}
/**
- * isDescendant
- * @param path TODO
- * @returns boolean
+ * Returns <code>true</code> if <code>path</code> is a descendant of this
+ * path, and <code>false</code> otherwise. If <code>path</code> is
+ * <code>null</code>, this method returns <code>false</code>.
+ *
+ * @param path the path to check (<code>null</code> permitted).
+ *
+ * @returns <code>true</code> if <code>path</code> is a descendant of this
+ * path, and <code>false</code> otherwise
*/
public boolean isDescendant(TreePath path)
{
-
- // Variables
- Object[] treepath;
- int index;
- int index2;
-
- // Get Descendant path
- treepath = path.getPath();
-
- // Locate Start Index
- index = 0;
- index2 = 0;
- while (treepath[index] != this.path[index2])
- index++;
-
- // Verify Paths
- while (treepath[index] == this.path[index2])
- {
- index++;
- index2++;
- }
-
- // Check for descendant
- if (index2 != this.path.length)
+ if (path == null)
return false;
-
- // Is Descendant
+ int count = getPathCount();
+ if (path.getPathCount() < count)
+ return false;
+ for (int i = 0; i < count; i++)
+ {
+ if (!this.path[i].equals(path.getPathComponent(i)))
+ return false;
+ }
return true;
-
}
/**
- * pathByAddingChild
- * @param element TODO
- * @returns TreePath
+ * Creates a new path that is equivalent to this path plus the specified
+ * element.
+ *
+ * @param element the element.
+ *
+ * @returns A tree path.
*/
public TreePath pathByAddingChild(Object element)
{
@@ -282,8 +280,12 @@ public class TreePath implements Serializable
}
/**
- * getParentPath
- * @returns TreePath
+ * Returns the parent path, which is a path containing all the same elements
+ * as this path, except for the last one. If this path contains only one
+ * element, the method returns <code>null</code>.
+ *
+ * @returns The parent path, or <code>null</code> if this path has only one
+ * element.
*/
public TreePath getParentPath()
{
diff --git a/javax/swing/tree/TreeSelectionModel.java b/javax/swing/tree/TreeSelectionModel.java
index c72617bff..4072ccc64 100644
--- a/javax/swing/tree/TreeSelectionModel.java
+++ b/javax/swing/tree/TreeSelectionModel.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java
index 14e6ea902..2c9136c51 100644
--- a/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/javax/swing/tree/VariableHeightLayoutCache.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -87,14 +87,6 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
} // setRootVisible()
/**
- * setRowHeight
- * @param value0 TODO
- */
- public void setRowHeight(int value0) {
- // TODO
- } // setRowHeight()
-
- /**
* setNodeDimensions
* @param value0 TODO
*/
diff --git a/javax/swing/tree/package.html b/javax/swing/tree/package.html
index 32d3d3c3e..22538e4ba 100644
--- a/javax/swing/tree/package.html
+++ b/javax/swing/tree/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.tree package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.tree</title></head>
<body>
-<p></p>
+<p>Interfaces and classes that support the {@link javax.swing.JTree}
+component.</p>
</body>
</html>
diff --git a/javax/swing/undo/AbstractUndoableEdit.java b/javax/swing/undo/AbstractUndoableEdit.java
index 5ba68f580..34c41aea2 100644
--- a/javax/swing/undo/AbstractUndoableEdit.java
+++ b/javax/swing/undo/AbstractUndoableEdit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/CannotRedoException.java b/javax/swing/undo/CannotRedoException.java
index f482b75bb..7d70a38c2 100644
--- a/javax/swing/undo/CannotRedoException.java
+++ b/javax/swing/undo/CannotRedoException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/CannotUndoException.java b/javax/swing/undo/CannotUndoException.java
index 0193921ed..9fc0ec3bd 100644
--- a/javax/swing/undo/CannotUndoException.java
+++ b/javax/swing/undo/CannotUndoException.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/CompoundEdit.java b/javax/swing/undo/CompoundEdit.java
index 730d5b253..e1cfbb619 100644
--- a/javax/swing/undo/CompoundEdit.java
+++ b/javax/swing/undo/CompoundEdit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/StateEdit.java b/javax/swing/undo/StateEdit.java
index 633807b71..80e4e33ec 100644
--- a/javax/swing/undo/StateEdit.java
+++ b/javax/swing/undo/StateEdit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/StateEditable.java b/javax/swing/undo/StateEditable.java
index a3dc40019..9a7fb0954 100644
--- a/javax/swing/undo/StateEditable.java
+++ b/javax/swing/undo/StateEditable.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/UndoManager.java b/javax/swing/undo/UndoManager.java
index fcdcf34ec..565b5ca88 100644
--- a/javax/swing/undo/UndoManager.java
+++ b/javax/swing/undo/UndoManager.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -78,7 +78,7 @@ import javax.swing.event.UndoableEditListener;
* <code>javax.swing.undo</code> package, the public methods of an
* <code>UndoManager</code> are safe to call from concurrent threads.
* The caller does not need to perform external synchronization, and
- * {@link javax.swing.event.UndoableEvent} sources do not need to
+ * {@link javax.swing.event.UndoableEditEvent} sources do not need to
* broadcast their events from inside the Swing worker thread.
*
* @author Sascha Brawer (brawer@dandelis.ch)
@@ -607,7 +607,7 @@ public class UndoManager
* <p><b>Thread Safety:</b> This method may safely be invoked from
* concurrent threads. The caller does not need to perform external
* synchronization. This means that {@link
- * javax.swing.event.UndoableEvent} sources do not need to broadcast
+ * javax.swing.event.UndoableEditEvent} sources do not need to broadcast
* their events from inside the Swing worker thread.
*
* @param event the event whose <code>edit</code> will be
diff --git a/javax/swing/undo/UndoableEdit.java b/javax/swing/undo/UndoableEdit.java
index 055fae0cd..982d7f2a7 100644
--- a/javax/swing/undo/UndoableEdit.java
+++ b/javax/swing/undo/UndoableEdit.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
diff --git a/javax/swing/undo/UndoableEditSupport.java b/javax/swing/undo/UndoableEditSupport.java
index 80234aa8a..918e73523 100644
--- a/javax/swing/undo/UndoableEditSupport.java
+++ b/javax/swing/undo/UndoableEditSupport.java
@@ -15,8 +15,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -187,7 +187,7 @@ public class UndoableEditSupport
/**
- * If {@link #beginEdit} has been called (so that the current
+ * If {@link #beginUpdate} has been called (so that the current
* update level is greater than zero), adds the specified edit
* to {@link #compoundEdit}. Otherwise, notify listeners of the
* edit by calling {@link #_postEdit(UndoableEdit)}.
@@ -233,12 +233,12 @@ public class UndoableEditSupport
/**
- * Creates a new instance of {@link #CompoundEdit}. Called by {@link
+ * Creates a new instance of {@link CompoundEdit}. Called by {@link
* #beginUpdate}. If a subclass wants {@link #beginUpdate} to work
* on a specific {@link #compoundEdit}, it should override this
* method.
*
- * @returns a newly created instance of {@link #CompoundEdit}.
+ * @returns a newly created instance of {@link CompoundEdit}.
*/
protected CompoundEdit createCompoundEdit()
{
diff --git a/javax/swing/undo/package.html b/javax/swing/undo/package.html
index a2b3599c0..125bd4446 100644
--- a/javax/swing/undo/package.html
+++ b/javax/swing/undo/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.undo package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
@@ -40,7 +40,7 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.undo</title></head>
<body>
-<p></p>
+<p>Provides a mechanism to support undo/redo operations.</p>
</body>
</html>