1:
37:
38: package ;
39:
40: import ;
41:
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47:
48:
52: public class MultiLookAndFeel extends LookAndFeel
53: {
54:
55:
58: public MultiLookAndFeel()
59: {
60:
61: }
62:
63:
68: public String getName()
69: {
70: return "Multiplexing Look and Feel";
71: }
72:
73:
78: public String getID()
79: {
80: return "Multiplex";
81: }
82:
83:
88: public String getDescription()
89: {
90: return "Allows multiple UI instances per component instance";
91: }
92:
93:
99: public boolean isNativeLookAndFeel()
100: {
101: return false;
102: }
103:
104:
110: public boolean isSupportedLookAndFeel()
111: {
112: return true;
113: }
114:
115:
120: public UIDefaults getDefaults()
121: {
122: UIDefaults defaults = new UIDefaults();
123: defaults.put("ButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
124: defaults.put("CheckBoxUI", "javax.swing.plaf.multi.MultiButtonUI");
125: defaults.put("CheckBoxMenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
126: defaults.put("ColorChooserUI",
127: "javax.swing.plaf.multi.MultiColorChooserUI");
128: defaults.put("ComboBoxUI", "javax.swing.plaf.multi.MultiComboBoxUI");
129: defaults.put("DesktopPaneUI", "javax.swing.plaf.multi.MultiDesktopPaneUI");
130: defaults.put("DesktopIconUI", "javax.swing.plaf.multi.MultiDesktopIconUI");
131: defaults.put("EditorPaneUI", "javax.swing.plaf.multi.MultiTextUI");
132: defaults.put("FileChooserUI", "javax.swing.plaf.multi.MultiFileChooserUI");
133: defaults.put("FormattedTextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
134: defaults.put("InternalFrameUI",
135: "javax.swing.plaf.multi.MultiInternalFrameUI");
136: defaults.put("LabelUI", "javax.swing.plaf.multi.MultiLabelUI");
137: defaults.put("ListUI", "javax.swing.plaf.multi.MultiListUI");
138: defaults.put("MenuItemUI", "javax.swing.plaf.multi.MultiMenuItemUI");
139: defaults.put("MenuUI", "javax.swing.plaf.multi.MultiMenuItemUI");
140: defaults.put("MenuBarUI", "javax.swing.plaf.multi.MultiMenuBarUI");
141: defaults.put("OptionPaneUI", "javax.swing.plaf.multi.MultiOptionPaneUI");
142: defaults.put("PanelUI", "javax.swing.plaf.multi.MultiPanelUI");
143: defaults.put("PasswordFieldUI", "javax.swing.plaf.multi.MultiTextUI");
144: defaults.put("PopupMenuUI", "javax.swing.plaf.multi.MultiPopupMenuUI");
145: defaults.put("PopupMenuSeparatorUI",
146: "javax.swing.plaf.multi.MultiSeparatorUI");
147: defaults.put("ProgressBarUI", "javax.swing.plaf.multi.MultiProgressBarUI");
148: defaults.put("RadioButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
149: defaults.put("RadioButtonMenuItemUI",
150: "javax.swing.plaf.multi.MultiMenuItemUI");
151: defaults.put("RootPaneUI", "javax.swing.plaf.multi.MultiRootPaneUI");
152: defaults.put("ScrollBarUI", "javax.swing.plaf.multi.MultiScrollBarUI");
153: defaults.put("ScrollPaneUI", "javax.swing.plaf.multi.MultiScrollPaneUI");
154: defaults.put("SeparatorUI", "javax.swing.plaf.multi.MultiSeparatorUI");
155: defaults.put("SliderUI", "javax.swing.plaf.multi.MultiSliderUI");
156: defaults.put("SpinnerUI", "javax.swing.plaf.multi.MultiSpinnerUI");
157: defaults.put("SplitPaneUI", "javax.swing.plaf.multi.MultiSplitPaneUI");
158: defaults.put("TabbedPaneUI", "javax.swing.plaf.multi.MultiTabbedPaneUI");
159: defaults.put("TableHeaderUI", "javax.swing.plaf.multi.MultiTableHeaderUI");
160: defaults.put("TableUI", "javax.swing.plaf.multi.MultiTableUI");
161: defaults.put("TextAreaUI", "javax.swing.plaf.multi.MultiTextUI");
162: defaults.put("TextFieldUI", "javax.swing.plaf.multi.MultiTextUI");
163: defaults.put("TextPaneUI", "javax.swing.plaf.multi.MultiTextUI");
164: defaults.put("ToggleButtonUI", "javax.swing.plaf.multi.MultiButtonUI");
165: defaults.put("ToolBarSeparatorUI",
166: "javax.swing.plaf.multi.MultiSeparatorUI");
167: defaults.put("ToolBarUI", "javax.swing.plaf.multi.MultiToolBarUI");
168: defaults.put("ToolTipUI", "javax.swing.plaf.multi.MultiToolTipUI");
169: defaults.put("ViewportUI", "javax.swing.plaf.multi.MultiViewportUI");
170: return defaults;
171: }
172:
173:
184: public static ComponentUI createUIs(ComponentUI mui, Vector uis,
185: JComponent target)
186: {
187:
188: ComponentUI ui = null;
189: LookAndFeel primary = UIManager.getLookAndFeel();
190: if (primary != null)
191: {
192: ui = UIManager.getUI(target);
193: uis.add(ui);
194: }
195:
196:
197: LookAndFeel[] auxlafs = UIManager.getAuxiliaryLookAndFeels();
198: for (int i = 0; i < auxlafs.length; i++)
199: {
200: LookAndFeel auxlaf = auxlafs[i];
201:
202:
203:
204:
205:
206: UIDefaults defaults = auxlaf.getDefaults();
207: ui = defaults.getUI(target);
208: if (ui != null)
209: uis.add(ui);
210: }
211:
212:
213: if (uis.size() > 1)
214: return mui;
215: else
216: return ui;
217: }
218:
219:
231: protected static ComponentUI[] uisToArray(Vector uis)
232: {
233: if (uis == null)
234: return new ComponentUI[0];
235: int size = uis.size();
236: if (size == 0)
237: return null;
238: ComponentUI[] result = new ComponentUI[size];
239: uis.copyInto(result);
240: return result;
241: }
242:
243: }