1. /*
  2. * @(#)SynthArrowButton.java 1.12 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.gtk;
  8. import java.awt.*;
  9. import javax.swing.*;
  10. /**
  11. * JButton object that draws a scaled Arrow in one of the cardinal directions.
  12. * <p>
  13. * <strong>Warning:</strong>
  14. * Serialized objects of this class will not be compatible with
  15. * future Swing releases. The current serialization support is
  16. * appropriate for short term storage or RMI between applications running
  17. * the same version of Swing. As of 1.4, support for long term storage
  18. * of all JavaBeans<sup><font size="-2">TM</font></sup>
  19. * has been added to the <code>java.beans</code> package.
  20. * Please see {@link java.beans.XMLEncoder}.
  21. *
  22. * @version 1.12, 01/23/03 (based on BasicArrowButton 1.24)
  23. * @author David Kloba
  24. */
  25. class SynthArrowButton extends JButton implements SwingConstants {
  26. private int direction;
  27. public SynthArrowButton(int direction) {
  28. super();
  29. setFocusable(false);
  30. setDirection(direction);
  31. setDefaultCapable(false);
  32. }
  33. public String getUIClassID() {
  34. return "ArrowButtonUI";
  35. }
  36. public void updateUI() {
  37. setUI(new SynthArrowButtonUI());
  38. }
  39. public void setDirection(int dir) {
  40. direction = dir;
  41. }
  42. public int getDirection() {
  43. return direction;
  44. }
  45. public Dimension getMinimumSize() {
  46. return new Dimension(5, 5);
  47. }
  48. public Dimension getMaximumSize() {
  49. return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  50. }
  51. private static class SynthArrowButtonUI extends SynthButtonUI {
  52. protected void installDefaults(AbstractButton b) {
  53. super.installDefaults(b);
  54. fetchStyle(b);
  55. }
  56. protected void paint(SynthContext context, Graphics g) {
  57. SynthLookAndFeel.paintForeground(context, g, null);
  58. }
  59. public Dimension getPreferredSize(JComponent c) {
  60. SynthContext context = getContext(c);
  61. int size = context.getStyle().getInt(context, "ArrowButton.size",
  62. 16);
  63. context.dispose();
  64. return new Dimension(size, size);
  65. }
  66. }
  67. }