summaryrefslogtreecommitdiff
path: root/javax/swing/plaf
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-09-10 15:31:29 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-09-10 15:31:29 +0000
commitd5a985a529854e100f7c37d30c35a12916b97717 (patch)
tree41e28377abd8d12d36dc11e4592fdb25ce8506f7 /javax/swing/plaf
parent988ea14cc6a504c6d5c7b9bfcbc01ca2b0a4e432 (diff)
downloadclasspath-d5a985a529854e100f7c37d30c35a12916b97717.tar.gz
2005-09-10 Andrew John Hughes <gnu_andrew@member.fsf.org>
Merge of generics-branch for 2005/08/14 - 2005/09/07.
Diffstat (limited to 'javax/swing/plaf')
-rw-r--r--javax/swing/plaf/basic/BasicArrowButton.java2
-rw-r--r--javax/swing/plaf/basic/BasicButtonUI.java16
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java6
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxUI.java16
-rw-r--r--javax/swing/plaf/basic/BasicDesktopPaneUI.java2
-rw-r--r--javax/swing/plaf/basic/BasicFileChooserUI.java357
-rw-r--r--javax/swing/plaf/basic/BasicIconFactory.java66
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameTitlePane.java50
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameUI.java21
-rw-r--r--javax/swing/plaf/basic/BasicLabelUI.java13
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java22
-rw-r--r--javax/swing/plaf/basic/BasicMenuBarUI.java84
-rw-r--r--javax/swing/plaf/basic/BasicMenuItemUI.java590
-rw-r--r--javax/swing/plaf/basic/BasicMenuUI.java7
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java6
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicScrollBarUI.java26
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneUI.java3
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java112
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java56
-rw-r--r--javax/swing/plaf/basic/BasicToggleButtonUI.java2
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java1584
-rw-r--r--javax/swing/plaf/metal/MetalBorders.java227
-rw-r--r--javax/swing/plaf/metal/MetalCheckBoxUI.java20
-rw-r--r--javax/swing/plaf/metal/MetalIconFactory.java979
-rw-r--r--javax/swing/plaf/metal/MetalInternalFrameTitlePane.java171
-rw-r--r--javax/swing/plaf/metal/MetalInternalFrameUI.java11
-rw-r--r--javax/swing/plaf/metal/MetalLabelUI.java47
-rw-r--r--javax/swing/plaf/metal/MetalLookAndFeel.java41
-rw-r--r--javax/swing/plaf/metal/MetalRadioButtonUI.java127
-rw-r--r--javax/swing/plaf/metal/MetalSliderUI.java212
-rw-r--r--javax/swing/plaf/metal/MetalTabbedPaneUI.java278
-rw-r--r--javax/swing/plaf/metal/MetalTreeUI.java4
-rw-r--r--javax/swing/plaf/multi/MultiButtonUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiColorChooserUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiComboBoxUI.java427
-rw-r--r--javax/swing/plaf/multi/MultiDesktopIconUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiDesktopPaneUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiFileChooserUI.java505
-rw-r--r--javax/swing/plaf/multi/MultiInternalFrameUI.java353
-rw-r--r--javax/swing/plaf/multi/MultiLabelUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiListUI.java446
-rw-r--r--javax/swing/plaf/multi/MultiLookAndFeel.java241
-rw-r--r--javax/swing/plaf/multi/MultiMenuBarUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiMenuItemUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiOptionPaneUI.java396
-rw-r--r--javax/swing/plaf/multi/MultiPanelUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiPopupMenuUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiProgressBarUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiRootPaneUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiScrollBarUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiScrollPaneUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiSeparatorUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiSliderUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiSpinnerUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiSplitPaneUI.java488
-rw-r--r--javax/swing/plaf/multi/MultiTabbedPaneUI.java444
-rw-r--r--javax/swing/plaf/multi/MultiTableHeaderUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiTableUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiTextUI.java617
-rw-r--r--javax/swing/plaf/multi/MultiToolBarUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiToolTipUI.java352
-rw-r--r--javax/swing/plaf/multi/MultiTreeUI.java628
-rw-r--r--javax/swing/plaf/multi/MultiViewportUI.java352
-rw-r--r--javax/swing/plaf/multi/package.html46
65 files changed, 15790 insertions, 1355 deletions
diff --git a/javax/swing/plaf/basic/BasicArrowButton.java b/javax/swing/plaf/basic/BasicArrowButton.java
index 4da4691f6..836ef2234 100644
--- a/javax/swing/plaf/basic/BasicArrowButton.java
+++ b/javax/swing/plaf/basic/BasicArrowButton.java
@@ -56,7 +56,7 @@ import javax.swing.border.Border;
public class BasicArrowButton extends JButton implements SwingConstants
{
/** The default size of the Arrow buttons. */
- private static int defaultSize = 10;
+ private static int defaultSize = 12;
/** The Polygon that points up. */
private static Polygon upIcon = new Polygon(new int[] { 0, 5, 9 },
diff --git a/javax/swing/plaf/basic/BasicButtonUI.java b/javax/swing/plaf/basic/BasicButtonUI.java
index 0c069da0f..6c80f14b6 100644
--- a/javax/swing/plaf/basic/BasicButtonUI.java
+++ b/javax/swing/plaf/basic/BasicButtonUI.java
@@ -115,21 +115,21 @@ public class BasicButtonUI extends ButtonUI
*/
protected String getPropertyPrefix()
{
- return "Button";
+ return "Button.";
}
protected void installDefaults(AbstractButton b)
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
String prefix = getPropertyPrefix();
- focusColor = defaults.getColor(prefix + ".focus");
- b.setForeground(defaults.getColor(prefix + ".foreground"));
- b.setBackground(defaults.getColor(prefix + ".background"));
- b.setMargin(defaults.getInsets(prefix + ".margin"));
- b.setBorder(defaults.getBorder(prefix + ".border"));
- b.setIconTextGap(defaults.getInt(prefix + ".textIconGap"));
+ focusColor = defaults.getColor(prefix + "focus");
+ b.setForeground(defaults.getColor(prefix + "foreground"));
+ b.setBackground(defaults.getColor(prefix + "background"));
+ b.setMargin(defaults.getInsets(prefix + "margin"));
+ b.setBorder(defaults.getBorder(prefix + "border"));
+ b.setIconTextGap(defaults.getInt(prefix + "textIconGap"));
b.setInputMap(JComponent.WHEN_FOCUSED,
- (InputMap) defaults.get(prefix + ".focusInputMap"));
+ (InputMap) defaults.get(prefix + "focusInputMap"));
b.setOpaque(true);
}
diff --git a/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java b/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
index da11898bf..945aea53d 100644
--- a/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicCheckBoxMenuItemUI.java
@@ -67,13 +67,13 @@ public class BasicCheckBoxMenuItemUI extends BasicMenuItemUI
}
/**
- * DOCUMENT ME!
+ * Returns the prefix for entries in the {@link UIDefaults} table.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return "CheckBoxMenuItem"
*/
protected String getPropertyPrefix()
{
- return null;
+ return "CheckBoxMenuItem";
}
/**
diff --git a/javax/swing/plaf/basic/BasicCheckBoxUI.java b/javax/swing/plaf/basic/BasicCheckBoxUI.java
index a2085ecba..3cf02a001 100644
--- a/javax/swing/plaf/basic/BasicCheckBoxUI.java
+++ b/javax/swing/plaf/basic/BasicCheckBoxUI.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package javax.swing.plaf.basic;
-import javax.swing.AbstractButton;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.UIDefaults;
@@ -58,17 +57,14 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI
return defaults.getIcon("CheckBox.icon");
}
- public void installUI(final JComponent c) {
- super.installUI(c);
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- ((AbstractButton) c).setIcon(defaults.getIcon("CheckBox.icon"));
- ((AbstractButton) c).setSelectedIcon(defaults.getIcon("CheckBox.checkIcon"));
- }
-
- // Overridden to change method access.
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "CheckBox."
+ */
public String getPropertyPrefix()
{
- return super.getPropertyPrefix();
+ return "CheckBox.";
}
}
diff --git a/javax/swing/plaf/basic/BasicDesktopPaneUI.java b/javax/swing/plaf/basic/BasicDesktopPaneUI.java
index b15700d6f..b59261b17 100644
--- a/javax/swing/plaf/basic/BasicDesktopPaneUI.java
+++ b/javax/swing/plaf/basic/BasicDesktopPaneUI.java
@@ -363,7 +363,7 @@ public class BasicDesktopPaneUI extends DesktopPaneUI
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- desktop.setBackground(defaults.getColor("Desktop.background"));
+ desktop.setBackground(defaults.getColor("desktop"));
}
/**
diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java
index fd34fbd62..2e38c012b 100644
--- a/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -142,25 +142,26 @@ public class BasicFileChooserUI extends FileChooserUI
/**
* DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ *
+ * @param e
+ * DOCUMENT ME!
*/
public void actionPerformed(ActionEvent e)
{
- Object obj = filelist.getSelectedValue();
+ Object obj = new String(parentPath + entry.getText());
if (obj != null)
{
- File f = filechooser.getFileSystemView().createFileObject(obj
- .toString());
- if (filechooser.isTraversable(f) &&
- filechooser.getFileSelectionMode() == JFileChooser.FILES_ONLY)
+ File f = filechooser.getFileSystemView().createFileObject(
+ obj.toString());
+ if (filechooser.isTraversable(f)
+ && filechooser.isDirectorySelectionEnabled())
filechooser.setCurrentDirectory(f);
- else
- {
- filechooser.setSelectedFile(f);
- filechooser.approveSelection();
- closeDialog();
- }
+ else
+ {
+ filechooser.setSelectedFile(f);
+ filechooser.approveSelection();
+ closeDialog();
+ }
}
}
}
@@ -359,53 +360,58 @@ public class BasicFileChooserUI extends FileChooserUI
/**
* DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ *
+ * @param e
+ * DOCUMENT ME!
*/
public void mouseClicked(MouseEvent e)
{
if (list.getSelectedValue() == null)
- return;
+ return;
FileSystemView fsv = filechooser.getFileSystemView();
if (timer.isRunning()
&& list.getSelectedValue().toString().equals(lastSelected.toString()))
{
- File f = fsv.createFileObject(lastSelected.toString());
- timer.stop();
- if (filechooser.isTraversable(f))
- {
- filechooser.setCurrentDirectory(f);
- filechooser.rescanCurrentDirectory();
- }
- else
- {
- filechooser.setSelectedFile(f);
- filechooser.approveSelection();
- closeDialog();
- }
+ File f = fsv.createFileObject(lastSelected.toString());
+ timer.stop();
+ if (filechooser.isTraversable(f))
+ {
+ filechooser.setCurrentDirectory(f);
+ filechooser.rescanCurrentDirectory();
+ }
+ else
+ {
+ filechooser.setSelectedFile(f);
+ filechooser.approveSelection();
+ closeDialog();
+ }
}
else
{
- File f = fsv.createFileObject(list.getSelectedValue().toString());
- if (filechooser.isTraversable(f))
- {
- setDirectorySelected(true);
- setDirectory(f);
- }
- else
- {
- setDirectorySelected(false);
- setDirectory(null);
- }
- lastSelected = list.getSelectedValue().toString();
- timer.restart();
+ String path = list.getSelectedValue().toString();
+ File f = fsv.createFileObject(path);
+ if (filechooser.isTraversable(f))
+ {
+ setDirectorySelected(true);
+ setDirectory(f);
+ }
+ else
+ {
+ setDirectorySelected(false);
+ setDirectory(null);
+ }
+ lastSelected = path;
+ parentPath = path.substring(0, path.lastIndexOf("/") + 1);
+ entry.setText(path.substring(path.lastIndexOf("/") + 1));
+ timer.restart();
}
}
/**
* DOCUMENT ME!
- *
- * @param e DOCUMENT ME!
+ *
+ * @param e
+ * DOCUMENT ME!
*/
public void mouseEntered(MouseEvent e)
{
@@ -943,10 +949,14 @@ public class BasicFileChooserUI extends FileChooserUI
/** DOCUMENT ME! */
JPanel closePanel;
+ /** Text box that displays file name */
+ JTextField entry;
+
+ /** Current parent path */
+ String parentPath;
+
// -- end private --
- private class ListLabelRenderer
- extends JLabel
- implements ListCellRenderer
+ private class ListLabelRenderer extends JLabel implements ListCellRenderer
{
/** DOCUMENT ME! */
final Color selected = new Color(153, 204, 255);
@@ -1058,27 +1068,33 @@ public class BasicFileChooserUI extends FileChooserUI
/**
* DOCUMENT ME!
- *
- * @param c DOCUMENT ME!
+ *
+ * @param c
+ * DOCUMENT ME!
*/
public void installUI(JComponent c)
{
if (c instanceof JFileChooser)
{
- JFileChooser fc = (JFileChooser) c;
- fc.resetChoosableFileFilters();
- createModel();
- clearIconCache();
- installDefaults(fc);
- installComponents(fc);
- installListeners(fc);
+ JFileChooser fc = (JFileChooser) c;
+ fc.resetChoosableFileFilters();
+ createModel();
+ clearIconCache();
+ installDefaults(fc);
+ installComponents(fc);
+ installListeners(fc);
+
+ Object path = filechooser.getCurrentDirectory();
+ if (path != null)
+ parentPath = path.toString().substring(path.toString().lastIndexOf("/"));
}
}
/**
* DOCUMENT ME!
- *
- * @param c DOCUMENT ME!
+ *
+ * @param c
+ * DOCUMENT ME!
*/
public void uninstallUI(JComponent c)
{
@@ -1090,7 +1106,9 @@ public class BasicFileChooserUI extends FileChooserUI
}
// FIXME: Indent the entries in the combobox
- private void boxEntries()
+ // Made this method package private to access it from within inner classes
+ // with better performance
+ void boxEntries()
{
ArrayList parentFiles = new ArrayList();
File parent = filechooser.getCurrentDirectory();
@@ -1098,12 +1116,12 @@ public class BasicFileChooserUI extends FileChooserUI
parent = filechooser.getFileSystemView().getDefaultDirectory();
while (parent != null)
{
- String name = parent.getName();
- if (name.equals(""))
- name = parent.getAbsolutePath();
+ String name = parent.getName();
+ if (name.equals(""))
+ name = parent.getAbsolutePath();
- parentFiles.add(parentFiles.size(), name);
- parent = parent.getParentFile();
+ parentFiles.add(parentFiles.size(), name);
+ parent = parent.getParentFile();
}
if (parentFiles.size() == 0)
@@ -1258,7 +1276,7 @@ public class BasicFileChooserUI extends FileChooserUI
JLabel fileNameLabel = new JLabel("File Name:");
JLabel fileTypesLabel = new JLabel("Files of Type:");
- JTextField entry = new JTextField();
+ entry = new JTextField();
filters = new JComboBox();
filterEntries();
@@ -1477,113 +1495,128 @@ public class BasicFileChooserUI extends FileChooserUI
/**
* DOCUMENT ME!
- *
- * @param fc DOCUMENT ME!
- *
+ *
+ * @param fc
+ * DOCUMENT ME!
* @return DOCUMENT ME!
*/
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
{
return new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent e)
{
- public void propertyChange(PropertyChangeEvent e)
- {
- // FIXME: Multiple file selection waiting on JList multiple selection bug.
- if (e.getPropertyName().equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY))
- {
- if (filechooser.getSelectedFile() == null)
- setFileName(null);
- else
- setFileName(filechooser.getSelectedFile().toString());
- int index = -1;
- File file = filechooser.getSelectedFile();
- for (index = 0; index < model.getSize(); index++)
- if (((File) model.getElementAt(index)).equals(file))
- break;
- if (index == -1)
- return;
- filelist.setSelectedIndex(index);
- filelist.ensureIndexIsVisible(index);
- filelist.revalidate();
- filelist.repaint();
- }
- else if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY))
- {
- //boxEntries();
- filelist.clearSelection();
- filelist.revalidate();
- filelist.repaint();
- setDirectorySelected(false);
- setDirectory(filechooser.getCurrentDirectory());
- }
- else if (e.getPropertyName().equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)
- || e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
- filterEntries();
- else if (e.getPropertyName().equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)
- || e.getPropertyName().equals(JFileChooser.DIALOG_TITLE_CHANGED_PROPERTY))
- {
- Window owner = SwingUtilities.windowForComponent(filechooser);
- if (owner instanceof JDialog)
- ((JDialog) owner).setTitle(getDialogTitle(filechooser));
- accept.setText(getApproveButtonText(filechooser));
- accept.setToolTipText(getApproveButtonToolTipText(filechooser));
- accept.setMnemonic(getApproveButtonMnemonic(filechooser));
- }
- else if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY))
- accept.setText(getApproveButtonText(filechooser));
- else if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY))
- accept.setToolTipText(getApproveButtonToolTipText(filechooser));
- else if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY))
- accept.setMnemonic(getApproveButtonMnemonic(filechooser));
- else if (e.getPropertyName().equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY))
- {
- if (filechooser.getControlButtonsAreShown())
- {
- GridBagConstraints c = new GridBagConstraints();
- c.gridy = 1;
- bottomPanel.add(filters, c);
-
- c.fill = GridBagConstraints.BOTH;
- c.gridy = 2;
- c.anchor = GridBagConstraints.EAST;
- bottomPanel.add(closePanel, c);
- bottomPanel.revalidate();
- bottomPanel.repaint();
- bottomPanel.doLayout();
- }
- else
- bottomPanel.remove(closePanel);
- }
- else if (e.getPropertyName().equals(JFileChooser.ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY))
- {
- if (filechooser.isAcceptAllFileFilterUsed())
- filechooser.addChoosableFileFilter(getAcceptAllFileFilter(filechooser));
- else
- filechooser.removeChoosableFileFilter(getAcceptAllFileFilter(filechooser));
- }
- else if (e.getPropertyName().equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY))
- {
- JComponent old = (JComponent) e.getOldValue();
- if (old != null)
- getAccessoryPanel().remove(old);
- JComponent newval = (JComponent) e.getNewValue();
- if (newval != null)
- getAccessoryPanel().add(newval);
- }
- if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)
- || e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)
- || e.getPropertyName().equals(JFileChooser.FILE_HIDING_CHANGED_PROPERTY))
- rescanCurrentDirectory(filechooser);
-
- filechooser.revalidate();
- filechooser.repaint();
- }
- };
+ // FIXME: Multiple file selection waiting on JList multiple selection
+ // bug.
+ if (e.getPropertyName().equals(
+ JFileChooser.SELECTED_FILE_CHANGED_PROPERTY))
+ {
+ if (filechooser.getSelectedFile() == null)
+ setFileName(null);
+ else
+ setFileName(filechooser.getSelectedFile().toString());
+ int index = -1;
+ File file = filechooser.getSelectedFile();
+ for (index = 0; index < model.getSize(); index++)
+ if (((File) model.getElementAt(index)).equals(file))
+ break;
+ if (index == -1)
+ return;
+ filelist.setSelectedIndex(index);
+ filelist.ensureIndexIsVisible(index);
+ filelist.revalidate();
+ filelist.repaint();
+ }
+ else if (e.getPropertyName().equals(
+ JFileChooser.DIRECTORY_CHANGED_PROPERTY))
+ {
+ filelist.clearSelection();
+ filelist.revalidate();
+ filelist.repaint();
+ setDirectorySelected(false);
+ setDirectory(filechooser.getCurrentDirectory());
+ boxEntries();
+ }
+ else if (e.getPropertyName().equals(
+ JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(
+ JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
+ filterEntries();
+ else if (e.getPropertyName().equals(
+ JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(
+ JFileChooser.DIALOG_TITLE_CHANGED_PROPERTY))
+ {
+ Window owner = SwingUtilities.windowForComponent(filechooser);
+ if (owner instanceof JDialog)
+ ((JDialog) owner).setTitle(getDialogTitle(filechooser));
+ accept.setText(getApproveButtonText(filechooser));
+ accept.setToolTipText(getApproveButtonToolTipText(filechooser));
+ accept.setMnemonic(getApproveButtonMnemonic(filechooser));
+ }
+ else if (e.getPropertyName().equals(
+ JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY))
+ accept.setText(getApproveButtonText(filechooser));
+ else if (e.getPropertyName().equals(
+ JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY))
+ accept.setToolTipText(getApproveButtonToolTipText(filechooser));
+ else if (e.getPropertyName().equals(
+ JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY))
+ accept.setMnemonic(getApproveButtonMnemonic(filechooser));
+ else if (e.getPropertyName().equals(
+ JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY))
+ {
+ if (filechooser.getControlButtonsAreShown())
+ {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridy = 1;
+ bottomPanel.add(filters, c);
+
+ c.fill = GridBagConstraints.BOTH;
+ c.gridy = 2;
+ c.anchor = GridBagConstraints.EAST;
+ bottomPanel.add(closePanel, c);
+ bottomPanel.revalidate();
+ bottomPanel.repaint();
+ bottomPanel.doLayout();
+ }
+ else
+ bottomPanel.remove(closePanel);
+ }
+ else if (e.getPropertyName().equals(
+ JFileChooser.ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY))
+ {
+ if (filechooser.isAcceptAllFileFilterUsed())
+ filechooser.addChoosableFileFilter(getAcceptAllFileFilter(filechooser));
+ else
+ filechooser.removeChoosableFileFilter(getAcceptAllFileFilter(filechooser));
+ }
+ else if (e.getPropertyName().equals(
+ JFileChooser.ACCESSORY_CHANGED_PROPERTY))
+ {
+ JComponent old = (JComponent) e.getOldValue();
+ if (old != null)
+ getAccessoryPanel().remove(old);
+ JComponent newval = (JComponent) e.getNewValue();
+ if (newval != null)
+ getAccessoryPanel().add(newval);
+ }
+ if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(
+ JFileChooser.FILE_FILTER_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(
+ JFileChooser.FILE_HIDING_CHANGED_PROPERTY))
+ rescanCurrentDirectory(filechooser);
+
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+ };
}
/**
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
public String getFileName()
diff --git a/javax/swing/plaf/basic/BasicIconFactory.java b/javax/swing/plaf/basic/BasicIconFactory.java
index 8dc209c50..56a67b029 100644
--- a/javax/swing/plaf/basic/BasicIconFactory.java
+++ b/javax/swing/plaf/basic/BasicIconFactory.java
@@ -1,5 +1,5 @@
/* BasicIconFactory.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,13 +44,11 @@ import java.awt.Graphics;
import java.awt.Polygon;
import java.io.Serializable;
-import javax.swing.AbstractButton;
import javax.swing.Icon;
-import javax.swing.UIDefaults;
-import javax.swing.UIManager;
+import javax.swing.JCheckBoxMenuItem;
/**
- * STUBBED
+ * Creates icons for the {@link BasicLookAndFeel}.
*/
public class BasicIconFactory implements Serializable
{
@@ -115,6 +113,56 @@ public class BasicIconFactory implements Serializable
}
/**
+ * The icon used for {@link JCheckBoxMenuItem}s in the
+ * {@link BasicLookAndFeel}. This icon has a size of 9x9 pixels.
+ */
+ static class CheckBoxMenuItemIcon
+ implements Icon
+ {
+ /**
+ * Returns the height of the icon in pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconHeight()
+ {
+ return 9;
+ }
+
+ /**
+ * Returns the width of the icon in pixels.
+ *
+ * @return the height of the icon
+ */
+ public int getIconWidth()
+ {
+ return 9;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component to be painted
+ * @param g the Graphics context to be painted with
+ * @param x the x position of the icon
+ * @param y the y position of the icon
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
+ if (item.isSelected())
+ {
+ // paint the check...
+ g.setColor(Color.black);
+ g.drawLine(x + 1, y + 3, x + 1, y + 4);
+ g.drawLine(x + 2, y + 4, x + 2, y + 5);
+ for (int i = 0; i < 5; i++)
+ g.drawLine(x + 3 + i, y + 5 - i, x + 3 + i, y + 6 - i);
+ }
+ }
+ }
+
+ /**
* The icon used for RadioButtons in the BasicLookAndFeel. This is an empty
* icon with a size of 13x13 pixels.
*/
@@ -253,9 +301,15 @@ public class BasicIconFactory implements Serializable
return radioButtonIcon;
}
+ /**
+ * Creates and returns an icon used when rendering {@link JCheckBoxMenuItem}
+ * components.
+ *
+ * @return An icon.
+ */
public static Icon getCheckBoxMenuItemIcon()
{
- return getCheckBoxIcon();
+ return new CheckBoxMenuItemIcon();
}
public static Icon getRadioButtonMenuItemIcon()
diff --git a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 92a6ea0bf..cc262948d 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -47,7 +47,6 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
-import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -514,18 +513,6 @@ public class BasicInternalFrameTitlePane extends JComponent
/** The button that maximizes the JInternalFrame. */
protected JButton maxButton;
- /** Active background color. */
- protected Color activeBGColor;
-
- /** Active foreground color. */
- protected Color activeFGColor;
-
- /** Inactive background color. */
- protected Color inactiveBGColor;
-
- /** Inactive foreground color. */
- protected Color inactiveFGColor;
-
/** The icon displayed in the restore button. */
protected Icon minIcon = BasicIconFactory.createEmptyFrameIcon();
@@ -680,10 +667,10 @@ public class BasicInternalFrameTitlePane extends JComponent
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
setFont(defaults.getFont("InternalFrame.titleFont"));
- activeFGColor = defaults.getColor("InternalFrame.activeTitleForeground");
- activeBGColor = defaults.getColor("InternalFrame.activeTitleBackground");
- inactiveFGColor = defaults.getColor("InternalFrame.inactiveTitleForeground");
- inactiveBGColor = defaults.getColor("InternalFrame.inactiveTitleBackground");
+ selectedTextColor = defaults.getColor("InternalFrame.activeTitleForeground");
+ selectedTitleColor = defaults.getColor("InternalFrame.activeTitleBackground");
+ notSelectedTextColor = defaults.getColor("InternalFrame.inactiveTitleForeground");
+ notSelectedTitleColor = defaults.getColor("InternalFrame.inactiveTitleBackground");
}
/**
@@ -692,10 +679,10 @@ public class BasicInternalFrameTitlePane extends JComponent
protected void uninstallDefaults()
{
setFont(null);
- activeFGColor = null;
- activeBGColor = null;
- inactiveFGColor = null;
- inactiveBGColor = null;
+ selectedTextColor = null;
+ selectedTitleColor = null;
+ notSelectedTextColor = null;
+ notSelectedTitleColor = null;
}
/**
@@ -715,12 +702,19 @@ public class BasicInternalFrameTitlePane extends JComponent
}
/**
- * This method sets the icons in the buttons. This is a no-op method here, it
- * can be overridden by subclasses to set icons for the minimize-, maximize-
- * and close-buttons.
+ * Set icons for the minimize-, maximize- and close-buttons.
*/
protected void setButtonIcons()
{
+ Icon icon = UIManager.getIcon("InternalFrame.closeIcon");
+ if (icon != null)
+ closeButton.setIcon(icon);
+ icon = UIManager.getIcon("InternalFrame.iconifyIcon");
+ if (icon != null)
+ iconButton.setIcon(icon);
+ icon = UIManager.getIcon("InternalFrame.maximizeIcon");
+ if (icon != null)
+ maxButton.setIcon(icon);
}
/**
@@ -828,9 +822,9 @@ public class BasicInternalFrameTitlePane extends JComponent
{
Color saved = g.getColor();
if (frame.isSelected())
- g.setColor(activeFGColor);
+ g.setColor(selectedTextColor);
else
- g.setColor(inactiveFGColor);
+ g.setColor(notSelectedTextColor);
title.setText(getTitle(frame.getTitle(), fm, title.getBounds().width));
SwingUtilities.paintComponent(g, title, null, title.getBounds());
g.setColor(saved);
@@ -849,9 +843,9 @@ public class BasicInternalFrameTitlePane extends JComponent
Color bg = getBackground();
if (frame.isSelected())
- bg = activeBGColor;
+ bg = selectedTitleColor;
else
- bg = inactiveBGColor;
+ bg = notSelectedTitleColor;
g.setColor(bg);
g.fillRect(0, 0, dims.width, dims.height);
g.setColor(saved);
diff --git a/javax/swing/plaf/basic/BasicInternalFrameUI.java b/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 3febe58f4..8f76ea0cc 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -74,7 +74,6 @@ import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.event.MouseInputAdapter;
import javax.swing.event.MouseInputListener;
-import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.UIResource;
@@ -1178,26 +1177,8 @@ public class BasicInternalFrameUI extends InternalFrameUI
*/
protected void installDefaults()
{
- // This is the border of InternalFrames in the BasicLookAndFeel.
- // Note that there exist entries for various border colors in
- // BasicLookAndFeel's defaults, but obviously they differ
- // from the colors that are actually used by the JDK.
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- Color borderColor = defaults.getColor("InternalFrame.borderColor");
- Border inner = BorderFactory.createLineBorder(borderColor, 1);
- Color borderDarkShadow = defaults.getColor
- ("InternalFrame.borderDarkShadow");
- Color borderHighlight = defaults.getColor
- ("InternalFrame.borderHighlight");
- Color borderShadow = defaults.getColor("InternalFrame.borderShadow");
- Color borderLight = defaults.getColor("InternalFrame.borderLight");
- Border outer = BorderFactory.createBevelBorder(BevelBorder.RAISED,
- borderShadow,
- borderHighlight,
- borderDarkShadow,
- borderShadow);
- Border border = new BorderUIResource.CompoundBorderUIResource(outer,
- inner);
+ Border border = defaults.getBorder("InternalFrame.border");
frame.setBorder(border);
frame.setFrameIcon(defaults.getIcon("InternalFrame.icon"));
// InternalFrames are invisible by default.
diff --git a/javax/swing/plaf/basic/BasicLabelUI.java b/javax/swing/plaf/basic/BasicLabelUI.java
index 16c132dfc..bb9ce6cb1 100644
--- a/javax/swing/plaf/basic/BasicLabelUI.java
+++ b/javax/swing/plaf/basic/BasicLabelUI.java
@@ -177,20 +177,9 @@ public class BasicLabelUI
if (icon != null)
icon.paintIcon(b, g, ir.x, ir.y);
+
if (text != null && !text.equals(""))
{
- g.setColor(b.getBackground());
-
- if (b.isOpaque())
- g.fillRect(vr.x, vr.y, vr.width, vr.height);
- else
- {
- g.fillRect(tr.x, tr.y, tr.width, tr.height);
- if (b.getBorder() != null)
- b.getBorder().paintBorder(b, g, tr.x, tr.y, tr.width, tr.height);
- b.setBorder(null);
- }
-
if (b.isEnabled())
paintEnabledText(b, g, text, tr.x, tr.y + fm.getAscent());
else
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index 3d84e5ad3..d35ac9eb9 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -305,14 +305,6 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"CheckBox.margin",new InsetsUIResource(2, 2, 2, 2),
"CheckBox.textIconGap", new Integer(4),
"CheckBox.textShiftOffset", new Integer(0),
- "CheckBoxMenuItem.icon",
- new UIDefaults.LazyValue()
- {
- public Object createValue(UIDefaults def)
- {
- return BasicIconFactory.getCheckBoxIcon();
- }
- },
"CheckBoxMenuItem.acceleratorFont", new FontUIResource("Dialog",
Font.PLAIN, 12),
"CheckBoxMenuItem.acceleratorForeground",
@@ -328,7 +320,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
{
public Object createValue(UIDefaults def)
{
- return BasicIconFactory.getMenuItemCheckIcon();
+ return BasicIconFactory.getCheckBoxMenuItemIcon();
}
},
"CheckBoxMenuItem.font", new FontUIResource("Dialog", Font.PLAIN, 12),
@@ -402,7 +394,6 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl F10", "maximize",
"ctrl alt shift F6","selectPreviousFrame"
}),
- "Desktop.background", new ColorUIResource(0, 92, 92),
"DesktopIcon.border", new BorderUIResource.CompoundBorderUIResource(null,
null),
"EditorPane.background", new ColorUIResource(Color.white),
@@ -526,7 +517,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
new ColorUIResource(Color.lightGray),
"InternalFrame.maximizeIcon", BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.minimizeIcon", BasicIconFactory.createEmptyFrameIcon(),
- "InternalFrame.titleFont", new FontUIResource("Dialog", Font.PLAIN, 12),
+ "InternalFrame.titleFont", new FontUIResource("Dialog", Font.BOLD, 12),
"InternalFrame.windowBindings", new Object[] {
"shift ESCAPE", "showSystemMenu",
"ctrl SPACE", "showSystemMenu",
@@ -654,7 +645,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
null, null),
"PasswordField.caretBlinkRate", new Integer(500),
"PasswordField.caretForeground", new ColorUIResource(Color.black),
- "PasswordField.font", new FontUIResource("MonoSpaced", Font.PLAIN, 12),
+ "PasswordField.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"PasswordField.foreground", new ColorUIResource(Color.black),
"PasswordField.inactiveBackground", new ColorUIResource(light),
"PasswordField.inactiveForeground", new ColorUIResource(Color.gray),
@@ -887,7 +878,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
"ESCAPE", "cancel",
"ctrl shift PAGE_UP", "scrollLeftExtendSelection",
- "shift KP_RIGHT", " selectNextColumnExtendSelection",
+ "shift KP_RIGHT", "selectNextColumnExtendSelection",
"ctrl PAGE_UP", "scrollLeftChangeSelection",
"shift PAGE_UP", "scrollUpExtendSelection",
"ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
@@ -1059,7 +1050,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"shift END", "selectLastExtendSelection",
"HOME", "selectFirst",
"ctrl END", "selectLastChangeLead",
- "ctrl /", "selectAll",
+ "ctrl SLASH", "selectAll",
"LEFT", "selectParent",
"shift HOME", "selectFirstExtendSelection",
"UP", "selectPrevious",
@@ -1086,7 +1077,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"shift KP_DOWN","selectNextExtendSelection",
"ctrl SPACE", "toggleSelectionPreserveAnchor",
"ctrl shift PAGE_UP", "scrollUpExtendSelection",
- "ctrl \\", "clearSelection",
+ "ctrl BACK_SLASH", "clearSelection",
"shift SPACE", "extendSelection",
"ctrl PAGE_UP", "scrollUpChangeLead",
"shift PAGE_UP","scrollUpExtendSelection",
@@ -1105,6 +1096,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Tree.selectionBackground", new ColorUIResource(Color.black),
"Tree.nonSelectionBackground", new ColorUIResource(new Color(239, 235, 231)),
"Tree.selectionBorderColor", new ColorUIResource(Color.black),
+ "Tree.selectionBorder", new BorderUIResource.LineBorderUIResource(Color.black),
"Tree.selectionForeground", new ColorUIResource(new Color(255, 255, 255)),
"Tree.textBackground", new ColorUIResource(new Color(255, 255, 255)),
"Tree.textForeground", new ColorUIResource(Color.black),
diff --git a/javax/swing/plaf/basic/BasicMenuBarUI.java b/javax/swing/plaf/basic/BasicMenuBarUI.java
index 95f6b84fb..6b9cad89c 100644
--- a/javax/swing/plaf/basic/BasicMenuBarUI.java
+++ b/javax/swing/plaf/basic/BasicMenuBarUI.java
@@ -38,19 +38,25 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
+import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JMenuBar;
+import javax.swing.MenuElement;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.MenuBarUI;
@@ -63,12 +69,15 @@ public class BasicMenuBarUI extends MenuBarUI
/*ContainerListener that listens to the ContainerEvents fired from menu bar*/
protected ContainerListener containerListener;
-
+
/*Property change listeners that listener to PropertyChangeEvent from menu bar*/
protected PropertyChangeListener propertyChangeListener;
/* menu bar for which this UI delegate is for*/
protected JMenuBar menuBar;
+
+ /* MouseListener that listens to the mouseEvents fired from menu bar*/
+ private MouseInputListener mouseListener;
/**
* Creates a new BasicMenuBarUI object.
@@ -78,6 +87,7 @@ public class BasicMenuBarUI extends MenuBarUI
changeListener = createChangeListener();
containerListener = createContainerListener();
propertyChangeListener = new PropertyChangeHandler();
+ mouseListener = new MouseInputHandler();
}
/**
@@ -183,6 +193,7 @@ public class BasicMenuBarUI extends MenuBarUI
{
menuBar.addContainerListener(containerListener);
menuBar.addPropertyChangeListener(propertyChangeListener);
+ menuBar.addMouseListener(mouseListener);
}
/**
@@ -229,6 +240,7 @@ public class BasicMenuBarUI extends MenuBarUI
{
menuBar.removeContainerListener(containerListener);
menuBar.removePropertyChangeListener(propertyChangeListener);
+ menuBar.removeMouseListener(mouseListener);
}
/**
@@ -301,4 +313,74 @@ public class BasicMenuBarUI extends MenuBarUI
menuBar.repaint();
}
}
+
+ private class MouseInputHandler implements MouseInputListener
+ {
+ /**
+ * Handles mouse clicked event
+ *
+ * @param e Mouse event
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ MenuElement[] me = menuBar.getSubElements();
+
+ for (int i = 0; i < me.length; i++)
+ menuBar.getMenu(i).setSelected(false);
+ }
+
+ /**
+ * Handles mouse pressed event
+ *
+ * @param e Mouse event
+ */
+ public void mousePressed(MouseEvent e)
+ {
+ }
+
+ /**
+ * Handles mouse released event
+ *
+ * @param e Mouse event
+ */
+ public void mouseReleased(MouseEvent e)
+ {
+ }
+
+ /**
+ * Handles mouse exited event
+ *
+ * @param e Mouse event
+ */
+ public void mouseExited(MouseEvent e)
+ {
+ }
+
+ /**
+ * Handles mouse dragged event
+ *
+ * @param e Mouse event
+ */
+ public void mouseDragged(MouseEvent e)
+ {
+ }
+
+ /**
+ * Handles mouse moved event
+ *
+ * @param e Mouse event
+ */
+ public void mouseMoved(MouseEvent e)
+ {
+ }
+
+ /**
+ * Handles mouse entered event
+ *
+ * @param e Mouse event
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ }
+ }
}
diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java
index 724e32f4c..e40e09170 100644
--- a/javax/swing/plaf/basic/BasicMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicMenuItemUI.java
@@ -1,39 +1,39 @@
/* BasicMenuItemUI.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-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. */
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ 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.basic;
@@ -178,9 +178,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Create MenuDragMouseListener to listen for mouse dragged events.
- *
- * @param c menu item to listen to
- *
+ *
+ * @param c
+ * menu item to listen to
* @return The MenuDragMouseListener
*/
protected MenuDragMouseListener createMenuDragMouseListener(JComponent c)
@@ -189,11 +189,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * Creates MenuKeyListener to listen to key events occuring when menu item
- * is visible on the screen.
- *
- * @param c menu item to listen to
- *
+ * Creates MenuKeyListener to listen to key events occuring when menu item is
+ * visible on the screen.
+ *
+ * @param c
+ * menu item to listen to
* @return The MenuKeyListener
*/
protected MenuKeyListener createMenuKeyListener(JComponent c)
@@ -203,9 +203,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Handles mouse input events occuring for this menu item
- *
- * @param c menu item to listen to
- *
+ *
+ * @param c
+ * menu item to listen to
* @return The MouseInputListener
*/
protected MouseInputListener createMouseInputListener(JComponent c)
@@ -216,9 +216,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Factory method to create a BasicMenuItemUI for the given {@link
* JComponent}, which should be a {@link JMenuItem}.
- *
- * @param c The {@link JComponent} a UI is being created for.
- *
+ *
+ * @param c
+ * The {@link JComponent} a UI is being created for.
* @return A BasicMenuItemUI for the {@link JComponent}.
*/
public static ComponentUI createUI(JComponent c)
@@ -228,8 +228,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Programatically clicks menu item.
- *
- * @param msm MenuSelectionManager for the menu hierarchy
+ *
+ * @param msm
+ * MenuSelectionManager for the menu hierarchy
*/
protected void doClick(MenuSelectionManager msm)
{
@@ -239,9 +240,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Returns maximum size for the specified menu item
- *
- * @param c component for which to get maximum size
- *
+ *
+ * @param c
+ * component for which to get maximum size
* @return Maximum size for the specified menu item.
*/
public Dimension getMaximumSize(JComponent c)
@@ -251,9 +252,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Returns minimum size for the specified menu item
- *
- * @param c component for which to get minimum size
- *
+ *
+ * @param c
+ * component for which to get minimum size
* @return Minimum size for the specified menu item.
*/
public Dimension getMinimumSize(JComponent c)
@@ -263,9 +264,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Returns path to this menu item.
- *
- * @return $MenuElement[]$ Returns array of menu elements
- * that constitute a path to this menu item.
+ *
+ * @return $MenuElement[]$ Returns array of menu elements that constitute a
+ * path to this menu item.
*/
public MenuElement[] getPath()
{
@@ -278,12 +279,12 @@ public class BasicMenuItemUI extends MenuItemUI
Component c = menuItem;
while (c instanceof MenuElement)
{
- path.add(0, (MenuElement) c);
+ path.add(0, (MenuElement) c);
- if (c instanceof JPopupMenu)
- c = ((JPopupMenu) c).getInvoker();
- else
- c = c.getParent();
+ if (c instanceof JPopupMenu)
+ c = ((JPopupMenu) c).getInvoker();
+ else
+ c = c.getParent();
}
MenuElement[] pathArray = new MenuElement[path.size()];
@@ -293,12 +294,15 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Returns preferred size for the given menu item.
- *
- * @param c menu item for which to get preferred size
- * @param checkIcon chech icon displayed in the given menu item
- * @param arrowIcon arrow icon displayed in the given menu item
- * @param defaultTextIconGap space between icon and text in the given menuItem
- *
+ *
+ * @param c
+ * menu item for which to get preferred size
+ * @param checkIcon
+ * check icon displayed in the given menu item
+ * @param arrowIcon
+ * arrow icon displayed in the given menu item
+ * @param defaultTextIconGap
+ * space between icon and text in the given menuItem
* @return $Dimension$ preferred size for the given menu item
*/
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,
@@ -316,31 +320,32 @@ public class BasicMenuItemUI extends MenuItemUI
if (accelerator != null)
{
- rect = getAcceleratorRect(accelerator,
- m.getToolkit().getFontMetrics(acceleratorFont));
+ rect = getAcceleratorRect(
+ accelerator,
+ m.getToolkit().getFontMetrics(acceleratorFont));
- // add width of accelerator's text
- d.width = d.width + rect.width + defaultAcceleratorLabelGap;
+ // add width of accelerator's text
+ d.width = d.width + rect.width + defaultAcceleratorLabelGap;
- // adjust the heigth of the preferred size if necessary
- if (d.height < rect.height)
- d.height = rect.height;
+ // adjust the heigth of the preferred size if necessary
+ if (d.height < rect.height)
+ d.height = rect.height;
}
if (checkIcon != null)
{
- d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap;
+ d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap;
- if (checkIcon.getIconHeight() > d.height)
- d.height = checkIcon.getIconHeight();
+ if (checkIcon.getIconHeight() > d.height)
+ d.height = checkIcon.getIconHeight();
}
if (arrowIcon != null && (c instanceof JMenu))
{
- d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap;
+ d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap;
- if (arrowIcon.getIconHeight() > d.height)
- d.height = arrowIcon.getIconHeight();
+ if (arrowIcon.getIconHeight() > d.height)
+ d.height = arrowIcon.getIconHeight();
}
return d;
@@ -348,26 +353,31 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Returns preferred size of the given component
- *
- * @param c component for which to return preferred size
- *
+ *
+ * @param c
+ * component for which to return preferred size
* @return $Dimension$ preferred size for the given component
*/
public Dimension getPreferredSize(JComponent c)
{
- return getPreferredMenuItemSize(c, checkIcon, arrowIcon,
- defaultTextIconGap);
+ return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap);
}
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "MenuItem"
+ */
protected String getPropertyPrefix()
{
- return null;
+ return "MenuItem";
}
/**
* This method installs the components for this {@link JMenuItem}.
- *
- * @param menuItem The {@link JMenuItem} to install components for.
+ *
+ * @param menuItem
+ * The {@link JMenuItem} to install components for.
*/
protected void installComponents(JMenuItem menuItem)
{
@@ -375,7 +385,7 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * This method installs the defaults that are defined in the Basic look and
+ * This method installs the defaults that are defined in the Basic look and
* feel for this {@link JMenuItem}.
*/
protected void installDefaults()
@@ -420,11 +430,12 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * Installs and initializes all fields for this UI delegate. Any properties
- * of the UI that need to be initialized and/or set to defaults will be
- * done now. It will also install any listeners necessary.
- *
- * @param c The {@link JComponent} that is having this UI installed.
+ * Installs and initializes all fields for this UI delegate. Any properties of
+ * the UI that need to be initialized and/or set to defaults will be done now.
+ * It will also install any listeners necessary.
+ *
+ * @param c
+ * The {@link JComponent} that is having this UI installed.
*/
public void installUI(JComponent c)
{
@@ -437,9 +448,11 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Paints given menu item using specified graphics context
- *
- * @param g The graphics context used to paint this menu item
- * @param c Menu Item to paint
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param c
+ * Menu Item to paint
*/
public void paint(Graphics g, JComponent c)
{
@@ -449,10 +462,13 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Paints background of the menu item
- *
- * @param g The graphics context used to paint this menu item
- * @param menuItem menu item to paint
- * @param bgColor Background color to use when painting menu item
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param menuItem
+ * menu item to paint
+ * @param bgColor
+ * Background color to use when painting menu item
*/
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)
{
@@ -465,15 +481,21 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Paints specified menu item
- *
- * @param g The graphics context used to paint this menu item
- * @param c menu item to paint
- * @param checkIcon check icon to use when painting menu item
- * @param arrowIcon arrow icon to use when painting menu item
- * @param background Background color of the menu item
- * @param foreground Foreground color of the menu item
- * @param defaultTextIconGap space to use between icon and
- * text when painting menu item
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param c
+ * menu item to paint
+ * @param checkIcon
+ * check icon to use when painting menu item
+ * @param arrowIcon
+ * arrow icon to use when painting menu item
+ * @param background
+ * Background color of the menu item
+ * @param foreground
+ * Foreground color of the menu item
+ * @param defaultTextIconGap
+ * space to use between icon and text when painting menu item
*/
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon,
Icon arrowIcon, Color background,
@@ -499,8 +521,10 @@ public class BasicMenuItemUI extends MenuItemUI
SwingUtilities.calculateInsetArea(br, m.getInsets(), vr);
paintBackground(g, m, m.getBackground());
- /* MenuItems insets are equal to menuItems margin, space between text and
- menuItems border. We need to paint insets region as well. */
+ /*
+ * MenuItems insets are equal to menuItems margin, space between text and
+ * menuItems border. We need to paint insets region as well.
+ */
Insets insets = m.getInsets();
br.x -= insets.left;
br.y -= insets.top;
@@ -509,95 +533,92 @@ public class BasicMenuItemUI extends MenuItemUI
// Menu item is considered to be highlighted when it is selected.
// But we don't want to paint the background of JCheckBoxMenuItems
- if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() &&
- (m.getParent() instanceof MenuElement))
+ if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed()
+ && (m.getParent() instanceof MenuElement))
{
- if (m.isContentAreaFilled())
- {
- g.setColor(selectionBackground);
- g.fillRect(br.x, br.y, br.width, br.height);
- }
+ 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 (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)
{
- SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,
- horAlign, vertTextPos, horTextPos,
- vr, cr, tr, defaultTextIconGap);
- if (m.isSelected())
- checkIcon.paintIcon(m, g, cr.x, cr.y);
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- defaults.getBorder("CheckBox.border").paintBorder(m, g, cr.x, cr.y,
- cr.width, cr.height);
-
- // We need to calculate position of the menu text and position of
- // user menu icon if there exists one relative to the check icon.
- // So we need to adjust view rectangle s.t. its starting point is at
- // checkIcon.width + defaultTextIconGap.
- vr.x = cr.x + cr.width + defaultTextIconGap;
+ SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,
+ horAlign, vertTextPos, horTextPos,
+ vr, cr, tr, defaultTextIconGap);
+ checkIcon.paintIcon(m, g, cr.x, cr.y);
+ // We need to calculate position of the menu text and position of
+ // user menu icon if there exists one relative to the check icon.
+ // So we need to adjust view rectangle s.t. its starting point is at
+ // checkIcon.width + defaultTextIconGap.
+ vr.x = cr.x + cr.width + defaultTextIconGap;
}
// if this is a submenu, then paint arrow icon to indicate it.
if (arrowIcon != null && (c instanceof JMenu))
{
- if (! ((JMenu) c).isTopLevelMenu())
- {
- int width = arrowIcon.getIconWidth();
- int height = arrowIcon.getIconHeight();
-
- arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,
- vr.y + 2);
- }
+ if (!((JMenu) c).isTopLevelMenu())
+ {
+ int width = arrowIcon.getIconWidth();
+ int height = arrowIcon.getIconHeight();
+
+ arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,
+ vr.y + 2);
+ }
}
- // paint text and user menu icon if it exists
+ // paint text and user menu icon if it exists
Icon i = m.getIcon();
- SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i,
- vertAlign, horAlign, vertTextPos,
- horTextPos, vr, ir, tr,
- defaultTextIconGap);
+ SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign,
+ horAlign, vertTextPos, horTextPos, vr,
+ ir, tr, defaultTextIconGap);
if (i != null)
i.paintIcon(c, g, ir.x, ir.y);
-
paintText(g, m, tr, m.getText());
- // paint accelerator
+ // paint accelerator
String acceleratorText = "";
if (m.getAccelerator() != null)
{
- acceleratorText = getAcceleratorText(m.getAccelerator());
- fm = g.getFontMetrics(acceleratorFont);
- ar.width = fm.stringWidth(acceleratorText);
- ar.x = br.width - ar.width;
- vr.x = br.width - ar.width;
-
- SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null,
- vertAlign, horAlign, vertTextPos,
- horTextPos, vr, ir, ar,
- defaultTextIconGap);
-
- paintAccelerator(g, m, ar, acceleratorText);
+ acceleratorText = getAcceleratorText(m.getAccelerator());
+ fm = g.getFontMetrics(acceleratorFont);
+ ar.width = fm.stringWidth(acceleratorText);
+ ar.x = br.width - ar.width;
+ vr.x = br.width - ar.width - defaultTextIconGap;
+
+ SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null,
+ vertAlign, horAlign, vertTextPos,
+ horTextPos, vr, ir, ar,
+ defaultTextIconGap);
+
+ paintAccelerator(g, m, ar, acceleratorText);
}
}
/**
* Paints label for the given menu item
- *
- * @param g The graphics context used to paint this menu item
- * @param menuItem menu item for which to draw its label
- * @param textRect rectangle specifiying position of the text relative to
- * the given menu item
- * @param text label of the menu item
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param menuItem
+ * menu item for which to draw its label
+ * @param textRect
+ * rectangle specifiying position of the text relative to the given
+ * menu item
+ * @param text
+ * label of the menu item
*/
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect,
String text)
@@ -606,43 +627,45 @@ public class BasicMenuItemUI extends MenuItemUI
g.setFont(f);
FontMetrics fm = g.getFontMetrics(f);
- if (text != null && ! text.equals(""))
+ if (text != null && !text.equals(""))
{
- if (menuItem.isEnabled())
+ if (menuItem.isEnabled())
{
// Menu item is considered to be highlighted when it is selected.
// But not if it's a JCheckBoxMenuItem
- if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() &&
- (menuItem.getParent() instanceof MenuElement))
+ if ((menuItem.isSelected() && checkIcon == null)
+ || menuItem.getModel().isArmed()
+ && (menuItem.getParent() instanceof MenuElement))
g.setColor(selectionForeground);
else
g.setColor(menuItem.getForeground());
}
- else
- // FIXME: should fix this to use 'disabledForeground', but its
- // default value in BasicLookAndFeel is null.
-
+ else
+ // FIXME: should fix this to use 'disabledForeground', but its
+ // default value in BasicLookAndFeel is null.
+
// FIXME: should there be different foreground colours for selected
// or deselected, when disabled?
g.setColor(Color.gray);
- int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
+ int mnemonicIndex = menuItem.getDisplayedMnemonicIndex();
- if (mnemonicIndex != -1)
- BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex,
- textRect.x,
- textRect.y
- + fm.getAscent());
- else
- BasicGraphicsUtils.drawString(g, text, 0, textRect.x,
- textRect.y + fm.getAscent());
+ if (mnemonicIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex,
+ textRect.x,
+ textRect.y
+ + fm.getAscent());
+ else
+ BasicGraphicsUtils.drawString(g, text, 0, textRect.x,
+ textRect.y + fm.getAscent());
}
}
/**
* This method uninstalls the components for this {@link JMenuItem}.
- *
- * @param menuItem The {@link JMenuItem} to uninstall components for.
+ *
+ * @param menuItem
+ * The {@link JMenuItem} to uninstall components for.
*/
protected void uninstallComponents(JMenuItem menuItem)
{
@@ -694,10 +717,11 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Performs the opposite of installUI. Any properties or resources that need
- * to be cleaned up will be done now. It will also uninstall any listeners
- * it has. In addition, any properties of this UI will be nulled.
- *
- * @param c The {@link JComponent} that is having this UI uninstalled.
+ * to be cleaned up will be done now. It will also uninstall any listeners it
+ * has. In addition, any properties of this UI will be nulled.
+ *
+ * @param c
+ * The {@link JComponent} that is having this UI uninstalled.
*/
public void uninstallUI(JComponent c)
{
@@ -709,9 +733,11 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* This method calls paint.
- *
- * @param g The graphics context used to paint this menu item
- * @param c The menu item to paint
+ *
+ * @param g
+ * The graphics context used to paint this menu item
+ * @param c
+ * The menu item to paint
*/
public void update(Graphics g, JComponent c)
{
@@ -720,9 +746,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Return text representation of the specified accelerator
- *
- * @param accelerator Accelerator for which to return string representation
- *
+ *
+ * @param accelerator
+ * Accelerator for which to return string representation
* @return $String$ Text representation of the given accelerator
*/
private String getAcceleratorText(KeyStroke accelerator)
@@ -745,10 +771,11 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Calculates and return rectange in which accelerator should be displayed
- *
- * @param accelerator accelerator for which to return the display rectangle
- * @param fm The font metrics used to measure the text
- *
+ *
+ * @param accelerator
+ * accelerator for which to return the display rectangle
+ * @param fm
+ * The font metrics used to measure the text
* @return $Rectangle$ reactangle which will be used to display accelerator
*/
private Rectangle getAcceleratorRect(KeyStroke accelerator, FontMetrics fm)
@@ -760,12 +787,16 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* Paints accelerator inside menu item
- *
- * @param g The graphics context used to paint the border
- * @param menuItem Menu item for which to draw accelerator
- * @param acceleratorRect rectangle representing position
- * of the accelerator relative to the menu item
- * @param acceleratorText accelerator's text
+ *
+ * @param g
+ * The graphics context used to paint the border
+ * @param menuItem
+ * Menu item for which to draw accelerator
+ * @param acceleratorRect
+ * rectangle representing position of the accelerator relative to the
+ * menu item
+ * @param acceleratorText
+ * accelerator's text
*/
private void paintAccelerator(Graphics g, JMenuItem menuItem,
Rectangle acceleratorRect,
@@ -786,10 +817,9 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * This class handles mouse events occuring inside the menu item.
- * Most of the events are forwarded for processing to MenuSelectionManager
- * of the current menu hierarchy.
- *
+ * This class handles mouse events occuring inside the menu item. Most of the
+ * events are forwarded for processing to MenuSelectionManager of the current
+ * menu hierarchy.
*/
protected class MouseInputHandler implements MouseInputListener
{
@@ -801,10 +831,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * This method is called when mouse is clicked on the menu item.
- * It forwards this event to MenuSelectionManager.
- *
- * @param e A {@link MouseEvent}.
+ * This method is called when mouse is clicked on the menu item. It forwards
+ * this event to MenuSelectionManager.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mouseClicked(MouseEvent e)
{
@@ -813,10 +844,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * This method is called when mouse is dragged inside the menu item.
- * It forwards this event to MenuSelectionManager.
- *
- * @param e A {@link MouseEvent}.
+ * This method is called when mouse is dragged inside the menu item. It
+ * forwards this event to MenuSelectionManager.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mouseDragged(MouseEvent e)
{
@@ -825,29 +857,31 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * This method is called when mouse enters menu item.
- * When this happens menu item is considered to be selected and selection path
- * in MenuSelectionManager is set. This event is also forwarded to MenuSelection
- * Manager for further processing.
- *
- * @param e A {@link MouseEvent}.
+ * This method is called when mouse enters menu item. When this happens menu
+ * item is considered to be selected and selection path in
+ * MenuSelectionManager is set. This event is also forwarded to
+ * MenuSelection Manager for further processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mouseEntered(MouseEvent e)
{
Component source = (Component) e.getSource();
if (source.getParent() instanceof MenuElement)
{
- MenuSelectionManager manager = MenuSelectionManager.defaultManager();
- manager.setSelectedPath(getPath());
- manager.processMouseEvent(e);
+ MenuSelectionManager manager = MenuSelectionManager.defaultManager();
+ manager.setSelectedPath(getPath());
+ manager.processMouseEvent(e);
}
}
/**
- * This method is called when mouse exits menu item. The event is
- * forwarded to MenuSelectionManager for processing.
- *
- * @param e A {@link MouseEvent}.
+ * This method is called when mouse exits menu item. The event is forwarded
+ * to MenuSelectionManager for processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mouseExited(MouseEvent e)
{
@@ -856,10 +890,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * This method is called when mouse is inside the menu item.
- * This event is forwarder to MenuSelectionManager for further processing.
- *
- * @param e A {@link MouseEvent}.
+ * This method is called when mouse is inside the menu item. This event is
+ * forwarder to MenuSelectionManager for further processing.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mouseMoved(MouseEvent e)
{
@@ -870,8 +905,9 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* This method is called when mouse is pressed. This event is forwarded to
* MenuSelectionManager for further processing.
- *
- * @param e A {@link MouseEvent}.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mousePressed(MouseEvent e)
{
@@ -883,8 +919,9 @@ public class BasicMenuItemUI extends MenuItemUI
* This method is called when mouse is released. If the mouse is released
* inside this menuItem, then this menu item is considered to be chosen and
* the menu hierarchy should be closed.
- *
- * @param e A {@link MouseEvent}.
+ *
+ * @param e
+ * A {@link MouseEvent}.
*/
public void mouseReleased(MouseEvent e)
{
@@ -893,12 +930,12 @@ public class BasicMenuItemUI extends MenuItemUI
if (e.getX() > 0 && e.getX() < size.width && e.getY() > 0
&& e.getY() < size.height)
{
- manager.clearSelectedPath();
- menuItem.doClick();
+ manager.clearSelectedPath();
+ menuItem.doClick();
}
else
- manager.processMouseEvent(e);
+ manager.processMouseEvent(e);
}
}
@@ -909,8 +946,9 @@ public class BasicMenuItemUI extends MenuItemUI
{
/**
* Tbis method is invoked when mouse is dragged over the menu item.
- *
- * @param e The MenuDragMouseEvent
+ *
+ * @param e
+ * The MenuDragMouseEvent
*/
public void menuDragMouseDragged(MenuDragMouseEvent e)
{
@@ -919,10 +957,11 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * Tbis method is invoked when mouse enters the menu item while it is
- * being dragged.
- *
- * @param e The MenuDragMouseEvent
+ * Tbis method is invoked when mouse enters the menu item while it is being
+ * dragged.
+ *
+ * @param e
+ * The MenuDragMouseEvent
*/
public void menuDragMouseEntered(MenuDragMouseEvent e)
{
@@ -931,27 +970,29 @@ public class BasicMenuItemUI extends MenuItemUI
}
/**
- * Tbis method is invoked when mouse exits the menu item while
- * it is being dragged
- *
- * @param e The MenuDragMouseEvent
+ * Tbis method is invoked when mouse exits the menu item while it is being
+ * dragged
+ *
+ * @param e
+ * The MenuDragMouseEvent
*/
public void menuDragMouseExited(MenuDragMouseEvent e)
{
}
/**
- * Tbis method is invoked when mouse was dragged and released
- * inside the menu item.
- *
- * @param e The MenuDragMouseEvent
+ * Tbis method is invoked when mouse was dragged and released inside the
+ * menu item.
+ *
+ * @param e
+ * The MenuDragMouseEvent
*/
public void menuDragMouseReleased(MenuDragMouseEvent e)
{
MenuElement[] path = e.getPath();
if (path[path.length - 1] instanceof JMenuItem)
- ((JMenuItem) path[path.length - 1]).doClick();
+ ((JMenuItem) path[path.length - 1]).doClick();
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
manager.clearSelectedPath();
@@ -966,8 +1007,9 @@ public class BasicMenuItemUI extends MenuItemUI
{
/**
* This method is invoked when key has been pressed
- *
- * @param e A {@link MenuKeyEvent}.
+ *
+ * @param e
+ * A {@link MenuKeyEvent}.
*/
public void menuKeyPressed(MenuKeyEvent e)
{
@@ -975,18 +1017,20 @@ public class BasicMenuItemUI extends MenuItemUI
/**
* This method is invoked when key has been pressed
- *
- * @param e A {@link MenuKeyEvent}.
+ *
+ * @param e
+ * A {@link MenuKeyEvent}.
*/
public void menuKeyReleased(MenuKeyEvent e)
{
}
/**
- * This method is invoked when key has been typed
- * It handles the mnemonic key for the menu item.
- *
- * @param e A {@link MenuKeyEvent}.
+ * This method is invoked when key has been typed It handles the mnemonic
+ * key for the menu item.
+ *
+ * @param e
+ * A {@link MenuKeyEvent}.
*/
public void menuKeyTyped(MenuKeyEvent e)
{
diff --git a/javax/swing/plaf/basic/BasicMenuUI.java b/javax/swing/plaf/basic/BasicMenuUI.java
index 4b07d7069..30be592ee 100644
--- a/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/javax/swing/plaf/basic/BasicMenuUI.java
@@ -189,9 +189,14 @@ public class BasicMenuUI extends BasicMenuItemUI
return c.getPreferredSize();
}
+ /**
+ * Returns the prefix for entries in the {@link UIDefaults} table.
+ *
+ * @return "Menu"
+ */
protected String getPropertyPrefix()
{
- return null;
+ return "Menu";
}
/**
diff --git a/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java b/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
index d5cd7f448..fa74a008b 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java
@@ -77,13 +77,13 @@ public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
}
/**
- * DOCUMENT ME!
+ * Returns the prefix for entries in the {@link UIDefaults} table.
*
- * @return $returnType$ DOCUMENT ME!
+ * @return "RadioButtonMenuItem"
*/
protected String getPropertyPrefix()
{
- return null;
+ return "RadioButtonMenuItem";
}
/**
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index 98738251c..fbd21241a 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -103,7 +103,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
*/
protected String getPropertyPrefix()
{
- return "RadioButton";
+ return "RadioButton.";
}
/**
@@ -117,7 +117,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
public Icon getDefaultIcon()
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- return defaults.getIcon(getPropertyPrefix() + ".icon");
+ return defaults.getIcon(getPropertyPrefix() + "icon");
}
/**
diff --git a/javax/swing/plaf/basic/BasicScrollBarUI.java b/javax/swing/plaf/basic/BasicScrollBarUI.java
index 892db2b03..58d8fc1f7 100644
--- a/javax/swing/plaf/basic/BasicScrollBarUI.java
+++ b/javax/swing/plaf/basic/BasicScrollBarUI.java
@@ -233,19 +233,19 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
{
if (block)
{
- // Only need to check it if it's block scrolling
- // We only block scroll if the click occurs
- // in the track.
- if (! trackListener.shouldScroll(direction))
- {
- trackHighlight = NO_HIGHLIGHT;
- scrollbar.repaint();
- return;
- }
- scrollByBlock(direction);
+ // Only need to check it if it's block scrolling
+ // We only block scroll if the click occurs
+ // in the track.
+ if (!trackListener.shouldScroll(direction))
+ {
+ trackHighlight = NO_HIGHLIGHT;
+ scrollbar.repaint();
+ return;
+ }
+ scrollByBlock(direction);
}
else
- scrollByUnit(direction);
+ scrollByUnit(direction);
}
}
@@ -659,7 +659,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
height = Math.max(incrButton.getPreferredSize().height,
decrButton.getPreferredSize().height);
height = Math.max(getMinimumThumbSize().height, height);
- height = Math.max(20, height);
height = Math.min(getMaximumThumbSize().height, height);
}
else
@@ -672,7 +671,6 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
width = Math.max(incrButton.getPreferredSize().width,
decrButton.getPreferredSize().width);
width = Math.max(getMinimumThumbSize().width, width);
- width = Math.max(20, width);
width = Math.min(getMaximumThumbSize().width, width);
}
@@ -875,7 +873,7 @@ public class BasicScrollBarUI extends ScrollBarUI implements LayoutManager,
trackRect = new Rectangle();
thumbRect = new Rectangle();
- scrollTimer = new Timer(200, null);
+ scrollTimer = new Timer(50, null);
scrollTimer.setRepeats(true);
installComponents();
diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java
index fd7224757..ef8e22823 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -870,7 +870,8 @@ public class BasicSplitPaneUI extends SplitPaneUI
transient int lastDragLocation = -1;
/** The distance the divider is moved when moved by keyboard actions. */
- protected static int KEYBOARD_DIVIDER_MOVE_OFFSET;
+ // Sun defines this as 3
+ protected static int KEYBOARD_DIVIDER_MOVE_OFFSET = 3;
/** The divider that divides this JSplitPane. */
protected BasicSplitPaneDivider divider;
diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index 9312d13dc..4559937eb 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -46,6 +46,7 @@ import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
@@ -54,6 +55,7 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import javax.swing.AbstractAction;
+import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.CellRendererPane;
import javax.swing.InputMap;
@@ -68,6 +70,7 @@ import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InputMapUIResource;
import javax.swing.plaf.TableUI;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
@@ -203,14 +206,44 @@ public class BasicTableUI
return new MouseInputHandler();
}
+ /**
+ * Return the maximum size of the table. The maximum height is the row
+ * height times the number of rows. The maximum width is the sum of
+ * the maximum widths of each column.
+ *
+ * @param comp the component whose maximum size is being queried,
+ * this is ignored.
+ * @return a Dimension object representing the maximum size of the table,
+ * or null if the table has no elements.
+ */
public Dimension getMaximumSize(JComponent comp)
{
- return getPreferredSize(comp);
+ int maxTotalColumnWidth = 0;
+ for (int i = 0; i < table.getColumnCount(); i++)
+ maxTotalColumnWidth += table.getColumnModel().getColumn(i).getMaxWidth();
+ if (maxTotalColumnWidth == 0 || table.getRowCount() == 0)
+ return null;
+ return new Dimension(maxTotalColumnWidth, table.getRowCount()*table.getRowHeight());
}
+ /**
+ * Return the minimum size of the table. The minimum height is the row
+ * height times the number of rows. The minimum width is the sum of
+ * the minimum widths of each column.
+ *
+ * @param comp the component whose minimum size is being queried,
+ * this is ignored.
+ * @return a Dimension object representing the minimum size of the table,
+ * or null if the table has no elements.
+ */
public Dimension getMinimumSize(JComponent comp)
{
- return getPreferredSize(comp);
+ int minTotalColumnWidth = 0;
+ for (int i = 0; i < table.getColumnCount(); i++)
+ minTotalColumnWidth += table.getColumnModel().getColumn(i).getMinWidth();
+ if (minTotalColumnWidth == 0 || table.getRowCount() == 0)
+ return null;
+ return new Dimension(minTotalColumnWidth, table.getRowCount()*table.getRowHeight());
}
public Dimension getPreferredSize(JComponent comp)
@@ -269,23 +302,70 @@ public class BasicTableUI
{
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap");
+ InputMapUIResource parentInputMap = new InputMapUIResource();
+ // FIXME: The JDK uses a LazyActionMap for parentActionMap
+ ActionMap parentActionMap = new ActionMap();
action = new TableAction();
Object keys[] = ancestorMap.allKeys();
- // Register the key bindings with the JTable.
+ // Register key bindings in the UI InputMap-ActionMap pair
// Note that we register key bindings with both the old and new modifier
// masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on.
for (int i = 0; i < keys.length; i++)
{
- table.registerKeyboardAction(action,(String)ancestorMap.get((KeyStroke)keys[i]),
- KeyStroke.getKeyStroke
- (((KeyStroke)keys[i]).getKeyCode(), convertModifiers(((KeyStroke)keys[i]).getModifiers())),
- JComponent.WHEN_FOCUSED);
-
- table.registerKeyboardAction(action,(String)ancestorMap.get((KeyStroke)keys[i]),
- KeyStroke.getKeyStroke
- (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()),
- JComponent.WHEN_FOCUSED);
+ parentInputMap.put(KeyStroke.getKeyStroke
+ (((KeyStroke)keys[i]).getKeyCode(), convertModifiers
+ (((KeyStroke)keys[i]).getModifiers())),
+ (String)ancestorMap.get((KeyStroke)keys[i]));
+
+ parentInputMap.put(KeyStroke.getKeyStroke
+ (((KeyStroke)keys[i]).getKeyCode(),
+ ((KeyStroke)keys[i]).getModifiers()),
+ (String)ancestorMap.get((KeyStroke)keys[i]));
+
+ parentActionMap.put
+ ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy
+ (action, (String)ancestorMap.get((KeyStroke)keys[i])));
+
}
+ // Set the UI InputMap-ActionMap pair to be the parents of the
+ // JTable's InputMap-ActionMap pair
+ parentInputMap.setParent
+ (table.getInputMap
+ (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent());
+ parentActionMap.setParent(table.getActionMap().getParent());
+ table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).
+ setParent(parentInputMap);
+ table.getActionMap().setParent(parentActionMap);
+ }
+
+ /**
+ * This class is used to mimmic the behaviour of the JDK when registering
+ * keyboard actions. It is the same as the private class used in JComponent
+ * for the same reason. This class receives an action event and dispatches
+ * it to the true receiver after altering the actionCommand property of the
+ * event.
+ */
+ private static class ActionListenerProxy
+ extends AbstractAction
+ {
+ ActionListener target;
+ String bindingCommandName;
+
+ public ActionListenerProxy(ActionListener li,
+ String cmd)
+ {
+ target = li;
+ bindingCommandName = cmd;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ ActionEvent derivedEvent = new ActionEvent(e.getSource(),
+ e.getID(),
+ bindingCommandName,
+ e.getModifiers());
+ target.actionPerformed(derivedEvent);
+ }
}
/**
@@ -305,7 +385,7 @@ public class BasicTableUI
{
ListSelectionModel rowModel = table.getSelectionModel();
ListSelectionModel colModel = table.getColumnModel().getSelectionModel();
-
+
int rowLead = rowModel.getLeadSelectionIndex();
int rowMax = table.getModel().getRowCount() - 1;
@@ -519,8 +599,6 @@ public class BasicTableUI
colModel, colMinSelected, colMaxSelected,
(e.getActionCommand().equals
("selectPreviousRowCell")), false);
-
- table.repaint();
}
else if (e.getActionCommand().equals("selectNextColumn"))
{
@@ -608,6 +686,10 @@ public class BasicTableUI
// to a keyboard input but we either want to ignore that input
// or we just haven't implemented its action yet.
}
+
+ if (table.isEditing() && e.getActionCommand() != "startEditing")
+ table.editingCanceled(new ChangeEvent("update"));
+ table.repaint();
table.scrollRectToVisible
(table.getCellRect(rowModel.getLeadSelectionIndex(),
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index 236c0ccd0..91ccb0056 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -150,6 +150,19 @@ public abstract class BasicTextUI extends TextUI
}
/**
+ * Indicates that the preferences of one of the child view has changed.
+ * This calls revalidate on the text component.
+ *
+ * @param view the child view which's preference has changed
+ * @param width <code>true</code> if the width preference has changed
+ * @param height <code>true</code> if the height preference has changed
+ */
+ public void preferenceChanged(View view, boolean width, boolean height)
+ {
+ textComponent.revalidate();
+ }
+
+ /**
* Sets the real root view.
*
* @param v the root view to set
@@ -157,15 +170,42 @@ public abstract class BasicTextUI extends TextUI
public void setView(View v)
{
if (view != null)
- view.setParent(null);
+ view.setParent(null);
if (v != null)
- v.setParent(this);
+ v.setParent(null);
view = v;
}
/**
+ * Returns the real root view, regardless of the index.
+ *
+ * @param index not used here
+ *
+ * @return the real root view, regardless of the index.
+ */
+ public View getView(int index)
+ {
+ return view;
+ }
+
+ /**
+ * Returns <code>1</code> since the RootView always contains one
+ * child, that is the real root of the View hierarchy.
+ *
+ * @return <code>1</code> since the RootView always contains one
+ * child, that is the real root of the View hierarchy
+ */
+ public int getViewCount()
+ {
+ if (view != null)
+ return 1;
+ else
+ return 0;
+ }
+
+ /**
* Returns the <code>Container</code> that contains this view. This
* normally will be the text component that is managed by this TextUI.
*
@@ -244,7 +284,7 @@ public abstract class BasicTextUI extends TextUI
* @return the position in the document that corresponds to the screen
* coordinates <code>x, y</code>
*/
- public int viewToModel(float x, float y, Shape a, Position.Bias b)
+ public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
{
return view.viewToModel(x, y, a, b);
}
@@ -326,7 +366,7 @@ public abstract class BasicTextUI extends TextUI
{
Dimension size = textComponent.getSize();
rootView.changedUpdate(ev, new Rectangle(0, 0, size.width, size.height),
- BasicTextUI.this);
+ rootView.getViewFactory());
}
/**
@@ -338,7 +378,7 @@ public abstract class BasicTextUI extends TextUI
{
Dimension size = textComponent.getSize();
rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height),
- BasicTextUI.this);
+ rootView.getViewFactory());
int caretPos = textComponent.getCaretPosition();
if (caretPos >= ev.getOffset())
textComponent.setCaretPosition(caretPos + ev.getLength());
@@ -353,7 +393,7 @@ public abstract class BasicTextUI extends TextUI
{
Dimension size = textComponent.getSize();
rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height),
- BasicTextUI.this);
+ rootView.getViewFactory());
int caretPos = textComponent.getCaretPosition();
if (caretPos >= ev.getOffset())
textComponent.setCaretPosition(ev.getOffset());
@@ -979,6 +1019,7 @@ public abstract class BasicTextUI extends TextUI
protected final void setView(View view)
{
rootView.setView(view);
+ view.setParent(rootView);
}
/**
@@ -999,6 +1040,7 @@ public abstract class BasicTextUI extends TextUI
Element elem = doc.getDefaultRootElement();
if (elem == null)
return;
- setView(factory.create(elem));
+ View view = factory.create(elem);
+ setView(view);
}
}
diff --git a/javax/swing/plaf/basic/BasicToggleButtonUI.java b/javax/swing/plaf/basic/BasicToggleButtonUI.java
index 84509ad6e..9106b0b66 100644
--- a/javax/swing/plaf/basic/BasicToggleButtonUI.java
+++ b/javax/swing/plaf/basic/BasicToggleButtonUI.java
@@ -56,7 +56,7 @@ public class BasicToggleButtonUI extends BasicButtonUI
*/
protected String getPropertyPrefix()
{
- return "ToggleButton";
+ return "ToggleButton.";
}
}
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
index 74bd6110b..6f714a39c 100644
--- a/javax/swing/plaf/basic/BasicTreeUI.java
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -66,12 +66,16 @@ import java.util.Hashtable;
import javax.swing.AbstractAction;
import javax.swing.Action;
+import javax.swing.ActionMap;
import javax.swing.CellRendererPane;
import javax.swing.Icon;
+import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
+import javax.swing.JTextField;
import javax.swing.JTree;
+import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.UIDefaults;
@@ -86,7 +90,9 @@ import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InputMapUIResource;
import javax.swing.plaf.TreeUI;
+import javax.swing.text.Caret;
import javax.swing.tree.AbstractLayoutCache;
import javax.swing.tree.DefaultTreeCellEditor;
import javax.swing.tree.DefaultTreeCellRenderer;
@@ -179,8 +185,8 @@ public class BasicTreeUI
protected Hashtable drawingCache;
/**
- * True if doing optimizations for a largeModel. Subclasses that don't
- * support this may wish to override createLayoutCache to not return a
+ * True if doing optimizations for a largeModel. Subclasses that don't support
+ * this may wish to override createLayoutCache to not return a
* FixedHeightLayoutCache instance.
*/
protected boolean largeModel;
@@ -195,9 +201,9 @@ public class BasicTreeUI
protected TreeSelectionModel treeSelectionModel;
/**
- * How much the depth should be offset to properly calculate x locations.
- * This is based on whether or not the root is visible, and if the root
- * handles are visible.
+ * How much the depth should be offset to properly calculate x locations. This
+ * is based on whether or not the root is visible, and if the root handles are
+ * visible.
*/
protected int depthOffset;
@@ -218,6 +224,18 @@ public class BasicTreeUI
/** Set to true if the editor has a different size than the renderer. */
protected boolean editorHasDifferentSize;
+ /** The action listener for the editor's Timer. */
+ private Timer editorTimer = new EditorUpdateTimer();
+
+ /** The new value of the node after editing. */
+ private Object newVal;
+
+ /** The action bound to KeyStrokes. */
+ private TreeAction action;
+
+ /** Boolean to keep track of editing. */
+ private boolean isEditing;
+
/** Listeners */
private PropertyChangeListener propertyChangeListener;
@@ -245,10 +263,7 @@ public class BasicTreeUI
public BasicTreeUI()
{
drawingCache = new Hashtable();
- cellEditor = createDefaultCellEditor();
- currentCellRenderer = createDefaultCellRenderer();
nodeDimensions = createNodeDimensions();
- rendererPane = createCellRendererPane();
configureLayoutCache();
propertyChangeListener = createPropertyChangeListener();
@@ -262,8 +277,6 @@ public class BasicTreeUI
treeExpansionListener = createTreeExpansionListener();
treeModelListener = createTreeModelListener();
- createdRenderer = true;
- createdCellEditor = true;
editingRow = -1;
lastSelectedRow = -1;
}
@@ -271,8 +284,8 @@ public class BasicTreeUI
/**
* Returns an instance of the UI delegate for the specified component.
*
- * @param c the <code>JComponent</code> for which we need a UI delegate
- * for.
+ * @param c
+ * the <code>JComponent</code> for which we need a UI delegate for.
* @return the <code>ComponentUI</code> for c.
*/
public static ComponentUI createUI(JComponent c)
@@ -293,18 +306,20 @@ public class BasicTreeUI
/**
* Sets the Hash color.
*
- * @param color the <code>Color</code> to set the Hash to.
+ * @param color
+ * the <code>Color</code> to set the Hash to.
*/
protected void setHashColor(Color color)
{
- // FIXME: not implemented
-
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ defaults.put("Tree.hash", color);
}
/**
* Sets the left child's indent value.
*
- * @param newAmount is the new indent value for the left child.
+ * @param newAmount
+ * is the new indent value for the left child.
*/
public void setLeftChildIndent(int newAmount)
{
@@ -324,7 +339,8 @@ public class BasicTreeUI
/**
* Sets the right child's indent value.
*
- * @param newAmount is the new indent value for the right child.
+ * @param newAmount
+ * is the new indent value for the right child.
*/
public void setRightChildIndent(int newAmount)
{
@@ -344,7 +360,8 @@ public class BasicTreeUI
/**
* Sets the expanded icon.
*
- * @param newG is the new expanded icon.
+ * @param newG
+ * is the new expanded icon.
*/
public void setExpandedIcon(Icon newG)
{
@@ -364,7 +381,8 @@ public class BasicTreeUI
/**
* Sets the collapsed icon.
*
- * @param newG is the new collapsed icon.
+ * @param newG
+ * is the new collapsed icon.
*/
public void setCollapsedIcon(Icon newG)
{
@@ -384,7 +402,8 @@ public class BasicTreeUI
/**
* Updates the componentListener, if necessary.
*
- * @param largeModel sets this.largeModel to it.
+ * @param largeModel
+ * sets this.largeModel to it.
*/
protected void setLargeModel(boolean largeModel)
{
@@ -409,7 +428,8 @@ public class BasicTreeUI
/**
* Sets the row height.
*
- * @param rowHeight is the height to set this.rowHeight to.
+ * @param rowHeight
+ * is the height to set this.rowHeight to.
*/
protected void setRowHeight(int rowHeight)
{
@@ -430,7 +450,8 @@ public class BasicTreeUI
* Sets the TreeCellRenderer to <code>tcr</code>. This invokes
* <code>updateRenderer</code>.
*
- * @param tcr is the new TreeCellRenderer.
+ * @param tcr
+ * is the new TreeCellRenderer.
*/
protected void setCellRenderer(TreeCellRenderer tcr)
{
@@ -456,7 +477,8 @@ public class BasicTreeUI
/**
* Sets the tree's model.
*
- * @param model to set the treeModel to.
+ * @param model
+ * to set the treeModel to.
*/
protected void setModel(TreeModel model)
{
@@ -477,7 +499,8 @@ public class BasicTreeUI
/**
* Sets the root to being visible.
*
- * @param newValue sets the visibility of the root
+ * @param newValue
+ * sets the visibility of the root
*/
protected void setRootVisible(boolean newValue)
{
@@ -497,7 +520,8 @@ public class BasicTreeUI
/**
* Determines whether the node handles are to be displayed.
*
- * @param newValue sets whether or not node handles should be displayed.
+ * @param newValue
+ * sets whether or not node handles should be displayed.
*/
protected void setShowsRootHandles(boolean newValue)
{
@@ -517,11 +541,13 @@ public class BasicTreeUI
/**
* Sets the cell editor.
*
- * @param editor to set the cellEditor to.
+ * @param editor
+ * to set the cellEditor to.
*/
protected void setCellEditor(TreeCellEditor editor)
{
cellEditor = editor;
+ createdCellEditor = true;
}
/**
@@ -537,7 +563,8 @@ public class BasicTreeUI
/**
* Configures the receiver to allow, or not allow, editing.
*
- * @param newValue sets the receiver to allow editing if true.
+ * @param newValue
+ * sets the receiver to allow editing if true.
*/
protected void setEditable(boolean newValue)
{
@@ -558,7 +585,8 @@ public class BasicTreeUI
* Resets the selection model. The appropriate listeners are installed on the
* model.
*
- * @param newLSM resets the selection model.
+ * @param newLSM
+ * resets the selection model.
*/
protected void setSelectionModel(TreeSelectionModel newLSM)
{
@@ -584,16 +612,19 @@ public class BasicTreeUI
* path will be drawn to. Will return null if any component in path is
* currently valid.
*
- * @param tree is the current tree the path will be drawn to.
- * @param path is the current path the tree to draw to.
- * @return the Rectangle enclosing the label portion that the last item in
- * the path will be drawn to.
+ * @param tree
+ * is the current tree the path will be drawn to.
+ * @param path
+ * is the current path the tree to draw to.
+ * @return the Rectangle enclosing the label portion that the last item in the
+ * path will be drawn to.
*/
public Rectangle getPathBounds(JTree tree, TreePath path)
{
if (path != null)
{
Object cell = path.getLastPathComponent();
+
TreeModel mod = tree.getModel();
if (mod != null)
{
@@ -609,13 +640,13 @@ public class BasicTreeUI
}
/**
- * Returns the path for passed in row. If row is not visible null is
- * returned.
+ * Returns the path for passed in row. If row is not visible null is returned.
*
- * @param tree is the current tree to return path for.
- * @param row is the row number of the row to return.
- * @return the path for passed in row. If row is not visible null is
- * returned.
+ * @param tree
+ * is the current tree to return path for.
+ * @param row
+ * is the row number of the row to return.
+ * @return the path for passed in row. If row is not visible null is returned.
*/
public TreePath getPathForRow(JTree tree, int row)
{
@@ -642,24 +673,34 @@ public class BasicTreeUI
* Returns the row that the last item identified in path is visible at. Will
* return -1 if any of the elments in the path are not currently visible.
*
- * @param tree is the current tree to return the row for.
- * @param path is the path used to find the row.
+ * @param tree
+ * is the current tree to return the row for.
+ * @param path
+ * is the path used to find the row.
* @return the row that the last item identified in path is visible at. Will
* return -1 if any of the elments in the path are not currently
* visible.
*/
public int getRowForPath(JTree tree, TreePath path)
{
- // FIXME: check visibility
- // right now, just returns last element because
- // expand/collapse is not implemented
- return path.getPathCount() - 1;
+ int row = path.getPathCount();
+ if (tree.isVisible(path))
+ return row;
+
+ path = path.getParentPath();
+ while (row > 0 && !tree.isVisible(path))
+ {
+ path = path.getParentPath();
+ row--;
+ }
+ return row;
}
/**
* Returns the number of rows that are being displayed.
*
- * @param tree is the current tree to return the number of rows for.
+ * @param tree
+ * is the current tree to return the number of rows for.
* @return the number of rows being displayed.
*/
public int getRowCount(JTree tree)
@@ -688,14 +729,17 @@ public class BasicTreeUI
* valid path. If you need to test if the returned object is exactly at x,y
* you should get the bounds for the returned path and test x,y against that.
*
- * @param tree the tree to search for the closest path
- * @param x is the x coordinate of the location to search
- * @param y is the y coordinate of the location to search
+ * @param tree
+ * the tree to search for the closest path
+ * @param x
+ * is the x coordinate of the location to search
+ * @param y
+ * is the y coordinate of the location to search
* @return the tree path closes to x,y.
*/
public TreePath getClosestPathForLocation(JTree tree, int x, int y)
{
- //FIXME: what if root is hidden? should not depend on (0,0)
+ // FIXME: what if root is hidden? should not depend on (0,0)
// should start counting rows from where root is.
int row = Math.round(y / getRowHeight());
@@ -712,16 +756,16 @@ public class BasicTreeUI
}
/**
- * Returns true if the tree is being edited. The item that is being edited
- * can be returned by getEditingPath().
+ * Returns true if the tree is being edited. The item that is being edited can
+ * be returned by getEditingPath().
*
- * @param tree is the tree to check for editing.
+ * @param tree
+ * is the tree to check for editing.
* @return true if the tree is being edited.
*/
public boolean isEditing(JTree tree)
{
- // FIXME: not implemented
- return false;
+ return isEditing;
}
/**
@@ -729,47 +773,53 @@ public class BasicTreeUI
* being edited. Returns true if the editor allows the editing session to
* stop.
*
- * @param tree is the tree to stop the editing on
+ * @param tree
+ * is the tree to stop the editing on
* @return true if the editor allows the editing session to stop.
*/
public boolean stopEditing(JTree tree)
{
- // FIXME: not implemented
- return false;
+ if (isEditing(tree))
+ completeEditing(true, false, false);
+ return !isEditing(tree);
}
/**
* Cancels the current editing session.
*
- * @param tree is the tree to cancel the editing session on.
+ * @param tree
+ * is the tree to cancel the editing session on.
*/
public void cancelEditing(JTree tree)
{
- // FIXME: not implemented
+ if (isEditing(tree))
+ completeEditing(false, true, false);
}
/**
* Selects the last item in path and tries to edit it. Editing will fail if
* the CellEditor won't allow it for the selected item.
*
- * @param tree is the tree to edit on.
- * @param path is the path in tree to edit on.
+ * @param tree
+ * is the tree to edit on.
+ * @param path
+ * is the path in tree to edit on.
*/
public void startEditingAtPath(JTree tree, TreePath path)
{
- // FIXME: not implemented
+ startEditing(path, null);
}
/**
* Returns the path to the element that is being editted.
*
- * @param tree is the tree to get the editing path from.
+ * @param tree
+ * is the tree to get the editing path from.
* @return the path that is being edited.
*/
public TreePath getEditingPath(JTree tree)
{
- // FIXME: not implemented
- return null;
+ return editingPath;
}
/**
@@ -808,8 +858,8 @@ public class BasicTreeUI
}
/**
- * Creates an instance of NodeDimensions that is able to determine the size
- * of a given node in the tree.
+ * Creates an instance of NodeDimensions that is able to determine the size of
+ * a given node in the tree.
*
* @return the NodeDimensions of a given node in the tree
*/
@@ -946,8 +996,11 @@ public class BasicTreeUI
*/
protected TreeCellEditor createDefaultCellEditor()
{
- return new DefaultTreeCellEditor(
- tree,
+ if (currentCellRenderer != null)
+ return new DefaultTreeCellEditor(tree,
+ (DefaultTreeCellRenderer) currentCellRenderer,
+ cellEditor);
+ return new DefaultTreeCellEditor(tree,
(DefaultTreeCellRenderer) createDefaultCellRenderer(),
cellEditor);
}
@@ -1037,8 +1090,8 @@ public class BasicTreeUI
}
/**
- * Make all the nodes that are expanded in JTree expanded in LayoutCache.
- * This invokes update ExpandedDescendants with the root path.
+ * Make all the nodes that are expanded in JTree expanded in LayoutCache. This
+ * invokes update ExpandedDescendants with the root path.
*/
protected void updateLayoutCacheExpandedNodes()
{
@@ -1050,7 +1103,8 @@ public class BasicTreeUI
* by getting the expanded descendants from the tree and forwarding to the
* tree state.
*
- * @param path the path used to update the expanded states
+ * @param path
+ * the path used to update the expanded states
*/
protected void updateExpandedDescendants(TreePath path)
{
@@ -1060,7 +1114,8 @@ public class BasicTreeUI
/**
* Returns a path to the last child of <code>parent</code>
*
- * @param parent is the topmost path to specified
+ * @param parent
+ * is the topmost path to specified
* @return a path to the last child of parent
*/
protected TreePath getLastChildPath(TreePath parent)
@@ -1078,12 +1133,14 @@ public class BasicTreeUI
/**
* Updates the cellEditor based on editability of the JTree that we're
- * contained in. Ig the tree is editable but doesn't have a cellEditor, a
+ * contained in. If the tree is editable but doesn't have a cellEditor, a
* basic one will be used.
*/
protected void updateCellEditor()
{
- // FIXME: not implemented
+ if (tree.isEditable() && cellEditor == null)
+ setCellEditor(createDefaultCellEditor());
+ createdCellEditor = true;
}
/**
@@ -1127,7 +1184,8 @@ public class BasicTreeUI
/**
* Messaged from the VisibleTreeNode after it has been expanded.
*
- * @param path is the path that has been expanded.
+ * @param path
+ * is the path that has been expanded.
*/
protected void pathWasExpanded(TreePath path)
{
@@ -1145,7 +1203,8 @@ public class BasicTreeUI
/**
* Install all defaults for the tree.
*
- * @param tree is the JTree to install defaults for
+ * @param tree
+ * is the JTree to install defaults for
*/
protected void installDefaults(JTree tree)
{
@@ -1159,6 +1218,7 @@ public class BasicTreeUI
rightChildIndent = defaults.getInt("Tree.rightChildIndent");
leftChildIndent = defaults.getInt("Tree.leftChildIndent");
setRowHeight(defaults.getInt("Tree.rowHeight"));
+ tree.requestFocusInWindow(false);
}
/**
@@ -1166,6 +1226,78 @@ public class BasicTreeUI
*/
protected void installKeyboardActions()
{
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+ InputMap focusInputMap = (InputMap) defaults.get("Tree.focusInputMap");
+ InputMapUIResource parentInputMap = new InputMapUIResource();
+ ActionMap parentActionMap = new ActionMap();
+ action = new TreeAction();
+ Object keys[] = focusInputMap.allKeys();
+
+ for (int i = 0; i < keys.length; i++)
+ {
+ parentInputMap.put(
+ KeyStroke.getKeyStroke(
+ ((KeyStroke) keys[i]).getKeyCode(),
+ convertModifiers(((KeyStroke) keys[i]).getModifiers())),
+ (String) focusInputMap.get((KeyStroke) keys[i]));
+
+ parentInputMap.put(
+ KeyStroke.getKeyStroke(
+ ((KeyStroke) keys[i]).getKeyCode(),
+ ((KeyStroke) keys[i]).getModifiers()),
+ (String) focusInputMap.get((KeyStroke) keys[i]));
+
+ parentActionMap.put(
+ (String) focusInputMap.get((KeyStroke) keys[i]),
+ new ActionListenerProxy(
+ action,
+ (String) focusInputMap.get((KeyStroke) keys[i])));
+
+ }
+
+ parentInputMap.setParent(tree.getInputMap(
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent());
+ parentActionMap.setParent(tree.getActionMap().getParent());
+ tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).setParent(
+ parentInputMap);
+ tree.getActionMap().setParent(parentActionMap);
+ }
+
+ /**
+ * Converts the modifiers.
+ *
+ * @param mod -
+ * modifier to convert
+ * @returns the new modifier
+ */
+ private int convertModifiers(int mod)
+ {
+ if ((mod & KeyEvent.SHIFT_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.SHIFT_MASK;
+ mod &= ~KeyEvent.SHIFT_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.CTRL_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.CTRL_MASK;
+ mod &= ~KeyEvent.CTRL_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.META_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.META_MASK;
+ mod &= ~KeyEvent.META_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.ALT_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.ALT_MASK;
+ mod &= ~KeyEvent.ALT_DOWN_MASK;
+ }
+ if ((mod & KeyEvent.ALT_GRAPH_DOWN_MASK) != 0)
+ {
+ mod |= KeyEvent.ALT_GRAPH_MASK;
+ mod &= ~KeyEvent.ALT_GRAPH_DOWN_MASK;
+ }
+ return mod;
}
/**
@@ -1180,7 +1312,6 @@ public class BasicTreeUI
tree.addKeyListener(keyListener);
tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
tree.addComponentListener(componentListener);
- cellEditor.addCellEditorListener(cellEditorListener);
tree.addTreeExpansionListener(treeExpansionListener);
if (treeModel != null)
treeModel.addTreeModelListener(treeModelListener);
@@ -1189,28 +1320,40 @@ public class BasicTreeUI
/**
* Install the UI for the component
*
- * @param c the component to install UI for
+ * @param c
+ * the component to install UI for
*/
public void installUI(JComponent c)
{
super.installUI(c);
installDefaults((JTree) c);
tree = (JTree) c;
+
+ currentCellRenderer = createDefaultCellRenderer();
+ rendererPane = createCellRendererPane();
+ createdRenderer = true;
+
+ setCellEditor(createDefaultCellEditor());
+ createdCellEditor = true;
+ isEditing = false;
+
TreeModel mod = tree.getModel();
setModel(mod);
tree.setRootVisible(true);
if (mod != null)
tree.expandPath(new TreePath(mod.getRoot()));
treeSelectionModel = tree.getSelectionModel();
- installListeners();
+
installKeyboardActions();
+ installListeners();
completeUIInstall();
}
/**
* Uninstall the defaults for the tree
*
- * @param tree to uninstall defaults for
+ * @param tree
+ * to uninstall defaults for
*/
protected void uninstallDefaults(JTree tree)
{
@@ -1222,7 +1365,8 @@ public class BasicTreeUI
/**
* Uninstall the UI for the component
*
- * @param c the component to uninstall UI for
+ * @param c
+ * the component to uninstall UI for
*/
public void uninstallUI(JComponent c)
{
@@ -1239,15 +1383,19 @@ public class BasicTreeUI
* component is being painted. Subclasses should override this method and use
* the specified Graphics object to render the content of the component.
*
- * @param g the Graphics context in which to paint
- * @param c the component being painted; this argument is often ignored, but
- * might be used if the UI object is stateless and shared by multiple
- * components
+ * @param g
+ * the Graphics context in which to paint
+ * @param c
+ * the component being painted; this argument is often ignored, but
+ * might be used if the UI object is stateless and shared by multiple
+ * components
*/
public void paint(Graphics g, JComponent c)
{
JTree tree = (JTree) c;
+
TreeModel mod = tree.getModel();
+
if (mod != null)
{
Object root = mod.getRoot();
@@ -1265,8 +1413,10 @@ public class BasicTreeUI
/**
* Ensures that the rows identified by beginRow through endRow are visible.
*
- * @param beginRow is the first row
- * @param endRow is the last row
+ * @param beginRow
+ * is the first row
+ * @param endRow
+ * is the last row
*/
protected void ensureRowsAreVisible(int beginRow, int endRow)
{
@@ -1276,7 +1426,8 @@ public class BasicTreeUI
/**
* Sets the preferred minimum size.
*
- * @param newSize is the new preferred minimum size.
+ * @param newSize
+ * is the new preferred minimum size.
*/
public void setPreferredMinSize(Dimension newSize)
{
@@ -1298,9 +1449,10 @@ public class BasicTreeUI
* Returns the preferred size to properly display the tree, this is a cover
* method for getPreferredSize(c, false).
*
- * @param c the component whose preferred size is being queried; this
- * argument is often ignored but might be used if the UI object is
- * stateless and shared by multiple components
+ * @param c
+ * the component whose preferred size is being queried; this argument
+ * is often ignored but might be used if the UI object is stateless
+ * and shared by multiple components
* @return the preferred size
*/
public Dimension getPreferredSize(JComponent c)
@@ -1312,8 +1464,10 @@ public class BasicTreeUI
* Returns the preferred size to represent the tree in c. If checkConsistancy
* is true, checkConsistancy is messaged first.
*
- * @param c the component whose preferred size is being queried.
- * @param checkConsistancy if true must check consistancy
+ * @param c
+ * the component whose preferred size is being queried.
+ * @param checkConsistancy
+ * if true must check consistancy
* @return the preferred size
*/
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy)
@@ -1333,8 +1487,7 @@ public class BasicTreeUI
count++;
Object nextNode = getNextVisibleNode(node);
if (nextNode != null)
- maxWidth = Math.max(
- maxWidth,
+ maxWidth = Math.max(maxWidth,
(int) (getCellBounds(0, 0, nextNode).getWidth()));
node = nextNode;
}
@@ -1347,7 +1500,8 @@ public class BasicTreeUI
* Returns the minimum size for this component. Which will be the min
* preferred size or (0,0).
*
- * @param c the component whose min size is being queried.
+ * @param c
+ * the component whose min size is being queried.
* @returns the preferred size or null
*/
public Dimension getMinimumSize(JComponent c)
@@ -1360,7 +1514,8 @@ public class BasicTreeUI
* Returns the maximum size for the component, which will be the preferred
* size if the instance is currently in JTree or (0,0).
*
- * @param c the component whose preferred size is being queried
+ * @param c
+ * the component whose preferred size is being queried
* @return the max size or null
*/
public Dimension getMaximumSize(JComponent c)
@@ -1378,7 +1533,7 @@ public class BasicTreeUI
*/
protected void completeEditing()
{
- // FIXME: not implemented
+ completeEditing(false, true, false);
}
/**
@@ -1387,37 +1542,94 @@ public class BasicTreeUI
* cancelEditing. If messageTree is true, the treeModel is messaged with
* valueForPathChanged.
*
- * @param messageStop message to stop editing
- * @param messageCancel message to cancel editing
- * @param messageTree message to treeModel
+ * @param messageStop
+ * message to stop editing
+ * @param messageCancel
+ * message to cancel editing
+ * @param messageTree
+ * message to treeModel
*/
protected void completeEditing(boolean messageStop, boolean messageCancel,
boolean messageTree)
{
- // FIXME: not implemented
+ if (messageStop)
+ {
+ getCellEditor().stopCellEditing();
+ stopEditingInCompleteEditing = true;
+ }
+
+ if (messageCancel)
+ {
+ getCellEditor().cancelCellEditing();
+ stopEditingInCompleteEditing = true;
+ }
+
+ if (messageTree)
+ tree.getModel().valueForPathChanged(tree.getLeadSelectionPath(), newVal);
}
/**
* Will start editing for node if there is a cellEditor and shouldSelectCall
* returns true. This assumes that path is valid and visible.
*
- * @param path is the path to start editing
- * @param event is the MouseEvent performed on the path
+ * @param path
+ * is the path to start editing
+ * @param event
+ * is the MouseEvent performed on the path
* @return true if successful
*/
protected boolean startEditing(TreePath path, MouseEvent event)
{
- // FIXME: not implemented
+ int x;
+ int y;
+ if (event == null)
+ {
+ Rectangle bounds = getPathBounds(tree, path);
+ x = bounds.x;
+ y = bounds.y;
+ }
+ else
+ {
+ x = event.getX();
+ y = event.getY();
+ }
+
+ updateCellEditor();
+ TreeCellEditor ed = getCellEditor();
+ if (ed != null && ed.shouldSelectCell(event) && ed.isCellEditable(event))
+ {
+ editingPath = path;
+ editingRow = tree.getRowForPath(editingPath);
+ Object val = editingPath.getLastPathComponent();
+ cellEditor.addCellEditorListener(cellEditorListener);
+ stopEditingInCompleteEditing = false;
+ boolean expanded = tree.isExpanded(editingPath);
+ isEditing = true;
+ editingComponent = ed.getTreeCellEditorComponent(tree, val, true,
+ expanded,
+ isLeaf(editingRow),
+ editingRow);
+ editingComponent.getParent().setVisible(true);
+ editingComponent.getParent().validate();
+ tree.add(editingComponent.getParent());
+ editingComponent.getParent().validate();
+ ((JTextField) editingComponent).requestFocusInWindow(false);
+ editorTimer.start();
+ return true;
+ }
return false;
}
/**
- * If the <code>mouseX</code> and <code>mouseY</code> are in the expand
- * or collapse region of the row, this will toggle the row.
+ * If the <code>mouseX</code> and <code>mouseY</code> are in the expand or
+ * collapse region of the row, this will toggle the row.
*
- * @param path the path we are concerned with
- * @param mouseX is the cursor's x position
- * @param mouseY is the cursor's y position
+ * @param path
+ * the path we are concerned with
+ * @param mouseX
+ * is the cursor's x position
+ * @param mouseY
+ * is the cursor's y position
*/
protected void checkForClickInExpandControl(TreePath path, int mouseX,
int mouseY)
@@ -1426,15 +1638,18 @@ public class BasicTreeUI
}
/**
- * Returns true if the <code>mouseX</code> and <code>mouseY</code> fall
- * in the area of row that is used to expand/collpse the node and the node at
- * row does not represent a leaf.
+ * Returns true if the <code>mouseX</code> and <code>mouseY</code> fall in
+ * the area of row that is used to expand/collpse the node and the node at row
+ * does not represent a leaf.
*
- * @param path the path we are concerned with
- * @param mouseX is the cursor's x position
- * @param mouseY is the cursor's y position
- * @return true if the <code>mouseX</code> and <code>mouseY</code> fall
- * in the area of row that is used to expand/collpse the node and the
+ * @param path
+ * the path we are concerned with
+ * @param mouseX
+ * is the cursor's x position
+ * @param mouseY
+ * is the cursor's y position
+ * @return true if the <code>mouseX</code> and <code>mouseY</code> fall in
+ * the area of row that is used to expand/collpse the node and the
* node at row does not represent a leaf.
*/
protected boolean isLocationInExpandControl(TreePath path, int mouseX,
@@ -1448,9 +1663,12 @@ public class BasicTreeUI
* Messaged when the user clicks the particular row, this invokes
* toggleExpandState.
*
- * @param path the path we are concerned with
- * @param mouseX is the cursor's x position
- * @param mouseY is the cursor's y position
+ * @param path
+ * the path we are concerned with
+ * @param mouseX
+ * is the cursor's x position
+ * @param mouseY
+ * is the cursor's y position
*/
protected void handleExpandControlClick(TreePath path, int mouseX, int mouseY)
{
@@ -1463,7 +1681,8 @@ public class BasicTreeUI
* invoked to scroll as many of the children to visible as possible (tries to
* scroll to last visible descendant of path).
*
- * @param path the path we are concerned with
+ * @param path
+ * the path we are concerned with
*/
protected void toggleExpandState(TreePath path)
{
@@ -1474,7 +1693,8 @@ public class BasicTreeUI
* Returning true signifies a mouse event on the node should toggle the
* selection of only the row under the mouse.
*
- * @param event is the MouseEvent performed on the row.
+ * @param event
+ * is the MouseEvent performed on the row.
* @return true signifies a mouse event on the node should toggle the
* selection of only the row under the mouse.
*/
@@ -1488,7 +1708,8 @@ public class BasicTreeUI
* Returning true signifies a mouse event on the node should select from the
* anchor point.
*
- * @param event is the MouseEvent performed on the node.
+ * @param event
+ * is the MouseEvent performed on the node.
* @return true signifies a mouse event on the node should select from the
* anchor point.
*/
@@ -1499,11 +1720,12 @@ public class BasicTreeUI
}
/**
- * Returning true indicates the row under the mouse should be toggled based
- * on the event. This is invoked after checkForClickInExpandControl, implying
- * the location is not in the expand (toggle) control.
+ * Returning true indicates the row under the mouse should be toggled based on
+ * the event. This is invoked after checkForClickInExpandControl, implying the
+ * location is not in the expand (toggle) control.
*
- * @param event is the MouseEvent performed on the row.
+ * @param event
+ * is the MouseEvent performed on the row.
* @return true indicates the row under the mouse should be toggled based on
* the event.
*/
@@ -1517,12 +1739,13 @@ public class BasicTreeUI
* Messaged to update the selection based on a MouseEvent over a particular
* row. If the even is a toggle selection event, the row is either selected,
* or deselected. If the event identifies a multi selection event, the
- * selection is updated from the anchor point. Otherwise, the row is
- * selected, and if the even specified a toggle event the row is
- * expanded/collapsed.
+ * selection is updated from the anchor point. Otherwise, the row is selected,
+ * and if the even specified a toggle event the row is expanded/collapsed.
*
- * @param path is the path selected for an event
- * @param event is the MouseEvent performed on the path.
+ * @param path
+ * is the path selected for an event
+ * @param event
+ * is the MouseEvent performed on the path.
*/
protected void selectPathForEvent(TreePath path, MouseEvent event)
{
@@ -1532,7 +1755,8 @@ public class BasicTreeUI
/**
* Returns true if the node at <code>row</code> is a leaf.
*
- * @param row is the row we are concerned with.
+ * @param row
+ * is the row we are concerned with.
* @return true if the node at <code>row</code> is a leaf.
*/
protected boolean isLeaf(int row)
@@ -1546,6 +1770,154 @@ public class BasicTreeUI
}
/**
+ * This class implements the actions that we want to happen when specific keys
+ * are pressed for the JTree. The actionPerformed method is called when a key
+ * that has been registered for the JTree is received.
+ */
+ class TreeAction
+ extends AbstractAction
+ {
+
+ /**
+ * What to do when this action is called.
+ *
+ * @param e
+ * the ActionEvent that caused this action.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ TreePath lead = tree.getLeadSelectionPath();
+
+ if (e.getActionCommand().equals("selectPreviousChangeLead")
+ || e.getActionCommand().equals("selectPreviousExtendSelection")
+ || e.getActionCommand().equals("selectPrevious")
+ || e.getActionCommand().equals("selectNext")
+ || e.getActionCommand().equals("selectNextExtendSelection")
+ || e.getActionCommand().equals("selectNextChangeLead"))
+ (new TreeIncrementAction(0, "")).actionPerformed(e);
+ else if (e.getActionCommand().equals("selectParent")
+ || e.getActionCommand().equals("selectChild"))
+ (new TreeTraverseAction(0, "")).actionPerformed(e);
+ else if (e.getActionCommand().equals("selectAll"))
+ {
+ TreePath[] paths = new TreePath[tree.getRowCount()];
+
+ Object curr = getNextVisibleNode(tree.getModel().getRoot());
+ int i = 0;
+ while (curr != null && i < paths.length)
+ {
+ paths[i] = new TreePath(getPathToRoot(curr, 0));
+ i++;
+ }
+
+ tree.addSelectionPaths(paths);
+ }
+ else if (e.getActionCommand().equals("startEditing"))
+ tree.startEditingAtPath(lead);
+ else if (e.getActionCommand().equals("toggle"))
+ {
+ if (tree.isEditing())
+ tree.stopEditing();
+ else
+ {
+ Object last = lead.getLastPathComponent();
+ TreePath path = new TreePath(getPathToRoot(last, 0));
+ if (!tree.getModel().isLeaf(last))
+ {
+ if (tree.isExpanded(path))
+ tree.collapsePath(path);
+ else
+ tree.expandPath(path);
+ }
+ }
+ }
+ else if (e.getActionCommand().equals("clearSelection"))
+ tree.clearSelection();
+
+ if (tree.isEditing() && !e.getActionCommand().equals("startEditing"))
+ tree.cancelEditing();
+
+ tree.scrollPathToVisible(lead);
+ }
+ }
+
+ /**
+ * This class is used to mimic the behaviour of the JDK when registering
+ * keyboard actions. It is the same as the private class used in JComponent
+ * for the same reason. This class receives an action event and dispatches it
+ * to the true receiver after altering the actionCommand property of the
+ * event.
+ */
+ private static class ActionListenerProxy
+ extends AbstractAction
+ {
+ ActionListener target;
+
+ String bindingCommandName;
+
+ public ActionListenerProxy(ActionListener li, String cmd)
+ {
+ target = li;
+ bindingCommandName = cmd;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ ActionEvent derivedEvent = new ActionEvent(e.getSource(), e.getID(),
+ bindingCommandName,
+ e.getModifiers());
+
+ target.actionPerformed(derivedEvent);
+ }
+ }
+
+ /**
+ * The timer that updates the editor component.
+ */
+ private class EditorUpdateTimer
+ extends Timer
+ implements ActionListener
+ {
+ /**
+ * Creates a new EditorUpdateTimer object with a default delay of 0.3
+ * seconds.
+ */
+ public EditorUpdateTimer()
+ {
+ super(300, null);
+ addActionListener(this);
+ }
+
+ /**
+ * Lets the caret blink and repaints the table.
+ */
+ public void actionPerformed(ActionEvent ev)
+ {
+ Caret c = ((JTextField) editingComponent).getCaret();
+ if (c != null)
+ c.setVisible(!c.isVisible());
+ tree.repaint();
+ }
+
+ /**
+ * Updates the blink delay according to the current caret.
+ */
+ public void update()
+ {
+ stop();
+ Caret c = ((JTextField) editingComponent).getCaret();
+ if (c != null)
+ {
+ setDelay(c.getBlinkRate());
+ if (((JTextField) editingComponent).isEditable())
+ start();
+ else
+ c.setVisible(false);
+ }
+ }
+ }
+
+ /**
* Updates the preferred size when scrolling, if necessary.
*/
public class ComponentHandler
@@ -1570,15 +1942,16 @@ public class BasicTreeUI
/**
* Invoked when the component's position changes.
*
- * @param e the event that occurs when moving the component
+ * @param e
+ * the event that occurs when moving the component
*/
public void componentMoved(ComponentEvent e)
{
}
/**
- * Creats, if necessary, and starts a Timer to check if needed to resize
- * the bounds
+ * Creats, if necessary, and starts a Timer to check if needed to resize the
+ * bounds
*/
protected void startTimer()
{
@@ -1595,10 +1968,11 @@ public class BasicTreeUI
}
/**
- * Public as a result of Timer. If the scrollBar is null, or not
- * adjusting, this stops the timer and updates the sizing.
+ * Public as a result of Timer. If the scrollBar is null, or not adjusting,
+ * this stops the timer and updates the sizing.
*
- * @param ae is the action performed
+ * @param ae
+ * is the action performed
*/
public void actionPerformed(ActionEvent ae)
{
@@ -1623,20 +1997,61 @@ public class BasicTreeUI
* Messaged when editing has stopped in the tree. Tells the listeners
* editing has stopped.
*
- * @param e is the notification event
+ * @param e
+ * is the notification event
*/
public void editingStopped(ChangeEvent e)
{
+ editingPath = null;
+ editingRow = -1;
+ stopEditingInCompleteEditing = false;
+ if (editingComponent != null)
+ {
+ tree.remove(editingComponent.getParent());
+ editingComponent = null;
+ }
+ if (cellEditor != null)
+ {
+ newVal = ((JTextField) getCellEditor().getCellEditorValue()).getText();
+ completeEditing(false, false, true);
+ if (cellEditor instanceof DefaultTreeCellEditor)
+ tree.removeTreeSelectionListener((DefaultTreeCellEditor) cellEditor);
+ cellEditor.removeCellEditorListener(cellEditorListener);
+ setCellEditor(null);
+ createdCellEditor = false;
+ }
+ isEditing = false;
+ tree.requestFocusInWindow(false);
+ editorTimer.stop();
}
/**
* Messaged when editing has been canceled in the tree. This tells the
* listeners the editor has canceled editing.
*
- * @param e is the notification event
+ * @param e
+ * is the notification event
*/
public void editingCanceled(ChangeEvent e)
{
+ editingPath = null;
+ editingRow = -1;
+ stopEditingInCompleteEditing = false;
+ if (editingComponent != null)
+ tree.remove(editingComponent.getParent());
+ editingComponent = null;
+ if (cellEditor != null)
+ {
+ if (cellEditor instanceof DefaultTreeCellEditor)
+ tree.removeTreeSelectionListener((DefaultTreeCellEditor) cellEditor);
+ cellEditor.removeCellEditorListener(cellEditorListener);
+ setCellEditor(null);
+ createdCellEditor = false;
+ }
+ tree.requestFocusInWindow(false);
+ editorTimer.stop();
+ isEditing = false;
+ tree.repaint();
}
}// CellEditorHandler
@@ -1657,17 +2072,19 @@ public class BasicTreeUI
* Invoked when focus is activated on the tree we're in, redraws the lead
* row. Invoked when a component gains the keyboard focus.
*
- * @param e is the focus event that is activated
+ * @param e
+ * is the focus event that is activated
*/
public void focusGained(FocusEvent e)
{
}
/**
- * Invoked when focus is deactivated on the tree we're in, redraws the
- * lead row. Invoked when a component loses the keyboard focus.
+ * Invoked when focus is deactivated on the tree we're in, redraws the lead
+ * row. Invoked when a component loses the keyboard focus.
*
- * @param e is the focus event that is deactivated
+ * @param e
+ * is the focus event that is deactivated
*/
public void focusLost(FocusEvent e)
{
@@ -1695,12 +2112,13 @@ public class BasicTreeUI
}
/**
- * Invoked when a key has been typed. Moves the keyboard focus to the
- * first element whose first letter matches the alphanumeric key pressed
- * by the user. Subsequent same key presses move the keyboard focus to the
- * next object that starts with the same letter.
+ * Invoked when a key has been typed. Moves the keyboard focus to the first
+ * element whose first letter matches the alphanumeric key pressed by the
+ * user. Subsequent same key presses move the keyboard focus to the next
+ * object that starts with the same letter.
*
- * @param e the key typed
+ * @param e
+ * the key typed
*/
public void keyTyped(KeyEvent e)
{
@@ -1709,164 +2127,18 @@ public class BasicTreeUI
/**
* Invoked when a key has been pressed.
*
- * @param e the key pressed
+ * @param e
+ * the key pressed
*/
public void keyPressed(KeyEvent e)
{
- TreeModel mod = BasicTreeUI.this.tree.getModel();
- TreePath start = BasicTreeUI.this.tree.getLeadSelectionPath();
- Object last = null;
- if (start != null)
- last = start.getLastPathComponent();
-
- if (last != null)
- {
- // DOWN, KP_DOWN
- if (e.getKeyCode() == KeyEvent.VK_DOWN
- || e.getKeyCode() == KeyEvent.VK_KP_DOWN)
- {
- Object next = BasicTreeUI.this.getNextVisibleNode(last);
- if (next != null)
- {
- TreePath newPath = new TreePath(getPathToRoot(next, 0));
- BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, newPath);
- if (e.isControlDown())
- tree.setLeadSelectionPath(newPath);
- else if (!mod.isLeaf(next) && e.isShiftDown())
- {
- BasicTreeUI.this.tree.expandPath(newPath);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillExpand(newPath);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeExpanded(newPath);
- }
- }
- }
- // UP, KP_UP
- else if (e.getKeyCode() == KeyEvent.VK_UP
- || e.getKeyCode() == KeyEvent.VK_KP_UP)
- {
- Object prev = BasicTreeUI.this.getPreviousVisibleNode(last);
-
- if (prev != null)
- {
- TreePath newPath = new TreePath(getPathToRoot(prev, 0));
- BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
- new TreePath(getPathToRoot(prev,
- 0)));
- if (e.isControlDown())
- tree.setLeadSelectionPath(newPath);
- else if (!mod.isLeaf(prev) && e.isShiftDown())
- {
- BasicTreeUI.this.tree.expandPath(newPath);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillExpand(newPath);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeExpanded(newPath);
- }
- }
- }
- // LEFT, KP_LEFT
- else if (e.getKeyCode() == KeyEvent.VK_LEFT
- || e.getKeyCode() == KeyEvent.VK_KP_LEFT)
- {
- TreePath path = new TreePath(getPathToRoot(last, 0));
- Object p = getParent(mod.getRoot(), last);
-
- if (!mod.isLeaf(last) && BasicTreeUI.this.tree.isExpanded(path))
- {
- BasicTreeUI.this.tree.collapsePath(path);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillCollapse(path);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeCollapsed(path);
- }
- else if (p != null)
- BasicTreeUI.this.selectPath(BasicTreeUI.this.tree,
- new TreePath(getPathToRoot(p, 0)));
- }
- // RIGHT, KP_RIGHT
- else if (e.getKeyCode() == KeyEvent.VK_RIGHT
- || e.getKeyCode() == KeyEvent.VK_KP_RIGHT)
- {
- TreePath path = new TreePath(getPathToRoot(last, 0));
-
- if (!mod.isLeaf(last) && BasicTreeUI.this.tree.isCollapsed(path))
- {
- BasicTreeUI.this.tree.expandPath(path);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillExpand(path);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeExpanded(path);
- }
- else
- {
- Object next = BasicTreeUI.this.getNextVisibleNode(last);
-
- if (next != null)
- BasicTreeUI.this.selectPath(
- BasicTreeUI.this.tree,
- new TreePath(
- getPathToRoot(
- next,
- 0)));
- }
- }
- // Enter
- else if (e.getKeyCode() == KeyEvent.VK_ENTER)
- {
- TreePath path = new TreePath(getPathToRoot(last, 0));
- if (!mod.isLeaf(last))
- {
- if (BasicTreeUI.this.tree.isExpanded(path))
- {
- BasicTreeUI.this.tree.collapsePath(path);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillCollapse(path);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeCollapsed(path);
- }
- else
- {
- BasicTreeUI.this.tree.expandPath(path);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillExpand(path);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeExpanded(path);
- }
- }
- }
- }
}
/**
* Invoked when a key has been released
*
- * @param e the key released
+ * @param e
+ * the key released
*/
public void keyReleased(KeyEvent e)
{
@@ -1874,7 +2146,7 @@ public class BasicTreeUI
}// KeyHandler
/**
- * MouseListener is responsible for updating the selevtion based on mouse
+ * MouseListener is responsible for updating the selection based on mouse
* events.
*/
public class MouseHandler
@@ -1891,7 +2163,8 @@ public class BasicTreeUI
/**
* Invoked when a mouse button has been pressed on a component.
*
- * @param e is the mouse event that occured
+ * @param e
+ * is the mouse event that occured
*/
public void mousePressed(MouseEvent e)
{
@@ -1899,12 +2172,12 @@ public class BasicTreeUI
/**
* Invoked when a mouse button is pressed on a component and then dragged.
- * MOUSE_DRAGGED events will continue to be delivered to the component
- * where the drag originated until the mouse button is released
- * (regardless of whether the mouse position is within the bounds of the
- * component).
+ * MOUSE_DRAGGED events will continue to be delivered to the component where
+ * the drag originated until the mouse button is released (regardless of
+ * whether the mouse position is within the bounds of the component).
*
- * @param e is the mouse event that occured
+ * @param e
+ * is the mouse event that occured
*/
public void mouseDragged(MouseEvent e)
{
@@ -1914,7 +2187,8 @@ public class BasicTreeUI
* Invoked when the mouse button has been moved on a component (with no
* buttons no down).
*
- * @param e the mouse event that occured
+ * @param e
+ * the mouse event that occured
*/
public void mouseMoved(MouseEvent e)
{
@@ -1923,7 +2197,8 @@ public class BasicTreeUI
/**
* Invoked when a mouse button has been released on a component.
*
- * @param e is the mouse event that occured
+ * @param e
+ * is the mouse event that occured
*/
public void mouseReleased(MouseEvent e)
{
@@ -1944,18 +2219,15 @@ public class BasicTreeUI
/** Destination that receives all events. */
protected Component destination;
- /** Number of mouse clicks on a non-leaf */
- private int clickCount = 0;
-
- /** The last non-leaf cell that was clicked */
- private Object lastClicked = null;
-
/**
* Constructor
*
- * @param source that events are coming from
- * @param destination that receives all events
- * @param e is the event received
+ * @param source
+ * that events are coming from
+ * @param destination
+ * that receives all events
+ * @param e
+ * is the event received
*/
public MouseInputHandler(Component source, Component destination,
MouseEvent e)
@@ -1963,99 +2235,67 @@ public class BasicTreeUI
}
/**
- * Invoked when the mouse button has been clicked (pressed and released)
- * on a component.
+ * Invoked when the mouse button has been clicked (pressed and released) on
+ * a component.
*
- * @param e mouse event that occured
+ * @param e
+ * mouse event that occured
*/
public void mouseClicked(MouseEvent e)
{
+ }
+
+ /**
+ * Invoked when a mouse button has been pressed on a component.
+ *
+ * @param e
+ * mouse event that occured
+ */
+ public void mousePressed(MouseEvent e)
+ {
Point click = e.getPoint();
- int row = Math.round(click.y / BasicTreeUI.this.getRowHeight());
- TreePath path = BasicTreeUI.this.getClosestPathForLocation(tree, click.x,
- click.y);
+ int row = Math.round(click.y / getRowHeight());
+ TreePath path = getClosestPathForLocation(tree, click.x, click.y);
if (path != null)
{
boolean inBounds = false;
boolean cntlClick = false;
- Rectangle bounds = BasicTreeUI.this.getPathBounds(
- BasicTreeUI.this.tree,
- path);
+ Rectangle bounds = getPathBounds(tree, path);
bounds.x -= rightChildIndent - 4;
bounds.width += rightChildIndent + 4;
if (bounds.contains(click.x, click.y))
inBounds = true;
- else if (BasicTreeUI.this.hasControlIcons()
- && (click.x < (bounds.x - rightChildIndent + 5) && click.x > (bounds.x
- - rightChildIndent - 5)))
+ else if (hasControlIcons()
+ && (click.x < (bounds.x - rightChildIndent + 5) &&
+ click.x > (bounds.x - rightChildIndent - 5)))
cntlClick = true;
- if ((inBounds || cntlClick) && BasicTreeUI.this.tree.isVisible(path))
+ if ((inBounds || cntlClick) && tree.isVisible(path))
{
- if (!cntlClick && !BasicTreeUI.this.isLeaf(row))
- {
- Object cell = path.getLastPathComponent();
- if (lastClicked != null && lastClicked.equals(cell))
- clickCount = 2;
- else
- {
- lastClicked = cell;
- clickCount = 1;
- }
- }
+ selectPath(tree, path);
- if (clickCount == 2 || cntlClick == true)
+ if ((e.getClickCount() == 2 || cntlClick) && !isLeaf(row))
{
- clickCount = 0;
- lastClicked = null;
- BasicTreeUI.this.tree.getSelectionModel().clearSelection();
- if (BasicTreeUI.this.tree.isExpanded(path))
- {
- BasicTreeUI.this.tree.collapsePath(path);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillCollapse(path);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeCollapsed(path);
- }
+ if (tree.isExpanded(path))
+ tree.collapsePath(path);
else
- {
- BasicTreeUI.this.tree.expandPath(path);
- try
- {
- BasicTreeUI.this.tree.fireTreeWillExpand(path);
- }
- catch (ExpandVetoException ev)
- {
- }
- BasicTreeUI.this.tree.fireTreeExpanded(path);
- }
+ tree.expandPath(path);
}
- BasicTreeUI.this.selectPath(BasicTreeUI.this.tree, path);
+ if (!cntlClick && tree.isEditable())
+ startEditing(path, e);
}
}
}
/**
- * Invoked when a mouse button has been pressed on a component.
- *
- * @param e mouse event that occured
- */
- public void mousePressed(MouseEvent e)
- {
- }
-
- /**
* Invoked when a mouse button has been released on a component.
*
- * @param e mouse event that occured
+ * @param e
+ * mouse event that occured
*/
public void mouseReleased(MouseEvent e)
{
@@ -2064,7 +2304,8 @@ public class BasicTreeUI
/**
* Invoked when the mouse enters a component.
*
- * @param e mouse event that occured
+ * @param e
+ * mouse event that occured
*/
public void mouseEntered(MouseEvent e)
{
@@ -2073,7 +2314,8 @@ public class BasicTreeUI
/**
* Invoked when the mouse exits a component.
*
- * @param e mouse event that occured
+ * @param e
+ * mouse event that occured
*/
public void mouseExited(MouseEvent e)
{
@@ -2081,12 +2323,12 @@ public class BasicTreeUI
/**
* Invoked when a mouse button is pressed on a component and then dragged.
- * MOUSE_DRAGGED events will continue to be delivered to the component
- * where the drag originated until the mouse button is released
- * (regardless of whether the mouse position is within the bounds of the
- * component).
+ * MOUSE_DRAGGED events will continue to be delivered to the component where
+ * the drag originated until the mouse button is released (regardless of
+ * whether the mouse position is within the bounds of the component).
*
- * @param e mouse event that occured
+ * @param e
+ * mouse event that occured
*/
public void mouseDragged(MouseEvent e)
{
@@ -2096,7 +2338,8 @@ public class BasicTreeUI
* Invoked when the mouse cursor has been moved onto a component but no
* buttons have been pushed.
*
- * @param e mouse event that occured
+ * @param e
+ * mouse event that occured
*/
public void mouseMoved(MouseEvent e)
{
@@ -2128,13 +2371,17 @@ public class BasicTreeUI
/**
* Responsible for getting the size of a particular node.
*
- * @param value the value to be represented
- * @param row row being queried
- * @param depth the depth of the row
- * @param expanded true if row is expanded
- * @param size a Rectangle containing the size needed to represent value
- * @return containing the node dimensions, or null if node has no
- * dimension
+ * @param value
+ * the value to be represented
+ * @param row
+ * row being queried
+ * @param depth
+ * the depth of the row
+ * @param expanded
+ * true if row is expanded
+ * @param size
+ * a Rectangle containing the size needed to represent value
+ * @return containing the node dimensions, or null if node has no dimension
*/
public Rectangle getNodeDimensions(Object value, int row, int depth,
boolean expanded, Rectangle size)
@@ -2171,8 +2418,9 @@ public class BasicTreeUI
/**
* This method gets called when a bound property is changed.
*
- * @param event A PropertyChangeEvent object describing the event source
- * and the property that has changed.
+ * @param event
+ * A PropertyChangeEvent object describing the event source and the
+ * property that has changed.
*/
public void propertyChange(PropertyChangeEvent event)
{
@@ -2197,8 +2445,9 @@ public class BasicTreeUI
/**
* This method gets called when a bound property is changed.
*
- * @param event A PropertyChangeEvent object describing the event source
- * and the property that has changed.
+ * @param event
+ * A PropertyChangeEvent object describing the event source and the
+ * property that has changed.
*/
public void propertyChange(PropertyChangeEvent event)
{
@@ -2222,7 +2471,8 @@ public class BasicTreeUI
/**
* Invoked when an action occurs.
*
- * @param e event that occured
+ * @param e
+ * event that occured
*/
public void actionPerformed(ActionEvent e)
{
@@ -2256,27 +2506,29 @@ public class BasicTreeUI
/**
* Called whenever an item in the tree has been expanded.
*
- * @param event is the event that occured
+ * @param event
+ * is the event that occured
*/
public void treeExpanded(TreeExpansionEvent event)
{
- BasicTreeUI.this.tree.repaint();
+ tree.repaint();
}
/**
* Called whenever an item in the tree has been collapsed.
*
- * @param event is the event that occured
+ * @param event
+ * is the event that occured
*/
public void treeCollapsed(TreeExpansionEvent event)
{
- BasicTreeUI.this.tree.repaint();
+ tree.repaint();
}
}// TreeExpansionHandler
/**
- * TreeHomeAction is used to handle end/home actions. Scrolls either the
- * first or last cell to be visible based on direction.
+ * TreeHomeAction is used to handle end/home actions. Scrolls either the first
+ * or last cell to be visible based on direction.
*/
public class TreeHomeAction
extends AbstractAction
@@ -2288,8 +2540,10 @@ public class BasicTreeUI
/**
* Constructor
*
- * @param direction - it is home or end
- * @param name is the name of the direction
+ * @param direction -
+ * it is home or end
+ * @param name
+ * is the name of the direction
*/
public TreeHomeAction(int direction, String name)
{
@@ -2298,7 +2552,8 @@ public class BasicTreeUI
/**
* Invoked when an action occurs.
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void actionPerformed(ActionEvent e)
{
@@ -2329,8 +2584,10 @@ public class BasicTreeUI
/**
* Constructor
*
- * @param direction up or down
- * @param name is the name of the direction
+ * @param direction
+ * up or down
+ * @param name
+ * is the name of the direction
*/
public TreeIncrementAction(int direction, String name)
{
@@ -2339,10 +2596,72 @@ public class BasicTreeUI
/**
* Invoked when an action occurs.
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void actionPerformed(ActionEvent e)
{
+ Object last = tree.getLeadSelectionPath().getLastPathComponent();
+
+ if (e.getActionCommand().equals("selectPreviousChangeLead"))
+ {
+ Object prev = getPreviousVisibleNode(last);
+
+ if (prev != null)
+ {
+ TreePath newPath = new TreePath(getPathToRoot(prev, 0));
+ selectPath(tree, new TreePath(getPathToRoot(prev, 0)));
+ tree.setLeadSelectionPath(newPath);
+ }
+ }
+ else if (e.getActionCommand().equals("selectPreviousExtendSelection"))
+ {
+ Object prev = getPreviousVisibleNode(last);
+ if (prev != null)
+ {
+ TreePath newPath = new TreePath(getPathToRoot(prev, 0));
+ tree.addSelectionPath(newPath);
+ tree.setLeadSelectionPath(newPath);
+ }
+ }
+ else if (e.getActionCommand().equals("selectPrevious"))
+ {
+ Object prev = getPreviousVisibleNode(last);
+ if (prev != null)
+ {
+ TreePath newPath = new TreePath(getPathToRoot(prev, 0));
+ selectPath(tree, new TreePath(getPathToRoot(prev, 0)));
+ }
+ }
+ else if (e.getActionCommand().equals("selectNext"))
+ {
+ Object next = getNextVisibleNode(last);
+ if (next != null)
+ {
+ TreePath newPath = new TreePath(getPathToRoot(next, 0));
+ selectPath(tree, newPath);
+ }
+ }
+ else if (e.getActionCommand().equals("selectNextExtendSelection"))
+ {
+ Object next = getNextVisibleNode(last);
+ if (next != null)
+ {
+ TreePath newPath = new TreePath(getPathToRoot(next, 0));
+ tree.addSelectionPath(newPath);
+ tree.setLeadSelectionPath(newPath);
+ }
+ }
+ else if (e.getActionCommand().equals("selectNextChangeLead"))
+ {
+ Object next = getNextVisibleNode(last);
+ if (next != null)
+ {
+ TreePath newPath = new TreePath(getPathToRoot(next, 0));
+ selectPath(tree, newPath);
+ tree.setLeadSelectionPath(newPath);
+ }
+ }
}
/**
@@ -2370,44 +2689,50 @@ public class BasicTreeUI
}
/**
- * Invoked after a node (or a set of siblings) has changed in some way.
- * The node(s) have not changed locations in the tree or altered their
- * children arrays, but other attributes have changed and may affect
- * presentation. Example: the name of a file has changed, but it is in the
- * same location in the file system. To indicate the root has changed,
- * childIndices and children will be null. Use e.getPath() to get the
- * parent of the changed node(s). e.getChildIndices() returns the
- * index(es) of the changed node(s).
+ * Invoked after a node (or a set of siblings) has changed in some way. The
+ * node(s) have not changed locations in the tree or altered their children
+ * arrays, but other attributes have changed and may affect presentation.
+ * Example: the name of a file has changed, but it is in the same location
+ * in the file system. To indicate the root has changed, childIndices and
+ * children will be null. Use e.getPath() to get the parent of the changed
+ * node(s). e.getChildIndices() returns the index(es) of the changed
+ * node(s).
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void treeNodesChanged(TreeModelEvent e)
{
+ tree.repaint();
}
/**
- * Invoked after nodes have been inserted into the tree. Use e.getPath()
- * to get the parent of the new node(s). e.getChildIndices() returns the
+ * Invoked after nodes have been inserted into the tree. Use e.getPath() to
+ * get the parent of the new node(s). e.getChildIndices() returns the
* index(es) of the new node(s) in ascending order.
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void treeNodesInserted(TreeModelEvent e)
{
+ tree.repaint();
}
/**
* Invoked after nodes have been removed from the tree. Note that if a
* subtree is removed from the tree, this method may only be invoked once
- * for the root of the removed subtree, not once for each individual set
- * of siblings removed. Use e.getPath() to get the former parent of the
- * deleted node(s). e.getChildIndices() returns, in ascending order, the
- * index(es) the node(s) had before being deleted.
+ * for the root of the removed subtree, not once for each individual set of
+ * siblings removed. Use e.getPath() to get the former parent of the deleted
+ * node(s). e.getChildIndices() returns, in ascending order, the index(es)
+ * the node(s) had before being deleted.
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void treeNodesRemoved(TreeModelEvent e)
{
+ tree.repaint();
}
/**
@@ -2417,10 +2742,12 @@ public class BasicTreeUI
* should become the new root of the tree. Use e.getPath() to get the path
* to the node. e.getChildIndices() returns null.
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void treeStructureChanged(TreeModelEvent e)
{
+ tree.repaint();
}
}// TreeModelHandler
@@ -2436,8 +2763,10 @@ public class BasicTreeUI
/**
* Constructor
*
- * @param direction up or down
- * @param name is the name of the direction
+ * @param direction
+ * up or down
+ * @param name
+ * is the name of the direction
*/
public TreePageAction(int direction, String name)
{
@@ -2446,7 +2775,8 @@ public class BasicTreeUI
/**
* Invoked when an action occurs.
*
- * @param e is the event that occured
+ * @param e
+ * is the event that occured
*/
public void actionPerformed(ActionEvent e)
{
@@ -2481,10 +2811,13 @@ public class BasicTreeUI
* Messaged when the selection changes in the tree we're displaying for.
* Stops editing, messages super and displays the changed paths.
*
- * @param event the event that characterizes the change.
+ * @param event
+ * the event that characterizes the change.
*/
public void valueChanged(TreeSelectionEvent event)
{
+ if (tree.isEditing())
+ tree.cancelEditing();
}
}// TreeSelectionHandler
@@ -2497,7 +2830,8 @@ public class BasicTreeUI
/**
* Constructor
*
- * @param name is the name of <code>Action</code> field
+ * @param name
+ * is the name of <code>Action</code> field
*/
public TreeToggleAction(String name)
{
@@ -2506,7 +2840,8 @@ public class BasicTreeUI
/**
* Invoked when an action occurs.
*
- * @param e the event that occured
+ * @param e
+ * the event that occured
*/
public void actionPerformed(ActionEvent e)
{
@@ -2524,9 +2859,8 @@ public class BasicTreeUI
} // TreeToggleAction
/**
- * TreeTraverseAction is the action used for left/right keys. Will toggle
- * the expandedness of a node, as well as potentially incrementing the
- * selection.
+ * TreeTraverseAction is the action used for left/right keys. Will toggle the
+ * expandedness of a node, as well as potentially incrementing the selection.
*/
public class TreeTraverseAction
extends AbstractAction
@@ -2539,8 +2873,10 @@ public class BasicTreeUI
/**
* Constructor
*
- * @param direction to traverse
- * @param name is the name of the direction
+ * @param direction
+ * to traverse
+ * @param name
+ * is the name of the direction
*/
public TreeTraverseAction(int direction, String name)
{
@@ -2549,10 +2885,38 @@ public class BasicTreeUI
/**
* Invoked when an action occurs.
*
- * @param e the event that occured
+ * @param e
+ * the event that occured
*/
public void actionPerformed(ActionEvent e)
{
+ TreeModel mod = tree.getModel();
+ Object last = tree.getLeadSelectionPath().getLastPathComponent();
+
+ if (e.getActionCommand().equals("selectParent"))
+ {
+ TreePath path = new TreePath(getPathToRoot(last, 0));
+ Object p = getParent(mod.getRoot(), last);
+
+ if (!mod.isLeaf(last) && tree.isExpanded(path))
+ tree.collapsePath(path);
+ else if (p != null)
+ selectPath(tree, new TreePath(getPathToRoot(p, 0)));
+ }
+ else if (e.getActionCommand().equals("selectChild"))
+ {
+ TreePath path = new TreePath(getPathToRoot(last, 0));
+
+ if (!mod.isLeaf(last) && tree.isCollapsed(path))
+ tree.expandPath(path);
+ else
+ {
+ Object next = getNextVisibleNode(last);
+
+ if (next != null)
+ selectPath(tree, new TreePath(getPathToRoot(next, 0)));
+ }
+ }
}
/**
@@ -2567,13 +2931,15 @@ public class BasicTreeUI
} // TreeTraverseAction
/**
- * Returns the cell bounds for painting selected cells
- * Package private for use in inner classes.
- *
- * @param x is the x location of the cell
- * @param y is the y location of the cell
- * @param cell is the Object to get the bounds for
+ * Returns 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)
@@ -2582,7 +2948,7 @@ public class BasicTreeUI
{
String s = cell.toString();
Font f = tree.getFont();
- FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());
+ FontMetrics fm = tree.getToolkit().getFontMetrics(f);
if (s != null)
return new Rectangle(x, y,
@@ -2593,17 +2959,21 @@ public class BasicTreeUI
}
/**
- * 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
+ * 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,
@@ -2620,8 +2990,8 @@ public class BasicTreeUI
}
if (!mod.isLeaf(startNode)
- && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0)))
- && mod.getChildCount(startNode) > 0)
+ && tree.isExpanded(new TreePath(getPathToRoot(startNode, 0)))
+ && !mod.isLeaf(startNode) && mod.getChildCount(startNode) > 0)
{
Object child = mod.getChild(startNode, 0);
if (child != null)
@@ -2635,11 +3005,16 @@ public class BasicTreeUI
/**
* Paints a node in the tree Package private for use in inner classes.
*
- * @param g the Graphics context in which to paint
- * @param x the x location of the node
- * @param y the y location of the node
- * @param tree the tree to draw on
- * @param node the object to draw
+ * @param g
+ * the Graphics context in which to paint
+ * @param x
+ * the x location of the node
+ * @param y
+ * the y location of the node
+ * @param tree
+ * the tree to draw on
+ * @param node
+ * the object to draw
*/
void paintNode(Graphics g, int x, int y, JTree tree, Object node,
boolean isLeaf)
@@ -2651,18 +3026,32 @@ public class BasicTreeUI
if (tree.isVisible(curr))
{
- TreeCellRenderer dtcr = tree.getCellRenderer();
- if (dtcr == null)
- dtcr = createDefaultCellRenderer();
-
if (!isLeaf)
expanded = tree.isExpanded(curr);
- Component c = dtcr.getTreeCellRendererComponent(tree, node, selected,
- expanded, isLeaf, 0,
- false);
- rendererPane.paintComponent(g, c, c.getParent(), getCellBounds(x, y,
- node));
+ if (editingComponent != null && editingPath != null && isEditing(tree)
+ && node.equals(editingPath.getLastPathComponent()))
+ {
+ Rectangle bounds = getPathBounds(tree, editingPath);
+ rendererPane.paintComponent(g, editingComponent.getParent(), null,
+ new Rectangle(0, 0, bounds.width,
+ bounds.height));
+ }
+ else
+ {
+ TreeCellRenderer dtcr = tree.getCellRenderer();
+ if (dtcr == null)
+ dtcr = createDefaultCellRenderer();
+
+ int row = getRowForPath(tree, curr);
+
+ Component c = dtcr.getTreeCellRendererComponent(tree, node,
+ selected, expanded,
+ isLeaf, row, false);
+
+ rendererPane.paintComponent(g, c, c.getParent(),
+ getCellBounds(x, y, node));
+ }
}
}
@@ -2670,15 +3059,22 @@ public class BasicTreeUI
* Recursively paints all elements of the tree Package private for use in
* inner classes.
*
- * @param g the Graphics context in which to paint
- * @param indentation of the current object
- * @param descent is the number of elements drawn
- * @param childNumber is the index of the current child in the tree
- * @param depth is the depth of the current object in the tree
- * @param tree is the tree to draw to
- * @param mod is the TreeModel we are using to draw
- * @param curr is the current object to draw
- *
+ * @param g
+ * the Graphics context in which to paint
+ * @param indentation
+ * of the current object
+ * @param descent
+ * is the number of elements drawn
+ * @param childNumber
+ * is the index of the current child in the tree
+ * @param depth
+ * is the depth of the current object in the tree
+ * @param tree
+ * is the tree to draw to
+ * @param mod
+ * is the TreeModel we are using to draw
+ * @param curr
+ * is the current object to draw
* @return int - current descent of the tree
*/
int paintRecursive(Graphics g, int indentation, int descent, int childNumber,
@@ -2709,7 +3105,9 @@ public class BasicTreeUI
y0 += halfHeight;
}
- int max = mod.getChildCount(curr);
+ int max = 0;
+ if (!mod.isLeaf(curr))
+ max = mod.getChildCount(curr);
if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
{
for (int i = 0; i < max; i++)
@@ -2733,7 +3131,8 @@ public class BasicTreeUI
}
if (tree.isExpanded(new TreePath(getPathToRoot(curr, 0))))
- if (y0 != heightOfLine && mod.getChildCount(curr) > 0)
+ if (y0 != heightOfLine && !mod.isLeaf(curr)
+ && mod.getChildCount(curr) > 0)
{
g.setColor(getHashColor());
g.drawLine(indentation + halfWidth, y0, indentation + halfWidth,
@@ -2744,18 +3143,25 @@ public class BasicTreeUI
}
/**
- * Recursively paints all the control icons on the tree.
- * Package private for use in inner classes.
- *
- * @param g the Graphics context in which to paint
- * @param indentation of the current object
- * @param descent is the number of elements drawn
- * @param childNumber is the index of the current child in the tree
- * @param depth is the depth of the current object in the tree
- * @param tree is the tree to draw to
- * @param mod is the TreeModel we are using to draw
- * @param curr is the current object to draw
- *
+ * Recursively paints all the control icons on the tree. Package private for
+ * use in inner classes.
+ *
+ * @param g
+ * the Graphics context in which to paint
+ * @param indentation
+ * of the current object
+ * @param descent
+ * is the number of elements drawn
+ * @param childNumber
+ * is the index of the current child in the tree
+ * @param depth
+ * is the depth of the current object in the tree
+ * @param tree
+ * is the tree to draw to
+ * @param mod
+ * is the TreeModel we are using to draw
+ * @param curr
+ * is the current object to draw
* @return int - current descent of the tree
*/
int paintControlIcons(Graphics g, int indentation, int descent,
@@ -2778,7 +3184,9 @@ public class BasicTreeUI
if (depth > 0 || tree.isRootVisible())
descent += rowHeight;
- int max = mod.getChildCount(node);
+ int max = 0;
+ if (!mod.isLeaf(node))
+ max = mod.getChildCount(node);
if (tree.isExpanded(new TreePath(getPathToRoot(node, 0))))
{
if (!node.equals(mod.getRoot()))
@@ -2803,8 +3211,8 @@ public class BasicTreeUI
}
/**
- * Returns true if the LookAndFeel implements the control icons
- * Package private for use in inner classes.
+ * Returns true if the LookAndFeel implements the control icons Package
+ * private for use in inner classes.
*
* @return true if control icons are visible
*/
@@ -2819,8 +3227,10 @@ public class BasicTreeUI
/**
* Returns the parent of the current node
*
- * @param root is the root of the tree
- * @param node is the current node
+ * @param root
+ * is the root of the tree
+ * @param node
+ * is the current node
* @return is the parent of the current node
*/
Object getParent(Object root, Object node)
@@ -2833,17 +3243,21 @@ public class BasicTreeUI
}
/**
- * Recursively checks the tree for the specified node, starting
- * at the root.
+ * Recursively checks the tree for the specified node, starting at the root.
*
- * @param root is starting node to start searching at.
- * @param node is the node to search for
+ * @param root
+ * is starting node to start searching at.
+ * @param node
+ * is the node to search for
* @return the parent node of node
*/
private Object findNode(Object root, Object node)
{
TreeModel mod = tree.getModel();
- for (int i = 0; i < mod.getChildCount(root); i++)
+ int size = 0;
+ if (!mod.isLeaf(root))
+ size = mod.getChildCount(root);
+ for (int i = 0; i < size; i++)
{
if (mod.getIndexOfChild(root, node) != -1)
return root;
@@ -2859,7 +3273,8 @@ public class BasicTreeUI
* Get next visible node in the tree. Package private for use in inner
* classes.
*
- * @param the current node
+ * @param the
+ * current node
* @return the next visible node in the JTree. Return null if there are no
* more.
*/
@@ -2889,10 +3304,11 @@ public class BasicTreeUI
}
/**
- * Get previous visible node in the tree.
- * Package private for use in inner classes.
+ * Get previous visible node in the tree. Package private for use in inner
+ * classes.
*
- * @param the current node
+ * @param the
+ * current node
* @return the next visible node in the JTree. Return null if there are no
* more.
*/
@@ -2922,16 +3338,16 @@ public class BasicTreeUI
}
/**
- * Returns the next node in the tree
- * Package private for use in inner classes.
- *
- * @param the current node
+ * Returns the next node in the tree Package private for use in inner classes.
+ *
+ * @param the
+ * current node
* @return the next node in the tree
*/
Object getNextNode(Object curr)
{
TreeModel mod = tree.getModel();
- if (mod.getChildCount(curr) > 0)
+ if (!mod.isLeaf(curr) && mod.getChildCount(curr) > 0)
return mod.getChild(curr, 0);
Object node = curr;
@@ -2948,10 +3364,11 @@ public class BasicTreeUI
}
/**
- * Returns the previous node in the tree
- * Package private for use in inner classes.
- *
- * @param the current node
+ * Returns the previous node in the tree Package private for use in inner
+ * classes.
+ *
+ * @param the
+ * current node
* @return the previous node in the tree
*/
Object getPreviousNode(Object node)
@@ -2966,21 +3383,27 @@ public class BasicTreeUI
if (sibling == null)
return parent;
- int size = mod.getChildCount(sibling);
+ int size = 0;
+ if (!mod.isLeaf(sibling))
+ size = mod.getChildCount(sibling);
while (size > 0)
{
sibling = mod.getChild(sibling, size - 1);
- size = mod.getChildCount(sibling);
+ if (!mod.isLeaf(sibling))
+ size = mod.getChildCount(sibling);
+ else
+ size = 0;
}
return sibling;
}
/**
- * Returns the next sibling in the tree
- * Package private for use in inner classes.
- *
- * @param the current node
+ * Returns the next sibling in the tree Package private for use in inner
+ * classes.
+ *
+ * @param the
+ * current node
* @return the next sibling in the tree
*/
Object getNextSibling(Object node)
@@ -2992,17 +3415,21 @@ public class BasicTreeUI
int index = mod.getIndexOfChild(parent, node) + 1;
- if (index == 0 || index >= mod.getChildCount(parent))
+ int size = 0;
+ if (!mod.isLeaf(parent))
+ size = mod.getChildCount(parent);
+ if (index == 0 || index >= size)
return null;
return mod.getChild(parent, index);
}
/**
- * Returns the previous sibling in the tree
- * Package private for use in inner classes.
+ * Returns the previous sibling in the tree Package private for use in inner
+ * classes.
*
- * @param the current node
+ * @param the
+ * current node
* @return the previous sibling in the tree
*/
Object getPreviousSibling(Object node)
@@ -3014,28 +3441,30 @@ public class BasicTreeUI
int index = mod.getIndexOfChild(parent, node) - 1;
- if (index < 0 || index >= mod.getChildCount(parent))
+ int size = 0;
+ if (!mod.isLeaf(parent))
+ size = mod.getChildCount(parent);
+ if (index < 0 || index >= size)
return null;
return mod.getChild(parent, index);
}
/**
- * Selects the specified path in the tree depending on modes.
- * Package private for use in inner classes.
+ * Selects the specified path in the tree depending on modes. Package private
+ * for use in inner classes.
*
- * @param tree is the tree we are selecting the path in
- * @param path is the path we are selecting
+ * @param tree
+ * is the tree we are selecting the path in
+ * @param path
+ * is the path we are selecting
*/
void selectPath(JTree tree, TreePath path)
{
if (path != null)
{
- if (tree.isPathSelected(path))
- tree.removeSelectionPath(path);
- else if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION)
+ if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
{
- tree.getSelectionModel().clearSelection();
tree.addSelectionPath(path);
tree.setLeadSelectionPath(path);
}
@@ -3045,8 +3474,9 @@ public class BasicTreeUI
}
else
{
- tree.getSelectionModel().setSelectionMode(
- TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+ tree.getSelectionModel().clearSelection();
tree.addSelectionPath(path);
tree.setLeadSelectionPath(path);
}
@@ -3054,12 +3484,13 @@ public class BasicTreeUI
}
/**
- * Returns the path from node to the root.
- * Package private for use in inner classes.
- *
- * @param node the node to get the path to
- * @param depth the depth of the tree to return a path for
- *
+ * Returns the path from node to the root. Package private for use in inner
+ * classes.
+ *
+ * @param node
+ * the node to get the path to
+ * @param depth
+ * the depth of the tree to return a path for
* @return an array of tree nodes that represent the path to node.
*/
Object[] getPathToRoot(Object node, int depth)
@@ -3080,8 +3511,9 @@ public class BasicTreeUI
/**
* Returns the level of the node in the tree.
- *
- * @param the current node
+ *
+ * @param the
+ * current node
* @return the number of the level
*/
int getLevel(Object node)
@@ -3102,11 +3534,16 @@ public class BasicTreeUI
/**
* Draws a vertical line using the given graphic context
*
- * @param g is the graphic context
- * @param c is the component the new line will belong to
- * @param x is the horizonal position
- * @param top specifies the top of the line
- * @param bottom specifies the bottom of the line
+ * @param g
+ * is the graphic context
+ * @param c
+ * is the component the new line will belong to
+ * @param x
+ * is the horizonal position
+ * @param top
+ * specifies the top of the line
+ * @param bottom
+ * specifies the bottom of the line
*/
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top,
int bottom)
@@ -3117,11 +3554,16 @@ public class BasicTreeUI
/**
* Draws a horizontal line using the given graphic context
*
- * @param g is the graphic context
- * @param c is the component the new line will belong to
- * @param y is the vertical position
- * @param left specifies the left point of the line
- * @param right specifies the right point of the line
+ * @param g
+ * is the graphic context
+ * @param c
+ * is the component the new line will belong to
+ * @param y
+ * is the vertical position
+ * @param left
+ * specifies the left point of the line
+ * @param right
+ * specifies the right point of the line
*/
protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left,
int right)
@@ -3132,13 +3574,17 @@ public class BasicTreeUI
/**
* Draws an icon at around a specific position
*
- * @param c is the component the new line will belong to
- * @param g is the graphic context
- * @param icon is the icon which will be drawn
- * @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
+ * @param c
+ * is the component the new line will belong to
+ * @param g
+ * is the graphic context
+ * @param icon
+ * is the icon which will be drawn
+ * @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
*/
protected void drawCentered(JComponent c, Graphics g, Icon icon, int x, int y)
{
diff --git a/javax/swing/plaf/metal/MetalBorders.java b/javax/swing/plaf/metal/MetalBorders.java
index 851324242..f55510684 100644
--- a/javax/swing/plaf/metal/MetalBorders.java
+++ b/javax/swing/plaf/metal/MetalBorders.java
@@ -45,17 +45,18 @@ import java.awt.Insets;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
-import javax.swing.JButton;
+import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
+import javax.swing.JTextField;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.UIResource;
-import javax.swing.plaf.basic.BasicGraphicsUtils;
import javax.swing.plaf.basic.BasicBorders;
+
/**
* This factory class creates borders for the different Swing components
* UI.
@@ -71,6 +72,9 @@ public class MetalBorders
/** The shared instance for getRolloverButtonBorder(). */
private static Border toolbarButtonBorder;
+ /** The shared instance for getTextFieldBorder(). */
+ private static Border textFieldBorder;
+
/**
* A MarginBorder that gets shared by multiple components.
* Created on demand by the private helper function {@link
@@ -187,6 +191,211 @@ public class MetalBorders
}
/**
+ * A simple 3D border.
+ */
+ public static class Flush3DBorder extends AbstractBorder
+ implements UIResource
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public Flush3DBorder()
+ {
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c, Insets newInsets)
+ {
+ if (newInsets == null)
+ newInsets = new Insets(2, 2, 2, 2);
+ else
+ {
+ newInsets.top = 2;
+ newInsets.left = 2;
+ newInsets.bottom = 2;
+ newInsets.right = 2;
+ }
+ return newInsets;
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawRect(x, y, w - 2, h - 2);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawRect(x + 1, y + 1, w - 2, h - 2);
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
+ g.setColor(savedColor);
+ }
+
+ }
+
+ /**
+ * A border used for the {@link JTextField} component.
+ */
+ public static class TextFieldBorder extends Flush3DBorder
+ implements UIResource
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public TextFieldBorder()
+ {
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component (ignored).
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+ if (c.isEnabled())
+ super.paintBorder(c, g, x, y, w, h);
+ else
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawRect(x, y, w - 1, h - 1);
+ g.setColor(savedColor);
+ }
+ }
+
+ }
+
+ /**
+ * A border used when painting {@link JInternalFrame} instances.
+ */
+ public static class InternalFrameBorder extends AbstractBorder
+ implements UIResource
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public InternalFrameBorder()
+ {
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ *
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c)
+ {
+ return getBorderInsets(c, null);
+ }
+
+ /**
+ * Returns the border insets.
+ *
+ * @param c the component (ignored).
+ * @return The border insets.
+ */
+ public Insets getBorderInsets(Component c, Insets newInsets)
+ {
+ if (newInsets == null)
+ newInsets = new Insets(5, 5, 5, 5);
+ else
+ {
+ newInsets.top = 5;
+ newInsets.left = 5;
+ newInsets.bottom = 5;
+ newInsets.right = 5;
+ }
+ return newInsets;
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ * @param w the width.
+ * @param h the height.
+ */
+ public void paintBorder(Component c, Graphics g, int x, int y, int w,
+ int h)
+ {
+
+ JInternalFrame f = (JInternalFrame) c;
+ if (f.isSelected())
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+
+ // fill the border background
+ g.fillRect(x, y, w, 5);
+ g.fillRect(x, y, 5, h);
+ g.fillRect(x + w - 5, y, 5, h);
+ g.fillRect(x, y + h - 5, w, 5);
+
+ // draw a dot in each corner
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x, y, 1, 1);
+ g.fillRect(x + w - 1, y, 1, 1);
+ g.fillRect(x + w - 1, y + h - 1, 1, 1);
+ g.fillRect(x, y + h - 1, 1, 1);
+
+ // draw the lines
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 14, y + 2, x + w - 15, y + 2);
+ g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3);
+ g.drawLine(x + 2, y + 14, x + 2, y + h - 15);
+ g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
+
+ // draw the line highlights
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
+ g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
+ g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
+ g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14);
+ }
+
+ }
+
+ /**
* A border used for {@link JMenu} and {@link JMenuItem} components.
*/
public static class MenuItemBorder
@@ -578,6 +787,20 @@ public class MetalBorders
}
/**
+ * Returns a border for use by the {@link JTextField} component.
+ *
+ * @return A border.
+ *
+ * @since 1.3
+ */
+ public static Border getTextFieldBorder()
+ {
+ if (textFieldBorder == null)
+ textFieldBorder = new TextFieldBorder();
+ return textFieldBorder;
+ }
+
+ /**
* Returns a border for Toolbar buttons in the Metal Look &amp; Feel.
*
* @return a border for Toolbar buttons in the Metal Look &amp; Feel
diff --git a/javax/swing/plaf/metal/MetalCheckBoxUI.java b/javax/swing/plaf/metal/MetalCheckBoxUI.java
index d59e38c54..c46cb5f2f 100644
--- a/javax/swing/plaf/metal/MetalCheckBoxUI.java
+++ b/javax/swing/plaf/metal/MetalCheckBoxUI.java
@@ -38,12 +38,17 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import javax.swing.JCheckBox;
import javax.swing.JComponent;
+import javax.swing.UIDefaults;
import javax.swing.plaf.ComponentUI;
-import javax.swing.plaf.basic.BasicCheckBoxUI;
+/**
+ * A UI delegate for the {@link JCheckBox} component under the
+ * {@link MetalLookAndFeel}.
+ */
public class MetalCheckBoxUI
- extends BasicCheckBoxUI
+ extends MetalRadioButtonUI
{
// FIXME: maybe replace by a Map of instances when this becomes stateful
@@ -71,4 +76,15 @@ public class MetalCheckBoxUI
instance = new MetalCheckBoxUI();
return instance;
}
+
+ /**
+ * Returns the prefix for properties defined in the {@link UIDefaults} table.
+ *
+ * @return The property prefix (<code>"CheckBox."</code>).
+ */
+ public String getPropertyPrefix()
+ {
+ return "CheckBox.";
+ }
}
+
diff --git a/javax/swing/plaf/metal/MetalIconFactory.java b/javax/swing/plaf/metal/MetalIconFactory.java
index 2c21d2b02..74386dce6 100644
--- a/javax/swing/plaf/metal/MetalIconFactory.java
+++ b/javax/swing/plaf/metal/MetalIconFactory.java
@@ -44,10 +44,15 @@ import java.awt.Graphics;
import java.io.Serializable;
import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JInternalFrame;
import javax.swing.JRadioButton;
+import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSlider;
import javax.swing.plaf.UIResource;
+
/**
* Creates icons for the {@link MetalLookAndFeel}.
*/
@@ -61,6 +66,77 @@ public class MetalIconFactory implements Serializable
public static final boolean LIGHT = true;
/**
+ * An icon displayed for {@link JCheckBoxMenuItem} components.
+ */
+ private static class CheckBoxMenuItemIcon implements Icon, Serializable
+ {
+ /**
+ * Creates a new icon instance.
+ */
+ public CheckBoxMenuItemIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon (10 pixels).
+ */
+ public int getIconWidth()
+ {
+ return 10;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon (10 pixels).
+ */
+ public int getIconHeight()
+ {
+ return 10;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
+
+ if (item.isArmed())
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y, x + 8, y);
+ g.drawLine(x, y + 1, x, y + 8);
+ g.drawLine(x + 2, y + 8, x + 8, y + 8);
+ g.drawLine(x + 8, y + 2, x + 8, y + 7);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 7, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 7);
+ g.drawLine(x + 1, y + 9, x + 9, y + 9);
+ g.drawLine(x + 9, y + 1, x + 9, y + 8);
+
+ // if the item is selected, we should draw a tick
+ if (item.isSelected())
+ {
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.fillRect(x + 2, y + 2, 2, 5);
+ for (int i = 0; i < 6; i++)
+ g.drawLine(x + 8 - i, y + i, x + 9 - i, y + i);
+ }
+
+ }
+ }
+
+ /**
* An icon representing a file (drawn as a piece of paper with the top-right
* corner turned down).
*/
@@ -219,19 +295,6 @@ public class MetalIconFactory implements Serializable
static class RadioButtonIcon
implements Icon, UIResource, Serializable
{
- /**
- * Draws the check in the RadioButton.
- *
- * @param c the component to draw on
- * @param g the Graphics context to draw with
- */
- protected void drawCheck(Component c, Graphics g)
- {
- g.setColor(MetalLookAndFeel.getBlack());
- g.fillRect(4, 3, 4, 6);
- g.drawLine(3, 4, 3, 7);
- g.drawLine(8, 4, 8, 7);
- }
/**
* Returns the width of the icon in pixels.
@@ -254,60 +317,167 @@ public class MetalIconFactory implements Serializable
}
/**
- * Paints the icon. This first paints the border of the RadioButton and
- * if the CheckBox is selected it calls {@link #drawCheck} to draw
- * the check.
+ * Paints the icon, taking into account whether or not the component is
+ * enabled, selected and/or armed.
*
- * @param c the Component to draw on (gets casted to JCheckBox)
+ * @param c the Component to draw on (must be an instance of
+ * {@link JRadioButton})
* @param g the Graphics context to draw with
* @param x the X position
* @param y the Y position
*/
- public void paintIcon(Component c, Graphics g, int x, int y)
- {
- Color dark = MetalLookAndFeel.getControlDarkShadow();
- Color light = MetalLookAndFeel.getWhite();
- g.translate(x, y);
-
- // The light 'circle'
- g.setColor(light);
- g.drawLine(4, 1, 10, 1);
- g.drawLine(2, 2, 3, 2);
- g.drawLine(8, 2, 11, 2);
- g.drawLine(2, 3, 2, 3);
- g.drawLine(11, 2, 11, 9);
- g.drawLine(1, 4, 1, 7);
- g.drawLine(12, 4, 12, 7);
- g.drawLine(2, 8, 2, 11);
- g.drawLine(11, 8, 11, 9);
- g.drawLine(10, 10, 10, 10);
- g.drawLine(2, 11, 9, 11);
- g.drawLine(4, 12, 7, 12);
-
- // The dark 'circle'
- g.setColor(dark);
- g.drawLine(4, 0, 7, 0);
- g.drawLine(2, 1, 3, 1);
- g.drawLine(8, 1, 9, 1);
- g.drawLine(1, 2, 1, 3);
- g.drawLine(10, 2, 10, 3);
- g.drawLine(0, 4, 0, 7);
- g.drawLine(11, 4, 11, 7);
- g.drawLine(1, 8, 1, 9);
- g.drawLine(10, 8, 10, 9);
- g.drawLine(2, 10, 3, 10);
- g.drawLine(8, 10, 9, 10);
- g.drawLine(4, 11, 7, 11);
-
- JRadioButton rb = (JRadioButton) c;
- if (rb.isSelected())
- drawCheck(c, g);
-
- g.translate(-x, -y);
- }
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ JRadioButton b = (JRadioButton) c;
+
+ // draw outer circle
+ if (b.isEnabled())
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
+ g.drawLine(x + 2, y + 1, x + 3, y + 1);
+ g.drawLine(x + 4, y, x + 7, y);
+ g.drawLine(x + 8, y + 1, x + 9, y + 1);
+ g.drawLine(x + 10, y + 2, x + 10, y + 3);
+ g.drawLine(x + 11, y + 4, x + 11, y + 7);
+ g.drawLine(x + 10, y + 8, x + 10, y + 9);
+ g.drawLine(x + 8, y + 10, x + 9, y + 10);
+ g.drawLine(x + 4, y + 11, x + 7, y + 11);
+ g.drawLine(x + 2, y + 10, x + 3, y + 10);
+ g.drawLine(x + 1, y + 9, x + 1, y + 8);
+ g.drawLine(x, y + 7, x, y + 4);
+ g.drawLine(x + 1, y + 2, x + 1, y + 3);
+
+ if (b.getModel().isArmed())
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 4, y + 10, x + 7, y + 10);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 10, y + 4, x + 10, y + 7);
+ g.fillRect(x + 2, y + 2, 8, 8);
+ }
+ else
+ {
+ // only draw inner highlight if not filled
+ if (b.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+
+ g.drawLine(x + 2, y + 8, x + 2, y + 9);
+ g.drawLine(x + 1, y + 4, x + 1, y + 7);
+ g.drawLine(x + 2, y + 2, x + 2, y + 3);
+ g.drawLine(x + 3, y + 2, x + 3, y + 2);
+ g.drawLine(x + 4, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 9, y + 2);
+ }
+ }
+
+ // draw outer highlight
+ if (b.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getWhite());
+
+ // outer
+ g.drawLine(x + 10, y + 1, x + 10, y + 1);
+ g.drawLine(x + 11, y + 2, x + 11, y + 3);
+ g.drawLine(x + 12, y + 4, x + 12, y + 7);
+ g.drawLine(x + 11, y + 8, x + 11, y + 9);
+ g.drawLine(x + 10, y + 10, x + 10, y + 10);
+ g.drawLine(x + 8, y + 11, x + 9, y + 11);
+ g.drawLine(x + 4, y + 12, x + 7, y + 12);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ }
+
+ if (b.isSelected())
+ {
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 4, y + 3, x + 7, y + 3);
+ g.fillRect(x + 3, y + 4, 6, 4);
+ g.drawLine(x + 4, y + 8, x + 7, y + 8);
+ }
+ g.setColor(savedColor);
+ }
}
+ /**
+ * An icon displayed for {@link JRadioButtonMenuItem} components.
+ */
+ private static class RadioButtonMenuItemIcon
+ implements Icon, Serializable
+ {
/**
+ * Creates a new icon instance.
+ */
+ public RadioButtonMenuItemIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 10;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 10;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color savedColor = g.getColor();
+ JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 2, y, x + 6, y);
+ g.drawLine(x + 7, y + 1, x + 7, y + 1);
+ g.drawLine(x + 8, y + 2, x + 8, y + 6);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 2, y + 8, x + 6, y + 8);
+ g.drawLine(x + 1, y + 7, x + 1, y + 7);
+ g.drawLine(x, y + 2, x, y + 6);
+ g.drawLine(x + 1, y + 1, x + 1, y + 1);
+
+ if (item.isSelected())
+ {
+ g.drawLine(x + 3, y + 2, x + 5, y + 2);
+ g.fillRect(x + 2, y + 3, 5, 3);
+ g.drawLine(x + 3, y + 6, x + 5, y + 6);
+ }
+
+ // highlight
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 3, y + 1, x + 6, y + 1);
+ g.drawLine(x + 8, y + 1, x + 8, y + 1);
+ g.drawLine(x + 9, y + 2, x + 9, y + 7);
+ g.drawLine(x + 8, y + 8, x + 8, y + 8);
+ g.drawLine(x + 2, y + 9, x + 7, y + 9);
+ g.drawLine(x + 1, y + 8, x + 1, y + 8);
+ g.drawLine(x + 1, y + 3, x + 1, y + 6);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.setColor(savedColor);
+ }
+ }
+
+ /**
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
@@ -353,13 +523,19 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ boolean enabled = false;
boolean focus = false;
- if (c != null)
- focus = c.hasFocus();
- // TODO: pick up the colors from the look and feel
+ if (c != null)
+ {
+ enabled = c.isEnabled();
+ focus = c.hasFocus();
+ }
// draw the outline
- g.setColor(Color.black);
+ if (enabled)
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
g.drawLine(x + 1, y, x + 13, y);
g.drawLine(x + 14, y + 1, x + 14, y + 7);
g.drawLine(x + 14, y + 8, x + 7, y + 15);
@@ -367,8 +543,11 @@ public class MetalIconFactory implements Serializable
g.drawLine(x, y + 7, x, y + 1);
// fill the icon
- g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium
- g.fillRect(x + 2, y + 2, 12, 7);
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x + 1, y + 2, 13, 7);
g.drawLine(x + 2, y + 9, x + 12, y + 9);
g.drawLine(x + 3, y + 10, x + 11, y + 10);
g.drawLine(x + 4, y + 11, x + 10, y + 11);
@@ -376,38 +555,488 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 6, y + 13, x + 8, y + 13);
g.drawLine(x + 7, y + 14, x + 7, y + 14);
- // draw highlights
- g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light
- g.drawLine(x + 1, y + 1, x + 13, y + 1);
- g.drawLine(x + 1, y + 2, x + 1, y + 8);
- g.drawLine(x + 2, y + 2, x + 2, y + 2);
- g.drawLine(x + 6, y + 2, x + 6, y + 2);
- g.drawLine(x + 10, y + 2, x + 10, y + 2);
+ // if the slider is enabled, draw dots and highlights
+ if (c.isEnabled())
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 11, y + 3, x + 11, y + 3);
- g.drawLine(x + 4, y + 4, x + 4, y + 4);
- g.drawLine(x + 8, y + 4, x + 8, y + 4);
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 9, y + 5, x + 9, y + 5);
- g.drawLine(x + 2, y + 6, x + 2, y + 6);
- g.drawLine(x + 6, y + 6, x + 6, y + 6);
- g.drawLine(x + 10, y + 6, x + 10, y + 6);
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 11, y + 7, x + 11, y + 7);
- // draw dots
- g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark
- g.drawLine(x + 3, y + 3, x + 3, y + 3);
- g.drawLine(x + 7, y + 3, x + 7, y + 3);
- g.drawLine(x + 11, y + 3, x + 11, y + 3);
+ // draw highlights
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ else
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 10, y + 2, x + 10, y + 2);
+
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 8, y + 4, x + 8, y + 4);
- g.drawLine(x + 5, y + 5, x + 5, y + 5);
- g.drawLine(x + 9, y + 5, x + 9, y + 5);
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 10, y + 6, x + 10, y + 6);
+ }
- g.drawLine(x + 3, y + 7, x + 3, y + 7);
- g.drawLine(x + 7, y + 7, x + 7, y + 7);
- g.drawLine(x + 11, y + 7, x + 11, y + 7);
+ }
+ }
+
+ /**
+ * An icon used for the 'close' button in the title frame of a
+ * {@link JInternalFrame}.
+ */
+ private static class InternalFrameCloseIcon implements Icon, Serializable
+ {
+ /** The icon size in pixels. */
+ private int size;
+
+ /**
+ * Creates a new icon.
+ *
+ * @param size the icon size (width and height) in pixels.
+ */
+ public InternalFrameCloseIcon(int size)
+ {
+ this.size = size;
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return size;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return size;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ // draw the gray areas first
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ g.drawLine(x + 1, y + 1, x + 13, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 12);
+ g.drawLine(x + 1, y + 13, x + 13, y + 13);
+ g.drawLine(x + 13, y + 2, x + 13, y + 12);
+
+ g.fillRect(x + 4, y + 4, 2, 2);
+ g.fillRect(x + 4, y + 9, 2, 2);
+ g.fillRect(x + 9, y + 4, 2, 2);
+ g.fillRect(x + 9, y + 9, 2, 2);
+ g.fillRect(x + 5, y + 5, 5, 5);
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x, y, x + 13, y);
+ g.drawLine(x, y + 1, x, y + 13);
+ g.drawLine(x + 3, y + 4, x + 4, y + 3);
+ g.drawLine(x + 3, y + 9, x + 5, y + 7);
+ g.drawLine(x + 7, y + 5, x + 9, y + 3);
+
+ g.drawLine(x + 12, y + 3, x + 12, y + 11);
+ g.drawLine(x + 3, y + 12, x + 12, y + 12);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 14, x + 14, y + 14);
+ g.drawLine(x + 14, y + 1, x + 14, y + 14);
+
+ g.drawLine(x + 5, y + 10, x + 5, y + 10);
+ g.drawLine(x + 6, y + 9, x + 7, y + 9);
+ g.drawLine(x + 10, y + 5, x + 10, y + 5);
+ g.drawLine(x + 9, y + 6, x + 9, y + 7);
+ g.drawLine(x + 10, y + 10, x + 11, y + 10);
+ g.drawLine(x + 10, y + 11, x + 10, y + 11);
+ }
+ }
+
+ /**
+ * The icon displayed at the top-left corner of a {@link JInternalFrame}.
+ */
+ private static class InternalFrameDefaultMenuIcon
+ implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameDefaultMenuIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.setColor(new Color(102, 102, 153));
+ g.fillRect(x + 1, y, 14, 2);
+ g.fillRect(x, y + 1, 2, 14);
+ g.fillRect(x + 1, y + 14, 14, 2);
+ g.fillRect(x + 14, y + 1, 2, 14);
+ g.drawLine(x + 2, y + 5, x + 14, y + 5);
+
+ g.setColor(new Color(204, 204, 255));
+ g.fillRect(x + 2, y + 2, 12, 3);
+
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 6, y + 3, x + 6, y + 3);
+ g.drawLine(x + 9, y + 3, x + 9, y + 3);
+ g.drawLine(x + 12, y + 3, x + 12, y + 3);
+ g.setColor(Color.white);
+ g.fillRect(x + 2, y + 6, 12, 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 5, y + 2, x + 5, y + 2);
+ g.drawLine(x + 8, y + 2, x + 8, y + 2);
+ g.drawLine(x + 11, y + 2, x + 11, y + 2);
+ }
+ }
+
+ /**
+ * An icon used in the title frame of a {@link JInternalFrame}. When you
+ * maximise an internal frame, this icon will replace the 'maximise' icon to
+ * provide a 'restore' option.
+ */
+ private static class InternalFrameAltMaximizeIcon
+ implements Icon, Serializable
+ {
+ /** The icon size in pixels. */
+ private int size;
+
+ /**
+ * Creates a new icon.
+ *
+ * @param size the icon size in pixels.
+ */
+ public InternalFrameAltMaximizeIcon(int size)
+ {
+ this.size = size;
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return size;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return size;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color color = MetalLookAndFeel.getControlDarkShadow();
+ if (c instanceof JInternalFrame)
+ {
+ JInternalFrame f = (JInternalFrame) c;
+ if (f.isSelected())
+ color = MetalLookAndFeel.getPrimaryControlShadow();
+ }
+ g.setColor(color);
+ g.drawLine(x + 12, y + 1, x + 13, y + 1);
+ g.drawLine(x + 11, y + 2, x + 12, y + 2);
+ g.drawLine(x + 10, y + 3, x + 11, y + 3);
+ g.drawLine(x + 8, y + 2, x + 8, y + 3);
+ g.fillRect(x + 8, y + 4, 3, 3);
+ g.drawLine(x + 11, y + 6, x + 12, y + 6);
+
+ g.drawLine(x + 1, y + 5, x + 5, y + 5);
+ g.drawLine(x + 1, y + 6, x + 1, y + 12);
+ g.drawLine(x + 9, y + 9, x + 9, y + 12);
+ g.drawLine(x + 1, y + 13, x + 9, y + 13);
+
+ g.drawLine(x + 2, y + 12, x + 2, y + 12);
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 12, y, x + 9, y + 3);
+ g.drawLine(x + 7, y + 1, x + 8, y + 1);
+ g.drawLine(x + 7, y + 2, x + 7, y + 6);
+ g.drawLine(x + 11, y + 5, x + 12, y + 5);
+ g.drawLine(x, y + 4, x + 5, y + 4);
+ g.drawLine(x, y + 5, x, y + 13);
+ g.drawLine(x + 3, y + 12, x + 8, y + 12);
+ g.drawLine(x + 8, y + 8, x + 8, y + 11);
+ g.drawLine(x + 9, y + 8, x + 9, y + 8);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 9, y + 2, x + 9, y + 2);
+ g.drawLine(x + 11, y + 4, x + 13, y + 2);
+ g.drawLine(x + 13, y + 6, x + 13, y + 6);
+ g.drawLine(x + 8, y + 7, x + 13, y + 7);
+ g.drawLine(x + 6, y + 5, x + 6, y + 5);
+ g.drawLine(x + 2, y + 6, x + 6, y + 6);
+ g.drawLine(x + 2, y + 6, x + 2, y + 11);
+ g.drawLine(x + 10, y + 8, x + 10, y + 13);
+ g.drawLine(x + 1, y + 14, x + 10, y + 14);
}
}
/**
+ * An icon used for the 'maximize' button in the title frame of a
+ * {@link JInternalFrame}.
+ */
+ private static class InternalFrameMaximizeIcon
+ implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameMaximizeIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color color = MetalLookAndFeel.getControlDarkShadow();
+ if (c instanceof JInternalFrame)
+ {
+ JInternalFrame f = (JInternalFrame) c;
+ if (f.isSelected())
+ color = MetalLookAndFeel.getPrimaryControlShadow();
+ }
+ g.setColor(color);
+ g.drawLine(x + 9, y + 1, x + 10, y + 1);
+ g.fillRect(x + 11, y + 1, 3, 3);
+ g.fillRect(x + 12, y + 4, 2, 2);
+ g.drawLine(x + 10, y + 3, x + 10, y + 3);
+ g.drawLine(x + 9, y + 4, x + 10, y + 4);
+ g.drawLine(x + 1, y + 5, x + 9, y + 5);
+ g.drawLine(x + 1, y + 6, x + 1, y + 12);
+ g.drawLine(x + 9, y + 6, x + 9, y + 12);
+ g.drawLine(x + 1, y + 13, x + 9, y + 13);
+
+ // fill
+ g.drawLine(x + 7, y + 6, x + 8, y + 6);
+ g.drawLine(x + 6, y + 7, x + 8, y + 7);
+ g.drawLine(x + 5, y + 8, x + 6, y + 8);
+ g.drawLine(x + 4, y + 9, x + 5, y + 9);
+ g.drawLine(x + 3, y + 10, x + 4, y + 10);
+ g.drawLine(x + 2, y + 11, x + 3, y + 11);
+ g.drawLine(x + 2, y + 12, x + 4, y + 12);
+ g.drawLine(x + 8, y + 8, x + 8, y + 8);
+
+ // draw black
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 8, y, x + 13, y);
+ g.drawLine(x + 8, y + 1, x + 8, y + 1);
+ g.drawLine(x + 10, y + 2, x + 9, y + 3);
+ g.drawLine(x, y + 4, x + 8, y + 4);
+ g.drawLine(x, y + 5, x, y + 13);
+
+ g.drawLine(x + 2, y + 10, x + 6, y + 6);
+ g.drawLine(x + 8, y + 9, x + 8, y + 11);
+ g.drawLine(x + 5, y + 12, x + 8, y + 12);
+
+ // draw white
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 2, y + 6, x + 5, y + 6);
+ g.drawLine(x + 2, y + 7, x + 2, y + 9);
+ g.drawLine(x + 4, y + 11, x + 7, y + 8);
+
+ g.drawLine(x + 1, y + 14, x + 10, y + 14);
+ g.drawLine(x + 10, y + 5, x + 10, y + 13);
+
+ g.drawLine(x + 9, y + 2, x + 9, y + 2);
+ g.drawLine(x + 11, y + 4, x + 11, y + 5);
+ g.drawLine(x + 13, y + 6, x + 14, y + 6);
+ g.drawLine(x + 14, y + 1, x + 14, y + 5);
+ }
+ }
+
+ /**
+ * An icon used in the title frame of a {@link JInternalFrame}.
+ */
+ private static class InternalFrameMinimizeIcon
+ implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameMinimizeIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color color = MetalLookAndFeel.getControlDarkShadow();
+ if (c instanceof JInternalFrame)
+ {
+ JInternalFrame f = (JInternalFrame) c;
+ if (f.isSelected())
+ color = MetalLookAndFeel.getPrimaryControlShadow();
+ }
+ g.setColor(color);
+ g.drawLine(x + 12, y + 1, x + 13, y + 1);
+ g.drawLine(x + 11, y + 2, x + 12, y + 2);
+ g.drawLine(x + 10, y + 3, x + 11, y + 3);
+ g.drawLine(x + 8, y + 2, x + 8, y + 3);
+ g.fillRect(x + 8, y + 4, 3, 3);
+ g.drawLine(x + 11, y + 6, x + 12, y + 6);
+
+ g.drawLine(x + 1, y + 8, x + 6, y + 8);
+ g.drawLine(x + 1, y + 9, x + 1, y + 12);
+ g.drawLine(x + 6, y + 9, x + 6, y + 12);
+ g.drawLine(x + 1, y + 13, x + 6, y + 13);
+
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
+ g.drawLine(x + 2, y + 12, x + 2, y + 12);
+
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 12, y, x + 9, y + 3);
+ g.drawLine(x + 7, y + 1, x + 8, y + 1);
+ g.drawLine(x + 7, y + 2, x + 7, y + 6);
+ g.drawLine(x, y + 7, x + 6, y + 7);
+ g.drawLine(x, y + 8, x, y + 13);
+ g.drawLine(x + 3, y + 12, x + 5, y + 12);
+ g.drawLine(x + 5, y + 10, x + 5, y + 11);
+ g.drawLine(x + 11, y + 5, x + 12, y + 5);
+
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 9, y + 2, x + 9, y + 2);
+ g.drawLine(x + 11, y + 4, x + 13, y + 2);
+ g.drawLine(x + 13, y + 6, x + 13, y + 6);
+ g.drawLine(x + 8, y + 7, x + 13, y + 7);
+ g.drawLine(x + 2, y + 9, x + 4, y + 9);
+ g.drawLine(x + 2, y + 10, x + 2, y + 11);
+ g.drawLine(x + 7, y + 9, x + 7, y + 13);
+ g.drawLine(x + 1, y + 14, x + 7, y + 14);
+ }
+ }
+
+ /**
* The icon used to display the thumb control on a horizontally oriented
* {@link JSlider} component.
*/
@@ -452,13 +1081,19 @@ public class MetalIconFactory implements Serializable
*/
public void paintIcon(Component c, Graphics g, int x, int y)
{
+ boolean enabled = false;
boolean focus = false;
- if (c != null)
- focus = c.hasFocus();
- // TODO: pick up the colors from the look and feel
+ if (c != null)
+ {
+ enabled = c.isEnabled();
+ focus = c.hasFocus();
+ }
// draw the outline
- g.setColor(Color.black);
+ if (enabled)
+ g.setColor(MetalLookAndFeel.getBlack());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
g.drawLine(x + 1, y, x + 7, y);
g.drawLine(x + 8, y, x + 15, y + 7);
g.drawLine(x + 14, y + 8, x + 8, y + 14);
@@ -466,8 +1101,11 @@ public class MetalIconFactory implements Serializable
g.drawLine(x, y + 13, x, y + 1);
// fill the icon
- g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204)); // medium
- g.fillRect(x + 2, y + 2, 7, 12);
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControl());
+ g.fillRect(x + 2, y + 1, 7, 13);
g.drawLine(x + 9, y + 2, x + 9, y + 12);
g.drawLine(x + 10, y + 3, x + 10, y + 11);
g.drawLine(x + 11, y + 4, x + 11, y + 10);
@@ -475,36 +1113,46 @@ public class MetalIconFactory implements Serializable
g.drawLine(x + 13, y + 6, x + 13, y + 8);
g.drawLine(x + 14, y + 7, x + 14, y + 7);
- // draw highlights
- g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255)); // light
- g.drawLine(x + 1, y + 1, x + 8, y + 1);
- g.drawLine(x + 1, y + 2, x + 1, y + 13);
- g.drawLine(x + 2, y + 2, x + 2, y + 2);
- g.drawLine(x + 2, y + 6, x + 2, y + 6);
- g.drawLine(x + 2, y + 10, x + 2, y + 10);
+ // if the slider is enabled, draw dots and highlights
+ if (enabled)
+ {
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getBlack());
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 3, y + 7, x + 3, y + 7);
+ g.drawLine(x + 3, y + 11, x + 3, y + 11);
- g.drawLine(x + 4, y + 4, x + 4, y + 4);
- g.drawLine(x + 4, y + 8, x + 4, y + 8);
+ g.drawLine(x + 5, y + 5, x + 5, y + 5);
+ g.drawLine(x + 5, y + 9, x + 5, y + 9);
- g.drawLine(x + 6, y + 2, x + 6, y + 2);
- g.drawLine(x + 6, y + 6, x + 6, y + 6);
- g.drawLine(x + 6, y + 10, x + 6, y + 10);
+ g.drawLine(x + 7, y + 3, x + 7, y + 3);
+ g.drawLine(x + 7, y + 7, x + 7, y + 7);
+ g.drawLine(x + 7, y + 11, x + 7, y + 11);
- // draw dots
- g.setColor(focus ? new Color(102, 102, 153) : Color.black); // dark
- g.drawLine(x + 3, y + 3, x + 3, y + 3);
- g.drawLine(x + 3, y + 7, x + 3, y + 7);
- g.drawLine(x + 3, y + 11, x + 3, y + 11);
+ // draw highlights
+ if (focus)
+ g.setColor(MetalLookAndFeel.getPrimaryControl());
+ else
+ g.setColor(MetalLookAndFeel.getWhite());
+ g.drawLine(x + 1, y + 1, x + 8, y + 1);
+ g.drawLine(x + 1, y + 2, x + 1, y + 13);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 2, y + 6, x + 2, y + 6);
+ g.drawLine(x + 2, y + 10, x + 2, y + 10);
- g.drawLine(x + 5, y + 5, x + 5, y + 5);
- g.drawLine(x + 5, y + 9, x + 5, y + 9);
+ g.drawLine(x + 4, y + 4, x + 4, y + 4);
+ g.drawLine(x + 4, y + 8, x + 4, y + 8);
- g.drawLine(x + 7, y + 3, x + 7, y + 3);
- g.drawLine(x + 7, y + 7, x + 7, y + 7);
- g.drawLine(x + 7, y + 11, x + 7, y + 11);
+ g.drawLine(x + 6, y + 2, x + 6, y + 2);
+ g.drawLine(x + 6, y + 6, x + 6, y + 6);
+ g.drawLine(x + 6, y + 10, x + 6, y + 10);
+
+ }
}
}
-
+
/**
* A tree control icon. This icon can be in one of two states: expanded and
* collapsed.
@@ -717,6 +1365,29 @@ public class MetalIconFactory implements Serializable
}
/**
+ * Returns an icon for use when rendering the {@link JCheckBox} component.
+ *
+ * @return A check box icon.
+ *
+ * @since 1.3
+ */
+ public static Icon getCheckBoxIcon()
+ {
+ return new MetalCheckBoxIcon();
+ }
+
+ /**
+ * Returns an icon for use when rendering the {@link JCheckBoxMenuItem}
+ * component.
+ *
+ * @return An icon.
+ */
+ public static Icon getCheckBoxMenuItemIcon()
+ {
+ return new CheckBoxMenuItemIcon();
+ }
+
+ /**
* Returns an icon for RadioButtons in the Metal L&amp;F.
*
* @return an icon for RadioButtons in the Metal L&amp;F
@@ -729,6 +1400,16 @@ public class MetalIconFactory implements Serializable
}
/**
+ * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
+ *
+ * @return A new icon instance.
+ */
+ public static Icon getRadioButtonMenuItemIcon()
+ {
+ return new RadioButtonMenuItemIcon();
+ }
+
+ /**
* Returns the icon used to display the thumb for a horizontally oriented
* {@link JSlider}.
*
@@ -740,6 +1421,72 @@ public class MetalIconFactory implements Serializable
}
/**
+ * Creates a new icon used to represent the 'close' button in the title
+ * pane of a {@link JInternalFrame}.
+ *
+ * @param size the icon size.
+ *
+ * @return A close icon.
+ */
+ public static Icon getInternalFrameCloseIcon(int size)
+ {
+ return new InternalFrameCloseIcon(size);
+ }
+
+ /**
+ * Creates a new icon for the menu in a {@link JInternalFrame}. This is the
+ * icon displayed at the top left of the frame.
+ *
+ * @return A menu icon.
+ */
+ public static Icon getInternalFrameDefaultMenuIcon()
+ {
+ return new InternalFrameDefaultMenuIcon();
+ }
+
+ /**
+ * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
+ *
+ * @param size the icon size in pixels.
+ *
+ * @return The icon.
+ *
+ * @see #getInternalFrameAltMaximizeIcon(int)
+ */
+ public static Icon getInternalFrameMaximizeIcon(int size)
+ {
+ return new InternalFrameMaximizeIcon();
+ }
+
+ /**
+ * Returns the icon used for the minimize button in the frame title for a
+ * {@link JInternalFrame}.
+ *
+ * @param size the icon size in pixels (ignored by this implementation).
+ *
+ * @return The icon.
+ */
+ public static Icon getInternalFrameMinimizeIcon(int size)
+ {
+ return new InternalFrameMinimizeIcon();
+ }
+
+ /**
+ * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
+ * that has been maximised.
+ *
+ * @param size the icon size in pixels.
+ *
+ * @return The icon.
+ *
+ * @see #getInternalFrameMaximizeIcon(int)
+ */
+ public static Icon getInternalFrameAltMaximizeIcon(int size)
+ {
+ return new InternalFrameAltMaximizeIcon(size);
+ }
+
+ /**
* Returns the icon used to display the thumb for a vertically oriented
* {@link JSlider}.
*
diff --git a/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java b/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
new file mode 100644
index 000000000..20526eba8
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalInternalFrameTitlePane.java
@@ -0,0 +1,171 @@
+/* MetalInternalFrameTitlePane.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.plaf.metal;
+
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.LayoutManager;
+
+import javax.swing.Icon;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
+
+/**
+ * The title pane for a {@link JInternalFrame}.
+ */
+public class MetalInternalFrameTitlePane extends BasicInternalFrameTitlePane
+{
+
+ protected boolean isPalette;
+
+ protected Icon paletteCloseIcon = MetalIconFactory.getInternalFrameCloseIcon(16);
+
+ protected int paletteTitleHeight = 12;
+
+ /**
+ * Creates a new title pane.
+ *
+ * @param f the internal frame.
+ */
+ public MetalInternalFrameTitlePane(JInternalFrame f)
+ {
+ super(f);
+ isPalette = false;
+ }
+
+ /**
+ * Fetches the colors used in the title pane.
+ */
+ protected void installDefaults()
+ {
+ super.installDefaults();
+ selectedTextColor = MetalLookAndFeel.getControlTextColor();
+ selectedTitleColor = MetalLookAndFeel.getWindowTitleBackground();
+ notSelectedTextColor = MetalLookAndFeel.getInactiveControlTextColor();
+ notSelectedTitleColor = MetalLookAndFeel.getWindowTitleInactiveBackground();
+ }
+
+ /**
+ * Clears the colors used for the title pane.
+ */
+ protected void uninstallDefaults()
+ {
+ super.uninstallDefaults();
+ selectedTextColor = null;
+ selectedTitleColor = null;
+ notSelectedTextColor = null;
+ notSelectedTitleColor = null;
+ }
+
+ /**
+ * Calls the super class to create the buttons, then calls
+ * <code>setBorderPainted(false)</code> and
+ * <code>setContentAreaFilled(false)</code> for each button.
+ */
+ protected void createButtons()
+ {
+ super.createButtons();
+ closeButton.setBorderPainted(false);
+ closeButton.setContentAreaFilled(false);
+ iconButton.setBorderPainted(false);
+ iconButton.setContentAreaFilled(false);
+ maxButton.setBorderPainted(false);
+ maxButton.setContentAreaFilled(false);
+ }
+
+ /**
+ * Overridden to do nothing.
+ */
+ protected void addSystemMenuItems(JMenu systemMenu)
+ {
+ // do nothing
+ }
+
+ /**
+ * Overridden to do nothing.
+ */
+ protected void showSystemMenu()
+ {
+ // do nothing
+ }
+
+ /**
+ * Creates a layout manager for the components in the title pane.
+ *
+ * @return A layout manager.
+ */
+ protected LayoutManager createLayout()
+ {
+ return new TitlePaneLayout()
+ {
+ public Dimension preferredLayoutSize(Container c)
+ {
+ return new Dimension(24, 24);
+ }
+ };
+ }
+
+ public void paintPalette(Graphics g)
+ {
+ // FIXME: needs implementing
+ // most likely this is equivalent to paintComponent(g) when the isPalette
+ // flag is true
+ }
+
+ public void paintComponent(Graphics g)
+ {
+ // probably need to check the isPalette flag here, if true pass over to
+ // paintPalette(Graphics)
+ super.paintComponent(g);
+ Dimension d = getSize();
+ if (frame.isSelected())
+ g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(0, d.height - 1, d.width - 1, d.height - 1);
+ }
+
+ public void setPalette(boolean b)
+ {
+ isPalette = b;
+ }
+}
+
diff --git a/javax/swing/plaf/metal/MetalInternalFrameUI.java b/javax/swing/plaf/metal/MetalInternalFrameUI.java
index 14143512e..7c7cb92e5 100644
--- a/javax/swing/plaf/metal/MetalInternalFrameUI.java
+++ b/javax/swing/plaf/metal/MetalInternalFrameUI.java
@@ -42,9 +42,11 @@ import java.util.HashMap;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
+import javax.swing.border.EmptyBorder;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;
+
public class MetalInternalFrameUI
extends BasicInternalFrameUI
{
@@ -85,4 +87,13 @@ public class MetalInternalFrameUI
return instance;
}
+
+ protected JComponent createNorthPane(JInternalFrame w)
+ {
+ titlePane = new MetalInternalFrameTitlePane(w);
+ titlePane.setBorder(new EmptyBorder(2, 2, 2, 2));
+ return titlePane;
+ }
+
+
}
diff --git a/javax/swing/plaf/metal/MetalLabelUI.java b/javax/swing/plaf/metal/MetalLabelUI.java
index cdd861227..fe8a9e4e4 100644
--- a/javax/swing/plaf/metal/MetalLabelUI.java
+++ b/javax/swing/plaf/metal/MetalLabelUI.java
@@ -38,17 +38,26 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+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;
import javax.swing.plaf.basic.BasicLabelUI;
+/**
+ * A UI delegate used for {@link JLabel}s in the {@link MetalLookAndFeel}.
+ */
public class MetalLabelUI
extends BasicLabelUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
/** The shared UI instance for JLabels. */
- private static MetalLabelUI instance = null;
+ protected static MetalLabelUI metalLabelUI;
/**
* Constructs a new instance of MetalLabelUI.
@@ -67,8 +76,36 @@ public class MetalLabelUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalLabelUI();
- return instance;
+ if (metalLabelUI == null)
+ metalLabelUI = new MetalLabelUI();
+ return metalLabelUI;
+ }
+
+ /**
+ * Draws the text for a disabled label, using the color defined in the
+ * {@link UIDefaults} 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"));
+ int mnemIndex = l.getDisplayedMnemonicIndex();
+ if (mnemIndex != -1)
+ BasicGraphicsUtils.drawStringUnderlineCharAt(g, s, mnemIndex, textX,
+ textY);
+ else
+ g.drawString(s, textX, textY);
+
+ g.setColor(savedColor);
}
}
diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java
index 7579c689b..5dfb7cc79 100644
--- a/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -42,16 +42,14 @@ import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
-import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
-import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.FontUIResource;
-import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.basic.BasicLookAndFeel;
+
/**
* A custom look and feel that is designed to look similar across different
* operating systems.
@@ -782,6 +780,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
new UIDefaults.ProxyLazyValue
("javax.swing.plaf.metal.MetalCheckBoxIcon"),
"CheckBoxMenuItem.background", new ColorUIResource(getControl()),
+ "CheckBoxMenuItem.checkIcon", MetalIconFactory.getCheckBoxMenuItemIcon(),
"ToolBar.background", new ColorUIResource(getControl()),
"Panel.background", new ColorUIResource(getControl()),
"Slider.background", new ColorUIResource(getControl()),
@@ -789,10 +788,18 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"ProgressBar.background", new ColorUIResource(getControl()),
"ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
"TabbedPane.background", new ColorUIResource(getControl()),
+ "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
+ "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
+ "InternalFrame.closeIcon",
+ MetalIconFactory.getInternalFrameCloseIcon(16),
+ "InternalFrame.maximizeIcon",
+ MetalIconFactory.getInternalFrameMaximizeIcon(16),
+ "InternalFrame.iconifyIcon",
+ MetalIconFactory.getInternalFrameMinimizeIcon(16),
"Label.background", new ColorUIResource(getControl()),
"Label.font", getControlTextFont(),
- "Label.disabledForeground", new ColorUIResource(getControlDisabled()),
- "Label.foreground", new ColorUIResource(getSystemTextColor()),
+ "Label.disabledForeground", new ColorUIResource(getInactiveControlTextColor()),
+ "Label.foreground", new ColorUIResource(getControlTextColor()),
"Menu.background", new ColorUIResource(getControl()),
"Menu.border", new MetalBorders.MenuItemBorder(),
"Menu.borderPainted", Boolean.TRUE,
@@ -808,6 +815,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"MenuItem.selectionBackground", getMenuSelectedBackground(),
"MenuItem.selectionForeground", getMenuSelectedForeground(),
"Panel.background", new ColorUIResource(getControl()),
+ "RadioButton.disabledText",
+ MetalLookAndFeel.getInactiveControlTextColor(),
"RadioButton.icon",
new UIDefaults.LazyValue()
{
@@ -816,6 +825,20 @@ public class MetalLookAndFeel extends BasicLookAndFeel
return MetalIconFactory.getRadioButtonIcon();
}
},
+ "RadioButton.focus", MetalLookAndFeel.getFocusColor(),
+ "RadioButton.font", MetalLookAndFeel.getControlTextFont(),
+ "RadioButton.select", MetalLookAndFeel.getControlShadow(),
+ "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(),
+ "RadioButtonMenuItem.borderPainted", Boolean.TRUE,
+ "RadioButtonMenuItem.checkIcon",
+ MetalIconFactory.getRadioButtonMenuItemIcon(),
+ "RadioButtonMenuItem.font", MetalLookAndFeel.getControlTextFont(),
+ "RadioButtonMenuItem.margin", new InsetsUIResource(2, 2, 2, 2),
+ "RadioButtonMenuItem.selectionBackground",
+ MetalLookAndFeel.getMenuSelectedBackground(),
+ "RadioButtonMenuItem.selectionForeground",
+ MetalLookAndFeel.getMenuSelectedForeground(),
+
"ScrollBar.background", new ColorUIResource(getControl()),
"ScrollBar.shadow", new ColorUIResource(getControlShadow()),
"ScrollBar.thumb", new ColorUIResource(getPrimaryControlShadow()),
@@ -837,6 +860,11 @@ public class MetalLookAndFeel extends BasicLookAndFeel
"Slider.trackWidth", new Integer(7),
"Slider.majorTickLength", new Integer(6),
+ "TabbedPane.font", new FontUIResource("Dialog", Font.BOLD, 12),
+ "TabbedPane.tabInsets", new InsetsUIResource(0, 9, 1, 9),
+ "TabbedPane.selectedTabPadInsets", new InsetsUIResource(2, 2, 2, 1),
+ "TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 6),
+
"ToggleButton.background", new ColorUIResource(getControl()),
"ToggleButton.border", MetalBorders.getButtonBorder(),
"ToggleButton.darkShadow", new ColorUIResource(getControlDarkShadow()),
@@ -895,7 +923,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
super.initSystemColorDefaults(defaults);
Object[] uiDefaults;
uiDefaults = new Object[] {
- "control", new ColorUIResource(getControl())
+ "control", new ColorUIResource(getControl()),
+ "desktop", new ColorUIResource(getDesktopColor())
};
defaults.putDefaults(uiDefaults);
}
diff --git a/javax/swing/plaf/metal/MetalRadioButtonUI.java b/javax/swing/plaf/metal/MetalRadioButtonUI.java
index a668f914e..4e80718a7 100644
--- a/javax/swing/plaf/metal/MetalRadioButtonUI.java
+++ b/javax/swing/plaf/metal/MetalRadioButtonUI.java
@@ -38,18 +38,37 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import 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;
+
+/**
+ * A UI delegate for the {@link JRadioButton} component under the
+ * {@link MetalLookAndFeel}.
+ */
public class MetalRadioButtonUI
extends BasicRadioButtonUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for JRadioButtons. */
- private static MetalRadioButtonUI instance = null;
-
+ /** Used to draw the focus rectangle. */
+ protected Color focusColor;
+
+ /** Used to fill the icon when the button is pressed. */
+ protected Color selectColor;
+
+ /** Used to draw disabled text. */
+ protected Color disabledTextColor;
+
/**
* Constructs a new instance of MetalRadioButtonUI.
*/
@@ -67,8 +86,102 @@ public class MetalRadioButtonUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalRadioButtonUI();
- return instance;
+ return new MetalRadioButtonUI();
+ }
+
+ /**
+ * Sets the default values for the specified button.
+ *
+ * @param b the button.
+ */
+ 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");
+ }
+
+ /**
+ * Clears any defaults set in the installDefaults() method.
+ *
+ * @param b the {@link JRadioButton}.
+ */
+ protected void uninstallDefaults(AbstractButton b)
+ {
+ super.uninstallDefaults(b);
+ disabledTextColor = null;
+ focusColor = null;
+ selectColor = null;
+ }
+
+ /**
+ * 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
+ * <code>RadioButton.select</code>.
+ *
+ * @return The select color.
+ */
+ protected Color getSelectColor()
+ {
+ return selectColor;
+ }
+
+ /**
+ * 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>.
+ *
+ * @return The disabled text color.
+ */
+ protected Color getDisabledTextColor()
+ {
+ return disabledTextColor;
+ }
+
+ /**
+ * 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
+ * <code>RadioButton.focus</code>.
+ *
+ * @return The color used to draw the focus rectangle.
+ *
+ * @see #paintFocus(Graphics, Rectangle, Dimension)
+ */
+ protected Color getFocusColor()
+ {
+ return focusColor;
+ }
+
+ /**
+ * Paints the {@link JRadioButton}.
+ *
+ * @param g the graphics device.
+ * @param c the component (an instance of {@link JRadioButton}).
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ super.paint(g, c);
+ // FIXME: disabled text isn't being drawn correctly, it's possible that
+ // it could be done here...
+ }
+
+ /**
+ * Paints the focus rectangle for the {@link JRadioButton}.
+ *
+ * @param g the graphics device.
+ * @param t the bounding rectangle for the text.
+ * @param d ???
+ */
+ protected void paintFocus(Graphics g, Rectangle t, Dimension d)
+ {
+ g.setColor(focusColor);
+ g.drawRect(t.x, t.y, t.width, t.height);
+ // FIXME: we seem to be drawing too tight a rectangle here, perhaps there
+ // is some padding to do somewhere???
}
+
}
diff --git a/javax/swing/plaf/metal/MetalSliderUI.java b/javax/swing/plaf/metal/MetalSliderUI.java
index 4b52c4b00..bd3212c84 100644
--- a/javax/swing/plaf/metal/MetalSliderUI.java
+++ b/javax/swing/plaf/metal/MetalSliderUI.java
@@ -42,8 +42,8 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.HashMap;
import javax.swing.Icon;
import javax.swing.JComponent;
@@ -59,13 +59,56 @@ import javax.swing.plaf.basic.BasicSliderUI;
public class MetalSliderUI
extends BasicSliderUI
{
- // TODO: find a use for this
+ /**
+ * A property change handler that updates the rendered component in response
+ * to specific property change events. This custom handler is used to
+ * intercept the "JSlider.isFilled" property, which is only recognised by
+ * the {@link MetalLookAndFeel}.
+ */
+ protected class MetalPropertyListener
+ extends BasicSliderUI.PropertyChangeHandler
+ {
+ /**
+ * Creates a new listener.
+ */
+ protected MetalPropertyListener()
+ {
+ }
+
+ /**
+ * Handles property change events. Events with the name "JSlider.isFilled"
+ * are handled here, and other events are passed to the superclass.
+ *
+ * @param e the property change event.
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(SLIDER_FILL))
+ {
+ Boolean b = (Boolean) e.getNewValue();
+ if (b == null)
+ filledSlider = false;
+ else
+ filledSlider = b.booleanValue();
+ }
+ else
+ super.propertyChange(e);
+ }
+ }
+
+ /** The thumb color (unused, because an icon is used to draw the thumb). */
protected static Color thumbColor;
- // TODO: find a use for this
+ /**
+ * The highlight color used for drawing the track rect when the slider is
+ * enabled.
+ */
protected static Color highlightColor;
- // TODO: find a use for this
+ /**
+ * The shadow color used for drawing the track rect when the slider is
+ * enabled.
+ */
protected static Color darkShadowColor;
/** The track width. */
@@ -85,17 +128,14 @@ public class MetalSliderUI
/** The gap between the track and the tick marks. */
protected final int TICK_BUFFER = 4;
+ /** A key to look up the filledSlider setting in the {@link UIManager}. */
+ protected final String SLIDER_FILL = "JSlider.isFilled";
+
/**
* A flag that controls whether or not the track is filled up to the value
* of the slider.
*/
protected boolean filledSlider;
-
- /** A key to look up the filledSlider setting in the {@link UIManager}. */
- protected final String SLIDER_FILL = "JSlider.isFilled";
-
- /** The UI instances for MetalSliderUIs */
- private static HashMap instances;
/**
* Constructs a new instance.
@@ -104,33 +144,27 @@ public class MetalSliderUI
{
super(null);
filledSlider = UIManager.getBoolean(SLIDER_FILL);
+ darkShadowColor = MetalLookAndFeel.getControlDarkShadow();
+ highlightColor = MetalLookAndFeel.getControlHighlight();
}
/**
* Returns an instance of MetalSliderUI.
*
- * @param component the component for which we return an UI instance
+ * @param component the component (ignored).
*
* @return an instance of MetalSliderUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instances == null)
- instances = new HashMap();
-
- Object o = instances.get(component);
- MetalSliderUI instance;
- if (o == null)
- {
- instance = new MetalSliderUI();
- instances.put(component, instance);
- }
- else
- instance = (MetalSliderUI) o;
-
- return instance;
+ return new MetalSliderUI();
}
+ /**
+ * Installs the default for this UI delegate in the supplied component.
+ *
+ * @param c the component.
+ */
public void installUI(JComponent c)
{
super.installUI(c);
@@ -140,6 +174,18 @@ public class MetalSliderUI
}
/**
+ * Creates a property change listener for the slider.
+ *
+ * @param slider the slider.
+ *
+ * @return A new instance of {@link MetalPropertyListener}.
+ */
+ protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
+ {
+ return new MetalPropertyListener();
+ }
+
+ /**
* Paints the thumb icon for the slider.
*
* @param g the graphics device.
@@ -153,46 +199,79 @@ public class MetalSliderUI
}
/**
- * Creates a property change listener for the slider.
- *
- * @param slider the slider.
- */
- protected PropertyChangeListener createPropertyChangeListener(JSlider slider)
- {
- // TODO: try to figure out why it might be necessary to override this
- // method as is done in Sun's implementation
- return super.createPropertyChangeListener(slider);
- }
-
- /**
* Paints the track along which the thumb control moves.
*
* @param g the graphics device.
*/
public void paintTrack(Graphics g)
{
+ Color shadowColor = MetalLookAndFeel.getControlShadow();
if (slider.getOrientation() == JSlider.HORIZONTAL)
- {
- if (filledSlider)
{
- // TODO: fill the track
+ int trackX = trackRect.x;
+ int trackY = trackRect.y + (trackRect.height - getTrackWidth()) / 2;
+ int trackW = trackRect.width - 1;
+ int trackH = getTrackWidth();
+
+ // draw border
+ if (slider.isEnabled())
+ BasicGraphicsUtils.drawEtchedRect(g, trackX, trackY, trackW, trackH,
+ darkShadowColor, shadowColor, darkShadowColor, highlightColor);
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawRect(trackX, trackY, trackW - 2, trackH - 2);
+ }
+
+ // fill track (if required)
+ if (filledSlider)
+ {
+ int xPos = xPositionForValue(slider.getValue());
+ int x = (slider.getInverted() ? xPos : trackRect.x);
+ int w = (slider.getInverted() ? trackX + trackW - xPos
+ : xPos - trackRect.x);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(x + 1, trackY + 1, w - 3, getTrackWidth() - 3);
+ if (slider.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(x + 1, trackY + 1, x + w - 3, trackY + 1);
+ g.drawLine(x + 1, trackY + 1, x + 1,
+ trackY + getTrackWidth() - 3);
+ }
+ }
}
- BasicGraphicsUtils.drawEtchedRect(g, trackRect.x, trackRect.y
- + (trackRect.height - getTrackWidth()) / 2, trackRect.width - 1,
- getTrackWidth(), Color.darkGray, Color.gray, Color.darkGray,
- Color.white);
- }
else
- {
- if (filledSlider)
{
- // TODO: fill the track
+ int trackX = trackRect.x + (trackRect.width - getTrackWidth()) / 2;
+ int trackY = trackRect.y;
+ int trackW = getTrackWidth();
+ int trackH = trackRect.height - 1;
+ if (slider.isEnabled())
+ BasicGraphicsUtils.drawEtchedRect(g, trackX, trackY, trackW, trackH,
+ darkShadowColor, shadowColor, darkShadowColor, highlightColor);
+ else
+ {
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawRect(trackX, trackY, trackW - 2, trackH - 2);
+ }
+
+ if (filledSlider)
+ {
+ int yPos = yPositionForValue(slider.getValue());
+ int y = (slider.getInverted() ? trackY : yPos);
+ int h = (slider.getInverted() ? yPos - trackY
+ : trackY + trackH - yPos);
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.fillRect(trackX + 1, y + 1, getTrackWidth() - 3, h - 3);
+ if (slider.isEnabled())
+ {
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(trackX + 1, y + 1, trackX + trackW - 3, y + 1);
+ g.drawLine(trackX + 1, y + 1, trackX + 1, y + h - 3);
+ }
+ }
}
- BasicGraphicsUtils.drawEtchedRect(g, trackRect.x + (trackRect.width
- - getTrackWidth()) / 2, trackRect.y, getTrackWidth(),
- trackRect.height - 1, Color.darkGray, Color.gray, Color.darkGray,
- Color.white);
- }
}
/**
@@ -262,12 +341,13 @@ public class MetalSliderUI
*/
protected int getThumbOverhang()
{
- // TODO: figure out what this is used for
+ // FIXME: for what might this method be used?
return 0;
}
protected void scrollDueToClickInTrack(int dir)
{
+ // FIXME: for what might this method be overridden?
super.scrollDueToClickInTrack(dir);
}
@@ -283,8 +363,10 @@ public class MetalSliderUI
{
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
- // TODO: get color from UIManager...
- g.setColor(new Color(153, 153, 204));
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength / 2);
}
@@ -300,8 +382,10 @@ public class MetalSliderUI
{
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
- // TODO: get color from UIManager...
- g.setColor(new Color(153, 153, 204));
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
g.drawLine(x, TICK_BUFFER, x, TICK_BUFFER + tickLength);
}
@@ -317,8 +401,10 @@ public class MetalSliderUI
{
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
- // TODO: get color from UIManager...
- g.setColor(new Color(153, 153, 204));
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength / 2, y);
}
@@ -334,8 +420,10 @@ public class MetalSliderUI
{
// Note the incoming 'g' has a translation in place to get us to the
// start of the tick rect already...
- // TODO: get color from UIManager...
- g.setColor(new Color(153, 153, 204));
+ if (slider.isEnabled())
+ g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
+ else
+ g.setColor(MetalLookAndFeel.getControlDisabled());
g.drawLine(TICK_BUFFER - 1, y, TICK_BUFFER - 1 + tickLength, y);
}
diff --git a/javax/swing/plaf/metal/MetalTabbedPaneUI.java b/javax/swing/plaf/metal/MetalTabbedPaneUI.java
index bf50f9172..1b5fe144f 100644
--- a/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+++ b/javax/swing/plaf/metal/MetalTabbedPaneUI.java
@@ -38,16 +38,70 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.awt.Graphics;
+import java.awt.LayoutManager;
import java.util.HashMap;
import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicTabbedPaneUI;
+/**
+ * A UI delegate used for the {@link JTabbedPane} component in the
+ * {@link MetalLookAndFeel}.
+ */
public class MetalTabbedPaneUI
extends BasicTabbedPaneUI
{
+ /**
+ * A {@link LayoutManager} responsible for placing all the tabs and the
+ * visible component inside the {@link JTabbedPane}. This class is only used
+ * for {@link JTabbedPane#WRAP_TAB_LAYOUT}.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
+ */
+ public class TabbedPaneLayout
+ extends BasicTabbedPaneUI.TabbedPaneLayout
+ {
+ /**
+ * Creates a new instance of the layout manager.
+ */
+ public TabbedPaneLayout()
+ {
+ }
+
+ /**
+ * Overridden to do nothing, because tab runs are not rotated in the
+ * {@link MetalLookAndFeel}.
+ *
+ * @param tabPlacement the tab placement (one of {@link #TOP},
+ * {@link #BOTTOM}, {@link #LEFT} or {@link #RIGHT}).
+ * @param selectedRun the index of the selected run.
+ */
+ protected void rotateTabRuns(int tabPlacement, int selectedRun)
+ {
+ // do nothing, because tab runs are not rotated in the MetalLookAndFeel
+ }
+
+ /**
+ * Overridden to do nothing, because the selected tab does not have extra
+ * padding in the {@link MetalLookAndFeel}.
+ *
+ * @param tabPlacement the tab placement (one of {@link #TOP},
+ * {@link #BOTTOM}, {@link #LEFT} or {@link #RIGHT}).
+ * @param selectedIndex the index of the selected tab.
+ */
+ protected void padSelectedTab(int tabPlacement, int selectedIndex)
+ {
+ // do nothing, because the selected tab does not have extra padding in
+ // the MetalLookAndFeel
+ }
+ }
+
/** The shared UI instance for JTabbedPanes. */
private static HashMap instances = null;
@@ -83,4 +137,228 @@ public class MetalTabbedPaneUI
return instance;
}
+
+ /**
+ * Creates and returns an instance of {@link TabbedPaneLayout}.
+ *
+ * @return A layout manager used by this UI delegate.
+ */
+ protected LayoutManager createLayoutManager()
+ {
+ return new TabbedPaneLayout();
+ }
+
+ /**
+ * Paints the border for a single tab.
+ *
+ * @param g the graphics device.
+ * @param tabPlacement the tab placement ({@link #TOP}, {@link #LEFT},
+ * {@link #BOTTOM} or {@link #RIGHT}).
+ * @param tabIndex the index of the tab to draw the border for.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param isSelected indicates whether or not the tab is selected.
+ */
+ protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
+ int x, int y, int w, int h, boolean isSelected)
+ {
+ if (tabPlacement == TOP)
+ paintTopTabBorder(tabIndex, g, x, y, w, h, 0, 0, isSelected);
+ else if (tabPlacement == LEFT)
+ paintLeftTabBorder(tabIndex, g, x, y, w, h, 0, 0, isSelected);
+ else if (tabPlacement == BOTTOM)
+ paintBottomTabBorder(tabIndex, g, x, y, w, h, 0, 0, isSelected);
+ else if (tabPlacement == RIGHT)
+ paintRightTabBorder(tabIndex, g, x, y, w, h, 0, 0, isSelected);
+ else
+ throw new AssertionError("Unrecognised 'tabPlacement' argument.");
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the top
+ * ({@link #TOP}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintTopTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ if (isSelected)
+ {
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 1, y + h, x + 1, y + 6);
+ g.drawLine(x + 1, y + 6, x + 6, y + 1);
+ g.drawLine(x + 6, y + 1, x + w - 1, y + 1);
+ }
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y + h - 1, x, y + 6);
+ g.drawLine(x, y + 6, x + 6, y);
+ g.drawLine(x + 6, y, x + w, y);
+ g.drawLine(x + w, y, x + w, y + h - 1);
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the left
+ * ({@link #LEFT}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintLeftTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ if (isSelected)
+ {
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 1, y + h, x + 1, y + 6);
+ g.drawLine(x + 1, y + 6, x + 6, y + 1);
+ g.drawLine(x + 6, y + 1, x + w - 1, y + 1);
+ }
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y + h, x, y + 6);
+ g.drawLine(x, y + 6, x + 6, y);
+ g.drawLine(x + 6, y, x + w - 1, y);
+ g.drawLine(x, y + h, x + w - 1, y + h);
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the right
+ * ({@link #RIGHT}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintRightTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ if (isSelected)
+ {
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x, y + 1, x + w - 7, y + 1);
+ g.drawLine(x + w - 7, y + 1, x + w - 1, y + 7);
+ }
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y, x + w - 7, y);
+ g.drawLine(x + w - 7, y, x + w - 1, y + 6);
+ g.drawLine(x + w - 1, y + 6, x + w - 1, y + h - 1);
+ g.drawLine(x + w - 1, y + h, x, y + h);
+ }
+
+ /**
+ * Paints the border for a tab assuming that the tab position is at the bottom
+ * ({@link #BOTTOM}).
+ *
+ * @param tabIndex the tab index.
+ * @param g the graphics device.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param btm ???
+ * @param rght ???
+ * @param isSelected indicates whether the tab is selected.
+ */
+ protected void paintBottomTabBorder(int tabIndex, Graphics g, int x, int y,
+ int w, int h, int btm, int rght, boolean isSelected)
+ {
+ if (isSelected)
+ {
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawLine(x + 1, y, x + 1, y + h - 7);
+ g.drawLine(x + 1, y + h - 7, x + 7, y + h - 1);
+ }
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawLine(x, y, x, y + h - 7);
+ g.drawLine(x, y + h - 7, x + 6, y + h - 1);
+ g.drawLine(x + 6, y + h - 1, x + w, y + h - 1);
+ g.drawLine(x + w, y + h - 1, x + w, y);
+ }
+
+ /**
+ * Paints the background for a tab.
+ *
+ * @param g the graphics device.
+ * @param tabPlacement the tab placement ({@link #TOP}, {@link #LEFT},
+ * {@link #BOTTOM} or {@link #RIGHT}).
+ * @param tabIndex the index of the tab to draw the border for.
+ * @param x the x-coordinate for the tab's bounding rectangle.
+ * @param y the y-coordinate for the tab's bounding rectangle.
+ * @param w the width for the tab's bounding rectangle.
+ * @param h the height for the tab's bounding rectangle.
+ * @param isSelected indicates whether or not the tab is selected.
+ */
+ protected void paintTabBackground(Graphics g, int tabPlacement,
+ int tabIndex, int x, int y, int w, int h, boolean isSelected)
+ {
+ if (isSelected)
+ g.setColor(MetalLookAndFeel.getControl());
+ else
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ int[] px, py;
+ if (tabPlacement == TOP)
+ {
+ px = new int[] {x + 6, x + w - 1, x + w -1, x + 2, x + 2};
+ py = new int[] {y + 2, y + 2, y + h - 1, y + h -1, y + 6};
+ }
+ else if (tabPlacement == LEFT)
+ {
+ px = new int[] {x + 6, x + w - 1, x + w -1, x + 2, x + 2};
+ py = new int[] {y + 2, y + 2, y + h - 1, y + h -1, y + 6};
+ }
+ else if (tabPlacement == BOTTOM)
+ {
+ px = new int[] {x + 2, x + w - 1, x + w -1, x + 8, x + 2};
+ py = new int[] {y, y, y + h - 1, y + h -1, y + h - 7};
+ }
+ else if (tabPlacement == RIGHT)
+ {
+ px = new int[] {x + 2, x + w - 7, x + w - 1, x + w - 1, x + 2};
+ py = new int[] {y + 2, y + 2, y + 7, y + h -1, y + h - 1};
+ }
+ else
+ throw new AssertionError("Unrecognised 'tabPlacement' argument.");
+ g.fillPolygon(px, py, 5);
+ }
+
+ /**
+ * Returns <code>true</code> if the tabs in the specified run should be
+ * padded to make the run fill the width/height of the {@link JTabbedPane}.
+ *
+ * @param tabPlacement the tab placement for the {@link JTabbedPane} (one of
+ * {@link #TOP}, {@link #BOTTOM}, {@link #LEFT} and {@link #RIGHT}).
+ * @param run the run index.
+ *
+ * @return A boolean.
+ */
+ protected boolean shouldPadTabRun(int tabPlacement, int run)
+ {
+ // as far as I can tell, all runs should be padded except the last run
+ // (which is drawn at the very top for tabPlacement == TOP)
+ return run < this.runCount - 1;
+ }
+
}
diff --git a/javax/swing/plaf/metal/MetalTreeUI.java b/javax/swing/plaf/metal/MetalTreeUI.java
index d85d61c24..8d16f7463 100644
--- a/javax/swing/plaf/metal/MetalTreeUI.java
+++ b/javax/swing/plaf/metal/MetalTreeUI.java
@@ -75,8 +75,8 @@ public class MetalTreeUI
MetalTreeUI instance;
if (o == null)
{
- instance = new MetalTreeUI();
- instances.put(component, instance);
+ instance = new MetalTreeUI();
+ instances.put(component, instance);
}
else
instance = (MetalTreeUI) o;
diff --git a/javax/swing/plaf/multi/MultiButtonUI.java b/javax/swing/plaf/multi/MultiButtonUI.java
new file mode 100644
index 000000000..ac2a5fa91
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiButtonUI.java
@@ -0,0 +1,352 @@
+/* MultiButtonUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ButtonUI} instances, one
+ * from the primary look and feel, and one or more from the auxiliary look and
+ * feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiButtonUI extends ButtonUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiButtonUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiButtonUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiButtonUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiButtonUI mui = new MultiButtonUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiButtonUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiButtonUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiButtonUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+} \ No newline at end of file
diff --git a/javax/swing/plaf/multi/MultiColorChooserUI.java b/javax/swing/plaf/multi/MultiColorChooserUI.java
new file mode 100644
index 000000000..8adb9500b
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiColorChooserUI.java
@@ -0,0 +1,352 @@
+/* MultiColorChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ColorChooserUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ColorChooserUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiColorChooserUI extends ColorChooserUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiColorChooserUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiColorChooserUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiColorChooserUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiColorChooserUI mui = new MultiColorChooserUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiColorChooserUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiColorChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiColorChooserUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiComboBoxUI.java b/javax/swing/plaf/multi/MultiComboBoxUI.java
new file mode 100644
index 000000000..05279d7d6
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiComboBoxUI.java
@@ -0,0 +1,427 @@
+/* MultiComboBoxUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ComboBoxUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiComboBoxUI extends ComboBoxUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiComboBoxUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiComboBoxUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiComboBoxUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiComboBoxUI mui = new MultiComboBoxUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiComboBoxUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#setPopupVisible(JComboBox, boolean)} method
+ * for all the UI delegates managed by this <code>MultiComboBoxUI</code>.
+ *
+ * @param c the component.
+ * @param visible the visible state.
+ */
+ public void setPopupVisible(JComboBox c, boolean visible) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ ui.setPopupVisible(c, visible);
+ }
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#isPopupVisible(JComboBox)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The result for the UI delegate from the primary look and feel.
+ */
+ public boolean isPopupVisible(JComboBox c) {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ result = ui.isPopupVisible(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ /* boolean ignored = */ ui.isPopupVisible(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComboBoxUI#isFocusTraversable(JComboBox)} method for all
+ * the UI delegates managed by this <code>MultiComboBoxUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return <code>true</code> if the combo box is traversable according to the
+ * UI delegate in the primary look and feel, and <code>false</code>
+ * otherwise.
+ */
+ public boolean isFocusTraversable(JComboBox c) {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ result = ui.isFocusTraversable(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComboBoxUI ui = (ComboBoxUI) iterator.next();
+ /* boolean ignored = */ ui.isFocusTraversable(c);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiDesktopIconUI.java b/javax/swing/plaf/multi/MultiDesktopIconUI.java
new file mode 100644
index 000000000..186ce32fe
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiDesktopIconUI.java
@@ -0,0 +1,352 @@
+/* MultiDesktopIconUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopIconUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link DesktopIconUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiDesktopIconUI extends DesktopIconUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiDesktopIconUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiDesktopIconUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiDesktopIconUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiDesktopIconUI mui = new MultiDesktopIconUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiDesktopIconUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiDesktopIconUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiDesktopIconUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiDesktopPaneUI.java b/javax/swing/plaf/multi/MultiDesktopPaneUI.java
new file mode 100644
index 000000000..d48fb2b01
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiDesktopPaneUI.java
@@ -0,0 +1,352 @@
+/* MultiDesktopIconUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.DesktopPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link DesktopPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiDesktopPaneUI extends DesktopPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiDesktopPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiDesktopPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiDesktopPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiDesktopPaneUI mui = new MultiDesktopPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiDesktopPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiDesktopPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiDesktopPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiFileChooserUI.java b/javax/swing/plaf/multi/MultiFileChooserUI.java
new file mode 100644
index 000000000..6f8826010
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiFileChooserUI.java
@@ -0,0 +1,505 @@
+/* MultiFileChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileView;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.FileChooserUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link FileChooserUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiFileChooserUI extends FileChooserUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiFileChooserUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiFileChooserUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiFileChooserUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiFileChooserUI mui = new MultiFileChooserUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiFileChooserUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getAcceptAllFileFilter(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the filter for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The filter returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public FileFilter getAcceptAllFileFilter(JFileChooser chooser) {
+ FileFilter result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getAcceptAllFileFilter(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* FileFilter ignored = */ ui.getAcceptAllFileFilter(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getFileView(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the view for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The view returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public FileView getFileView(JFileChooser chooser) {
+ FileView result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getFileView(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* FileView ignored = */ ui.getFileView(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getApproveButtonText(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the text for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The text returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public String getApproveButtonText(JFileChooser chooser) {
+ String result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getApproveButtonText(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* String ignored = */ ui.getApproveButtonText(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#getDialogTitle(JFileChooser)} method
+ * for all the UI delegates managed by this <code>MultiFileChooserUI</code>,
+ * returning the title for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param chooser the file chooser.
+ *
+ * @return The title returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public String getDialogTitle(JFileChooser chooser) {
+ String result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ result = ui.getDialogTitle(chooser);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ /* String ignored = */ ui.getDialogTitle(chooser);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#rescanCurrentDirectory(JFileChooser)}
+ * method for all the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>.
+ *
+ * @param chooser the file chooser.
+ */
+ public void rescanCurrentDirectory(JFileChooser chooser) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ ui.rescanCurrentDirectory(chooser);
+ }
+ }
+
+ /**
+ * Calls the {@link FileChooserUI#ensureFileIsVisible(JFileChooser, File)}
+ * method for all the UI delegates managed by this
+ * <code>MultiFileChooserUI</code>.
+ *
+ * @param chooser the file chooser.
+ * @param file the file.
+ */
+ public void ensureFileIsVisible(JFileChooser chooser, File file) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ FileChooserUI ui = (FileChooserUI) iterator.next();
+ ui.ensureFileIsVisible(chooser, file);
+ }
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiInternalFrameUI.java b/javax/swing/plaf/multi/MultiInternalFrameUI.java
new file mode 100644
index 000000000..01d1df6a1
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiInternalFrameUI.java
@@ -0,0 +1,353 @@
+/* MultiInternalFrameUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.InternalFrameUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link InternalFrameUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiInternalFrameUI extends InternalFrameUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiInternalFrameUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiInternalFrameUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiInternalFrameUI</code>
+ * is returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiInternalFrameUI mui = new MultiInternalFrameUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiInternalFrameUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiInternalFrameUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiInternalFrameUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiLabelUI.java b/javax/swing/plaf/multi/MultiLabelUI.java
new file mode 100644
index 000000000..ba5b9d473
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiLabelUI.java
@@ -0,0 +1,352 @@
+/* MultiLabelUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.LabelUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link LabelUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiLabelUI extends LabelUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiLabelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiLabelUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiLabelUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiLabelUI mui = new MultiLabelUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiLabelUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiLabelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiLabelUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiListUI.java b/javax/swing/plaf/multi/MultiListUI.java
new file mode 100644
index 000000000..7350b4541
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiListUI.java
@@ -0,0 +1,446 @@
+/* MultiListUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ListUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ListUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiListUI extends ListUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiListUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiListUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiListUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiListUI mui = new MultiListUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiListUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiListUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#locationToIndex(JList, Point)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the index for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param location the location.
+ *
+ * @return The index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int locationToIndex(JList list, Point location) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.locationToIndex(list, location);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* int ignored = */ ui.locationToIndex(list, location);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#indexToLocation(JList, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param index the index.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Point indexToLocation(JList list, int index) {
+ Point result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.indexToLocation(list, index);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* Point ignored = */ ui.indexToLocation(list, index);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ListUI#getCellBounds(JList, int, int)} method for all
+ * the UI delegates managed by this <code>MultiListUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param list the list.
+ * @param index1 the first index.
+ * @param index2 the second index.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getCellBounds(JList list, int index1, int index2) {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ result = ui.getCellBounds(list, index1, index2);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ListUI ui = (ListUI) iterator.next();
+ /* Rectangle ignored = */ ui.getCellBounds(list, index1, index2);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiLookAndFeel.java b/javax/swing/plaf/multi/MultiLookAndFeel.java
new file mode 100644
index 000000000..a70a8ff69
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiLookAndFeel.java
@@ -0,0 +1,241 @@
+/* MultiLookAndFeel.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.util.Vector;
+
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A look and feel that provides the ability to use auxiliary look and feels
+ * in addition to the primary look and feel.
+ */
+public class MultiLookAndFeel extends LookAndFeel {
+
+ /**
+ * Creates a new instance of the look and feel.
+ */
+ public MultiLookAndFeel()
+ {
+ }
+
+ /**
+ * Returns the name for the look and feel.
+ *
+ * @return "Multiplexing Look and Feel".
+ */
+ public String getName()
+ {
+ return "Multiplexing Look and Feel";
+ }
+
+ /**
+ * Returns an identifier for the look and feel.
+ *
+ * @return "Multiplex".
+ */
+ public String getID()
+ {
+ return "Multiplex";
+ }
+
+ /**
+ * Returns a description of the look and feel.
+ *
+ * @return A description of the look and feel.
+ */
+ public String getDescription()
+ {
+ return "Allows multiple UI instances per component instance";
+ }
+
+ /**
+ * Returns <code>false</code> to indicate that this look and feel is not
+ * native to any platform.
+ *
+ * @return <code>false</code>.
+ */
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>true</code> always, since this look and feel is supported on
+ * all platforms.
+ *
+ * @return <code>true</code>.
+ */
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
+
+ /**
+ * Creates and returns the UI defaults for this look and feel.
+ *
+ * @return The UI defaults.
+ */
+ public UIDefaults getDefaults()
+ {
+ UIDefaults defaults = new UIDefaults();
+ defaults.put("ButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("CheckBoxUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("CheckBoxMenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("ColorChooserUI",
+ "javax.swing.plaf.multi.MultiColorChooserUI");
+ defaults.put("ComboBoxUI", "javax.swing.plaf.multi.MultiComboBoxUI");
+ defaults.put("DesktopPaneUI", "javax.swing.plaf.multi.MultiDesktopPaneUI");
+ defaults.put("DesktopIconUI", "javax.swing.plaf.multi.MultiDesktopIconUI");
+ defaults.put("EditorPaneUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("FileChooserUI", "javax.swing.plaf.multi.MultiFileChooserUI");
+ defaults.put("FormattedTextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("InternalFrameUI",
+ "javax.swing.plaf.multi.MultiInternalFrameUI");
+ defaults.put("LabelUI", "javax.swing.plaf.multi.MultiLabelUI");
+ defaults.put("ListUI", "javax.swing.plaf.multi.MultiListUI");
+ defaults.put("MenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("MenuUI", "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("MenuBarUI", "javax.swing.plaf.multi.MultiMenuBarUI");
+ defaults.put("OptionPaneUI", "javax.swing.plaf.multi.MultiOptionPaneUI");
+ defaults.put("PanelUI", "javax.swing.plaf.multi.MultiPanelUI");
+ defaults.put("PasswordFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("PopupMenuUI", "javax.swing.plaf.multi.MultiPopupMenuUI");
+ defaults.put("PopupMenuSeparatorUI",
+ "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("ProgressBarUI", "javax.swing.plaf.multi.MultiProgressBarUI");
+ defaults.put("RadioButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("RadioButtonMenuItemUI",
+ "javax.swing.plaf.multi.MultiMenuItemUI");
+ defaults.put("RootPaneUI", "javax.swing.plaf.multi.MultiRootPaneUI");
+ defaults.put("ScrollBarUI", "javax.swing.plaf.multi.MultiScrollBarUI");
+ defaults.put("ScrollPaneUI", "javax.swing.plaf.multi.MultiScrollPaneUI");
+ defaults.put("SeparatorUI", "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("SliderUI", "javax.swing.plaf.multi.MultiSliderUI");
+ defaults.put("SpinnerUI", "javax.swing.plaf.multi.MultiSpinnerUI");
+ defaults.put("SplitPaneUI", "javax.swing.plaf.multi.MultiSplitPaneUI");
+ defaults.put("TabbedPaneUI", "javax.swing.plaf.multi.MultiTabbedPaneUI");
+ defaults.put("TableHeaderUI", "javax.swing.plaf.multi.MultiTableHeaderUI");
+ defaults.put("TableUI", "javax.swing.plaf.multi.MultiTableUI");
+ defaults.put("TextAreaUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("TextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("TextPaneUI", "javax.swing.plaf.multi.MultiTextUI");
+ defaults.put("ToggleButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
+ defaults.put("ToolBarSeparatorUI",
+ "javax.swing.plaf.multi.MultiSeparatorUI");
+ defaults.put("ToolBarUI", "javax.swing.plaf.multi.MultiToolBarUI");
+ defaults.put("ToolTipUI", "javax.swing.plaf.multi.MultiToolTipUI");
+ defaults.put("ViewportUI", "javax.swing.plaf.multi.MultiViewportUI");
+ return defaults;
+ }
+
+ /**
+ * Creates the UI delegates for the <code>target</code> component and
+ * returns a multiplexing UI delegate (<code>mui</code>) if there are
+ * multiple delegates.
+ *
+ * @param mui a multiplexing UI delegate appropriate for the component.
+ * @param uis a vector into which the UI delegates will be added.
+ * @param target the target component.
+ *
+ * @return A UI delegate.
+ */
+ public static ComponentUI createUIs(ComponentUI mui, Vector uis,
+ JComponent target)
+ {
+ // get primary UI delegate for 'target', and add it to uis
+ ComponentUI ui = null;
+ LookAndFeel primary = UIManager.getLookAndFeel();
+ if (primary != null)
+ {
+ ui = UIManager.getUI(target);
+ uis.add(ui);
+ }
+ // for any auxiliary look and feels in use, get the UI delegate and add
+ // it to uis
+ LookAndFeel[] auxlafs = UIManager.getAuxiliaryLookAndFeels();
+ for (int i = 0; i < auxlafs.length; i++)
+ {
+ LookAndFeel auxlaf = auxlafs[i];
+ // FIXME: here I call getDefaults() to get the UI delegate from the
+ // auxiliary look and feel. But getDefaults() creates a new set of
+ // defaults every time it is called, which is wasteful. Unfortunately
+ // I cannot find another way to get the UI delegate, so I'm doing it
+ // anyway...
+ UIDefaults defaults = auxlaf.getDefaults();
+ ui = defaults.getUI(target);
+ if (ui != null)
+ uis.add(ui);
+ }
+ // if uis contains more than 1 delegate, return mui, otherwise return
+ // the primary delegate
+ if (uis.size() > 1)
+ return mui;
+ else
+ return ui;
+ }
+
+ /**
+ * Returns an array containing the same {@link ComponentUI} instances as
+ * <code>uis</code>. If <code>uis</code> is <code>null</code>, a zero-length
+ * array is returned.
+ *
+ * @param uis a list of {@link ComponentUI} references (<code>null</code>
+ * permitted).
+ *
+ * @return An array containing the same {@link ComponentUI} instances as
+ * <code>uis</code>, or <code>null</code> if <code>uis</code> is
+ * empty.
+ */
+ protected static ComponentUI[] uisToArray(Vector uis)
+ {
+ if (uis == null)
+ return new ComponentUI[0];
+ int size = uis.size();
+ if (size == 0)
+ return null;
+ ComponentUI[] result = new ComponentUI[size];
+ uis.copyInto(result);
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiMenuBarUI.java b/javax/swing/plaf/multi/MultiMenuBarUI.java
new file mode 100644
index 000000000..a8e805af1
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiMenuBarUI.java
@@ -0,0 +1,352 @@
+/* MultiMenuBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MenuBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiMenuBarUI extends MenuBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiMenuBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiMenuBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiMenuBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiMenuBarUI mui = new MultiMenuBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiMenuBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiMenuBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiMenuBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiMenuItemUI.java b/javax/swing/plaf/multi/MultiMenuItemUI.java
new file mode 100644
index 000000000..ccab5feec
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiMenuItemUI.java
@@ -0,0 +1,352 @@
+/* MultiMenuItemUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.MenuItemUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MenuItemUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiMenuItemUI extends MenuItemUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiMenuItemUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiMenuItemUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiItemUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiMenuItemUI mui = new MultiMenuItemUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiMenuItemUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiMenuItemUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiMenuItemUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiOptionPaneUI.java b/javax/swing/plaf/multi/MultiOptionPaneUI.java
new file mode 100644
index 000000000..c5cb913a0
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiOptionPaneUI.java
@@ -0,0 +1,396 @@
+/* MultiOptionPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JOptionPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.OptionPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link OptionPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiOptionPaneUI extends OptionPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiOptionPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiOptionPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiOptionPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiOptionPaneUI mui = new MultiOptionPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiOptionPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiOptionPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link OptionPaneUI#selectInitialValue(JOptionPane)} method for
+ * all the UI delegates managed by this <code>MultiOptionPaneUI</code>.
+ *
+ * @param pane the option pane.
+ */
+ public void selectInitialValue(JOptionPane pane) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ ui.selectInitialValue(pane);
+ }
+ }
+
+ /**
+ * Calls the {@link OptionPaneUI#containsCustomComponents(JOptionPane)}
+ * method for all the UI delegates managed by this
+ * <code>MultiOptionPaneUI</code>, returning the result for the UI delegate
+ * from the primary look and feel.
+ *
+ * @param pane the option pane.
+ *
+ * @return The result for the UI delegate from the primary look and feel.
+ */
+ public boolean containsCustomComponents(JOptionPane pane) {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ result = ui.containsCustomComponents(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ OptionPaneUI ui = (OptionPaneUI) iterator.next();
+ /* boolean ignored = */ ui.containsCustomComponents(pane);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiPanelUI.java b/javax/swing/plaf/multi/MultiPanelUI.java
new file mode 100644
index 000000000..67629b2fe
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiPanelUI.java
@@ -0,0 +1,352 @@
+/* MultiPanelUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PanelUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link PanelUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiPanelUI extends PanelUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiPanelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiPanelUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiPanelUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiPanelUI mui = new MultiPanelUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiPanelUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiPanelUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiPanelUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiPopupMenuUI.java b/javax/swing/plaf/multi/MultiPopupMenuUI.java
new file mode 100644
index 000000000..161429d29
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiPopupMenuUI.java
@@ -0,0 +1,352 @@
+/* MultiPopupMenuUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.PopupMenuUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link PopupMenuUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiPopupMenuUI extends PopupMenuUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiPopupMenuUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiPopupMenuUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiPopupMenuUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiPopupMenuUI mui = new MultiPopupMenuUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiPopupMenuUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiPopupMenuUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiPopupMenuUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiProgressBarUI.java b/javax/swing/plaf/multi/MultiProgressBarUI.java
new file mode 100644
index 000000000..c5dbbe815
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiProgressBarUI.java
@@ -0,0 +1,352 @@
+/* MultiProgressBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ProgressBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ProgressBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiProgressBarUI extends ProgressBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiProgressBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiProgressBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiProgressBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiProgressBarUI mui = new MultiProgressBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiProgressBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiProgressBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiProgressBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiRootPaneUI.java b/javax/swing/plaf/multi/MultiRootPaneUI.java
new file mode 100644
index 000000000..bd0cb5c1d
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiRootPaneUI.java
@@ -0,0 +1,352 @@
+/* MultiRootPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.RootPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link RootPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiRootPaneUI extends RootPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiRootPanelUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiRootPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiRootPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiRootPaneUI mui = new MultiRootPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiRootPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiRootPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiRootPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiScrollBarUI.java b/javax/swing/plaf/multi/MultiScrollBarUI.java
new file mode 100644
index 000000000..1a993b840
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiScrollBarUI.java
@@ -0,0 +1,352 @@
+/* MultiScrollBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ScrollBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ScrollBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiScrollBarUI extends ScrollBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiScrollBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiScrollBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiScrollBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiScrollBarUI mui = new MultiScrollBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiScrollBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiScrollBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiScrollBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiScrollPaneUI.java b/javax/swing/plaf/multi/MultiScrollPaneUI.java
new file mode 100644
index 000000000..a50c3ba7f
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiScrollPaneUI.java
@@ -0,0 +1,352 @@
+/* MultiScrollPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ScrollPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ScrollPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiScrollPaneUI extends ScrollPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiScrollPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiScrollPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiScrollPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiScrollPaneUI mui = new MultiScrollPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiScrollPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiScrollPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiScrollPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiSeparatorUI.java b/javax/swing/plaf/multi/MultiSeparatorUI.java
new file mode 100644
index 000000000..f8e4feae7
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiSeparatorUI.java
@@ -0,0 +1,352 @@
+/* MultiSeparatorUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SeparatorUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link MultiSeparatorUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSeparatorUI extends SeparatorUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSeparatorUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSeparatorUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSeparatorUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSeparatorUI mui = new MultiSeparatorUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSeparatorUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSeparatorUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSeparatorUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiSliderUI.java b/javax/swing/plaf/multi/MultiSliderUI.java
new file mode 100644
index 000000000..8a4aab6e0
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiSliderUI.java
@@ -0,0 +1,352 @@
+/* MultiSliderUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SliderUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SliderUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSliderUI extends SliderUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSliderUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSliderUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSliderUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSliderUI mui = new MultiSliderUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSliderUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSliderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSliderUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiSpinnerUI.java b/javax/swing/plaf/multi/MultiSpinnerUI.java
new file mode 100644
index 000000000..70068e82a
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiSpinnerUI.java
@@ -0,0 +1,352 @@
+/* MultiSpinnerUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SpinnerUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SpinnerUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSpinnerUI extends SpinnerUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSpinnerUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSpinnerUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSpinnerUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSpinnerUI mui = new MultiSpinnerUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSpinnerUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSpinnerUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSpinnerUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiSplitPaneUI.java b/javax/swing/plaf/multi/MultiSplitPaneUI.java
new file mode 100644
index 000000000..f481f8109
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiSplitPaneUI.java
@@ -0,0 +1,488 @@
+/* MultiSplitPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JSplitPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.SplitPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link SplitPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiSplitPaneUI extends SplitPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiSplitPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiSplitPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiSplitPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiSplitPaneUI mui = new MultiSplitPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiSplitPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#resetToPreferredSizes(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ */
+ public void resetToPreferredSizes(JSplitPane pane) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.resetToPreferredSizes(pane);
+ }
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#setDividerLocation(JSplitPane, int)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ * @param location the location.
+ */
+ public void setDividerLocation(JSplitPane pane, int location) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.setDividerLocation(pane, location);
+ }
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getDividerLocation(JSplitPane)} method for all
+ * the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getDividerLocation(JSplitPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getMinimumDividerLocation(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getMinimumDividerLocation(JSplitPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getMinimumDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getMinimumDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#getMaximumDividerLocation(JSplitPane)} method
+ * for all the UI delegates managed by this <code>MultiSplitPaneUI</code>,
+ * returning the location for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param pane the component.
+ *
+ * @return The location returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getMaximumDividerLocation(JSplitPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ result = ui.getMaximumDividerLocation(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ /* int ignored = */ ui.getMaximumDividerLocation(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link SplitPaneUI#finishedPaintingChildren(JSplitPane,
+ * Graphics)} method for all the UI delegates managed by this
+ * <code>MultiSplitPaneUI</code>.
+ *
+ * @param pane the component.
+ * @param g the graphics device.
+ */
+ public void finishedPaintingChildren(JSplitPane pane, Graphics g) {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ SplitPaneUI ui = (SplitPaneUI) iterator.next();
+ ui.finishedPaintingChildren(pane, g);
+ }
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiTabbedPaneUI.java b/javax/swing/plaf/multi/MultiTabbedPaneUI.java
new file mode 100644
index 000000000..575de192a
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiTabbedPaneUI.java
@@ -0,0 +1,444 @@
+/* MultiTabbedPaneUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TabbedPaneUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TabbedPaneUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTabbedPaneUI extends TabbedPaneUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTabbedPaneUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTabbedPaneUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTabbedPaneUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTabbedPaneUI mui = new MultiTabbedPaneUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTabbedPaneUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTabbedPaneUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#tabForCoordinate(JTabbedPane, int, int)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the tab index for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return The tab index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int tabForCoordinate(JTabbedPane pane, int x, int y) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.tabForCoordinate(pane, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.tabForCoordinate(pane, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#getTabBounds(JTabbedPane, int)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the bounds for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ * @param index the index.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getTabBounds(JTabbedPane pane, int index) {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.getTabBounds(pane, index);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.getTabRunCount(pane);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TabbedPaneUI#getTabRunCount(JTabbedPane)}
+ * method for all the UI delegates managed by this
+ * <code>MultiTabbedPaneUI</code>, returning the nt for the UI
+ * delegate from the primary look and feel.
+ *
+ * @param pane the tabbed pane.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getTabRunCount(JTabbedPane pane) {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ result = ui.getTabRunCount(pane);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TabbedPaneUI ui = (TabbedPaneUI) iterator.next();
+ /* int ignored = */ ui.getTabRunCount(pane);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiTableHeaderUI.java b/javax/swing/plaf/multi/MultiTableHeaderUI.java
new file mode 100644
index 000000000..6c59cef6c
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiTableHeaderUI.java
@@ -0,0 +1,352 @@
+/* MultiTableHeaderUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TableHeaderUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TableHeaderUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTableHeaderUI extends TableHeaderUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTableHeaderUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTableHeaderUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTableHeaderUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTableHeaderUI mui = new MultiTableHeaderUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTableHeaderUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTableHeaderUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTableHeaderUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiTableUI.java b/javax/swing/plaf/multi/MultiTableUI.java
new file mode 100644
index 000000000..2e5b5bcf5
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiTableUI.java
@@ -0,0 +1,352 @@
+/* MultiTableUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TableUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TableUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTableUI extends TableUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTableUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTableUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTableUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTableUI mui = new MultiTableUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTableUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTableUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTableUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiTextUI.java b/javax/swing/plaf/multi/MultiTextUI.java
new file mode 100644
index 000000000..c5dee247d
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiTextUI.java
@@ -0,0 +1,617 @@
+/* MultiTextUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TextUI;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.EditorKit;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.Position;
+import javax.swing.text.View;
+import javax.swing.text.Position.Bias;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TextUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTextUI extends TextUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTextUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTextUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTextUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTextUI mui = new MultiTextUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTextUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#modelToView(JTextComponent, int)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle modelToView(JTextComponent tc, int pos)
+ throws BadLocationException
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.modelToView(tc, pos);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* Rectangle ignored = */ ui.modelToView(tc, pos);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#modelToView(JTextComponent, int, Position.Bias)}
+ * method for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle modelToView(JTextComponent tc, int pos, Bias bias)
+ throws BadLocationException
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.modelToView(tc, pos, bias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* Rectangle ignored = */ ui.modelToView(tc, pos, bias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#viewToModel(JTextComponent, Point)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param t the text component.
+ * @param pt the point.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int viewToModel(JTextComponent t, Point pt)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.viewToModel(t, pt);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.viewToModel(t, pt);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#viewToModel(JTextComponent, Point, Bias[])} method
+ * for all the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int viewToModel(JTextComponent tc, Point loc, Bias[] outBias)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.viewToModel(tc, loc, outBias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.viewToModel(tc, loc, outBias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#getNextVisualPositionFrom(JTextComponent, int,
+ * Position.Bias, int, Position.Bias[])} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the position for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The position returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getNextVisualPositionFrom(JTextComponent tc, int pos, Bias bias,
+ int direction, Bias[] outBias) throws BadLocationException
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getNextVisualPositionFrom(tc, pos, bias, direction,
+ outBias);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* int ignored = */ ui.getNextVisualPositionFrom(tc, pos, bias,
+ direction, outBias);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#damageRange(JTextComponent, int, int)} method for
+ * all the UI delegates managed by this <code>MultiTextUI</code>.
+ *
+ * @param tc the component.
+ * @param start the start position.
+ * @param end the end position.
+ */
+ public void damageRange(JTextComponent tc, int start, int end)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ ui.damageRange(tc, start, end);
+ }
+ }
+
+ /**
+ * Calls the {@link TextUI#damageRange(JTextComponent, int, int,
+ * Position.Bias, Position.Bias)} method for all the UI delegates managed by
+ * this <code>MultiTextUI</code>.
+ *
+ * @param tc the component.
+ * @param start the start position.
+ * @param end the end position.
+ * @param startBias the start bias.
+ * @param endBias the end bias.
+ */
+ public void damageRange(JTextComponent tc, int start, int end,
+ Bias startBias, Bias endBias)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ ui.damageRange(tc, start, end, startBias, endBias);
+ }
+ }
+
+ /**
+ * Calls the {@link TextUI#getEditorKit(JTextComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the editor kit for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The editor kit returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public EditorKit getEditorKit(JTextComponent tc)
+ {
+ EditorKit result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getEditorKit(tc);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* EditorKit ignored = */ ui.getEditorKit(tc);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TextUI#getRootView(JTextComponent)} method for all
+ * the UI delegates managed by this <code>MultiTextUI</code>,
+ * returning the view for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tc the text component.
+ *
+ * @return The view returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public View getRootView(JTextComponent tc)
+ {
+ View result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ result = ui.getRootView(tc);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TextUI ui = (TextUI) iterator.next();
+ /* View ignored = */ ui.getRootView(tc);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiToolBarUI.java b/javax/swing/plaf/multi/MultiToolBarUI.java
new file mode 100644
index 000000000..afe63bf35
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiToolBarUI.java
@@ -0,0 +1,352 @@
+/* MultiToolBarUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ToolBarUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ToolBarUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiToolBarUI extends ToolBarUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiToolBarUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiToolBarUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiToolBarUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiToolBarUI mui = new MultiToolBarUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiToolBarUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiToolBarUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiToolBarUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiToolTipUI.java b/javax/swing/plaf/multi/MultiToolTipUI.java
new file mode 100644
index 000000000..fcd622dd8
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiToolTipUI.java
@@ -0,0 +1,352 @@
+/* MultiToolTipUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ToolTipUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ToolTipUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiToolTipUI extends ToolTipUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiToolTipUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiToolTipUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiToolTipUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiToolTipUI mui = new MultiToolTipUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiToolTipUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiToolTipUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiToolTipUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiTreeUI.java b/javax/swing/plaf/multi/MultiTreeUI.java
new file mode 100644
index 000000000..de1dc6cc7
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiTreeUI.java
@@ -0,0 +1,628 @@
+/* MultiTreeUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.JTree;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.TreeUI;
+import javax.swing.tree.TreePath;
+
+/**
+ * A UI delegate that that coordinates multiple {@link TreeUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiTreeUI extends TreeUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiTreeUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiTreeUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiTreeUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiTreeUI mui = new MultiTreeUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiTreeUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getPathBounds(JTree, TreePath)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the bounds for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The bounds returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Rectangle getPathBounds(JTree tree, TreePath path)
+ {
+ Rectangle result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getPathBounds(tree, path);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* Rectangle ignored = */ ui.getPathBounds(tree, path);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getPathForRow(JTree, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getPathForRow(JTree tree, int row)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getPathForRow(tree, row);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getPathForRow(tree, row);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getRowForPath(JTree, TreePath)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the row index for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The row index returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getRowForPath(JTree tree, TreePath path)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getRowForPath(tree, path);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* int ignored = */ ui.getRowForPath(tree, path);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getRowCount(JTree)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getRowCount(JTree tree)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getRowCount(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* int ignored = */ ui.getRowCount(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#getClosestPathForLocation(JTree, int, int)} method
+ * for all the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getClosestPathForLocation(JTree tree, int x, int y)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getClosestPathForLocation(tree, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getClosestPathForLocation(tree, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#isEditing(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The result returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public boolean isEditing(JTree tree)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.isEditing(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* boolean ignored = */ ui.isEditing(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#stopEditing(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The result returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public boolean stopEditing(JTree tree)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.stopEditing(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* boolean ignored = */ ui.stopEditing(tree);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link TreeUI#cancelEditing(JTree)} method for
+ * all the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param tree the tree component.
+ */
+ public void cancelEditing(JTree tree)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ ui.cancelEditing(tree);
+ }
+ }
+
+ /**
+ * Calls the {@link TreeUI#startEditingAtPath(JTree, TreePath)} method for
+ * all the UI delegates managed by this <code>MultiTreeUI</code>.
+ *
+ * @param tree the tree component.
+ * @param path the path.
+ */
+ public void startEditingAtPath(JTree tree, TreePath path)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ ui.startEditingAtPath(tree, path);
+ }
+ }
+
+ /**
+ * Calls the {@link TreeUI#getEditingPath(JTree)} method for all
+ * the UI delegates managed by this <code>MultiTreeUI</code>,
+ * returning the path for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param tree the tree component.
+ *
+ * @return The path returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public TreePath getEditingPath(JTree tree)
+ {
+ TreePath result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ result = ui.getEditingPath(tree);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ TreeUI ui = (TreeUI) iterator.next();
+ /* TreePath ignored = */ ui.getEditingPath(tree);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/MultiViewportUI.java b/javax/swing/plaf/multi/MultiViewportUI.java
new file mode 100644
index 000000000..33bbc3b7f
--- /dev/null
+++ b/javax/swing/plaf/multi/MultiViewportUI.java
@@ -0,0 +1,352 @@
+/* MultiViewPortUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.multi;
+
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.swing.JComponent;
+import javax.swing.LookAndFeel;
+import javax.swing.UIManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.ViewportUI;
+
+/**
+ * A UI delegate that that coordinates multiple {@link ViewportUI}
+ * instances, one from the primary look and feel, and one or more from the
+ * auxiliary look and feel(s).
+ *
+ * @see UIManager#addAuxiliaryLookAndFeel(LookAndFeel)
+ */
+public class MultiViewportUI extends ViewportUI
+{
+
+ /** A list of references to the actual component UIs. */
+ protected Vector uis;
+
+ /**
+ * Creates a new <code>MultiViewPortUI</code> instance.
+ *
+ * @see #createUI(JComponent)
+ */
+ public MultiViewportUI()
+ {
+ uis = new Vector();
+ }
+
+ /**
+ * Creates a delegate object for the specified component. If any auxiliary
+ * look and feels support this component, a <code>MultiViewportUI</code> is
+ * returned, otherwise the UI from the default look and feel is returned.
+ *
+ * @param target the component.
+ *
+ * @see MultiLookAndFeel#createUIs(ComponentUI, Vector, JComponent)
+ */
+ public static ComponentUI createUI(JComponent target)
+ {
+ MultiViewportUI mui = new MultiViewportUI();
+ return MultiLookAndFeel.createUIs(mui, mui.uis, target);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#installUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param c the component.
+ */
+ public void installUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.installUI(c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#uninstallUI(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param c the component.
+ */
+ public void uninstallUI(JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.uninstallUI(c);
+ }
+ }
+
+ /**
+ * Returns an array containing the UI delegates managed by this
+ * <code>MultiViewportUI</code>. The first item in the array is always
+ * the UI delegate from the installed default look and feel.
+ *
+ * @return An array of UI delegates.
+ */
+ public ComponentUI[] getUIs()
+ {
+ return MultiLookAndFeel.uisToArray(uis);
+ }
+
+ /**
+ * Calls the {@link ComponentUI#contains(JComponent, int, int)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the result for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ * @param x the x-coordinate.
+ * @param y the y-coordinate.
+ *
+ * @return <code>true</code> if the specified (x, y) coordinate falls within
+ * the bounds of the component as rendered by the UI delegate in the
+ * primary look and feel, and <code>false</code> otherwise.
+ */
+ public boolean contains(JComponent c, int x, int y)
+ {
+ boolean result = false;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.contains(c, x, y);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* boolean ignored = */ ui.contains(c, x, y);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#update(Graphics, JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.update(g, c);
+ }
+ }
+
+ /**
+ * Calls the <code>paint(Graphics, JComponent)</code> method for all the UI
+ * delegates managed by this <code>MultiViewportUI</code>.
+ *
+ * @param g the graphics device.
+ * @param c the component.
+ */
+ public void paint(Graphics g, JComponent c)
+ {
+ Iterator iterator = uis.iterator();
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ ui.paint(g, c);
+ }
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getPreferredSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the preferred size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The preferred size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getPreferredSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getPreferredSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMinimumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the minimum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The minimum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMinimumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMinimumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMinimumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getMaximumSize(JComponent)} method for all
+ * the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the maximum size for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The maximum size returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Dimension getMaximumSize(JComponent c)
+ {
+ Dimension result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getMaximumSize(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Dimension ignored = */ ui.getMaximumSize(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChildrenCount(JComponent)} method
+ * for all the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the count for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component.
+ *
+ * @return The count returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public int getAccessibleChildrenCount(JComponent c)
+ {
+ int result = 0;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChildrenCount(c);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* int ignored = */ ui.getAccessibleChildrenCount(c);
+ }
+ return result;
+ }
+
+ /**
+ * Calls the {@link ComponentUI#getAccessibleChild(JComponent, int)} method
+ * for all the UI delegates managed by this <code>MultiViewportUI</code>,
+ * returning the child for the UI delegate from the primary look and
+ * feel.
+ *
+ * @param c the component
+ * @param i the child index.
+ *
+ * @return The child returned by the UI delegate from the primary
+ * look and feel.
+ */
+ public Accessible getAccessibleChild(JComponent c, int i)
+ {
+ Accessible result = null;
+ Iterator iterator = uis.iterator();
+ // first UI delegate provides the return value
+ if (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ result = ui.getAccessibleChild(c, i);
+ }
+ // return values from auxiliary UI delegates are ignored
+ while (iterator.hasNext())
+ {
+ ComponentUI ui = (ComponentUI) iterator.next();
+ /* Accessible ignored = */ ui.getAccessibleChild(c, i);
+ }
+ return result;
+ }
+
+}
diff --git a/javax/swing/plaf/multi/package.html b/javax/swing/plaf/multi/package.html
new file mode 100644
index 000000000..568a7d0bf
--- /dev/null
+++ b/javax/swing/plaf/multi/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.plaf.metal package.
+ Copyright (C) 2002, 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. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.plaf.multi</title></head>
+
+<body>
+<p>Provides a look and feel that can combine a primary look and feel with one or more auxiliary look and feels.</p>
+
+</body>
+</html>