summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schuster <theBohemian@gmx.net>2006-06-16 12:36:19 +0000
committerRobert Schuster <theBohemian@gmx.net>2006-06-16 12:36:19 +0000
commit24dc722bcc37ab04baafe72ec62a47e7b51d7732 (patch)
treeafe7154e4abbd99c076fa07d860c043ce1820fbf
parent5d9f204931d936961985b41a3e4d0146915df0c9 (diff)
downloadclasspath-24dc722bcc37ab04baafe72ec62a47e7b51d7732.tar.gz
2006-06-16 Robert Schuster <robertschuster@fsfe.org>
* javax/swing/plaf/basic/BasicRadioButtonUI.java: (installDefaults): Removed unneccessary code. (paint): Removed complex if-cascade, revert to default icon if icon property is not set. (getPreferredSize): New method.
-rw-r--r--ChangeLog11
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java78
2 files changed, 68 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 5956790fd..2bd993a36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-06-16 Robert Schuster <robertschuster@fsfe.org>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java:
+ (installDefaults): Removed unneccessary code.
+ (paint): Removed complex if-cascade, revert to default icon if
+ icon property is not set.
+ (getPreferredSize): New method.
+
2006-06-16 Roman Kennke <kennke@aicas.com>
PR 28027
@@ -333,6 +341,7 @@
compatibility with filters.
(getParameter): Modified to allow access to above.
+>>>>>>> 1.7824
2006-06-13 Sven de Marothy <sven@physto.se>
* gnu/java/awt/peer/gtk/CairoSurface.java
@@ -354,6 +363,7 @@
or not the labels are visible,
(paintTrack): Shift track down one pixel.
+>>>>>>> 1.7799
2006-06-13 Lillian Angel <langel@redhat.com>
* java/awt/image/PixelGrabber.java
@@ -1124,6 +1134,7 @@
(TreeIncrementAction.actionPerformed): Use action name as command.
(TreeIncrementAction.isEnabled): Implemented.
+>>>>>>> 1.7796
2006-06-08 Mark Wielaard <mark@klomp.org>
PR 27917
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index a7da21c4f..aed4d69d6 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -42,6 +42,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
+import java.awt.Insets;
import java.awt.Rectangle;
import javax.swing.AbstractButton;
@@ -92,14 +93,6 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
protected void installDefaults(AbstractButton b)
{
super.installDefaults(b);
- if (b.getIcon() == null)
- b.setIcon(icon);
- if (b.getSelectedIcon() == null)
- b.setSelectedIcon(icon);
- if (b.getDisabledIcon() == null)
- b.setDisabledIcon(icon);
- if (b.getDisabledSelectedIcon() == null)
- b.setDisabledSelectedIcon(icon);
}
/**
@@ -145,16 +138,17 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
g.setFont(f);
ButtonModel m = b.getModel();
- Icon currentIcon = null;
- if (m.isSelected() && m.isEnabled())
- currentIcon = b.getSelectedIcon();
- else if (! m.isSelected() && m.isEnabled())
- currentIcon = b.getIcon();
- else if (m.isSelected() && ! m.isEnabled())
- currentIcon = b.getDisabledSelectedIcon();
- else // (!m.isSelected() && ! m.isEnabled())
- currentIcon = b.getDisabledIcon();
+ // FIXME: Do a filtering on any customized icon if the following property
+ // is set.
+ boolean enabled = b.isEnabled();
+
+ Icon currentIcon = b.getIcon();
+ if (currentIcon == null)
+ {
+ currentIcon = getDefaultIcon();
+ }
+
SwingUtilities.calculateInnerArea(b, vr);
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f),
b.getText(), currentIcon,
@@ -162,15 +156,57 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
vr, ir, tr, b.getIconTextGap() + defaultTextShiftOffset);
- if (currentIcon != null)
- {
- currentIcon.paintIcon(c, g, ir.x, ir.y);
- }
+ currentIcon.paintIcon(c, g, ir.x, ir.y);
+
if (text != null)
paintText(g, b, tr, text);
if (b.hasFocus() && b.isFocusPainted() && m.isEnabled())
paintFocus(g, tr, c.getSize());
}
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ // This is basically the same code as in
+ // BasicGraphicsUtils.getPreferredButtonSize() but takes the default icon
+ // property into account. JRadioButton and subclasses always have an icon:
+ // the check box. If the user explicitly changes it with setIcon() that
+ // one will be used for layout calculations and painting instead.
+ // The other icon properties are ignored.
+ AbstractButton b = (AbstractButton) c;
+
+ Rectangle contentRect;
+ Rectangle viewRect;
+ Rectangle iconRect = new Rectangle();
+ Rectangle textRect = new Rectangle();
+ Insets insets = b.getInsets();
+
+ Icon i = b.getIcon();
+ if (i == null)
+ i = getDefaultIcon();
+
+ viewRect = new Rectangle();
+
+ SwingUtilities.layoutCompoundLabel(
+ b, // for the component orientation
+ b.getFontMetrics(b.getFont()),
+ b.getText(),
+ i,
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ viewRect, iconRect, textRect,
+ defaultTextIconGap + defaultTextShiftOffset);
+
+ contentRect = textRect.union(iconRect);
+
+ return new Dimension(insets.left
+ + contentRect.width
+ + insets.right + b.getHorizontalAlignment(),
+ insets.top
+ + contentRect.height
+ + insets.bottom);
+ }
/**
* Paints the focus indicator for JRadioButtons.