18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.sun.java.swing.plaf.motif;
26
27 import java.awt.*;
28 import javax.swing.*;
29 import javax.swing.plaf.*;
30 import javax.swing.border.*;
31 import javax.swing.plaf.basic.*;
32 import java.io.Serializable;
33 import java.awt.event.*;
34 import java.beans.*;
35
36 /**
37 * ComboBox motif look and feel
38 * <p> * <strong>Warning:</strong>
39 * Serialized objects of this class will not be compatible with
40 * future Swing releases. The current serialization support is appropriate
41 * for short term storage or RMI between applications running the same
42 * version of Swing. A future release of Swing will provide support for
43 * long term persistence.
44 *
45 * @author Arnaud Weber
46 */
47 @SuppressWarnings("serial") // Same-version serialization only
48 public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
49 Icon arrowIcon;
50 static final int HORIZ_MARGIN = 3;
51
52 public static ComponentUI createUI(JComponent c) {
53 return new MotifComboBoxUI();
54 }
55
56 public void installUI(JComponent c) {
57 super.installUI(c);
58 arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"),
244 if ( comboBox.isEditable() )
245 return arrowIcon.getIconWidth() + (2 * HORIZ_MARGIN);
246 else
247 return arrowIcon.getIconWidth() + (3 * HORIZ_MARGIN) + 2;
248 }
249
250 public void configureEditor() {
251 super.configureEditor();
252 editor.setBackground( UIManager.getColor( "text" ) );
253 }
254
255 protected LayoutManager createLayoutManager() {
256 return new ComboBoxLayoutManager();
257 }
258
259 private Component motifGetEditor() {
260 return editor;
261 }
262
263 /**
264 * This inner class is marked "public" due to a compiler bug.
265 * This class should be treated as a "protected" inner class.
266 * Instantiate it only within subclasses of <FooUI>.
267 */
268 public class ComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
269 public ComboBoxLayoutManager() {
270 MotifComboBoxUI.this.super();
271 }
272 public void layoutContainer(Container parent) {
273 if ( motifGetEditor() != null ) {
274 Rectangle cvb = rectangleForCurrentValue();
275 cvb.x += 1;
276 cvb.y += 1;
277 cvb.width -= 1;
278 cvb.height -= 2;
279 motifGetEditor().setBounds(cvb);
280 }
281 }
282 }
283
284 @SuppressWarnings("serial") // Same-version serialization only
285 static class MotifComboBoxArrowIcon implements Icon, Serializable {
286 private Color lightShadow;
327
328 public int getIconWidth() {
329 return 11;
330 }
331
332 public int getIconHeight() {
333 return 11;
334 }
335 }
336
337 /**
338 *{@inheritDoc}
339 *
340 * @since 1.6
341 */
342 protected PropertyChangeListener createPropertyChangeListener() {
343 return new MotifPropertyChangeListener();
344 }
345
346 /**
347 * This class should be made "protected" in future releases.
348 */
349 private class MotifPropertyChangeListener
350 extends BasicComboBoxUI.PropertyChangeHandler {
351 public void propertyChange(PropertyChangeEvent e) {
352 super.propertyChange(e);
353 String propertyName = e.getPropertyName();
354 if (propertyName == "enabled") {
355 if (comboBox.isEnabled()) {
356 Component editor = motifGetEditor();
357 if (editor != null) {
358 editor.setBackground(UIManager.getColor("text"));
359 }
360 }
361 }
362 }
363 }
364 }
|
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.sun.java.swing.plaf.motif;
26
27 import java.awt.*;
28 import javax.swing.*;
29 import javax.swing.plaf.*;
30 import javax.swing.border.*;
31 import javax.swing.plaf.basic.*;
32 import java.io.Serializable;
33 import java.awt.event.*;
34 import java.beans.*;
35
36 /**
37 * ComboBox motif look and feel
38 * <p>
39 * <strong>Warning:</strong>
40 * Serialized objects of this class will not be compatible with
41 * future Swing releases. The current serialization support is appropriate
42 * for short term storage or RMI between applications running the same
43 * version of Swing. A future release of Swing will provide support for
44 * long term persistence.
45 *
46 * @author Arnaud Weber
47 */
48 @SuppressWarnings("serial") // Same-version serialization only
49 public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
50 Icon arrowIcon;
51 static final int HORIZ_MARGIN = 3;
52
53 public static ComponentUI createUI(JComponent c) {
54 return new MotifComboBoxUI();
55 }
56
57 public void installUI(JComponent c) {
58 super.installUI(c);
59 arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"),
245 if ( comboBox.isEditable() )
246 return arrowIcon.getIconWidth() + (2 * HORIZ_MARGIN);
247 else
248 return arrowIcon.getIconWidth() + (3 * HORIZ_MARGIN) + 2;
249 }
250
251 public void configureEditor() {
252 super.configureEditor();
253 editor.setBackground( UIManager.getColor( "text" ) );
254 }
255
256 protected LayoutManager createLayoutManager() {
257 return new ComboBoxLayoutManager();
258 }
259
260 private Component motifGetEditor() {
261 return editor;
262 }
263
264 /**
265 * This inner class is marked "public" due to a compiler bug.
266 * This class should be treated as a "protected" inner class.
267 * Instantiate it only within subclasses of {@code <FooUI>}.
268 */
269 public class ComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
270 public ComboBoxLayoutManager() {
271 MotifComboBoxUI.this.super();
272 }
273 public void layoutContainer(Container parent) {
274 if ( motifGetEditor() != null ) {
275 Rectangle cvb = rectangleForCurrentValue();
276 cvb.x += 1;
277 cvb.y += 1;
278 cvb.width -= 1;
279 cvb.height -= 2;
280 motifGetEditor().setBounds(cvb);
281 }
282 }
283 }
284
285 @SuppressWarnings("serial") // Same-version serialization only
286 static class MotifComboBoxArrowIcon implements Icon, Serializable {
287 private Color lightShadow;
328
329 public int getIconWidth() {
330 return 11;
331 }
332
333 public int getIconHeight() {
334 return 11;
335 }
336 }
337
338 /**
339 *{@inheritDoc}
340 *
341 * @since 1.6
342 */
343 protected PropertyChangeListener createPropertyChangeListener() {
344 return new MotifPropertyChangeListener();
345 }
346
347 /**
348 * This class should be made "protected" in future releases.
349 */
350 private class MotifPropertyChangeListener
351 extends BasicComboBoxUI.PropertyChangeHandler {
352 public void propertyChange(PropertyChangeEvent e) {
353 super.propertyChange(e);
354 String propertyName = e.getPropertyName();
355 if (propertyName == "enabled") {
356 if (comboBox.isEnabled()) {
357 Component editor = motifGetEditor();
358 if (editor != null) {
359 editor.setBackground(UIManager.getColor("text"));
360 }
361 }
362 }
363 }
364 }
365 }
|