summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/plaf
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf')
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicBorders.java79
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java5
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java6
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java8
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java11
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java33
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java16
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicListUI.java22
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java2
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java42
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java1
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java2
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java4
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java27
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java300
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java4
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTextPaneUI.java8
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java23
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java5
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java463
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalBorders.java141
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java39
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java5
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java6
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java24
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java9
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java12
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java88
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java16
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java13
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java6
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java27
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java14
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java121
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalUtils.java252
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/OceanTheme.java34
36 files changed, 1006 insertions, 862 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java b/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java
index cec7bec8501..5d4ce18932b 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicBorders.java
@@ -51,7 +51,6 @@ import javax.swing.JButton;
import javax.swing.JPopupMenu;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.border.BevelBorder;
@@ -95,21 +94,18 @@ public class BasicBorders
*/
public static Border getButtonBorder()
{
- UIDefaults defaults;
Border outer;
- defaults = UIManager.getLookAndFeelDefaults();
-
/* The keys for UIDefaults have been determined by writing a
* test program that dumps the UIDefaults to stdout; that program
* was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
* the key "light" is usually called "highlight", and "highlight"
* is usually called "lightHighlight".
*/
- outer = new ButtonBorder(defaults.getColor("Button.shadow"),
- defaults.getColor("Button.darkShadow"),
- defaults.getColor("Button.light"),
- defaults.getColor("Button.highlight"));
+ outer = new ButtonBorder(UIManager.getColor("Button.shadow"),
+ UIManager.getColor("Button.darkShadow"),
+ UIManager.getColor("Button.light"),
+ UIManager.getColor("Button.highlight"));
/* While the inner border is shared between multiple buttons,
* we do not share the outer border because ButtonBorders store
@@ -145,11 +141,8 @@ public class BasicBorders
*/
public static Border getRadioButtonBorder()
{
- UIDefaults defaults;
Border outer;
- defaults = UIManager.getLookAndFeelDefaults();
-
/* The keys for UIDefaults have been determined by writing a
* test program that dumps the UIDefaults to stdout; that program
* was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
@@ -157,10 +150,10 @@ public class BasicBorders
* is usually called "lightHighlight".
*/
outer = new RadioButtonBorder(
- defaults.getColor("RadioButton.shadow"),
- defaults.getColor("RadioButton.darkShadow"),
- defaults.getColor("RadioButton.light"),
- defaults.getColor("RadioButton.highlight"));
+ UIManager.getColor("RadioButton.shadow"),
+ UIManager.getColor("RadioButton.darkShadow"),
+ UIManager.getColor("RadioButton.light"),
+ UIManager.getColor("RadioButton.highlight"));
/* While the inner border is shared between multiple buttons, we
* do not share the outer border because RadioButtonBorders, being
@@ -197,11 +190,8 @@ public class BasicBorders
*/
public static Border getToggleButtonBorder()
{
- UIDefaults defaults;
Border outer;
- defaults = UIManager.getLookAndFeelDefaults();
-
/* The keys for UIDefaults have been determined by writing a
* test program that dumps the UIDefaults to stdout; that program
* was run on a JDK 1.4.1_01 for GNU/Linux. Note that in the API,
@@ -209,10 +199,10 @@ public class BasicBorders
* is usually called "lightHighlight".
*/
outer = new ToggleButtonBorder(
- defaults.getColor("ToggleButton.shadow"),
- defaults.getColor("ToggleButton.darkShadow"),
- defaults.getColor("ToggleButton.light"),
- defaults.getColor("ToggleButton.highlight"));
+ UIManager.getColor("ToggleButton.shadow"),
+ UIManager.getColor("ToggleButton.darkShadow"),
+ UIManager.getColor("ToggleButton.light"),
+ UIManager.getColor("ToggleButton.highlight"));
/* While the inner border is shared between multiple buttons, we
* do not share the outer border because ToggleButtonBorders, being
@@ -247,12 +237,9 @@ public class BasicBorders
*/
public static Border getMenuBarBorder()
{
- UIDefaults defaults;
-
/* See comment in methods above for why this border is not shared. */
- defaults = UIManager.getLookAndFeelDefaults();
- return new MenuBarBorder(defaults.getColor("MenuBar.shadow"),
- defaults.getColor("MenuBar.highlight"));
+ return new MenuBarBorder(UIManager.getColor("MenuBar.shadow"),
+ UIManager.getColor("MenuBar.highlight"));
}
@@ -279,12 +266,9 @@ public class BasicBorders
*/
public static Border getSplitPaneBorder()
{
- UIDefaults defaults;
-
/* See comment in methods above for why this border is not shared. */
- defaults = UIManager.getLookAndFeelDefaults();
- return new SplitPaneBorder(defaults.getColor("SplitPane.highlight"),
- defaults.getColor("SplitPane.darkShadow"));
+ return new SplitPaneBorder(UIManager.getColor("SplitPane.highlight"),
+ UIManager.getColor("SplitPane.darkShadow"));
}
@@ -314,13 +298,10 @@ public class BasicBorders
*/
public static Border getSplitPaneDividerBorder()
{
- UIDefaults defaults;
-
/* See comment in methods above for why this border is not shared. */
- defaults = UIManager.getLookAndFeelDefaults();
return new SplitPaneDividerBorder(
- defaults.getColor("SplitPane.highlight"),
- defaults.getColor("SplitPane.darkShadow"));
+ UIManager.getColor("SplitPane.highlight"),
+ UIManager.getColor("SplitPane.darkShadow"));
}
@@ -346,15 +327,12 @@ public class BasicBorders
*/
public static Border getTextFieldBorder()
{
- UIDefaults defaults;
-
/* See comment in methods above for why this border is not shared. */
- defaults = UIManager.getLookAndFeelDefaults();
return new FieldBorder(
- defaults.getColor("TextField.shadow"),
- defaults.getColor("TextField.darkShadow"),
- defaults.getColor("TextField.light"),
- defaults.getColor("TextField.highlight"));
+ UIManager.getColor("TextField.shadow"),
+ UIManager.getColor("TextField.darkShadow"),
+ UIManager.getColor("TextField.light"),
+ UIManager.getColor("TextField.highlight"));
}
@@ -394,17 +372,14 @@ public class BasicBorders
*/
public static Border getInternalFrameBorder()
{
- UIDefaults defaults;
Color shadow, darkShadow, highlight, lightHighlight, line;
/* See comment in methods above for why this border is not shared. */
- defaults = UIManager.getLookAndFeelDefaults();
-
- shadow = defaults.getColor("InternalFrame.borderShadow");
- darkShadow = defaults.getColor("InternalFrame.borderDarkShadow");
- highlight = defaults.getColor("InternalFrame.borderLight");
- lightHighlight = defaults.getColor("InternalFrame.borderHighlight");
- line = defaults.getColor("InternalFrame.borderColor");
+ shadow = UIManager.getColor("InternalFrame.borderShadow");
+ darkShadow = UIManager.getColor("InternalFrame.borderDarkShadow");
+ highlight = UIManager.getColor("InternalFrame.borderLight");
+ lightHighlight = UIManager.getColor("InternalFrame.borderHighlight");
+ line = UIManager.getColor("InternalFrame.borderColor");
return new BorderUIResource.CompoundBorderUIResource(
/* outer border */
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
index 2d3dbd350e0..7a63331b9c8 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicButtonUI.java
@@ -52,7 +52,6 @@ import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ButtonUI;
import javax.swing.plaf.ComponentUI;
@@ -161,7 +160,6 @@ public class BasicButtonUI extends ButtonUI
b.setIconTextGap(UIManager.getInt(prefix + "textIconGap"));
b.setInputMap(JComponent.WHEN_FOCUSED,
(InputMap) UIManager.get(prefix + "focusInputMap"));
- b.setRolloverEnabled(UIManager.getBoolean(prefix + "rollover"));
}
/**
@@ -444,9 +442,8 @@ public class BasicButtonUI extends ButtonUI
}
else
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
String prefix = getPropertyPrefix();
- g.setColor(defaults.getColor(prefix + "disabledText"));
+ g.setColor(UIManager.getColor(prefix + "disabledText"));
g.drawString(text, textRect.x, textRect.y + fm.getAscent());
}
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
index 3cf02a00156..14dadb85cf9 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicCheckBoxUI.java
@@ -40,7 +40,6 @@ package javax.swing.plaf.basic;
import javax.swing.Icon;
import javax.swing.JComponent;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
@@ -53,12 +52,11 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI
public Icon getDefaultIcon()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- return defaults.getIcon("CheckBox.icon");
+ return UIManager.getIcon("CheckBox.icon");
}
/**
- * Returns the prefix for entries in the {@link UIDefaults} table.
+ * Returns the prefix for entries in the {@link UIManager} defaults table.
*
* @return "CheckBox."
*/
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
index 464c8dd9f63..b22aa15f901 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -805,10 +805,10 @@ public class BasicComboBoxUI extends ComboBoxUI
isPressed, hasFocus);
if (! comboBox.isEnabled())
{
- comp.setBackground(UIManager.getLookAndFeelDefaults().getColor(
- "ComboBox.disabledBackground"));
- comp.setForeground(UIManager.getLookAndFeelDefaults().getColor(
- "ComboBox.disabledForeground"));
+ comp.setBackground(UIManager.getColor(
+ "ComboBox.disabledBackground"));
+ comp.setForeground(UIManager.getColor(
+ "ComboBox.disabledForeground"));
comp.setEnabled(false);
}
comp.setBounds(0, 0, bounds.width, bounds.height);
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java
index d5b34d9eef6..d514a87c8ee 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java
@@ -42,10 +42,7 @@ 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.
@@ -76,14 +73,6 @@ public class BasicEditorPaneUI extends BasicTextUI
// 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.
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
index 9c639656545..60179dc0706 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -79,7 +79,6 @@ import javax.swing.ListCellRenderer;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -1429,27 +1428,25 @@ public class BasicFileChooserUI extends FileChooserUI
*/
protected void installStrings(JFileChooser fc)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ acceptAllFileFilterText = UIManager.getString("FileChooser.acceptAllFileFilterText");
+ cancelButtonMnemonic = UIManager.getInt("FileChooser.cancelButtonMnemonic");
+ cancelButtonText = UIManager.getString("FileChooser.cancelButtonText");
+ cancelButtonToolTipText = UIManager.getString("FileChooser.cancelButtonToolTipText");
- acceptAllFileFilterText = defaults.getString("FileChooser.acceptAllFileFilterText");
- cancelButtonMnemonic = defaults.getInt("FileChooser.cancelButtonMnemonic");
- cancelButtonText = defaults.getString("FileChooser.cancelButtonText");
- cancelButtonToolTipText = defaults.getString("FileChooser.cancelButtonToolTipText");
+ dirDescText = UIManager.getString("FileChooser.directoryDescriptionText");
+ fileDescText = UIManager.getString("FileChooser.fileDescriptionText");
- dirDescText = defaults.getString("FileChooser.directoryDescriptionText");
- fileDescText = defaults.getString("FileChooser.fileDescriptionText");
+ helpButtonMnemonic = UIManager.getInt("FileChooser.helpButtonMnemonic");
+ helpButtonText = UIManager.getString("FileChooser.helpButtonText");
+ helpButtonToolTipText = UIManager.getString("FileChooser.helpButtonToolTipText");
- helpButtonMnemonic = defaults.getInt("FileChooser.helpButtonMnemonic");
- helpButtonText = defaults.getString("FileChooser.helpButtonText");
- helpButtonToolTipText = defaults.getString("FileChooser.helpButtonToolTipText");
+ openButtonMnemonic = UIManager.getInt("FileChooser.openButtonMnemonic");
+ openButtonText = UIManager.getString("FileChooser.openButtonText");
+ openButtonToolTipText = UIManager.getString("FileChooser.openButtonToolTipText");
- openButtonMnemonic = defaults.getInt("FileChooser.openButtonMnemonic");
- openButtonText = defaults.getString("FileChooser.openButtonText");
- openButtonToolTipText = defaults.getString("FileChooser.openButtonToolTipText");
-
- saveButtonMnemonic = defaults.getInt("FileChooser.saveButtonMnemonic");
- saveButtonText = defaults.getString("FileChooser.saveButtonText");
- saveButtonToolTipText = defaults.getString("FileChooser.saveButtonToolTipText");
+ saveButtonMnemonic = UIManager.getInt("FileChooser.saveButtonMnemonic");
+ saveButtonText = UIManager.getString("FileChooser.saveButtonText");
+ saveButtonToolTipText = UIManager.getString("FileChooser.saveButtonToolTipText");
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 73d3e6173d3..56022f3331e 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -66,7 +66,6 @@ import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
/**
@@ -718,13 +717,11 @@ public class BasicInternalFrameTitlePane extends JComponent
*/
protected void installDefaults()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- title.setFont(defaults.getFont("InternalFrame.titleFont"));
- selectedTextColor = defaults.getColor("InternalFrame.activeTitleForeground");
- selectedTitleColor = defaults.getColor("InternalFrame.activeTitleBackground");
- notSelectedTextColor = defaults.getColor("InternalFrame.inactiveTitleForeground");
- notSelectedTitleColor = defaults.getColor("InternalFrame.inactiveTitleBackground");
+ title.setFont(UIManager.getFont("InternalFrame.titleFont"));
+ selectedTextColor = UIManager.getColor("InternalFrame.activeTitleForeground");
+ selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
+ notSelectedTextColor = UIManager.getColor("InternalFrame.inactiveTitleForeground");
+ notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
@@ -901,6 +898,9 @@ public class BasicInternalFrameTitlePane extends JComponent
*/
protected void paintTitleBackground(Graphics g)
{
+ if (!isOpaque())
+ return;
+
Color saved = g.getColor();
Dimension dims = getSize();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
index 33932991473..2d66645fb7d 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicListUI.java
@@ -703,12 +703,17 @@ public class BasicListUI extends ListUI
*/
protected int getRowHeight(int row)
{
- if (row < 0 || row >= cellHeights.length)
- return -1;
- else if (cellHeight != -1)
- return cellHeight;
+ int height;
+ if (cellHeights == null)
+ height = cellHeight;
else
- return cellHeights[row];
+ {
+ if (row < 0 || row >= cellHeights.length)
+ height = -1;
+ else
+ height = cellHeights[row];
+ }
+ return height;
}
/**
@@ -803,9 +808,7 @@ public class BasicListUI extends ListUI
// If a fixed cell height is set, then we can work more efficient.
if (cellHeight > 0)
- {
- index = Math.max(y0 / cellHeight, index);
- }
+ index = Math.min(y0 / cellHeight, index);
// If we have no fixed cell height, we must add up each cell height up
// to y0.
else
@@ -992,8 +995,7 @@ public class BasicListUI extends ListUI
*/
protected void installKeyboardActions()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- InputMap focusInputMap = (InputMap)defaults.get("List.focusInputMap");
+ InputMap focusInputMap = (InputMap) UIManager.get("List.focusInputMap");
InputMapUIResource parentInputMap = new InputMapUIResource();
// FIXME: The JDK uses a LazyActionMap for parentActionMap
ActionMap parentActionMap = new ActionMapUIResource();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
index 8ebe650350c..13c78add6f8 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -1159,7 +1159,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Tree.hash", new ColorUIResource(new Color(128, 128, 128)),
"Tree.leftChildIndent", new Integer(7),
"Tree.rightChildIndent", new Integer(13),
- "Tree.rowHeight", new Integer(16),
+ "Tree.rowHeight", new Integer(0),
"Tree.scrollsOnExpand", Boolean.TRUE,
"Tree.selectionBackground", new ColorUIResource(Color.black),
"Tree.nonSelectionBackground", new ColorUIResource(new Color(255, 255, 255)),
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
index 2a3556a5db9..c8754a3e049 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -475,7 +475,6 @@ public class BasicMenuItemUI extends MenuItemUI
menuItem.setHorizontalTextPosition(SwingConstants.TRAILING);
menuItem.setHorizontalAlignment(SwingConstants.LEADING);
- menuItem.setOpaque(true);
}
/**
@@ -553,11 +552,20 @@ public class BasicMenuItemUI extends MenuItemUI
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
- Dimension size = getPreferredSize(menuItem);
- Color foreground = g.getColor();
- g.setColor(bgColor);
- g.drawRect(0, 0, size.width, size.height);
- g.setColor(foreground);
+ // Menu item is considered to be highlighted when it is selected.
+ // But we don't want to paint the background of JCheckBoxMenuItems
+ ButtonModel mod = menuItem.getModel();
+ if ((menuItem.isSelected() && checkIcon == null) || (mod != null &&
+ mod.isArmed())
+ && (menuItem.getParent() instanceof MenuElement))
+ {
+ if (menuItem.isContentAreaFilled())
+ {
+ g.setColor(selectionBackground);
+ g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
+ }
+ }
+
}
/**
@@ -612,28 +620,6 @@ 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.
- // But we don't want to paint the background of JCheckBoxMenuItems
- ButtonModel mod = m.getModel();
- if ((m.isSelected() && checkIcon == null) || (mod != null &&
- mod.isArmed())
- && (m.getParent() instanceof MenuElement))
- {
- if (m.isContentAreaFilled())
- {
- g.setColor(selectionBackground);
- g.fillRect(br.x, br.y, br.width, br.height);
- }
- }
- else
- {
- if (m.isContentAreaFilled())
- {
- g.setColor(m.getBackground());
- g.fillRect(br.x, br.y, br.width, br.height);
- }
- }
-
// If this menu item is a JCheckBoxMenuItem then paint check icon
if (checkIcon != null)
{
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
index 827cbb0f50d..e638b68e1dc 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicMenuUI.java
@@ -211,7 +211,6 @@ public class BasicMenuUI extends BasicMenuItemUI
selectionForeground = UIManager.getColor("Menu.selectionForeground");
arrowIcon = UIManager.getIcon("Menu.arrowIcon");
oldBorderPainted = UIManager.getBoolean("Menu.borderPainted");
- menuItem.setOpaque(true);
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
index 88d949b1caf..d3674664d4c 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -212,6 +212,8 @@ public class BasicProgressBarUI extends ProgressBarUI
/**
* Holds the value of the bouncing box that is returned by {@link #getBox}.
+ *
+ * @since 1.5
*/
protected Rectangle boxRect;
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
index f3698e85908..66e53803722 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -48,7 +48,6 @@ 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;
@@ -122,8 +121,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
*/
public Icon getDefaultIcon()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- return defaults.getIcon(getPropertyPrefix() + "icon");
+ return UIManager.getIcon(getPropertyPrefix() + "icon");
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
index 2f5eaf391e1..a2f5b82dbec 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -62,7 +62,6 @@ import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -501,14 +500,12 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
*/
protected void configureScrollBarColors()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
-
- trackColor = defaults.getColor("ScrollBar.track");
- trackHighlightColor = defaults.getColor("ScrollBar.trackHighlight");
- thumbColor = defaults.getColor("ScrollBar.thumb");
- thumbHighlightColor = defaults.getColor("ScrollBar.thumbHighlight");
- thumbDarkShadowColor = defaults.getColor("ScrollBar.thumbDarkShadow");
- thumbLightShadowColor = defaults.getColor("ScrollBar.thumbShadow");
+ trackColor = UIManager.getColor("ScrollBar.track");
+ trackHighlightColor = UIManager.getColor("ScrollBar.trackHighlight");
+ thumbColor = UIManager.getColor("ScrollBar.thumb");
+ thumbHighlightColor = UIManager.getColor("ScrollBar.thumbHighlight");
+ thumbDarkShadowColor = UIManager.getColor("ScrollBar.thumbDarkShadow");
+ thumbLightShadowColor = UIManager.getColor("ScrollBar.thumbShadow");
}
/**
@@ -660,11 +657,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
width += decrButton.getPreferredSize().getWidth();
width += (scrollbar.getMaximum() - scrollbar.getMinimum());
-
- height = Math.max(incrButton.getPreferredSize().height,
- decrButton.getPreferredSize().height);
- height = Math.max(getMinimumThumbSize().height, height);
- height = Math.min(getMaximumThumbSize().height, height);
+ height = UIManager.getInt("ScrollBar.width");
}
else
{
@@ -672,11 +665,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
height += decrButton.getPreferredSize().getHeight();
height += (scrollbar.getMaximum() - scrollbar.getMinimum());
-
- width = Math.max(incrButton.getPreferredSize().width,
- decrButton.getPreferredSize().width);
- width = Math.max(getMinimumThumbSize().width, width);
- width = Math.min(getMaximumThumbSize().width, width);
+ width = UIManager.getInt("ScrollBar.width");
}
Insets insets = scrollbar.getInsets();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
index 746f628df6f..cf31e8b5df1 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -126,14 +126,14 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
int i = 0;
if (place == null)
- i = 2;
+ i = 2;
else if (place.equals(JSplitPane.TOP) || place.equals(JSplitPane.LEFT))
- i = 0;
+ i = 0;
else if (place.equals(JSplitPane.BOTTOM)
|| place.equals(JSplitPane.RIGHT))
- i = 1;
+ i = 1;
else
- throw new IllegalArgumentException("Illegal placement in JSplitPane");
+ throw new IllegalArgumentException("Illegal placement in JSplitPane");
components[i] = component;
resetSizeAt(i);
splitPane.revalidate();
@@ -164,7 +164,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
protected int getInitialLocation(Insets insets)
{
if (insets != null)
- return insets.left;
+ return insets.left;
return 0;
}
@@ -205,7 +205,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
Dimension dims = c.getPreferredSize();
if (dims != null)
- return dims.width;
+ return dims.width;
return 0;
}
@@ -250,23 +250,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (container instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) container;
- distributeExtraSpace();
- Insets insets = split.getInsets();
- int width = getInitialLocation(insets);
- Dimension dims = split.getSize();
- for (int i = 0; i < components.length; i += 2)
- {
- if (components[i] == null)
- continue;
- setComponentToSize(components[i], sizes[i], width, insets, dims);
- width += sizes[i];
- }
- if (components[1] != null)
- {
- setComponentToSize(components[1], sizes[1], width, insets, dims);
- width += sizes[1];
- }
+ JSplitPane split = (JSplitPane) container;
+ distributeExtraSpace();
+ Insets insets = split.getInsets();
+ int width = getInitialLocation(insets);
+ Dimension dims = split.getSize();
+ for (int i = 0; i < components.length; i += 2)
+ {
+ if (components[i] == null)
+ continue;
+ setComponentToSize(components[i], sizes[i], width, insets, dims);
+ width += sizes[i];
+ }
+ if (components[1] != null)
+ {
+ setComponentToSize(components[1], sizes[1], width, insets, dims);
+ width += sizes[1];
+ }
}
}
@@ -297,23 +297,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (target instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) target;
- Insets insets = target.getInsets();
-
- int height = 0;
- int width = 0;
- for (int i = 0; i < components.length; i++)
- {
- if (components[i] == null)
- continue;
- Dimension dims = components[i].getMinimumSize();
- if (dims != null)
- {
- width += dims.width;
- height = Math.max(height, dims.height);
- }
- }
- return new Dimension(width, height);
+ JSplitPane split = (JSplitPane) target;
+ Insets insets = target.getInsets();
+
+ int height = 0;
+ int width = 0;
+ for (int i = 0; i < components.length; i++)
+ {
+ if (components[i] == null)
+ continue;
+ Dimension dims = components[i].getMinimumSize();
+ if (dims != null)
+ {
+ width += dims.width;
+ height = Math.max(height, dims.height);
+ }
+ }
+ return new Dimension(width, height);
}
return null;
}
@@ -331,24 +331,24 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (target instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) target;
- Insets insets = target.getInsets();
-
- int height = 0;
- int width = 0;
- for (int i = 0; i < components.length; i++)
- {
- if (components[i] == null)
- continue;
- Dimension dims = components[i].getPreferredSize();
- if (dims != null)
- {
- width += dims.width;
- if (! (components[i] instanceof BasicSplitPaneDivider))
- height = Math.max(height, dims.height);
- }
- }
- return new Dimension(width, height);
+ JSplitPane split = (JSplitPane) target;
+ Insets insets = target.getInsets();
+
+ int height = 0;
+ int width = 0;
+ for (int i = 0; i < components.length; i++)
+ {
+ if (components[i] == null)
+ continue;
+ Dimension dims = components[i].getPreferredSize();
+ if (dims != null)
+ {
+ width += dims.width;
+ if (!(components[i] instanceof BasicSplitPaneDivider))
+ height = Math.max(height, dims.height);
+ }
+ }
+ return new Dimension(width, height);
}
return null;
}
@@ -362,11 +362,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
for (int i = 0; i < components.length; i++)
{
- if (component == components[i])
- {
- components[i] = null;
- sizes[i] = 0;
- }
+ if (component == components[i])
+ {
+ components[i] = null;
+ sizes[i] = 0;
+ }
}
}
@@ -378,7 +378,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
protected void resetSizeAt(int index)
{
if (components[index] != null)
- sizes[index] = getPreferredSizeOfComponent(components[index]);
+ sizes[index] = getPreferredSizeOfComponent(components[index]);
}
/**
@@ -387,7 +387,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
public void resetToPreferredSizes()
{
for (int i = 0; i < components.length; i++)
- resetSizeAt(i);
+ resetSizeAt(i);
}
/**
@@ -433,13 +433,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
if (left != null)
{
- components[0] = left;
- resetSizeAt(0);
+ components[0] = left;
+ resetSizeAt(0);
}
if (right != null)
{
- components[1] = right;
- resetSizeAt(1);
+ components[1] = right;
+ resetSizeAt(1);
}
components[2] = divider;
resetSizeAt(2);
@@ -480,9 +480,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
Dimension dims = components[index].getMinimumSize();
if (dims != null)
- return dims.width;
+ return dims.width;
else
- return 0;
+ return 0;
}
} //end BasicHorizontalLayoutManager
@@ -534,7 +534,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
Dimension dims = c.getPreferredSize();
if (dims != null)
- return dims.height;
+ return dims.height;
return 0;
}
@@ -563,23 +563,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (container instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) container;
- Insets insets = container.getInsets();
-
- int height = 0;
- int width = 0;
- for (int i = 0; i < components.length; i++)
- {
- if (components[i] == null)
- continue;
- Dimension dims = components[i].getMinimumSize();
- if (dims != null)
- {
- height += dims.height;
- width = Math.max(width, dims.width);
- }
- }
- return new Dimension(width, height);
+ JSplitPane split = (JSplitPane) container;
+ Insets insets = container.getInsets();
+
+ int height = 0;
+ int width = 0;
+ for (int i = 0; i < components.length; i++)
+ {
+ if (components[i] == null)
+ continue;
+ Dimension dims = components[i].getMinimumSize();
+ if (dims != null)
+ {
+ height += dims.height;
+ width = Math.max(width, dims.width);
+ }
+ }
+ return new Dimension(width, height);
}
return null;
}
@@ -597,23 +597,23 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (container instanceof JSplitPane)
{
- JSplitPane split = (JSplitPane) container;
- Insets insets = container.getInsets();
-
- int height = 0;
- int width = 0;
- for (int i = 0; i < components.length; i++)
- {
- if (components[i] == null)
- continue;
- Dimension dims = components[i].getPreferredSize();
- if (dims != null)
- {
- height += dims.height;
- width = Math.max(width, dims.width);
- }
- }
- return new Dimension(width, height);
+ JSplitPane split = (JSplitPane) container;
+ Insets insets = container.getInsets();
+
+ int height = 0;
+ int width = 0;
+ for (int i = 0; i < components.length; i++)
+ {
+ if (components[i] == null)
+ continue;
+ Dimension dims = components[i].getPreferredSize();
+ if (dims != null)
+ {
+ height += dims.height;
+ width = Math.max(width, dims.width);
+ }
+ }
+ return new Dimension(width, height);
}
return null;
}
@@ -652,9 +652,9 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
Dimension dims = components[index].getMinimumSize();
if (dims != null)
- return dims.height;
+ return dims.height;
else
- return 0;
+ return 0;
}
}
@@ -813,27 +813,27 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY))
{
- int newSize = splitPane.getDividerSize();
- int[] tmpSizes = layoutManager.getSizes();
- dividerSize = tmpSizes[2];
- int newSpace = newSize - tmpSizes[2];
- tmpSizes[2] = newSize;
-
- tmpSizes[0] += newSpace / 2;
- tmpSizes[1] += newSpace / 2;
+ int newSize = splitPane.getDividerSize();
+ int[] tmpSizes = layoutManager.getSizes();
+ dividerSize = tmpSizes[2];
+ int newSpace = newSize - tmpSizes[2];
+ tmpSizes[2] = newSize;
+
+ tmpSizes[0] += newSpace / 2;
+ tmpSizes[1] += newSpace / 2;
- layoutManager.setSizes(tmpSizes);
+ layoutManager.setSizes(tmpSizes);
}
else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))
{
- int max = layoutManager.getAvailableSize(splitPane.getSize(),
- splitPane.getInsets());
- int dividerLoc = getDividerLocation(splitPane);
- double prop = ((double) dividerLoc) / max;
-
- resetLayoutManager();
- if (prop <= 1 && prop >= 0)
- splitPane.setDividerLocation(prop);
+ int max = layoutManager.getAvailableSize(splitPane.getSize(),
+ splitPane.getInsets());
+ int dividerLoc = getDividerLocation(splitPane);
+ double prop = ((double) dividerLoc) / max;
+
+ resetLayoutManager();
+ if (prop <= 1 && prop >= 0)
+ splitPane.setDividerLocation(prop);
}
layoutManager.layoutContainer(splitPane);
splitPane.repaint();
@@ -843,13 +843,13 @@ public class BasicSplitPaneUI extends SplitPaneUI
// Don't have to deal with resize_weight (as there
// will be no extra space associated with this
// event - the changes to the weighting will
- // be taken into account the next time the
+ // be taken into account the next time the
// sizes change.)
- // Don't have to deal with divider_location
+ // Don't have to deal with divider_location
// The method in JSplitPane calls our setDividerLocation
// so we'll know about those anyway.
// Don't have to deal with last_divider_location
- // Although I'm not sure why, it doesn't seem to
+ // Although I'm not sure why, it doesn't seem to
// have any effect on Sun's JSplitPane.
// one_touch_expandable changes are dealt with
// by our divider.
@@ -962,10 +962,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (c instanceof JSplitPane)
{
- splitPane = (JSplitPane) c;
- installDefaults();
- installListeners();
- installKeyboardActions();
+ splitPane = (JSplitPane) c;
+ installDefaults();
+ installListeners();
+ installKeyboardActions();
}
}
@@ -1218,8 +1218,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
if (nonContinuousLayoutDivider == null)
{
- nonContinuousLayoutDivider = new Canvas();
- nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY);
+ nonContinuousLayoutDivider = new Canvas();
+ nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY);
}
return nonContinuousLayoutDivider;
}
@@ -1300,12 +1300,14 @@ public class BasicSplitPaneUI extends SplitPaneUI
{
location = validLocation(location);
Container p = jc.getParent();
- Dimension rightPrefSize = jc.getRightComponent().getPreferredSize();
+ Component right = jc.getRightComponent();
+ Dimension rightPrefSize = right == null ? new Dimension(0, 0)
+ : right.getPreferredSize();
Dimension size = jc.getSize();
// check if the size has been set for the splitpane
if (size.width == 0 && size.height == 0)
size = jc.getPreferredSize();
-
+
if (getOrientation() == 0 && location > size.height)
{
location = size.height;
@@ -1324,11 +1326,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
p = p.getParent();
}
}
-
+
setLastDragLocation(getDividerLocation(splitPane));
splitPane.setLastDividerLocation(getDividerLocation(splitPane));
int[] tmpSizes = layoutManager.getSizes();
- tmpSizes[0] = location
+ tmpSizes[0] = location
- layoutManager.getInitialLocation(splitPane.getInsets());
tmpSizes[1] = layoutManager.getAvailableSize(splitPane.getSize(),
splitPane.getInsets())
@@ -1483,19 +1485,21 @@ public class BasicSplitPaneUI extends SplitPaneUI
*/
protected void startDragging()
{
+ Component left = splitPane.getLeftComponent();
+ Component right = splitPane.getRightComponent();
dividerSize = divider.getDividerSize();
setLastDragLocation(-1);
- if (! splitPane.getLeftComponent().isLightweight()
- || ! splitPane.getRightComponent().isLightweight())
+ if ((left != null && !left.isLightweight())
+ || (right != null && !right.isLightweight()))
draggingHW = true;
if (splitPane.isContinuousLayout())
nonContinuousLayoutDivider.setVisible(false);
else
{
- nonContinuousLayoutDivider.setVisible(true);
- nonContinuousLayoutDivider.setBounds(divider.getBounds());
+ nonContinuousLayoutDivider.setVisible(true);
+ nonContinuousLayoutDivider.setBounds(divider.getBounds());
}
splitPane.revalidate();
splitPane.repaint();
@@ -1518,12 +1522,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
splitPane.setDividerLocation(location);
else
{
- Point p = nonContinuousLayoutDivider.getLocation();
- if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
- p.x = location;
- else
- p.y = location;
- nonContinuousLayoutDivider.setLocation(p);
+ Point p = nonContinuousLayoutDivider.getLocation();
+ if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
+ p.x = location;
+ else
+ p.y = location;
+ nonContinuousLayoutDivider.setLocation(p);
}
setLastDragLocation(location);
splitPane.repaint();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
index 25a845b36b8..015443946d7 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTableUI.java
@@ -66,7 +66,6 @@ import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.LookAndFeel;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
@@ -398,8 +397,7 @@ public class BasicTableUI extends TableUI
protected void installKeyboardActions()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap");
+ InputMap ancestorMap = (InputMap) UIManager.get("Table.ancestorInputMap");
InputMapUIResource parentInputMap = new InputMapUIResource();
// FIXME: The JDK uses a LazyActionMap for parentActionMap
ActionMap parentActionMap = new ActionMapUIResource();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextPaneUI.java
index decbed56829..a988c5a63c8 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTextPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextPaneUI.java
@@ -45,12 +45,9 @@ import javax.swing.JTextPane;
import javax.swing.plaf.ColorUIResource;
import javax.swing.UIDefaults;
import javax.swing.plaf.ComponentUI;
-import javax.swing.text.Element;
-import javax.swing.text.PlainView;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
-import javax.swing.text.View;
public class BasicTextPaneUI extends BasicEditorPaneUI
{
@@ -64,11 +61,6 @@ public class BasicTextPaneUI extends BasicEditorPaneUI
return new BasicTextPaneUI();
}
- public View create(Element elem)
- {
- return new PlainView(elem);
- }
-
/**
* Returns the prefix for entries in the {@link UIDefaults} table.
*
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
index b9de92640c8..e8eeece3b32 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTextUI.java
@@ -58,7 +58,6 @@ import javax.swing.JComponent;
import javax.swing.LookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@@ -618,13 +617,14 @@ public abstract class BasicTextUI extends TextUI
protected Keymap createKeymap()
{
String prefix = getPropertyPrefix();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
JTextComponent.KeyBinding[] bindings =
- (JTextComponent.KeyBinding[]) defaults.get(prefix + ".keyBindings");
+ (JTextComponent.KeyBinding[]) UIManager.get(prefix + ".keyBindings");
if (bindings == null)
{
bindings = new JTextComponent.KeyBinding[0];
- defaults.put(prefix + ".keyBindings", bindings);
+ // FIXME: Putting something into the defaults map is certainly wrong.
+ // Must be fixed somehow.
+ UIManager.put(prefix + ".keyBindings", bindings);
}
Keymap km = JTextComponent.addKeymap(getKeymapName(),
@@ -661,17 +661,16 @@ public abstract class BasicTextUI extends TextUI
InputMap getInputMap(int condition)
{
String prefix = getPropertyPrefix();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
switch (condition)
{
case JComponent.WHEN_IN_FOCUSED_WINDOW:
// FIXME: is this the right string? nobody seems to use it.
- return (InputMap) defaults.get(prefix + ".windowInputMap");
+ return (InputMap) UIManager.get(prefix + ".windowInputMap");
case JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT:
- return (InputMap) defaults.get(prefix + ".ancestorInputMap");
+ return (InputMap) UIManager.get(prefix + ".ancestorInputMap");
default:
case JComponent.WHEN_FOCUSED:
- return (InputMap) defaults.get(prefix + ".focusInputMap");
+ return (InputMap) UIManager.get(prefix + ".focusInputMap");
}
}
@@ -685,12 +684,14 @@ public abstract class BasicTextUI extends TextUI
ActionMap getActionMap()
{
String prefix = getPropertyPrefix();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- ActionMap am = (ActionMap) defaults.get(prefix + ".actionMap");
+ ActionMap am = (ActionMap) UIManager.get(prefix + ".actionMap");
if (am == null)
{
am = createActionMap();
- defaults.put(prefix + ".actionMap", am);
+ // FIXME: Putting something in the UIDefaults map is certainly wrong.
+ // However, the whole method seems wrong and must be replaced by
+ // something that is less wrong.
+ UIManager.put(prefix + ".actionMap", am);
}
return am;
}
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
index ef4ed835f86..7bf2a4ab167 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicToolBarUI.java
@@ -404,6 +404,8 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
boolean tmp = ((loc == SwingConstants.NORTH)
|| (loc == SwingConstants.SOUTH) || (loc == -1));
+ cachedOrientation = toolBar.getOrientation();
+ cachedBounds = toolBar.getSize();
if (((cachedOrientation == SwingConstants.HORIZONTAL) && tmp)
|| ((cachedOrientation == VERTICAL) && ! tmp))
{
@@ -571,9 +573,6 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
dragWindow = createDragWindow(toolBar);
- cachedBounds = toolBar.getPreferredSize();
- cachedOrientation = toolBar.getOrientation();
-
nonRolloverBorder = createNonRolloverBorder();
rolloverBorder = createRolloverBorder();
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
index e967cd424fc..2d54983e61f 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicTreeUI.java
@@ -81,7 +81,6 @@ import javax.swing.KeyStroke;
import javax.swing.LookAndFeel;
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;
@@ -239,14 +238,14 @@ public class BasicTreeUI extends TreeUI
/** Boolean to keep track of editing. */
boolean isEditing;
- /** The bounds of the current cell. */
- Rectangle bounds;
-
/** The current path of the visible nodes in the tree. */
TreePath currentVisiblePath;
/** The gap between the icon and text. */
int gap = 4;
+
+ /** Default row height, if none was set. */
+ int rowHeight = 20;
/** Listeners */
private PropertyChangeListener propertyChangeListener;
@@ -304,7 +303,7 @@ public class BasicTreeUI extends TreeUI
*/
protected Color getHashColor()
{
- return UIManager.getLookAndFeelDefaults().getColor("Tree.hash");
+ return UIManager.getColor("Tree.hash");
}
/**
@@ -315,8 +314,8 @@ public class BasicTreeUI extends TreeUI
*/
protected void setHashColor(Color color)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- defaults.put("Tree.hash", color);
+ // FIXME: Putting something in the UIDefaults map is certainly wrong.
+ UIManager.put("Tree.hash", color);
}
/**
@@ -437,6 +436,8 @@ public class BasicTreeUI extends TreeUI
*/
protected void setRowHeight(int rowHeight)
{
+ if (rowHeight == 0)
+ rowHeight = this.rowHeight;
treeState.setRowHeight(rowHeight);
}
@@ -624,21 +625,19 @@ public class BasicTreeUI extends TreeUI
*/
public Rectangle getPathBounds(JTree tree, TreePath path)
{
+ Rectangle bounds = null;
+ int row = -1;
+ Object cell = null;
if (path != null)
{
- Object cell = path.getLastPathComponent();
-
- if (treeModel != null)
- {
- Object root = treeModel.getRoot();
-
- if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root)))
- root = getNextNode(root);
- Point loc = getCellLocation(0, 0, tree, treeModel, cell, root);
- return getCellBounds(loc.x, loc.y, cell);
- }
+ row = getRowForPath(tree, path);
+ cell = path.getLastPathComponent();
+ bounds = new Rectangle(0, row * getRowHeight(), 0, 0);
}
- return null;
+ return nodeDimensions.getNodeDimensions(cell, row,
+ getLevel(cell),
+ tree.isExpanded(path),
+ bounds);
}
/**
@@ -700,7 +699,6 @@ public class BasicTreeUI extends TreeUI
*/
public int getRowCount(JTree tree)
{
- updateCurrentVisiblePath();
if (currentVisiblePath != null)
return currentVisiblePath.getPathCount();
return 0;
@@ -1035,7 +1033,9 @@ public class BasicTreeUI extends TreeUI
*/
protected void uninstallKeyboardActions()
{
- // TODO: Implement this properly.
+ action = null;
+ tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(null);
+ tree.getActionMap().setParent(null);
}
/**
@@ -1227,7 +1227,7 @@ public class BasicTreeUI extends TreeUI
rightChildIndent = UIManager.getInt("Tree.rightChildIndent");
leftChildIndent = UIManager.getInt("Tree.leftChildIndent");
setRowHeight(UIManager.getInt("Tree.rowHeight"));
- tree.setRowHeight(UIManager.getInt("Tree.rowHeight"));
+ tree.setRowHeight(getRowHeight());
tree.requestFocusInWindow(false);
tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand"));
setExpandedIcon(UIManager.getIcon("Tree.expandedIcon"));
@@ -1239,8 +1239,7 @@ public class BasicTreeUI extends TreeUI
*/
protected void installKeyboardActions()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- InputMap focusInputMap = (InputMap) defaults.get("Tree.focusInputMap");
+ InputMap focusInputMap = (InputMap) UIManager.get("Tree.focusInputMap");
InputMapUIResource parentInputMap = new InputMapUIResource();
ActionMap parentActionMap = new ActionMapUIResource();
action = new TreeAction();
@@ -1409,14 +1408,30 @@ public class BasicTreeUI extends TreeUI
JTree tree = (JTree) c;
if (currentVisiblePath == null)
updateCurrentVisiblePath();
-
- if (currentVisiblePath != null && treeModel != null)
+
+ Rectangle clip = g.getClipBounds();
+ Insets insets = tree.getInsets();
+
+ if (clip != null && treeModel != null && currentVisiblePath != null)
{
- Object root = treeModel.getRoot();
- paintRecursive(g, 0, 0, 0, tree, treeModel, root);
-
- if (hasControlIcons())
- paintControlIcons(g, 0, 0, 0, tree, treeModel, root);
+ int startIndex = tree.getClosestRowForLocation(clip.x, clip.y);
+ int endIndex = tree.getClosestRowForLocation(clip.x + clip.width,
+ clip.y + clip.height);
+
+ paintVerticalPartOfLeg(g, clip, insets, currentVisiblePath);
+ for (int i = startIndex; i <= endIndex; i++)
+ {
+ Object curr = currentVisiblePath.getPathComponent(i);
+ boolean isLeaf = treeModel.isLeaf(curr);
+ TreePath path = new TreePath(getPathToRoot(curr, 0));
+
+ boolean isExpanded = tree.isExpanded(path);
+ Rectangle bounds = getPathBounds(tree, path);
+ paintHorizontalPartOfLeg(g, clip, insets, bounds, path, i,
+ isExpanded, false, isLeaf);
+ paintRow(g, clip, insets, bounds, path, i, isExpanded, false,
+ isLeaf);
+ }
}
}
@@ -1590,7 +1605,7 @@ public class BasicTreeUI extends TreeUI
int y;
if (event == null)
{
- bounds = getPathBounds(tree, path);
+ Rectangle bounds = getPathBounds(tree, path);
x = bounds.x;
y = bounds.y;
}
@@ -1670,7 +1685,7 @@ public class BasicTreeUI extends TreeUI
if (!isLeaf(row))
{
- bounds = getPathBounds(tree, path);
+ Rectangle bounds = getPathBounds(tree, path);
if (hasControlIcons() && (mouseX < bounds.x)
&& (mouseX > (bounds.x - getCurrentControlIcon(path).getIconWidth() - gap)))
@@ -1991,7 +2006,7 @@ public class BasicTreeUI extends TreeUI
}
/**
- * Creats, if necessary, and starts a Timer to check if needed to resize the
+ * Creates, if necessary, and starts a Timer to check if needed to resize the
* bounds
*/
protected void startTimer()
@@ -2227,7 +2242,7 @@ public class BasicTreeUI extends TreeUI
if (path != null)
{
- bounds = getPathBounds(tree, path);
+ Rectangle bounds = getPathBounds(tree, path);
int row = getRowForPath(tree, path);
boolean cntlClick = isLocationInExpandControl(path, click.x, click.y);
@@ -2268,6 +2283,7 @@ public class BasicTreeUI extends TreeUI
handleExpandControlClick(path, click.x, click.y);
if (cellEditor != null)
cellEditor.cancelCellEditing();
+ tree.scrollPathToVisible(path);
}
else if (tree.isEditable())
startEditing(path, e);
@@ -2451,9 +2467,12 @@ public class BasicTreeUI extends TreeUI
}
/**
- * Responsible for getting the size of a particular node.
+ * Returns, by reference in bounds, the size and x origin to place value at.
+ * The calling method is responsible for determining the Y location.
+ * If bounds is null, a newly created Rectangle should be returned,
+ * otherwise the value should be placed in bounds and returned.
*
- * @param value
+ * @param cell
* the value to be represented
* @param row
* row being queried
@@ -2465,10 +2484,23 @@ public class BasicTreeUI extends TreeUI
* 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,
+ public Rectangle getNodeDimensions(Object cell, int row, int depth,
boolean expanded, Rectangle size)
{
- return null;
+ if (size == null || cell == null)
+ return null;
+
+ String s = cell.toString();
+ Font f = tree.getFont();
+ FontMetrics fm = tree.getToolkit().getFontMetrics(f);
+
+ if (s != null)
+ {
+ size.x = getRowX(row, depth);
+ size.width = SwingUtilities.computeStringWidth(fm, s);
+ size.height = fm.getHeight();
+ }
+ return size;
}
/**
@@ -2478,7 +2510,9 @@ public class BasicTreeUI extends TreeUI
*/
protected int getRowX(int row, int depth)
{
- return 0;
+ if (row == 0)
+ return 0;
+ return depth * rightChildIndent;
}
}// NodeDimensionsHandler
@@ -3057,241 +3091,6 @@ public class BasicTreeUI extends TreeUI
}
/**
- * 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(f);
-
- if (s != null)
- return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s),
- 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))
- {
- int level = getLevel(node);
- if (level == 0)
- return new Point(x, y);
- if (!tree.isRootVisible() &&
- tree.isExpanded(new TreePath(mod.getRoot())))
- return new Point(x + ((level - 1) * rightChildIndent), y);
- return new Point(x + (level * rightChildIndent), y);
- }
- return getCellLocation(x, y + rowHeight, tree, mod, node,
- getNextVisibleNode(startNode));
- }
-
- /**
- * 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 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 depth, JTree tree, TreeModel mod, Object curr)
- {
- Rectangle clip = tree.getVisibleRect();
- if (indentation > clip.x + clip.width + rightChildIndent
- || descent > clip.y + clip.height + getRowHeight())
- return descent;
-
- TreePath path = new TreePath(getPathToRoot(curr, 0));
- int halfHeight = getRowHeight() / 2;
- int halfWidth = rightChildIndent / 2;
- int y0 = descent + halfHeight;
- int heightOfLine = descent + halfHeight;
- int row = getRowForPath(tree, path);
- boolean isRootVisible = tree.isRootVisible();
- boolean isExpanded = tree.isExpanded(path);
- boolean isLeaf = mod.isLeaf(curr);
- Rectangle bounds = getPathBounds(tree, path);
- Object root = mod.getRoot();
-
- if (isLeaf)
- {
- paintRow(g, clip, null, bounds, path, row, true, false, true);
- descent += getRowHeight();
- }
- else
- {
- if (depth > 0 || isRootVisible)
- {
- paintRow(g, clip, null, bounds, path, row, isExpanded, false, false);
- descent += getRowHeight();
- y0 += halfHeight;
- }
-
- if (isExpanded)
- {
- int max = mod.getChildCount(curr);
- for (int i = 0; i < max; i++)
- {
- Object child = mod.getChild(curr, i);
- boolean childVis = tree.isVisible(new TreePath
- (getPathToRoot(child, 0)));
- int indent = indentation + rightChildIndent;
- if (!isRootVisible && depth == 0)
- indent = 0;
- else if (isRootVisible ||
- (!isRootVisible && !curr.equals(root)) && childVis)
- {
- g.setColor(getHashColor());
- heightOfLine = descent + halfHeight;
- paintHorizontalLine(g, (JComponent) tree, heightOfLine,
- indentation + halfWidth, indentation + rightChildIndent);
- }
-
- descent = paintRecursive(g, indent, descent, depth + 1,
- tree, mod, child);
- }
- }
- }
-
- if (isExpanded)
- if (y0 != heightOfLine
- && (mod.getChildCount(curr) > 0 &&
- tree.isVisible(new TreePath(getPathToRoot(mod.getChild
- (curr, 0), 0)))))
- {
- g.setColor(getHashColor());
- paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, y0,
- 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 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 node
- * is the current object to draw
- * @return int current descent of the tree
- */
- int paintControlIcons(Graphics g, int indentation, int descent,
- int depth, JTree tree, TreeModel mod,
- Object node)
- {
- int rowHeight = getRowHeight();
- TreePath path = new TreePath(getPathToRoot(node, 0));
- Icon icon = getCurrentControlIcon(path);
-
- Rectangle clip = tree.getVisibleRect();
- if (indentation > clip.x + clip.width + rightChildIndent
- || descent > clip.y + clip.height + getRowHeight())
- return descent;
-
- if (mod.isLeaf(node))
- descent += rowHeight;
- else
- {
- if (!node.equals(mod.getRoot()) &&
- (tree.isRootVisible() || getLevel(node) != 1))
- {
- int width = icon.getIconWidth();
- int height = icon.getIconHeight() + 2;
- int posX = indentation - rightChildIndent;
- int posY = descent;
- if (width > rightChildIndent)
- posX -= gap;
- else posX += width/2;
-
- if (height < rowHeight)
- posY += height/2;
-
- icon.paintIcon(tree, g, posX, posY);
- }
-
- if (depth > 0 || tree.isRootVisible())
- descent += rowHeight;
-
- if (tree.isExpanded(path))
- {
- int max = 0;
- if (!mod.isLeaf(node))
- max = mod.getChildCount(node);
-
- for (int i = 0; i < max; i++)
- {
- int indent = indentation + rightChildIndent;
- Object child = mod.getChild(node, i);
- if (depth == 0 && !tree.isRootVisible())
- indent = 1;
- if (tree.isVisible(new TreePath(getPathToRoot(child, 0))))
- descent = paintControlIcons(g, indent, descent, depth + 1,
- tree, mod, child);
- }
- }
- }
-
- return descent;
- }
-
- /**
* Returns true if the LookAndFeel implements the control icons. Package
* private for use in inner classes.
*
@@ -3376,7 +3175,6 @@ public class BasicTreeUI extends TreeUI
*/
Object getPreviousVisibleNode(Object node)
{
- updateCurrentVisiblePath();
if (currentVisiblePath != null)
{
Object[] nodes = currentVisiblePath.getPath();
@@ -3568,16 +3366,22 @@ public class BasicTreeUI extends TreeUI
int getLevel(Object node)
{
int count = -1;
-
+
Object current = node;
- do
+ if (treeModel != null)
{
- current = getParent(treeModel.getRoot(), current);
- count++;
+ Object root = treeModel.getRoot();
+ if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root)))
+ count--;
+
+ do
+ {
+ current = getParent(root, current);
+ count++;
+ }
+ while (current != null);
}
- while (current != null);
-
return count;
}
@@ -3598,6 +3402,8 @@ public class BasicTreeUI extends TreeUI
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top,
int bottom)
{
+ // FIXME: Check if drawing a dashed line or not.
+ g.setColor(getHashColor());
g.drawLine(x, top, x, bottom);
}
@@ -3618,6 +3424,8 @@ public class BasicTreeUI extends TreeUI
protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left,
int right)
{
+ // FIXME: Check if drawing a dashed line or not.
+ g.setColor(getHashColor());
g.drawLine(left, y, right, y);
}
@@ -3633,14 +3441,19 @@ public class BasicTreeUI extends TreeUI
* @param x
* is the center position in x-direction
* @param y
- * is the center position in y-direction FIXME what to do if x <
- * (icon.width / 2). Same with y
+ * is the center position in y-direction
*/
protected void drawCentered(Component c, Graphics g, Icon icon, int x, int y)
{
- int beginPositionX = x - icon.getIconWidth() / 2;
- int beginPositionY = y - icon.getIconHeight() / 2;
- icon.paintIcon(c, g, beginPositionX, beginPositionY);
+ x -= icon.getIconWidth() / 2;
+ y -= icon.getIconHeight() / 2;
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
+ icon.paintIcon(c, g, x, y);
}
/**
@@ -3653,6 +3466,7 @@ public class BasicTreeUI extends TreeUI
*/
protected void drawDashedHorizontalLine(Graphics g, int y, int x1, int x2)
{
+ g.setColor(getHashColor());
for (int i = x1; i < x2; i += 2)
g.drawLine(i, y, i + 1, y);
}
@@ -3667,6 +3481,7 @@ public class BasicTreeUI extends TreeUI
*/
protected void drawDashedVerticalLine(Graphics g, int x, int y1, int y2)
{
+ g.setColor(getHashColor());
for (int i = y1; i < y2; i += 2)
g.drawLine(x, i, x, i + 1);
}
@@ -3691,8 +3506,15 @@ public class BasicTreeUI extends TreeUI
boolean isExpanded, boolean hasBeenExpanded,
boolean isLeaf)
{
- if (treeModel != null && hasControlIcons())
- paintControlIcons(g, 0, 0, 0, tree, treeModel, path.getLastPathComponent());
+ if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf))
+ {
+ Icon icon = getCurrentControlIcon(path);
+ int iconW = icon.getIconWidth();
+ int x = bounds.x - rightChildIndent + iconW/2;
+ if (x + iconW > bounds.x)
+ x = bounds.x - rightChildIndent - gap;
+ icon.paintIcon(tree, g, x, bounds.y + bounds.height/2 - icon.getIconHeight()/2);
+ }
}
/**
@@ -3703,9 +3525,9 @@ public class BasicTreeUI extends TreeUI
* @param g - the graphics configuration
* @param clipBounds -
* @param insets -
- * @param bounds - bounds of expand control
- * @param path - path to draw control for
- * @param row - row to draw control for
+ * @param bounds - bounds of the cell
+ * @param path - path to draw leg for
+ * @param row - row to start drawing at
* @param isExpanded - is the row expanded
* @param hasBeenExpanded - has the row already been expanded
* @param isLeaf - is the path a leaf
@@ -3716,7 +3538,9 @@ public class BasicTreeUI extends TreeUI
boolean isExpanded, boolean hasBeenExpanded,
boolean isLeaf)
{
- // FIXME: not implemented
+ if (row != 0)
+ paintHorizontalLine(g, tree, bounds.y + bounds.height/2, bounds.x - gap - 2,
+ bounds.x);
}
/**
@@ -3731,7 +3555,24 @@ public class BasicTreeUI extends TreeUI
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds,
Insets insets, TreePath path)
{
- // FIXME: not implemented
+ int max = tree.getVisibleRowCount();
+ for (int i = 0; i < max; i++)
+ {
+ Object curr = path.getPathComponent(i);
+ TreePath currPath = new TreePath(getPathToRoot(curr, 0));
+ int numChild = treeModel.getChildCount(curr);
+ if (numChild > 0 && tree.isExpanded(currPath))
+ {
+ Rectangle bounds = getPathBounds(tree, currPath);
+ Rectangle lastChildBounds = getPathBounds(tree,
+ new TreePath(getPathToRoot(
+ treeModel.getChild(curr, numChild - 1),
+ 0)));
+ paintVerticalLine(g, tree, bounds.x + gap + 2, bounds.y +
+ bounds.height - 2, lastChildBounds.y +
+ lastChildBounds.height/2);
+ }
+ }
}
/**
@@ -3762,7 +3603,12 @@ public class BasicTreeUI extends TreeUI
{
if (!validCachedPreferredSize)
updateCachedPreferredSize();
- bounds.x += gap;
+
+
+ paintExpandControl(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf);
+
+ if (row != 0)
+ bounds.x += gap;
bounds.width = preferredSize.width + bounds.x;
if (editingComponent != null && editingPath != null && isEditing(tree)
@@ -3808,10 +3654,7 @@ public class BasicTreeUI extends TreeUI
boolean isLeaf)
{
Object node = path.getLastPathComponent();
- if (treeModel != null && (!isLeaf && !node.equals(treeModel.getRoot())) &&
- (tree.isRootVisible() || getLevel(node) != 1))
- return true;
- return false;
+ return (!isLeaf && getLevel(node) != 0 && hasControlIcons());
}
/**
@@ -3824,24 +3667,28 @@ public class BasicTreeUI extends TreeUI
return;
Object next = treeModel.getRoot();
- Rectangle bounds = getCellBounds(0, 0, next);
- boolean rootVisible = isRootVisible();
+ TreePath rootPath = new TreePath(next);
+ Rectangle bounds = getPathBounds(tree, rootPath);
// If root is not a valid size to be visible, or is
// not visible and the tree is expanded, then the next node acts
// as the root
- if ((bounds.width == 0 && bounds.height == 0) || (!rootVisible
+ if ((bounds.width == 0 && bounds.height == 0) || (!isRootVisible()
&& tree.isExpanded(new TreePath(next))))
+ {
next = getNextNode(next);
+ rootPath = new TreePath(next);
+ }
Object root = next;
TreePath current = null;
while (next != null)
{
if (current == null)
- current = new TreePath(next);
- else
- current = current.pathByAddingChild(next);
+ current = rootPath;
+ else
+ current = current.pathByAddingChild(next);
+
do
{
TreePath path = new TreePath(getPathToRoot(next, 0));
@@ -3860,7 +3707,7 @@ public class BasicTreeUI extends TreeUI
{
next = getNextSibling(parent);
if (next == null)
- parent = getParent(treeModel.getRoot(), next);
+ parent = getParent(root, parent);
}
}
}
@@ -3870,9 +3717,7 @@ public class BasicTreeUI extends TreeUI
}
currentVisiblePath = current;
- if (currentVisiblePath != null)
- tree.setVisibleRowCount(currentVisiblePath.getPathCount());
- else tree.setVisibleRowCount(0);
+ tree.setVisibleRowCount(getRowCount(tree));
if (tree.getSelectionModel() != null && tree.getSelectionCount() == 0 &&
currentVisiblePath != null)
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java b/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
index 4fa3b364056..28143d51ecd 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalBorders.java
@@ -56,7 +56,6 @@ import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
@@ -131,6 +130,82 @@ public class MetalBorders
public void paintBorder(Component c, Graphics g, int x, int y, int w,
int h)
{
+ // With the OceanTheme the button border is painted entirely different.
+ // However, I couldn't figure out how this is determined besides checking
+ // for instanceof OceanTheme. The button painting is definitely not
+ // influenced by a UI default property and it is definitely performed
+ // by the same Border class.
+ if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme)
+ paintOceanButtonBorder(c, g, x, y, w, h);
+ else
+ {
+ ButtonModel bmodel = null;
+
+ if (c instanceof AbstractButton)
+ bmodel = ((AbstractButton) c).getModel();
+
+ Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
+ Color shadow = MetalLookAndFeel.getControlShadow();
+ Color light = MetalLookAndFeel.getControlHighlight();
+ Color middle = MetalLookAndFeel.getControl();
+
+ if (c.isEnabled())
+ {
+ // draw dark border
+ g.setColor(darkShadow);
+ g.drawRect(x, y, w - 2, h - 2);
+
+ if (!bmodel.isPressed())
+ {
+ // draw light border
+ g.setColor(light);
+ g.drawRect(x + 1, y + 1, w - 2, h - 2);
+
+ // draw crossing pixels of both borders
+ g.setColor(middle);
+ g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
+ }
+ else
+ {
+ // draw light border
+ g.setColor(light);
+ g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
+ g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
+
+ // draw shadow border
+ g.setColor(middle);
+ g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
+
+ // draw crossing pixels of both borders
+ g.setColor(shadow);
+ g.drawRect(x + 1, y + h - 2, 0, 0);
+ g.drawRect(x + w - 2, y + 1, 0, 0);
+ }
+ }
+ else
+ {
+ // draw disabled border
+ g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
+ g.drawRect(x, y, w - 2, h - 2);
+ }
+ }
+ }
+
+ /**
+ * Paints the button border for the OceanTheme.
+ *
+ * @param c the button
+ * @param g the graphics context
+ * @param x the X coordinate of the upper left corner of the painting rect
+ * @param y the Y coordinate of the upper left corner of the painting rect
+ * @param w the width of the painting rect
+ * @param h the height of the painting rect
+ */
+ private void paintOceanButtonBorder(Component c, Graphics g, int x,
+ int y, int w, int h)
+ {
ButtonModel bmodel = null;
if (c instanceof AbstractButton)
@@ -138,44 +213,31 @@ public class MetalBorders
Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
Color shadow = MetalLookAndFeel.getControlShadow();
- Color light = MetalLookAndFeel.getWhite();
+ Color light = MetalLookAndFeel.getControlHighlight();
Color middle = MetalLookAndFeel.getControl();
if (c.isEnabled())
- {
- // draw dark border
- g.setColor(darkShadow);
- g.drawRect(x, y, w - 2, h - 2);
-
- if (!bmodel.isPressed())
- {
- // draw light border
- g.setColor(light);
- g.drawRect(x + 1, y + 1, w - 2, h - 2);
-
- // draw crossing pixels of both borders
- g.setColor(middle);
- g.drawRect(x + 1, y + h - 2, 0, 0);
- g.drawRect(x + w - 2, y + 1, 0, 0);
- }
- else
- {
- // draw light border
- g.setColor(light);
- g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
- g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
-
- // draw shadow border
- g.setColor(middle);
- g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
- g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
-
- // draw crossing pixels of both borders
- g.setColor(shadow);
- g.drawRect(x + 1, y + h - 2, 0, 0);
- g.drawRect(x + w - 2, y + 1, 0, 0);
- }
- }
+ {
+ if (bmodel.isPressed())
+ {
+ // draw fat border
+ g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
+ g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
+ }
+ else if (bmodel.isRollover())
+ {
+ g.setColor(shadow);
+ g.drawRect(x, y, w - 1, h - 1);
+ g.drawRect(x + 2, y + 2, w - 5, h - 5);
+ g.setColor(darkShadow);
+ g.drawRect(x + 1, y + 1, w - 3, h - 3);
+ }
+ else
+ {
+ g.setColor(darkShadow);
+ g.drawRect(x, y, w - 1, h - 1);
+ }
+ }
else
{
// draw disabled border
@@ -654,24 +716,23 @@ public class MetalBorders
{
JOptionPane pane = (JOptionPane) f.getContentPane();
int type = pane.getMessageType();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
if (type == JOptionPane.QUESTION_MESSAGE)
{
- Color bc = defaults.getColor(
+ Color bc = UIManager.getColor(
"OptionPane.questionDialog.border.background");
if (bc != null)
g.setColor(bc);
}
if (type == JOptionPane.WARNING_MESSAGE)
{
- Color bc = defaults.getColor(
+ Color bc = UIManager.getColor(
"OptionPane.warningDialog.border.background");
if (bc != null)
g.setColor(bc);
}
else if (type == JOptionPane.ERROR_MESSAGE)
{
- Color bc = defaults.getColor(
+ Color bc = UIManager.getColor(
"OptionPane.errorDialog.border.background");
if (bc != null)
g.setColor(bc);
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
index 02c39c1499e..10e51117329 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalButtonUI.java
@@ -47,7 +47,7 @@ import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JComponent;
-import javax.swing.UIDefaults;
+import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
@@ -78,10 +78,9 @@ public class MetalButtonUI
public MetalButtonUI()
{
super();
- UIDefaults def = UIManager.getLookAndFeelDefaults();
- focusColor = def.getColor(getPropertyPrefix() + "focus");
- selectColor = def.getColor(getPropertyPrefix() + "select");
- disabledTextColor = def.getColor(getPropertyPrefix() + "disabledText");
+ focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+ selectColor = UIManager.getColor(getPropertyPrefix() + "select");
+ disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
}
/**
@@ -135,11 +134,8 @@ public class MetalButtonUI
public void installDefaults(AbstractButton button)
{
super.installDefaults(button);
- if (button.isRolloverEnabled())
- {
- if (button.getBorder() instanceof UIResource)
- button.setBorder(MetalBorders.getRolloverBorder());
- }
+ button.setRolloverEnabled(UIManager.getBoolean(
+ getPropertyPrefix() + "rollover"));
}
/**
@@ -148,8 +144,7 @@ public class MetalButtonUI
public void uninstallDefaults(AbstractButton button)
{
super.uninstallDefaults(button);
- if (button.getBorder() instanceof UIResource)
- button.setBorder(null);
+ button.setRolloverEnabled(false);
}
/**
@@ -230,4 +225,24 @@ public class MetalButtonUI
g.drawString(text, textRect.x, textRect.y + fm.getAscent());
}
}
+
+ /**
+ * If the property <code>Button.gradient</code> is set, then a gradient is
+ * painted as background, otherwise the normal superclass behaviour is
+ * called.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+ if (b.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null
+ && !b.getModel().isPressed() && b.isEnabled())
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL,
+ getPropertyPrefix() + "gradient");
+ paint(g, c);
+ }
+ else
+ super.update(g, c);
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java b/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java
index 6b9f31b85b6..fb8280e44da 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalCheckBoxIcon.java
@@ -44,6 +44,8 @@ import java.io.Serializable;
import javax.swing.Icon;
import javax.swing.JCheckBox;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
/**
@@ -128,6 +130,9 @@ public class MetalCheckBoxIcon
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ if (UIManager.get("CheckBox.gradient") != null)
+ MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
+ SwingConstants.VERTICAL, "CheckBox.gradient");
border.paintBorder(c, g, x, y, getIconWidth(), getIconHeight());
JCheckBox cb = (JCheckBox) c;
if (cb.isSelected())
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
index 6f4feccfc37..bcb86e61047 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalIconFactory.java
@@ -52,6 +52,8 @@ import javax.swing.JInternalFrame;
import javax.swing.JRadioButton;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSlider;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
@@ -779,6 +781,10 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ if (UIManager.get("RadioButton.gradient") != null)
+ MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
+ SwingConstants.VERTICAL, "RadioButton.gradient");
+
Color savedColor = g.getColor();
JRadioButton b = (JRadioButton) c;
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java b/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
index 33eb3491ad0..2cf5f67d55d 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
@@ -55,7 +55,6 @@ import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
@@ -260,9 +259,8 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
notSelectedTextColor = MetalLookAndFeel.getInactiveControlTextColor();
notSelectedTitleColor = MetalLookAndFeel.getWindowTitleInactiveBackground();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- paletteTitleHeight = defaults.getInt("InternalFrame.paletteTitleHeight");
- paletteCloseIcon = defaults.getIcon("InternalFrame.paletteCloseIcon");
+ paletteTitleHeight = UIManager.getInt("InternalFrame.paletteTitleHeight");
+ paletteCloseIcon = UIManager.getIcon("InternalFrame.paletteCloseIcon");
minIcon = MetalIconFactory.getInternalFrameAltMaximizeIcon(16);
title = new JLabel(frame.getTitle(),
@@ -351,8 +349,14 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
{
Color savedColor = g.getColor();
Rectangle b = SwingUtilities.getLocalBounds(this);
- g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
- g.fillRect(b.x, b.y, b.width, b.height);
+
+ if (UIManager.get("InternalFrame.activeTitleGradient") != null
+ && frame.isSelected())
+ {
+ MetalUtils.paintGradient(g, b.x, b.y, b.width, b.height,
+ SwingConstants.VERTICAL,
+ "InternalFrame.activeTitleGradient");
+ }
MetalUtils.fillMetalPattern(this, g, b.x + 4, b.y + 2, b.width
- paletteCloseIcon.getIconWidth() - 13, b.height - 5,
MetalLookAndFeel.getPrimaryControlHighlight(),
@@ -393,6 +397,14 @@ public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
// draw the metal pattern
+ if (UIManager.get("InternalFrame.activeTitleGradient") != null
+ && frame.isSelected())
+ {
+ MetalUtils.paintGradient(g, 0, 0, getWidth(), getHeight(),
+ SwingConstants.VERTICAL,
+ "InternalFrame.activeTitleGradient");
+ }
+
Rectangle b = title.getBounds();
int startX = b.x + b.width + 5;
int endX = startX;
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java
index e4eaa71724d..12b858e0a93 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalLabelUI.java
@@ -43,7 +43,6 @@ import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JLabel;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicGraphicsUtils;
@@ -83,22 +82,20 @@ public class MetalLabelUI
/**
* Draws the text for a disabled label, using the color defined in the
- * {@link UIDefaults} with the key <code>Label.disabledForeground</code>.
+ * {@link UIManager} defaults with the key
+ * <code>Label.disabledForeground</code>.
*
* @param l the label.
* @param g the graphics device.
* @param s the label text.
* @param textX the x-coordinate for the label.
* @param textY the y-coordinate for the label.
- *
- * @see UIManager#getLookAndFeelDefaults()
*/
protected void paintDisabledText(JLabel l, Graphics g, String s, int textX,
int textY)
{
Color savedColor = g.getColor();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- g.setColor(defaults.getColor("Label.disabledForeground"));
+ g.setColor(UIManager.getColor("Label.disabledForeground"));
int mnemIndex = l.getDisplayedMnemonicIndex();
if (mnemIndex != -1)
BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
index ec8014b17b3..da019379bf5 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -693,6 +693,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"DesktopIconUI", "javax.swing.plaf.metal.MetalDesktopIconUI",
"InternalFrameUI", "javax.swing.plaf.metal.MetalInternalFrameUI",
"LabelUI", "javax.swing.plaf.metal.MetalLabelUI",
+ "MenuBarUI", "javax.swing.plaf.metal.MetalMenuBarUI",
"PopupMenuSeparatorUI",
"javax.swing.plaf.metal.MetalPopupMenuSeparatorUI",
"ProgressBarUI", "javax.swing.plaf.metal.MetalProgressBarUI",
@@ -1162,7 +1163,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Tree.line", getPrimaryControl(),
"Tree.openIcon", MetalIconFactory.getTreeFolderIcon(),
"Tree.rightChildIndent", new Integer(13),
- "Tree.rowHeight", new Integer(20),
+ "Tree.rowHeight", new Integer(0),
"Tree.scrollsOnExpand", Boolean.TRUE,
"Tree.selectionBackground", getTextHighlightColor(),
"Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(new Color(102, 102, 153)),
@@ -1201,4 +1202,13 @@ public class MetalLookAndFeel extends BasicLookAndFeel
defaults.putDefaults(uiDefaults);
}
+ /**
+ * Returns the current theme setting for the Metal L&amp;F.
+ *
+ * @return the current theme setting for the Metal L&amp;F
+ */
+ public static MetalTheme getCurrentTheme()
+ {
+ return theme;
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
new file mode 100644
index 00000000000..31d8d671fa1
--- /dev/null
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalMenuBarUI.java
@@ -0,0 +1,88 @@
+/* MetalMenuBarUI.java -- MenuBar UI for 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.Graphics;
+
+import javax.swing.JComponent;
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicMenuBarUI;
+
+/**
+ * A UI implementation for MenuBar in the Metal Look &amp; Feel.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ *
+ * @since 1.5
+ */
+public class MetalMenuBarUI extends BasicMenuBarUI
+{
+ /**
+ * Creates and returns a new instance of this UI for the specified component.
+ *
+ * @param c the component to create a UI for
+ *
+ * @return the UI for the component
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new MetalMenuBarUI();
+ }
+
+
+ /**
+ * If the property <code>MenuBar.gradient</code> is set, then a gradient
+ * is painted as background, otherwise the normal superclass behaviour is
+ * called.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ if (c.isOpaque() && UIManager.get("MenuBar.gradient") != null)
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL, "MenuBar.gradient");
+ paint(g, c);
+ }
+ else
+ super.update(g, c);
+ }
+
+}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
index f37626e630f..de71fe8e5b2 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java
@@ -46,7 +46,6 @@ import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JRadioButton;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicRadioButtonUI;
@@ -96,10 +95,9 @@ public class MetalRadioButtonUI
public void installDefaults(AbstractButton b)
{
super.installDefaults(b);
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- disabledTextColor = defaults.getColor("RadioButton.disabledText");
- focusColor = defaults.getColor("RadioButton.focus");
- selectColor = defaults.getColor("RadioButton.select");
+ disabledTextColor = UIManager.getColor("RadioButton.disabledText");
+ focusColor = UIManager.getColor("RadioButton.focus");
+ selectColor = UIManager.getColor("RadioButton.select");
}
/**
@@ -118,7 +116,7 @@ public class MetalRadioButtonUI
/**
* Returns the color used to fill the {@link JRadioButton}'s icon when the
* button is pressed. The default color is obtained from the
- * {@link UIDefaults} via an entry with the key
+ * {@link UIManager} defaults via an entry with the key
* <code>RadioButton.select</code>.
*
* @return The select color.
@@ -130,8 +128,8 @@ public class MetalRadioButtonUI
/**
* Returns the color for the {@link JRadioButton}'s text when the button is
- * disabled. The default color is obtained from the {@link UIDefaults} via
- * an entry with the key <code>RadioButton.disabledText</code>.
+ * disabled. The default color is obtained from the {@link UIManager}
+ * defaults via an entry with the key <code>RadioButton.disabledText</code>.
*
* @return The disabled text color.
*/
@@ -143,7 +141,7 @@ public class MetalRadioButtonUI
/**
* Returns the color used to draw the focus rectangle when the
* {@link JRadioButton} has the focus. The default color is obtained from
- * the {@link UIDefaults} via an entry with the key
+ * the {@link UIManager} defaults via an entry with the key
* <code>RadioButton.focus</code>.
*
* @return The color used to draw the focus rectangle.
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
index 9602ade9947..0ff501f89a9 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalScrollBarUI.java
@@ -48,7 +48,6 @@ import java.beans.PropertyChangeListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicScrollBarUI;
@@ -195,8 +194,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
*/
protected JButton createDecreaseButton(int orientation)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- scrollBarWidth = defaults.getInt("ScrollBar.width");
+ scrollBarWidth = UIManager.getInt("ScrollBar.width");
decreaseButton = new MetalScrollButton(orientation, scrollBarWidth,
isFreeStanding);
return decreaseButton;
@@ -213,8 +211,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
*/
protected JButton createIncreaseButton(int orientation)
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- scrollBarWidth = defaults.getInt("ScrollBar.width");
+ scrollBarWidth = UIManager.getInt("ScrollBar.width");
increaseButton = new MetalScrollButton(orientation, scrollBarWidth,
isFreeStanding);
return increaseButton;
@@ -403,8 +400,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
}
// draw the shadow line
- UIDefaults def = UIManager.getLookAndFeelDefaults();
- g.setColor(def.getColor("ScrollBar.shadow"));
+ g.setColor(UIManager.getColor("ScrollBar.shadow"));
g.drawLine(x + w, y + 1, x + w, y + h - 1);
}
@@ -456,8 +452,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
}
// draw the shadow line
- UIDefaults def = UIManager.getLookAndFeelDefaults();
- g.setColor(def.getColor("ScrollBar.shadow"));
+ g.setColor(UIManager.getColor("ScrollBar.shadow"));
g.drawLine(x + 1, y + h, x + w - 2, y + h);
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java
index b39fb23366e..dbcc0910d46 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalSplitPaneUI.java
@@ -42,7 +42,6 @@ import java.awt.Color;
import javax.swing.JComponent;
import javax.swing.JSplitPane;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSplitPaneDivider;
@@ -83,9 +82,8 @@ public class MetalSplitPaneUI extends BasicSplitPaneUI
*/
public BasicSplitPaneDivider createDefaultDivider()
{
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- Color light = defaults.getColor("SplitPane.highlight");
- Color dark = defaults.getColor("SplitPane.darkShadow");
+ Color light = UIManager.getColor("SplitPane.highlight");
+ Color dark = UIManager.getColor("SplitPane.darkShadow");
return new MetalSplitPaneDivider(this, light, dark);
}
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
index 46a19bdbe9e..0b56d591442 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
@@ -47,8 +47,8 @@ import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JToggleButton;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonUI;
@@ -131,10 +131,9 @@ public class MetalToggleButtonUI
public void installDefaults(AbstractButton b)
{
super.installDefaults(b);
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- focusColor = defaults.getColor(getPropertyPrefix() + "focus");
- selectColor = defaults.getColor(getPropertyPrefix() + "select");
- disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");
+ focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+ selectColor = UIManager.getColor(getPropertyPrefix() + "select");
+ disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
}
/**
@@ -200,5 +199,23 @@ public class MetalToggleButtonUI
g.drawRect(fr.x - 1, fr.y - 1, fr.width + 1, fr.height + 1);
g.setColor(saved);
}
+
+ /**
+ * If the property <code>ToggleButton.gradient</code> is set, then a gradient
+ * is painted as background, otherwise the normal superclass behaviour is
+ * called.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ if (c.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null)
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL,
+ getPropertyPrefix() + "gradient");
+ paint(g, c);
+ }
+ else
+ super.update(g, c);
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
index 5085d170ac2..f183ed5a149 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalToolTipUI.java
@@ -56,7 +56,6 @@ import javax.swing.JToolTip;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
@@ -107,13 +106,12 @@ public class MetalToolTipUI
public MetalToolTipUI()
{
super();
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- activeBorder = defaults.getBorder("ToolTip.border");
- inactiveBorder = defaults.getBorder("ToolTip.borderInactive");
- isAcceleratorHidden = defaults.getBoolean("ToolTip.hideAccelerator");
- acceleratorFont = defaults.getFont("MenuItem.acceleratorFont");
- acceleratorForeground = defaults.getColor("MenuItem.acceleratorForeground");
- acceleratorDelimiter = defaults.getString("MenuItem.acceleratorDelimiter");
+ activeBorder = UIManager.getBorder("ToolTip.border");
+ inactiveBorder = UIManager.getBorder("ToolTip.borderInactive");
+ isAcceleratorHidden = UIManager.getBoolean("ToolTip.hideAccelerator");
+ acceleratorFont = UIManager.getFont("MenuItem.acceleratorFont");
+ acceleratorForeground = UIManager.getColor("MenuItem.acceleratorForeground");
+ acceleratorDelimiter = UIManager.getString("MenuItem.acceleratorDelimiter");
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java
index 0ffa0d17470..24432a2b5f6 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalTreeUI.java
@@ -41,24 +41,10 @@ package javax.swing.plaf.metal;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
-import java.awt.event.ComponentListener;
-import java.awt.event.FocusListener;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseListener;
-import java.beans.PropertyChangeListener;
-import java.util.Hashtable;
import javax.swing.JComponent;
import javax.swing.JTree;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
-import javax.swing.tree.TreeCellEditor;
-import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
-import javax.swing.event.CellEditorListener;
-import javax.swing.event.TreeExpansionListener;
-import javax.swing.event.TreeModelListener;
-import javax.swing.event.TreeSelectionListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTreeUI;
@@ -67,19 +53,6 @@ import javax.swing.plaf.basic.BasicTreeUI;
*/
public class MetalTreeUI extends BasicTreeUI
{
-
- /** Listeners */
- private PropertyChangeListener propertyChangeListener;
- private FocusListener focusListener;
- private TreeSelectionListener treeSelectionListener;
- private MouseListener mouseListener;
- private KeyListener keyListener;
- private PropertyChangeListener selectionModelPropertyChangeListener;
- private ComponentListener componentListener;
- private CellEditorListener cellEditorListener;
- private TreeExpansionListener treeExpansionListener;
- private TreeModelListener treeModelListener;
-
/**
* Constructs a new instance of <code>MetalTreeUI</code>.
*/
@@ -128,71 +101,8 @@ public class MetalTreeUI extends BasicTreeUI
*/
public void installUI(JComponent c)
{
- tree = (JTree) c;
- configureLayoutCache();
-
- 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);
- tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand"));
- rightChildIndent = defaults.getInt("Tree.rightChildIndent");
- leftChildIndent = defaults.getInt("Tree.leftChildIndent");
- setRowHeight(defaults.getInt("Tree.rowHeight"));
- tree.setRowHeight(defaults.getInt("Tree.rowHeight"));
- tree.requestFocusInWindow(false);
-
- setExpandedIcon(defaults.getIcon("Tree.expandedIcon"));
- setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon"));
-
- currentCellRenderer = createDefaultCellRenderer();
- rendererPane = createCellRendererPane();
- createdRenderer = true;
- setCellEditor(createDefaultCellEditor());
- createdCellEditor = true;
- TreeModel mod = tree.getModel();
- setModel(mod);
-
- treeSelectionModel = tree.getSelectionModel();
- drawingCache = new Hashtable();
- nodeDimensions = createNodeDimensions();
-
- propertyChangeListener = createPropertyChangeListener();
- focusListener = createFocusListener();
- treeSelectionListener = createTreeSelectionListener();
- mouseListener = createMouseListener();
- keyListener = createKeyListener();
- selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();
- componentListener = createComponentListener();
- cellEditorListener = createCellEditorListener();
- treeExpansionListener = createTreeExpansionListener();
- treeModelListener = createTreeModelListener();
-
- editingRow = -1;
- lastSelectedRow = -1;
-
- installKeyboardActions();
-
- tree.addPropertyChangeListener(propertyChangeListener);
- tree.addFocusListener(focusListener);
- tree.addTreeSelectionListener(treeSelectionListener);
- tree.addMouseListener(mouseListener);
- tree.addKeyListener(keyListener);
- tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
- tree.addComponentListener(componentListener);
- tree.addTreeExpansionListener(treeExpansionListener);
- if (treeModel != null)
- treeModel.addTreeModelListener(treeModelListener);
-
- if (mod != null)
- {
- TreePath path = new TreePath(mod.getRoot());
- if (!tree.isExpanded(path))
- toggleExpandState(path);
- }
-
- completeUIInstall();
+ // TODO: What to do here, if anything?
+ super.installUI(c);
}
/**
@@ -212,31 +122,8 @@ public class MetalTreeUI extends BasicTreeUI
*/
public void uninstallUI(JComponent c)
{
- tree.setFont(null);
- tree.setForeground(null);
- tree.setBackground(null);
-
- uninstallKeyboardActions();
-
- tree.removePropertyChangeListener(propertyChangeListener);
- tree.removeFocusListener(focusListener);
- tree.removeTreeSelectionListener(treeSelectionListener);
- tree.removeMouseListener(mouseListener);
- 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);
-
- tree = null;
- uninstallComponents();
- completeUIUninstall();
+ // TODO: What to do here?
+ super.uninstallUI(c);
}
/**
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
index c0b4e657676..50112ce2161 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalUtils.java
@@ -44,6 +44,10 @@ import java.awt.Graphics2D;
import java.awt.TexturePaint;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
+import java.util.List;
+
+import javax.swing.SwingConstants;
+import javax.swing.UIManager;
/**
* Some utility and helper methods for the Metal Look &amp; Feel.
@@ -151,4 +155,252 @@ class MetalUtils
g.fillRect(3, 3, 1, 1);
g.dispose();
}
+
+ /**
+ * Paints the typical Metal gradient. See {@link #paintGradient(Graphics,
+ * int, int, int, int, double, double, Color, Color, Color, int)}
+ * for more details.
+ *
+ * The parameters are fetched from the UIManager using the key
+ * <code>uiProp</code>. The value is expected to be a {@link List} that
+ * contains 4 values: two {@link Double}s and 3 {@link Color} object that
+ * together make up the parameters passed to the painting method.
+ *
+ * @param g the graphics context to use
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @param dir the direction of the gradient, either
+ * @param uiProp the key of the UIManager property that has the parameters
+ */
+ static void paintGradient(Graphics g, int x, int y, int w, int h,
+ int dir, String uiProp)
+ {
+ List params = (List) UIManager.get(uiProp);
+ double g1 = ((Double) params.get(0)).doubleValue();
+ double g2 = ((Double) params.get(1)).doubleValue();
+ Color c1 = (Color) params.get(2);
+ Color c2 = (Color) params.get(3);
+ Color c3 = (Color) params.get(4);
+ paintGradient(g, x, y, w, h, g1, g2, c1, c2, c3, dir);
+ }
+
+ /**
+ * Paints the typical Metal gradient. The gradient is painted as follows:
+ * <pre>
+ *
+ * +-------+--------+--------+-----------------------------+
+ * | | | | |
+ * +-------+--------+--------+-----------------------------+
+ * c1 -> c2 -- c2 -> c1 --------> c3
+ * < -g1- > < -g2- > < -g1- >
+ * </pre>
+ *
+ * There are 4 distinct areas in this gradient:
+ * <ol>
+ * <li>A gradient from color 1 to color 2 with the relative width specified
+ * by <code>g1</code></li>
+ * <li>A solid area with the color 2 and the relative width specified by
+ * <code>g2</code></li>
+ * <li>A gradient from color 2 to color 1 with the relative width specified
+ * by <code>g1</code></li>
+ *
+ * @param g the graphics context to use
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @param g1 the relative width of the c1->c2 gradients
+ * @param g2 the relative width of the c2 solid area
+ * @param c1 the color 1
+ * @param c2 the color 2
+ * @param c3 the color 3
+ * @param dir the direction of the gradient, either
+ * {@link SwingConstants#HORIZONTAL} or {@link SwingConstants#VERTICAL}
+ */
+ static void paintGradient(Graphics g, int x, int y, int w, int h, double g1,
+ double g2, Color c1, Color c2, Color c3, int dir)
+ {
+ if (dir == SwingConstants.HORIZONTAL)
+ paintHorizontalGradient(g, x, y, w, h, g1, g2, c1, c2, c3);
+ else
+ paintVerticalGradient(g, x, y, w, h, g1, g2, c1, c2, c3);
+ }
+
+ /**
+ * Paints a horizontal gradient. See {@link #paintGradient(Graphics, int,
+ * int, int, int, double, double, Color, Color, Color, int)} for details.
+ *
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @param g1 the relative width of the c1->c2 gradients
+ * @param g2 the relative width of the c2 solid area
+ * @param c1 the color 1
+ * @param c2 the color 2
+ * @param c3 the color 3
+ */
+ static void paintHorizontalGradient(Graphics g, int x, int y, int w, int h,
+ double g1, double g2, Color c1, Color c2,
+ Color c3)
+ {
+ // Calculate the coordinates.
+ // The size of the first gradient area (c1->2).
+ int w1 = (int) (w * g1);
+ // The size of the solid c2 area.
+ int w2 = (int) (w * g2);
+ int x0 = x;
+ int x1 = x0 + w1;
+ int x2 = x1 + w2;
+ int x3 = x2 + w1;
+ int x4 = x + w;
+
+ // Paint first gradient area (c1->c2).
+ int xc; // The current y coordinate.
+ for (xc = x0; xc < x1; xc++)
+ {
+ if (xc > x + w)
+ break;
+
+ // Perform color interpolation;
+ double factor = (xc - x0) / (double) w1;
+ int rInt = (int) ((c2.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c2.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c2.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ g.drawLine(xc, y, xc, y + h);
+ }
+ // Paint solid c2 area.
+ g.setColor(c2);
+ g.fillRect(x1, y, x2 - x1, h);
+
+ // Paint second gradient area (c2->c1).
+ for (xc = x2; xc < x3; xc++)
+ {
+ if (xc > x + w)
+ break;
+
+ // Perform color interpolation;
+ double factor = (xc - x2) / (double) w1;
+ int rInt = (int) ((c1.getRed() - c2.getRed()) * factor + c2.getRed());
+ int gInt = (int) ((c1.getGreen() - c2.getGreen()) * factor
+ + c2.getGreen());
+ int bInt = (int) ((c1.getBlue() - c2.getBlue()) * factor
+ + c2.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ g.drawLine(xc, y, xc, y + h);
+ }
+
+ // Paint third gradient area (c1->c3).
+ for (xc = x3; xc < x4; xc++)
+ {
+ if (xc > x + w)
+ break;
+
+ // Perform color interpolation;
+ double factor = (xc - x3) / (double) (x4 - x3);
+ int rInt = (int) ((c3.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c3.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c3.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ g.drawLine(xc, y, xc, y + h);
+ }
+ }
+
+ /**
+ * Paints a vertical gradient. See {@link #paintGradient(Graphics, int, int,
+ * int, int, double, double, Color, Color, Color, int)} for details.
+ *
+ * @param x the X coordinate of the upper left corner of the rectangle
+ * @param y the Y coordinate of the upper left corner of the rectangle
+ * @param w the width of the rectangle
+ * @param h the height of the rectangle
+ * @param g1 the relative width of the c1->c2 gradients
+ * @param g2 the relative width of the c2 solid area
+ * @param c1 the color 1
+ * @param c2 the color 2
+ * @param c3 the color 3
+ */
+ static void paintVerticalGradient(Graphics g, int x, int y, int w, int h,
+ double g1, double g2, Color c1, Color c2,
+ Color c3)
+ {
+ // Calculate the coordinates.
+ // The size of the first gradient area (c1->2).
+ int w1 = (int) (h * g1);
+ // The size of the solid c2 area.
+ int w2 = (int) (h * g2);
+ int y0 = y;
+ int y1 = y0 + w1;
+ int y2 = y1 + w2;
+ int y3 = y2 + w1;
+ int y4 = y + h;
+
+ // Paint first gradient area (c1->c2).
+ int yc; // The current y coordinate.
+ for (yc = y0; yc < y1; yc++)
+ {
+ if (yc > y + h)
+ break;
+
+ // Perform color interpolation;
+ double factor = (yc - y0) / (double) w1;
+ int rInt = (int) ((c2.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c2.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c2.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ g.drawLine(x, yc, x + w, yc);
+ }
+ // Paint solid c2 area.
+ g.setColor(c2);
+ g.fillRect(x, y1, w, y2 - y1);
+
+ // Paint second gradient area (c2->c1).
+ for (yc = y2; yc < y3; yc++)
+ {
+ if (yc > y + h)
+ break;
+
+ // Perform color interpolation;
+ double factor = (yc - y2) / (double) w1;
+ int rInt = (int) ((c1.getRed() - c2.getRed()) * factor + c2.getRed());
+ int gInt = (int) ((c1.getGreen() - c2.getGreen()) * factor
+ + c2.getGreen());
+ int bInt = (int) ((c1.getBlue() - c2.getBlue()) * factor
+ + c2.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ g.drawLine(x, yc, x + w, yc);
+ }
+
+ // Paint third gradient area (c1->c3).
+ for (yc = y3; yc < y4; yc++)
+ {
+ if (yc > y + h)
+ break;
+
+ // Perform color interpolation;
+ double factor = (yc - y3) / (double) (y4 - y3);
+ int rInt = (int) ((c3.getRed() - c1.getRed()) * factor + c1.getRed());
+ int gInt = (int) ((c3.getGreen() - c1.getGreen()) * factor
+ + c1.getGreen());
+ int bInt = (int) ((c3.getBlue() - c1.getBlue()) * factor
+ + c1.getBlue());
+ Color interpolated = new Color(rInt, gInt, bInt);
+ g.setColor(interpolated);
+ g.drawLine(x, yc, x + w, yc);
+ }
+ }
}
diff --git a/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java b/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java
index 85a8cb1ff86..f1886b167cf 100644
--- a/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java
+++ b/libjava/classpath/javax/swing/plaf/metal/OceanTheme.java
@@ -37,6 +37,9 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+import java.util.Arrays;
+
import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
@@ -204,6 +207,37 @@ public class OceanTheme extends DefaultMetalTheme
*/
public void addCustomEntriesToTable(UIDefaults defaults)
{
+ defaults.put("Button.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("CheckBox.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("CheckBoxMenuItem.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("MenuBar.gradient", Arrays.asList(new Object[]
+ {new Double(1.0), new Double(0.0), new ColorUIResource(Color.WHITE),
+ new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
+ defaults.put("RadioButton.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("RadioButtonMenuItem.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("ScrollBar.gradient", Arrays.asList(new Object[]
+ {new Double(1.0), new Double(0.0), new ColorUIResource(Color.WHITE),
+ new ColorUIResource(218, 218, 218), new ColorUIResource(218, 218, 218)}));
+ defaults.put("Slider.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.2), new ColorUIResource(200, 221, 242),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("ToggleButton.gradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+ defaults.put("InternalFrame.activeTitleGradient", Arrays.asList(new Object[]
+ {new Double(0.3), new Double(0.0), new ColorUIResource(221, 232, 243),
+ new ColorUIResource(Color.WHITE), new ColorUIResource(184, 207, 229)}));
+
defaults.put("Button.rollover", Boolean.TRUE);
}
}
OpenPOWER on IntegriCloud