1. /*
  2. * @(#)SynthRadioButtonUI.java 1.5 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 java.awt.event.*;
  10. import javax.swing.*;
  11. import javax.swing.border.*;
  12. import javax.swing.plaf.*;
  13. import javax.swing.text.View;
  14. /**
  15. * This comes from BasicRadioButtonUI v 1.65.
  16. *
  17. * @version 1.5, 01/23/03
  18. * @author Jeff Dinkins
  19. */
  20. class SynthRadioButtonUI extends SynthToggleButtonUI {
  21. /**
  22. * Icon to use if one has not been specified for the radio button.
  23. */
  24. private Icon icon;
  25. // ********************************
  26. // Create PLAF
  27. // ********************************
  28. public static ComponentUI createUI(JComponent b) {
  29. return new SynthRadioButtonUI();
  30. }
  31. void fetchStyle(AbstractButton b) {
  32. super.fetchStyle(b);
  33. icon = null;
  34. }
  35. protected String getPropertyPrefix() {
  36. return "RadioButton.";
  37. }
  38. /**
  39. * Returns the Icon used in calculating the pref/min/max size.
  40. */
  41. protected Icon getSizingIcon(AbstractButton b) {
  42. return getIcon(b);
  43. }
  44. /**
  45. * Returns the Icon to use in painting the button.
  46. */
  47. protected Icon getIcon(AbstractButton b) {
  48. Icon icon = b.getIcon();
  49. if (icon != null) {
  50. Icon sIcon = super.getIcon(b);
  51. if (sIcon != null) {
  52. icon = sIcon;
  53. }
  54. }
  55. else {
  56. icon = getDefaultIcon(b);
  57. }
  58. return icon;
  59. }
  60. protected Icon getDefaultIcon(AbstractButton b) {
  61. if (icon == null) {
  62. SynthContext context = getContext(b);
  63. icon = context.getStyle().getIcon(context,
  64. getPropertyPrefix() + "icon");
  65. context.dispose();
  66. }
  67. return icon;
  68. }
  69. }