diff options
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic')
21 files changed, 464 insertions, 236 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java b/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java index 56e4e7073e5..f796d9a730a 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicArrowButton.java @@ -116,6 +116,8 @@ public class BasicArrowButton extends JButton implements SwingConstants this.shadow = shadow; this.darkShadow = darkShadow; this.highlight = highlight; + // Mark the button as not closing the popup, we handle this ourselves. + putClientProperty(BasicLookAndFeel.DONT_CANCEL_POPUP, Boolean.TRUE); } /** diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java index 1010139b8fc..43001b8dbfc 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java @@ -57,7 +57,8 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI * * @return A new instance of <code>BasicCheckBoxUI</code>. */ - public static ComponentUI createUI(JComponent c) { + public static ComponentUI createUI(JComponent c) + { return new BasicCheckBoxUI(); } diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java index 48195ff293b..3c8d1e8c589 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxRenderer.java @@ -75,12 +75,24 @@ public class BasicComboBoxRenderer /** * Returns preferredSize of the renderer - * + * * @return preferredSize of the renderer */ public Dimension getPreferredSize() { - return super.getPreferredSize(); + if (this.getText() != null && ! this.getText().equals("")) + return super.getPreferredSize(); + else + { + // If the combo box option's text is empty or null, it won't size + // properly (ie, it'll be way too short)... so we throw in a dummy + // space to trick the superclass's sizing methods. + String oldText = this.getText(); + this.setText(" "); + Dimension d = super.getPreferredSize(); + this.setText(oldText); + return d; + } } /** diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java index ea6f9850435..2cb1623cbc2 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java @@ -921,8 +921,8 @@ public class BasicComboBoxUI extends ComboBoxUI Object prototype = comboBox.getPrototypeDisplayValue(); if (prototype != null) { - Component comp = renderer.getListCellRendererComponent - (listBox, prototype, -1, false, false); + Component comp = renderer.getListCellRendererComponent(listBox, + prototype, -1, false, false); currentValuePane.add(comp); comp.setFont(comboBox.getFont()); Dimension renderSize = comp.getPreferredSize(); @@ -938,8 +938,8 @@ public class BasicComboBoxUI extends ComboBoxUI { for (int i = 0; i < size; ++i) { - Component comp = renderer.getListCellRendererComponent - (listBox, model.getElementAt(i), -1, false, false); + Component comp = renderer.getListCellRendererComponent(listBox, + model.getElementAt(i), -1, false, false); currentValuePane.add(comp); comp.setFont(comboBox.getFont()); Dimension renderSize = comp.getPreferredSize(); diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java index 0d822955bbc..c29829d777d 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboPopup.java @@ -677,7 +677,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup { Point point = SwingUtilities.convertPoint((Component) e.getSource(), e.getPoint(), list); - MouseEvent newEvent= new MouseEvent((Component) e.getSource(), + MouseEvent newEvent = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), point.x, point.y, e.getModifiers(), diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java index 9adb0c642ba..1356db4aeec 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java @@ -699,10 +699,10 @@ public class BasicFileChooserUI extends FileChooserUI String fileDescText; /** Is a directory selected? */ - boolean dirSelected = false; + boolean dirSelected; /** The current directory. */ - File currDir = null; + File currDir; // FIXME: describe what is contained in the bottom panel /** The bottom panel. */ diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java index 6beac6c971b..23bcdc315ee 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java @@ -179,10 +179,10 @@ public class BasicInternalFrameUI extends InternalFrameUI protected final int RESIZE_NONE = 0; /** The x offset from the top left corner of the JInternalFrame. */ - private transient int xOffset = 0; + private transient int xOffset; /** The y offset from the top left corner of the JInternalFrame. */ - private transient int yOffset = 0; + private transient int yOffset; /** The direction that the resize is occuring in. */ private transient int direction = -1; @@ -314,7 +314,7 @@ public class BasicInternalFrameUI extends InternalFrameUI frame.setCursor(Cursor.getDefaultCursor()); showingCursor = Cursor.DEFAULT_CURSOR; } - else if (e.getSource()==frame && frame.isResizable()) + else if (e.getSource() == frame && frame.isResizable()) { setCursor(e); } diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java index 5a08b2a3982..0f6e0243fcf 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -79,7 +79,9 @@ import javax.swing.plaf.IconUIResource; import javax.swing.plaf.InsetsUIResource; /** - * BasicLookAndFeel + * A basic implementation of Swing's Look and Feel framework. This can serve + * as a base for custom look and feel implementations. + * * @author Andrew Selkirk */ public abstract class BasicLookAndFeel extends LookAndFeel @@ -126,8 +128,11 @@ public abstract class BasicLookAndFeel extends LookAndFeel Component target = ev.getComponent(); if (target instanceof Container) target = ((Container) target).findComponentAt(ev.getPoint()); - if (! m.isComponentPartOfCurrentMenu(target)) - m.clearSelectedPath(); + if (m.getSelectedPath().length > 0 + && ! m.isComponentPartOfCurrentMenu(target)) + { + m.clearSelectedPath(); + } } } @@ -193,10 +198,21 @@ public abstract class BasicLookAndFeel extends LookAndFeel static final long serialVersionUID = -6096995660290287879L; /** + * This is a key for a client property that tells the PopupHelper that + * it shouldn't close popups when the mouse event target has this + * property set. This is used when the component handles popup closing + * itself. + */ + static final String DONT_CANCEL_POPUP = "noCancelPopup"; + + /** * Helps closing menu popups when user clicks outside of the menu area. */ private transient PopupHelper popupHelper; + /** + * Maps the audio actions for this l&f. + */ private ActionMap audioActionMap; /** @@ -425,9 +441,15 @@ public abstract class BasicLookAndFeel extends LookAndFeel } /** - * loadResourceBundle - * @param defaults TODO + * Loads the resource bundle in 'resources/basic' and adds the contained + * key/value pairs to the <code>defaults</code> table. + * + * @param defaults the UI defaults to load the resources into */ + // FIXME: This method is not used atm and private and thus could be removed. + // However, I consider this method useful for providing localized + // descriptions and similar stuff and therefore think that we should use it + // instead and provide the resource bundles. private void loadResourceBundle(UIDefaults defaults) { ResourceBundle bundle; @@ -446,7 +468,9 @@ public abstract class BasicLookAndFeel extends LookAndFeel } /** - * initComponentDefaults + * Populates the <code>defaults</code> table with UI default values for + * colors, fonts, keybindings and much more. + * * @param defaults the defaults table (<code>null</code> not permitted). */ protected void initComponentDefaults(UIDefaults defaults) @@ -509,7 +533,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel return BasicIconFactory.getMenuItemCheckIcon(); } }, - "CheckBox.margin",new InsetsUIResource(2, 2, 2, 2), + "CheckBox.margin", new InsetsUIResource(2, 2, 2, 2), "CheckBox.textIconGap", new Integer(4), "CheckBox.textShiftOffset", new Integer(0), "CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog", @@ -599,7 +623,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "ctrl F4", "close", "KP_DOWN", "down", "ctrl F10", "maximize", - "ctrl alt shift F6","selectPreviousFrame" + "ctrl alt shift F6", "selectPreviousFrame" }), "DesktopIcon.border", new BorderUIResource.CompoundBorderUIResource(null, null), @@ -1069,14 +1093,14 @@ public abstract class BasicLookAndFeel extends LookAndFeel "PAGE_DOWN", "positiveBlockIncrement", "END", "maxScroll", "HOME", "minScroll", - "LEFT", "positiveUnitIncrement", + "LEFT", "negativeUnitIncrement", "KP_UP", "negativeUnitIncrement", "KP_DOWN", "positiveUnitIncrement", "UP", "negativeUnitIncrement", - "RIGHT", "negativeUnitIncrement", - "KP_LEFT", "positiveUnitIncrement", + "RIGHT", "positiveUnitIncrement", + "KP_LEFT", "negativeUnitIncrement", "DOWN", "positiveUnitIncrement", - "KP_RIGHT", "negativeUnitIncrement" + "KP_RIGHT", "positiveUnitIncrement" }), "ScrollBar.foreground", new ColorUIResource(light), "ScrollBar.maximumThumbSize", new DimensionUIResource(4096, 4096), @@ -1091,7 +1115,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "ScrollPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "PAGE_UP", "scrollUp", "KP_LEFT", "unitScrollLeft", - "ctrl PAGE_DOWN","scrollRight", + "ctrl PAGE_DOWN", "scrollRight", "PAGE_DOWN", "scrollDown", "KP_RIGHT", "unitScrollRight", "LEFT", "unitScrollLeft", @@ -1167,7 +1191,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "SplitPaneDivider.border", BasicBorders.getSplitPaneDividerBorder(), "SplitPaneDivider.draggingColor", new ColorUIResource(Color.DARK_GRAY), "TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { - "ctrl PAGE_DOWN","navigatePageDown", + "ctrl PAGE_DOWN", "navigatePageDown", "ctrl PAGE_UP", "navigatePageUp", "ctrl UP", "requestFocus", "ctrl KP_UP", "requestFocus" @@ -1220,13 +1244,13 @@ public abstract class BasicLookAndFeel extends LookAndFeel "COPY", "copy", "ctrl KP_UP", "selectPreviousRowChangeLead", "PASTE", "paste", - "shift PAGE_DOWN","scrollDownExtendSelection", + "shift PAGE_DOWN", "scrollDownExtendSelection", "PAGE_DOWN", "scrollDownChangeSelection", "END", "selectLastColumn", "shift END", "selectLastColumnExtendSelection", "HOME", "selectFirstColumn", "ctrl END", "selectLastRow", - "ctrl shift END","selectLastRowExtendSelection", + "ctrl shift END", "selectLastRowExtendSelection", "LEFT", "selectPreviousColumn", "shift HOME", "selectFirstColumnExtendSelection", "UP", "selectPreviousRow", @@ -1234,7 +1258,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel "ctrl HOME", "selectFirstRow", "shift LEFT", "selectPreviousColumnExtendSelection", "DOWN", "selectNextRow", - "ctrl shift HOME","selectFirstRowExtendSelection", + "ctrl shift HOME", "selectFirstRowExtendSelection", "shift UP", "selectPreviousRowExtendSelection", "F2", "startEditing", "shift RIGHT", "selectNextColumnExtendSelection", diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java index 69c9c4507b0..63a09bff6a2 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java @@ -239,9 +239,10 @@ public class BasicMenuItemUI extends MenuItemUI { if (e.getPropertyName() == "accelerator") { - InputMap map = SwingUtilities.getUIInputMap(menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW); + InputMap map = SwingUtilities.getUIInputMap(menuItem, + JComponent.WHEN_IN_FOCUSED_WINDOW); if (map != null) - map.remove((KeyStroke)e.getOldValue()); + map.remove((KeyStroke) e.getOldValue()); else map = new ComponentInputMapUIResource(menuItem); @@ -499,7 +500,8 @@ public class BasicMenuItemUI extends MenuItemUI */ public Dimension getPreferredSize(JComponent c) { - return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); + return getPreferredMenuItemSize(c, checkIcon, arrowIcon, + defaultTextIconGap); } /** @@ -535,8 +537,10 @@ public class BasicMenuItemUI extends MenuItemUI prefix + ".foreground", prefix + ".font"); menuItem.setMargin(UIManager.getInsets(prefix + ".margin")); acceleratorFont = UIManager.getFont(prefix + ".acceleratorFont"); - acceleratorForeground = UIManager.getColor(prefix + ".acceleratorForeground"); - acceleratorSelectionForeground = UIManager.getColor(prefix + ".acceleratorSelectionForeground"); + acceleratorForeground = UIManager.getColor(prefix + + ".acceleratorForeground"); + acceleratorSelectionForeground = UIManager.getColor(prefix + + ".acceleratorSelectionForeground"); selectionBackground = UIManager.getColor(prefix + ".selectionBackground"); selectionForeground = UIManager.getColor(prefix + ".selectionForeground"); acceleratorDelimiter = UIManager.getString(prefix + ".acceleratorDelimiter"); @@ -551,13 +555,15 @@ public class BasicMenuItemUI extends MenuItemUI */ protected void installKeyboardActions() { - InputMap focusedWindowMap = SwingUtilities.getUIInputMap(menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW); + InputMap focusedWindowMap = SwingUtilities.getUIInputMap(menuItem, + JComponent.WHEN_IN_FOCUSED_WINDOW); if (focusedWindowMap == null) focusedWindowMap = new ComponentInputMapUIResource(menuItem); KeyStroke accelerator = menuItem.getAccelerator(); if (accelerator != null) focusedWindowMap.put(accelerator, "doClick"); - SwingUtilities.replaceUIInputMap(menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW, focusedWindowMap); + SwingUtilities.replaceUIInputMap(menuItem, + JComponent.WHEN_IN_FOCUSED_WINDOW, focusedWindowMap); ActionMap UIActionMap = SwingUtilities.getUIActionMap(menuItem); if (UIActionMap == null) @@ -1268,8 +1274,8 @@ public class BasicMenuItemUI extends MenuItemUI Insets insets = m.getInsets(); viewRect.x += insets.left; viewRect.y += insets.top; - viewRect.width -= (insets.left + insets.right); - viewRect.height -= (insets.top + insets.bottom); + viewRect.width -= insets.left + insets.right; + viewRect.height -= insets.top + insets.bottom; // Fetch the fonts. Font font = m.getFont(); diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java index 91bf614340d..9acf8210d9e 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java @@ -139,8 +139,8 @@ public class BasicOptionPaneUI extends OptionPaneUI ((JDialog) owner).dispose(); //else we probably have some kind of internal frame. - JInternalFrame inf = (JInternalFrame) SwingUtilities.getAncestorOfClass(JInternalFrame.class, - optionPane); + JInternalFrame inf = (JInternalFrame) SwingUtilities.getAncestorOfClass( + JInternalFrame.class, optionPane); if (inf != null) { try @@ -433,7 +433,7 @@ public class BasicOptionPaneUI extends OptionPaneUI public static final int MinimumHeight = 90; /** Whether the JOptionPane contains custom components. */ - protected boolean hasCustomComponents = false; + protected boolean hasCustomComponents; // The initialFocusComponent seems to always be set to a button (even if // I try to set initialSelectionValue). This is different from what the @@ -821,8 +821,8 @@ public class BasicOptionPaneUI extends OptionPaneUI if (remainder.length() == 0) return; - // Recursivly call ourselves to burst the remainder of the string, - if ((remainder.length() > maxll || remainder.contains("\n"))) + // Recursively call ourselves to burst the remainder of the string, + if (remainder.length() > maxll || remainder.contains("\n")) burstStringInto(c, remainder, maxll); else // Add the remainder to the container and be done. @@ -979,7 +979,7 @@ public class BasicOptionPaneUI extends OptionPaneUI case JOptionPane.DEFAULT_OPTION: return (optionPane.getWantsInput()) ? new Object[] { OK_STRING, CANCEL_STRING } : - ( optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE ) ? + (optionPane.getMessageType() == JOptionPane.QUESTION_MESSAGE) ? new Object[] { YES_STRING, NO_STRING, CANCEL_STRING } : // ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, PLAIN_MESSAGE new Object[] { OK_STRING }; diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java index 2518a91997a..df4c3aebdfd 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java @@ -384,7 +384,7 @@ public class BasicProgressBarUI extends ProgressBarUI } int index = getAnimationIndex(); - if (animationIndex > (numFrames) / 2) + if (animationIndex > numFrames / 2) index = numFrames - getAnimationIndex(); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) @@ -671,7 +671,8 @@ public class BasicProgressBarUI extends ProgressBarUI else { g.setColor(c.getForeground()); - g.fillRect(vr.x, vr.y + vr.height - amountFull, vr.width, amountFull); + g.fillRect(vr.x, vr.y + vr.height - amountFull, vr.width, + amountFull); } if (progressBar.isStringPainted() && !progressBar.getString().equals("")) diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java index 64a1deca572..a7da21c4f6e 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java @@ -70,7 +70,8 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI * * @return a new instance of <code>BasicRadioButtonUI</code> */ - public static ComponentUI createUI(final JComponent c) { + public static ComponentUI createUI(final JComponent c) + { return new BasicRadioButtonUI(); } @@ -155,8 +156,8 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI currentIcon = b.getDisabledIcon(); SwingUtilities.calculateInnerArea(b, vr); - String text = SwingUtilities.layoutCompoundLabel - (c, g.getFontMetrics(f), b.getText(), currentIcon, + 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); diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java index f2448548472..b29026342e0 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java @@ -1,5 +1,5 @@ /* BasicScrollBarUI.java -- - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,8 +38,6 @@ exception statement from your version. */ package javax.swing.plaf.basic; -import gnu.classpath.NotImplementedException; - import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -56,10 +54,14 @@ import java.awt.event.MouseMotionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; import javax.swing.BoundedRangeModel; +import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JScrollBar; +import javax.swing.JSlider; import javax.swing.LookAndFeel; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; @@ -67,6 +69,7 @@ import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.plaf.ActionMapUIResource; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ScrollBarUI; @@ -397,9 +400,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, return false; if (direction == POSITIVE_SCROLL) - return (value > scrollbar.getValue()); + return value > scrollbar.getValue(); else - return (value < scrollbar.getValue()); + return value < scrollbar.getValue(); } } @@ -724,7 +727,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, int orientation = scrollbar.getOrientation(); switch (orientation) { - case (JScrollBar.HORIZONTAL): + case JScrollBar.HORIZONTAL: incrButton = createIncreaseButton(EAST); decrButton = createDecreaseButton(WEST); break; @@ -762,15 +765,151 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, } /** - * This method installs the keyboard actions for the scrollbar. + * Installs the input map from the look and feel defaults, and a + * corresponding action map. Note the the keyboard bindings will only + * work when the {@link JScrollBar} component has the focus, which is rare. */ protected void installKeyboardActions() - throws NotImplementedException { - // FIXME: implement. + InputMap keyMap = getInputMap( + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + SwingUtilities.replaceUIInputMap(scrollbar, + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, keyMap); + ActionMap map = getActionMap(); + SwingUtilities.replaceUIActionMap(scrollbar, map); + } + + /** + * Uninstalls the input map and action map installed by + * {@link #installKeyboardActions()}. + */ + protected void uninstallKeyboardActions() + { + SwingUtilities.replaceUIActionMap(scrollbar, null); + SwingUtilities.replaceUIInputMap(scrollbar, + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null); + } + + InputMap getInputMap(int condition) + { + if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) + return (InputMap) UIManager.get("ScrollBar.focusInputMap"); + return null; + } + + /** + * Returns the action map for the {@link JScrollBar}. All scroll bars + * share a single action map which is created the first time this method is + * called, then stored in the UIDefaults table for subsequent access. + * + * @return The shared action map. + */ + ActionMap getActionMap() + { + ActionMap map = (ActionMap) UIManager.get("ScrollBar.actionMap"); + + if (map == null) // first time here + { + map = createActionMap(); + if (map != null) + UIManager.put("ScrollBar.actionMap", map); + } + return map; } /** + * Creates the action map shared by all {@link JSlider} instances. + * This method is called once by {@link #getActionMap()} when it + * finds no action map in the UIDefaults table...after the map is + * created, it gets added to the defaults table so that subsequent + * calls to {@link #getActionMap()} will return the same shared + * instance. + * + * @return The action map. + */ + ActionMap createActionMap() + { + ActionMap map = new ActionMapUIResource(); + map.put("positiveUnitIncrement", + new AbstractAction("positiveUnitIncrement") { + public void actionPerformed(ActionEvent event) + { + JScrollBar sb = (JScrollBar) event.getSource(); + if (sb.isVisible()) + { + int delta = sb.getUnitIncrement(1); + sb.setValue(sb.getValue() + delta); + } + } + } + ); + map.put("positiveBlockIncrement", + new AbstractAction("positiveBlockIncrement") { + public void actionPerformed(ActionEvent event) + { + JScrollBar sb = (JScrollBar) event.getSource(); + if (sb.isVisible()) + { + int delta = sb.getBlockIncrement(1); + sb.setValue(sb.getValue() + delta); + } + } + } + ); + map.put("negativeUnitIncrement", + new AbstractAction("negativeUnitIncrement") { + public void actionPerformed(ActionEvent event) + { + JScrollBar sb = (JScrollBar) event.getSource(); + if (sb.isVisible()) + { + int delta = sb.getUnitIncrement(-1); + sb.setValue(sb.getValue() + delta); + } + } + } + ); + map.put("negativeBlockIncrement", + new AbstractAction("negativeBlockIncrement") { + public void actionPerformed(ActionEvent event) + { + JScrollBar sb = (JScrollBar) event.getSource(); + if (sb.isVisible()) + { + int delta = sb.getBlockIncrement(-1); + sb.setValue(sb.getValue() + delta); + } + } + } + ); + map.put("minScroll", + new AbstractAction("minScroll") { + public void actionPerformed(ActionEvent event) + { + JScrollBar sb = (JScrollBar) event.getSource(); + if (sb.isVisible()) + { + sb.setValue(sb.getMinimum()); + } + } + } + ); + map.put("maxScroll", + new AbstractAction("maxScroll") { + public void actionPerformed(ActionEvent event) + { + JScrollBar sb = (JScrollBar) event.getSource(); + if (sb.isVisible()) + { + sb.setValue(sb.getMaximum()); + } + } + } + ); + return map; + } + + /** * This method installs any listeners for the scrollbar. This method also * installs listeners for things such as the JButtons and the timer. */ @@ -806,19 +945,20 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, super.installUI(c); if (c instanceof JScrollBar) { - scrollbar = (JScrollBar) c; + scrollbar = (JScrollBar) c; - trackRect = new Rectangle(); - thumbRect = new Rectangle(); + trackRect = new Rectangle(); + thumbRect = new Rectangle(); - scrollTimer = new Timer(300, null); + scrollTimer = new Timer(300, null); installDefaults(); - installComponents(); - configureScrollBarColors(); - installListeners(); + installComponents(); + configureScrollBarColors(); + installListeners(); + installKeyboardActions(); - calculatePreferredSize(); + calculatePreferredSize(); } } @@ -1140,16 +1280,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, } /** - * This method uninstalls any keyboard actions this scrollbar acquired - * during install. - */ - protected void uninstallKeyboardActions() - throws NotImplementedException - { - // FIXME: implement. - } - - /** * This method uninstalls any listeners that were registered during install. */ protected void uninstallListeners() @@ -1186,6 +1316,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, */ public void uninstallUI(JComponent c) { + uninstallKeyboardActions(); uninstallListeners(); uninstallDefaults(); uninstallComponents(); @@ -1226,9 +1357,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, // If the length is 0, you shouldn't be able to even see where the thumb is. // This really shouldn't ever happen, but just in case, we'll return the middle. if (len == 0) - return ((max - min) / 2); + return (max - min) / 2; - value = ((yPos - trackRect.y) * (max - min) / len + min); + value = (yPos - trackRect.y) * (max - min) / len + min; // If this isn't a legal value, then we'll have to move to one now. if (value > max) @@ -1259,9 +1390,9 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager, // 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); + return (max - min) / 2; - value = ((xPos - trackRect.x) * (max - min) / len + min); + value = (xPos - trackRect.x) * (max - min) / len + min; // If this isn't a legal value, then we'll have to move to one now. if (value > max) diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java index 03fb2255e88..a0616a8c1cf 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java @@ -516,7 +516,7 @@ public class BasicScrollPaneUI extends ScrollPaneUI { map = createActionMap(); if (map != null) - UIManager.put("Slider.actionMap", map); + UIManager.put("ScrollPane.actionMap", map); } return map; } diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java index 0569768a627..2fb16f12e63 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicSliderUI.java @@ -68,7 +68,6 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JSlider; import javax.swing.LookAndFeel; -import javax.swing.RepaintManager; import javax.swing.SwingUtilities; import javax.swing.Timer; import javax.swing.UIManager; @@ -483,9 +482,9 @@ public class BasicSliderUI extends SliderUI value = valueForYPosition(currentMouseY); if (direction == POSITIVE_SCROLL) - return (value > slider.getValue()); + return value > slider.getValue(); else - return (value < slider.getValue()); + return value < slider.getValue(); } } @@ -1152,10 +1151,6 @@ public class BasicSliderUI extends SliderUI Dimension d = getThumbSize(); thumbRect.width = d.width; thumbRect.height = d.height; - if (slider.getOrientation() == JSlider.HORIZONTAL) - thumbRect.y = trackRect.y; - else - thumbRect.x = trackRect.x; } /** @@ -1189,11 +1184,11 @@ public class BasicSliderUI extends SliderUI if (slider.getOrientation() == JSlider.HORIZONTAL) { thumbRect.x = xPositionForValue(value) - thumbRect.width / 2; - thumbRect.y = trackRect.y; + thumbRect.y = trackRect.y + 1; } else { - thumbRect.x = trackRect.x; + thumbRect.x = trackRect.x + 1; thumbRect.y = yPositionForValue(value) - thumbRect.height / 2; } } @@ -1298,7 +1293,11 @@ public class BasicSliderUI extends SliderUI tickRect.x = trackRect.x; tickRect.y = trackRect.y + trackRect.height; tickRect.width = trackRect.width; - tickRect.height = (slider.getPaintTicks() ? getTickLength() : 0); + tickRect.height = slider.getPaintTicks() ? getTickLength() : 0; + + // this makes our Mauve tests pass...can't explain it! + if (!slider.getPaintTicks()) + tickRect.y--; if (tickRect.y + tickRect.height > contentRect.y + contentRect.height) tickRect.height = contentRect.y + contentRect.height - tickRect.y; @@ -1307,33 +1306,55 @@ public class BasicSliderUI extends SliderUI { tickRect.x = trackRect.x + trackRect.width; tickRect.y = trackRect.y; - tickRect.width = (slider.getPaintTicks() ? getTickLength() : 0); + tickRect.width = slider.getPaintTicks() ? getTickLength() : 0; tickRect.height = trackRect.height; + // this makes our Mauve tests pass...can't explain it! + if (!slider.getPaintTicks()) + tickRect.x--; + if (tickRect.x + tickRect.width > contentRect.x + contentRect.width) tickRect.width = contentRect.x + contentRect.width - tickRect.x; } } /** - * This method calculates the size and position of the labelRect. It must - * take into account the orientation of the slider. + * Calculates the <code>labelRect</code> field, taking into account the + * orientation of the slider. */ protected void calculateLabelRect() { if (slider.getOrientation() == JSlider.HORIZONTAL) { - labelRect.x = contentRect.x; - labelRect.y = tickRect.y + tickRect.height; - labelRect.width = contentRect.width; + if (slider.getPaintLabels()) + { + labelRect.x = contentRect.x; + labelRect.y = tickRect.y + tickRect.height - 1; + labelRect.width = contentRect.width; + } + else + { + labelRect.x = trackRect.x; + labelRect.y = tickRect.y + tickRect.height; + labelRect.width = trackRect.width; + } labelRect.height = getHeightOfTallestLabel(); } else { - labelRect.x = tickRect.x + tickRect.width; - labelRect.y = contentRect.y; + if (slider.getPaintLabels()) + { + labelRect.x = tickRect.x + tickRect.width - 1; + labelRect.y = contentRect.y; + labelRect.height = contentRect.height; + } + else + { + labelRect.x = tickRect.x + tickRect.width; + labelRect.y = trackRect.y; + labelRect.height = trackRect.height; + } labelRect.width = getWidthOfWidestLabel(); - labelRect.height = contentRect.height; } } @@ -1644,7 +1665,7 @@ public class BasicSliderUI extends SliderUI int width; int height; - Point a = new Point(trackRect.x, trackRect.y); + Point a = new Point(trackRect.x, trackRect.y + 1); Point b = new Point(a); Point c = new Point(a); Point d = new Point(a); @@ -2226,12 +2247,12 @@ public class BasicSliderUI extends SliderUI // is. This really shouldn't ever happen, but just in case, we'll return // the middle. if (len == 0) - return ((max - min) / 2); + return (max - min) / 2; if (! drawInverted()) - value = ((len - (yPos - trackRect.y)) * (max - min) / len + min); + value = (len - (yPos - trackRect.y)) * (max - min) / len + min; else - value = ((yPos - trackRect.y) * (max - min) / len + min); + value = (yPos - trackRect.y) * (max - min) / len + min; // If this isn't a legal value, then we'll have to move to one now. if (value > max) @@ -2262,12 +2283,12 @@ public class BasicSliderUI extends SliderUI // is. This really shouldn't ever happen, but just in case, we'll return // the middle. if (len == 0) - return ((max - min) / 2); + return (max - min) / 2; if (! drawInverted()) - value = ((xPos - trackRect.x) * (max - min) / len + min); + value = (xPos - trackRect.x) * (max - min) / len + min; else - value = ((len - (xPos - trackRect.x)) * (max - min) / len + min); + value = (len - (xPos - trackRect.x)) * (max - min) / len + min; // If this isn't a legal value, then we'll have to move to one now. if (value > max) diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java index 1b5249770ec..1b2552837c6 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java @@ -530,6 +530,20 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants int tabPlacement = tabPane.getTabPlacement(); Insets insets = tabPane.getInsets(); + + int selectedIndex = tabPane.getSelectedIndex(); + + Component selectedComponent = null; + if (selectedIndex >= 0) + selectedComponent = tabPane.getComponentAt(selectedIndex); + // The RI doesn't seem to change the component if the new selected + // component == null. This is probably so that applications can add + // one single component for every tab. + if (selectedComponent != null) + { + setVisibleComponent(selectedComponent); + } + int childCount = tabPane.getComponentCount(); if (childCount > 0) { @@ -1411,6 +1425,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants private boolean tabsOpaque; /** + * The currently visible component. + */ + private Component visibleComponent; + + /** * Creates a new BasicTabbedPaneUI object. */ public BasicTabbedPaneUI() @@ -2479,7 +2498,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants */ protected Component getVisibleComponent() { - return tabPane.getComponentAt(tabPane.getSelectedIndex()); + return visibleComponent; } /** @@ -2489,8 +2508,19 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants */ protected void setVisibleComponent(Component component) { - component.setVisible(true); - tabPane.setSelectedComponent(component); + // Make old component invisible. + if (visibleComponent != null && visibleComponent != component + && visibleComponent.getParent() == tabPane) + { + visibleComponent.setVisible(false); + } + + // Make new component visible. + if (component != null && ! component.isVisible()) + { + component.setVisible(true); + } + visibleComponent = component; } /** diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java index ce8846ff8af..abe7cab43b3 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicTableHeaderUI.java @@ -249,11 +249,11 @@ public class BasicTableHeaderUI extends TableHeaderUI originalCursor = header.getCursor(); if (p < x) - header.setCursor(Cursor.getPredefinedCursor - (Cursor.W_RESIZE_CURSOR)); + header.setCursor(Cursor.getPredefinedCursor( + Cursor.W_RESIZE_CURSOR)); else - header.setCursor(Cursor.getPredefinedCursor - (Cursor.E_RESIZE_CURSOR)); + header.setCursor(Cursor.getPredefinedCursor( + Cursor.E_RESIZE_CURSOR)); } else { @@ -368,7 +368,7 @@ public class BasicTableHeaderUI extends TableHeaderUI int x = e.getX(); int p = 0; - int col = model.getColumnCount()-1; + int col = model.getColumnCount() - 1; int n = model.getColumnCount(); // This loop does not find the column if the mouse if out of the @@ -504,7 +504,7 @@ public class BasicTableHeaderUI extends TableHeaderUI comp.setBackground(header.getBackground()); comp.setForeground(header.getForeground()); if (comp instanceof JComponent) - ((JComponent)comp).setBorder(cellBorder); + ((JComponent) comp).setBorder(cellBorder); rendererPane.paintComponent(gfx, comp, header, bounds.x, bounds.y, bounds.width, bounds.height); } @@ -513,11 +513,11 @@ public class BasicTableHeaderUI extends TableHeaderUI // This displays a running rectangle that is much simplier than the total // animation, as it is seen in Sun's application. // TODO animate the collumn dragging like in Sun's jre. - if (draggingHeaderRect!=null) + if (draggingHeaderRect != null) { gfx.setColor(header.getForeground()); - gfx.drawRect(draggingHeaderRect.x, draggingHeaderRect.y+2, - draggingHeaderRect.width-1, draggingHeaderRect.height-6); + gfx.drawRect(draggingHeaderRect.x, draggingHeaderRect.y + 2, + draggingHeaderRect.width - 1, draggingHeaderRect.height - 6); } } @@ -533,7 +533,7 @@ public class BasicTableHeaderUI extends TableHeaderUI TableColumnModel cmod = header.getColumnModel(); TableCellRenderer defaultRend = header.getDefaultRenderer(); int ncols = cmod.getColumnCount(); - Dimension ret = new Dimension(0,0); + Dimension ret = new Dimension(0, 0); int spacing = 0; if (header.getTable() != null @@ -556,7 +556,7 @@ public class BasicTableHeaderUI extends TableHeaderUI comp.setBackground(header.getBackground()); comp.setForeground(header.getForeground()); if (comp instanceof JComponent) - ((JComponent)comp).setBorder(cellBorder); + ((JComponent) comp).setBorder(cellBorder); Dimension d = comp.getPreferredSize(); ret.width += spacing; diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java index d3abba217cd..cdd44a711e7 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java @@ -269,8 +269,8 @@ public class BasicTableUI extends TableUI begin = new Point(e.getX(), e.getY()); curr = new Point(e.getX(), e.getY()); //if control is pressed and the cell is already selected, deselect it - if (e.isControlDown() && table. - isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin))) + if (e.isControlDown() && table.isCellSelected( + table.rowAtPoint(begin), table.columnAtPoint(begin))) { table.getSelectionModel(). removeSelectionInterval(table.rowAtPoint(begin), @@ -467,22 +467,21 @@ public class BasicTableUI extends TableUI // Register key bindings in the UI InputMap-ActionMap pair for (int i = 0; i < keys.length; i++) { - KeyStroke stroke = (KeyStroke)keys[i]; + KeyStroke stroke = (KeyStroke) keys[i]; String actionString = (String) ancestorMap.get(stroke); parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString); - parentActionMap.put (actionString, - new ActionListenerProxy (action, actionString)); + parentActionMap.put(actionString, + new ActionListenerProxy(action, actionString)); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair - parentInputMap.setParent - (table.getInputMap - (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); + parentInputMap.setParent(table.getInputMap( + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); @@ -532,10 +531,12 @@ public class BasicTableUI extends TableUI * * @param e the ActionEvent that caused this action. */ - public void actionPerformed (ActionEvent e) + public void actionPerformed(ActionEvent e) { - DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); - DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); + DefaultListSelectionModel rowModel + = (DefaultListSelectionModel) table.getSelectionModel(); + DefaultListSelectionModel colModel + = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; @@ -556,7 +557,7 @@ public class BasicTableUI extends TableUI else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) - table.editCellAt(rowLead,colLead); + table.editCellAt(rowLead, colLead); } else if (command.equals("selectFirstRowExtendSelection")) { @@ -572,7 +573,7 @@ public class BasicTableUI extends TableUI } else if (command.equals("selectLastRow")) { - rowModel.setSelectionInterval(rowMax,rowMax); + rowModel.setSelectionInterval(rowMax, rowMax); } else if (command.equals("selectNextRowExtendSelection")) { @@ -580,7 +581,7 @@ public class BasicTableUI extends TableUI } else if (command.equals("selectFirstRow")) { - rowModel.setSelectionInterval(0,0); + rowModel.setSelectionInterval(0, 0); } else if (command.equals("selectNextColumnExtendSelection")) { @@ -603,9 +604,8 @@ public class BasicTableUI extends TableUI { int target; if (rowLead == getFirstVisibleRowIndex()) - target = Math.max - (0, rowLead - (getLastVisibleRowIndex() - - getFirstVisibleRowIndex() + 1)); + target = Math.max(0, rowLead - (getLastVisibleRowIndex() + - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); @@ -621,9 +621,8 @@ public class BasicTableUI extends TableUI { int target; if (colLead == getLastVisibleColumnIndex()) - target = Math.min - (colMax, colLead + (getLastVisibleColumnIndex() - - getFirstVisibleColumnIndex() + 1)); + target = Math.min(colMax, colLead + (getLastVisibleColumnIndex() + - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); @@ -639,9 +638,8 @@ public class BasicTableUI extends TableUI { int target; if (colLead == getFirstVisibleColumnIndex()) - target = Math.max - (0, colLead - (getLastVisibleColumnIndex() - - getFirstVisibleColumnIndex() + 1)); + target = Math.max(0, colLead - (getLastVisibleColumnIndex() + - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); @@ -701,12 +699,10 @@ public class BasicTableUI extends TableUI { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, - (command.equals - ("selectPreviousColumnCell"))); + command.equals("selectPreviousColumnCell")); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, - (command.equals - ("selectPreviousRowCell"))); + command.equals("selectPreviousRowCell")); return; } @@ -728,15 +724,13 @@ public class BasicTableUI extends TableUI // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, - rowModel, rowMinSelected, rowMaxSelected, - (command.equals - ("selectPreviousColumnCell")), true); + rowModel, rowMinSelected, rowMaxSelected, + command.equals("selectPreviousColumnCell"), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, - colModel, colMinSelected, colMaxSelected, - (command.equals - ("selectPreviousRowCell")), false); + colModel, colMinSelected, colMaxSelected, + command.equals("selectPreviousRowCell"), false); } else if (command.equals("selectNextColumn")) { @@ -747,9 +741,8 @@ public class BasicTableUI extends TableUI { int target; if (colLead == getFirstVisibleColumnIndex()) - target = Math.max - (0, colLead - (getLastVisibleColumnIndex() - - getFirstVisibleColumnIndex() + 1)); + target = Math.max(0, colLead - (getLastVisibleColumnIndex() + - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); @@ -760,9 +753,8 @@ public class BasicTableUI extends TableUI { int target; if (rowLead == getLastVisibleRowIndex()) - target = Math.min - (rowMax, rowLead + (getLastVisibleRowIndex() - - getFirstVisibleRowIndex() + 1)); + target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex() + - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); @@ -773,9 +765,8 @@ public class BasicTableUI extends TableUI { int target; if (colLead == getLastVisibleColumnIndex()) - target = Math.min - (colMax, colLead + (getLastVisibleColumnIndex() - - getFirstVisibleColumnIndex() + 1)); + target = Math.min(colMax, colLead + (getLastVisibleColumnIndex() + - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); @@ -795,9 +786,8 @@ public class BasicTableUI extends TableUI { int target; if (rowLead == getLastVisibleRowIndex()) - target = Math.min - (rowMax, rowLead + (getLastVisibleRowIndex() - - getFirstVisibleRowIndex() + 1)); + target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex() + - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); @@ -808,9 +798,8 @@ public class BasicTableUI extends TableUI { int target; if (rowLead == getFirstVisibleRowIndex()) - target = Math.max - (0, rowLead - (getLastVisibleRowIndex() - - getFirstVisibleRowIndex() + 1)); + target = Math.max(0, rowLead - (getLastVisibleRowIndex() + - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); @@ -819,34 +808,37 @@ public class BasicTableUI extends TableUI } else if (command.equals("selectNextRowChangeLead")) { - if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) + if (rowModel.getSelectionMode() + != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); - colModel.setSelectionInterval(colLead,colLead); + colModel.setSelectionInterval(colLead, colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { - if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) + if (rowModel.getSelectionMode() + != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), - Math.min(rowLead -1, 0)); - colModel.setSelectionInterval(colLead,colLead); + Math.min(rowLead - 1, 0)); + colModel.setSelectionInterval(colLead, colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { - if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) + if (colModel.getSelectionMode() + != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn - rowModel.setSelectionInterval(rowLead,rowLead); + rowModel.setSelectionInterval(rowLead, rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } @@ -855,10 +847,11 @@ public class BasicTableUI extends TableUI } else if (command.equals("selectPreviousColumnChangeLead")) { - if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) + if (colModel.getSelectionMode() + != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn - rowModel.setSelectionInterval(rowLead,rowLead); + rowModel.setSelectionInterval(rowLead, rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); @@ -924,9 +917,9 @@ public class BasicTableUI extends TableUI && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); - table.scrollRectToVisible - (table.getCellRect(rowModel.getLeadSelectionIndex(), - colModel.getLeadSelectionIndex(), false)); + table.scrollRectToVisible(table.getCellRect( + rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), + false)); } /** @@ -1010,13 +1003,13 @@ public class BasicTableUI extends TableUI * @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) + 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 + // 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 ? @@ -1115,9 +1108,9 @@ public class BasicTableUI extends TableUI * @param reverse true if SHIFT was pressed for the event */ - void advanceSingleSelection (ListSelectionModel firstModel, int firstMax, - ListSelectionModel secondModel, int secondMax, - boolean reverse) + 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 @@ -1136,8 +1129,8 @@ public class BasicTableUI extends TableUI // do we have to wrap the "seconds"? if (reverse && (firstLead == 0) || !reverse && (firstLead == firstMax)) - secondModel.setSelectionInterval((secondLead + 1)%(secondMax + 1), - (secondLead + 1)%(secondMax + 1)); + secondModel.setSelectionInterval((secondLead + 1) % (secondMax + 1), + (secondLead + 1) % (secondMax + 1)); // if not, just reselect the current lead else secondModel.setSelectionInterval(secondLead, secondLead); @@ -1152,8 +1145,8 @@ public class BasicTableUI extends TableUI firstLead -= 2; } // select the next "first" - firstModel.setSelectionInterval ((firstLead + 1)%(firstMax + 1), - (firstLead + 1)%(firstMax + 1)); + firstModel.setSelectionInterval((firstLead + 1) % (firstMax + 1), + (firstLead + 1) % (firstMax + 1)); } } @@ -1212,7 +1205,7 @@ public class BasicTableUI extends TableUI public void installUI(JComponent comp) { - table = (JTable)comp; + table = (JTable) comp; rendererPane = new CellRendererPane(); table.add(rendererPane); @@ -1282,8 +1275,8 @@ public class BasicTableUI extends TableUI int rowMargin = table.getRowMargin(); TableColumnModel cmodel = table.getColumnModel(); - int [] widths = new int[cn+1]; - for (int i = c0; i <=cn ; i++) + int[] widths = new int[cn + 1]; + for (int i = c0; i <= cn; i++) { widths[i] = cmodel.getColumn(i).getWidth() - columnMargin; } diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java index b058175a454..34261cfe644 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java @@ -603,10 +603,12 @@ public abstract class BasicTextUI extends TextUI // Fetch the colors for enabled/disabled text components. background = UIManager.getColor(prefix + ".background"); inactiveBackground = UIManager.getColor(prefix + ".inactiveBackground"); - textComponent.setDisabledTextColor - (UIManager.getColor(prefix + ".inactiveForeground")); - textComponent.setSelectedTextColor(UIManager.getColor(prefix + ".selectionForeground")); - textComponent.setSelectionColor(UIManager.getColor(prefix + ".selectionBackground")); + textComponent.setDisabledTextColor(UIManager.getColor(prefix + + ".inactiveForeground")); + textComponent.setSelectedTextColor(UIManager.getColor(prefix + + ".selectionForeground")); + textComponent.setSelectionColor(UIManager.getColor(prefix + + ".selectionBackground")); } /** @@ -639,7 +641,8 @@ public abstract class BasicTextUI extends TextUI Clipboard cb = Toolkit.getDefaultToolkit().getSystemSelection(); if (cb != null) { - StringSelection selection = new StringSelection(textComponent.getSelectedText()); + StringSelection selection = new StringSelection( + textComponent.getSelectedText()); cb.setContents(selection, selection); } } @@ -853,7 +856,8 @@ public abstract class BasicTextUI extends TextUI */ protected void uninstallKeyboardActions() { - SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, null); + SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, + null); SwingUtilities.replaceUIActionMap(textComponent, null); } @@ -1114,13 +1118,14 @@ public abstract class BasicTextUI extends TextUI && Utilities.getRowStart(t, nextPosBelow) != p1RowStart) { posBelow = nextPosBelow; - nextPosBelow = Utilities.getPositionBelow(t, posBelow, l1.x); + nextPosBelow = Utilities.getPositionBelow(t, posBelow, + l1.x); if (posBelow == nextPosBelow) break; } - // Now posBelow is an offset on the last line which has to be damaged - // completely. (newPosBelow is on the same line as p1) + // Now posBelow is an offset on the last line which has to be + // damaged completely. (newPosBelow is on the same line as p1) // Retrieve the rectangle of posBelow and use its y and height // value to calculate the final height of the multiple line diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java index eabac157036..8fce2f08a66 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java @@ -417,8 +417,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants int w = 0; int h = 0; - boolean tmp = ((loc == SwingConstants.NORTH) - || (loc == SwingConstants.SOUTH) || (loc == -1)); + boolean tmp = (loc == SwingConstants.NORTH) + || (loc == SwingConstants.SOUTH) || (loc == -1); cachedOrientation = toolBar.getOrientation(); cachedBounds = toolBar.getSize(); @@ -1084,7 +1084,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants isDragging = true; if (dragWindow != null) - dragWindow.setOffset(new Point(cachedBounds.width/2, cachedBounds.height/2)); + dragWindow.setOffset(new Point(cachedBounds.width / 2, + cachedBounds.height / 2)); dragTo(e.getPoint(), origin); } diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java index 8cbea7f592d..4c139fe465b 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java @@ -248,7 +248,7 @@ public class BasicTreeUI int gap = 4; /** The max height of the nodes in the tree. */ - int maxHeight = 0; + int maxHeight; /** The hash color. */ Color hashColor; @@ -1129,7 +1129,7 @@ public class BasicTreeUI { Enumeration expanded = tree.getExpandedDescendants(path); while (expanded.hasMoreElements()) - treeState.setExpandedState(((TreePath) expanded.nextElement()), true); + treeState.setExpandedState((TreePath) expanded.nextElement(), true); } /** @@ -1140,7 +1140,7 @@ public class BasicTreeUI */ protected TreePath getLastChildPath(TreePath parent) { - return ((TreePath) parent.getLastPathComponent()); + return (TreePath) parent.getLastPathComponent(); } /** @@ -1295,21 +1295,21 @@ public class BasicTreeUI ActionMapUIResource am = new ActionMapUIResource(); Action action; - action= new TreeAction(); + action = new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. - action= new TreeHomeAction(-1, "selectFirst"); + action = new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); - action= new TreeHomeAction(-1, "selectFirstChangeLead"); + action = new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); - action= new TreeHomeAction(-1, "selectFirstExtendSelection"); + action = new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); - action= new TreeHomeAction(1, "selectLast"); + action = new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); - action= new TreeHomeAction(1, "selectLastChangeLead"); + action = new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); - action= new TreeHomeAction(1, "selectLastExtendSelection"); + action = new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. @@ -1414,8 +1414,8 @@ public class BasicTreeUI if (treeSelectionModel != null && selectionModelPropertyChangeListener != null) { - treeSelectionModel.addPropertyChangeListener - (selectionModelPropertyChangeListener); + treeSelectionModel.addPropertyChangeListener( + selectionModelPropertyChangeListener); } componentListener = createComponentListener(); @@ -1819,7 +1819,7 @@ public class BasicTreeUI Insets i = tree.getInsets(); int left = getRowX(tree.getRowForPath(path), path.getPathCount() - 1) - -getRightChildIndent() - width / 2 + i.left; + - getRightChildIndent() - width / 2 + i.left; cntlClick = mouseX >= left && mouseX <= left + width; } return cntlClick; @@ -2207,7 +2207,7 @@ public class BasicTreeUI { cancelEditing(tree); } - }// CellEditorHandler + } // CellEditorHandler /** * Repaints the lead selection row when focus is lost/grained. @@ -2255,7 +2255,7 @@ public class BasicTreeUI void repaintLeadRow() { TreePath lead = tree.getLeadSelectionPath(); - if (lead!=null) + if (lead != null) tree.repaint(tree.getPathBounds(lead)); } } @@ -2588,7 +2588,7 @@ public class BasicTreeUI { return BasicTreeUI.this.getRowX(row, depth); } - }// NodeDimensionsHandler + } // NodeDimensionsHandler /** * PropertyChangeListener for the tree. Updates the appropriate variable, or @@ -2742,7 +2742,7 @@ public class BasicTreeUI tree.revalidate(); tree.repaint(); } - }// TreeExpansionHandler + } // TreeExpansionHandler /** * TreeHomeAction is used to handle end/home actions. Scrolls either the first @@ -3040,7 +3040,7 @@ public class BasicTreeUI treeState.treeStructureChanged(e); tree.repaint(); } - }// TreeModelHandler + } // TreeModelHandler /** * TreePageAction handles page up and page down events. @@ -3125,7 +3125,7 @@ public class BasicTreeUI } else { - newVisible.y -= (visible.height - newVisible.height); + newVisible.y -= visible.height - newVisible.height; newVisible.height = visible.height; } @@ -3169,7 +3169,7 @@ public class BasicTreeUI { return (tree != null) && tree.isEnabled(); } - }// TreePageAction + } // TreePageAction /** * Listens for changes in the selection model and updates the display @@ -3208,13 +3208,13 @@ public class BasicTreeUI Rectangle n = treeState.getBounds(event.getNewLeadSelectionPath(), new Rectangle()); - if (o!=null) + if (o != null) tree.repaint(o); - if (n!=null) + if (n != null) tree.repaint(n); } } - }// TreeSelectionHandler + } // TreeSelectionHandler /** * For the first selected row expandedness will be toggled. @@ -3315,7 +3315,7 @@ public class BasicTreeUI // is not visible. TreePath parent = current.getParentPath(); if (parent != null && - !(parent.getPathCount()==1 && !tree.isRootVisible()) ) + ! (parent.getPathCount() == 1 && ! tree.isRootVisible())) tree.setSelectionPath(parent); } } @@ -3647,7 +3647,7 @@ public class BasicTreeUI if (parent != null) { Rectangle parentBounds = getPathBounds(tree, parent); - paintVerticalLine(g, tree, parentBounds.x + 2* gap, + paintVerticalLine(g, tree, parentBounds.x + 2 * gap, parentBounds.y + parentBounds.height / 2, bounds.y + bounds.height / 2); } @@ -3717,7 +3717,7 @@ public class BasicTreeUI boolean isLeaf) { Object node = path.getLastPathComponent(); - return (! isLeaf && hasControlIcons()); + return ! isLeaf && hasControlIcons(); } /** |