Skip to content

Commit cdd316b

Browse files
committed
image path correction
1 parent afcb812 commit cdd316b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ public void paintIcon(Component c, Graphics g, int x, int y) {
885885
}
886886
}
887887
if (icon != null) {
888-
if (!((AbstractButton)c).isSelected()) {
888+
if (!((AbstractButton) c).isSelected()) {
889889
Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
890890
Part part;
891891
if (type == JRadioButtonMenuItem.class) {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
import javax.swing.JRadioButtonMenuItem;
4141
import javax.swing.UIManager;
4242

43+
import java.io.File;
44+
4345
public class TestImageIconWithJRadioButtonMenuItem {
4446

45-
private static final String instructionsText = """
47+
private static final String INSTRUCTIONS = """
4648
Two JRadioButtonMenuItem will be shown.
4749
One JRadioButtonMenuItem is with image icon and
4850
another one without image icon.
@@ -54,7 +56,7 @@ public static void main(String[] args) throws Exception {
5456
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
5557
PassFailJFrame.builder()
5658
.title("JRadioButtonMenuItem Instructions")
57-
.instructions(instructionsText)
59+
.instructions(INSTRUCTIONS)
5860
.rows(10)
5961
.columns(40)
6062
.testUI(TestImageIconWithJRadioButtonMenuItem::doTest)
@@ -63,10 +65,11 @@ public static void main(String[] args) throws Exception {
6365
}
6466

6567
public static JFrame doTest() {
66-
String imgPath1 = "./duke.gif";
68+
String imgDir = System.getProperty("test.src", ".");
69+
String imgPath = imgDir + File.separator + "duke.gif";
6770

6871
JFrame frame = new JFrame("RadioButtonWithImageIcon");
69-
ImageIcon imageIcon1 = new ImageIcon(imgPath1);
72+
ImageIcon imageIcon1 = new ImageIcon(imgPath);
7073
AbstractButton button1 = new JRadioButtonMenuItem("JRadioButtonMenuItem 1",
7174
imageIcon1);
7275
button1.setSelected(true);

0 commit comments

Comments
 (0)