Skip to content

Commit ead3bdb

Browse files
committed
RadioButton not drawn. ImageIcon on the fly
1 parent 2eb4932 commit ead3bdb

File tree

2 files changed

+11
-37
lines changed

2 files changed

+11
-37
lines changed

src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -884,38 +884,6 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
884884
}
885885
}
886886
if (icon != null) {
887-
if (!((AbstractButton) c).isSelected()) {
888-
Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
889-
Part part;
890-
if (type == JRadioButtonMenuItem.class) {
891-
part = Part.BP_RADIOBUTTON;
892-
} else {
893-
part = Part.MP_POPUPCHECK;
894-
}
895-
State backgroundState;
896-
State state;
897-
if (isEnabled(c, null)) {
898-
backgroundState = State.NORMAL;
899-
state = (type == JRadioButtonMenuItem.class)
900-
? State.BULLETNORMAL
901-
: State.CHECKMARKNORMAL;
902-
} else {
903-
backgroundState = State.DISABLEDPUSHED;
904-
state =
905-
(type == JRadioButtonMenuItem.class)
906-
? State.BULLETDISABLED
907-
: State.CHECKMARKDISABLED;
908-
}
909-
XPStyle xp = XPStyle.getXP();
910-
if (xp != null) {
911-
Skin skin;
912-
skin = xp.getSkin(c, backgroundPart);
913-
skin.paintSkin(g, x, y,
914-
getIconWidth(), getIconHeight(), backgroundState);
915-
skin = xp.getSkin(c, part);
916-
skin.paintSkin(g, x - 2 * OFFSET, y + OFFSET, state);
917-
}
918-
}
919887
icon.paintIcon(c, g, x + 3 * OFFSET, y + OFFSET);
920888
}
921889
}

test/jdk/javax/swing/JMenuItem/TestImageIconWithJRadioButtonMenuItem.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
* @run main/manual TestImageIconWithJRadioButtonMenuItem
3333
*/
3434

35+
import java.awt.Color;
36+
import java.awt.Graphics;
37+
import java.awt.image.BufferedImage;
3538
import javax.swing.AbstractButton;
3639
import javax.swing.ButtonGroup;
3740
import javax.swing.ImageIcon;
@@ -46,8 +49,8 @@ public class TestImageIconWithJRadioButtonMenuItem {
4649

4750
private static final String INSTRUCTIONS = """
4851
Two JRadioButtonMenuItem will be shown.
49-
One JRadioButtonMenuItem is with image icon and
50-
another one without image icon.
52+
One JRadioButtonMenuItem is with image icon of a red square
53+
and another one without image icon.
5154
Verify that for JRadioButtonMenuItem with image icon,
5255
radiobutton is been shown alongside the image icon.
5356
If radiobutton is shown, test passes else fails.""";
@@ -65,11 +68,14 @@ public static void main(String[] args) throws Exception {
6568
}
6669

6770
public static JFrame doTest() {
68-
String imgDir = System.getProperty("test.src", ".");
69-
String imgPath = imgDir + File.separator + "duke.gif";
71+
BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
72+
Graphics g = img.getGraphics();
73+
g.setColor(Color.red);
74+
g.fillRect(0, 0, img.getWidth(), img.getHeight());
75+
g.dispose();
7076

7177
JFrame frame = new JFrame("RadioButtonWithImageIcon");
72-
ImageIcon imageIcon1 = new ImageIcon(imgPath);
78+
ImageIcon imageIcon1 = new ImageIcon(img);
7379
AbstractButton button1 = new JRadioButtonMenuItem("JRadioButtonMenuItem 1",
7480
imageIcon1);
7581
button1.setSelected(true);

0 commit comments

Comments
 (0)