-
Bug
-
Resolution: Fixed
-
P4
-
1.1.5, 1.2.2, 1.3.0, 1.4.0, 1.4.1
-
hopper
-
x86, sparc
-
linux, solaris_7, windows_95, windows_98, windows_2000
-
Verified
The setMargin() method works for the top, right, and bottom insets but for
some reason does not work for the left inset. As demo with the following
program the buttons/checkboxes always align to the left margin.
================================================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class rButton extends JFrame {
rButton() {
Container c = getContentPane();
c.setLayout(new FlowLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
c.add(p1);
c.add(p2);
ImageIcon icon = new ImageIcon("./red-ball.gif");
JRadioButton []rb1 = {
new JRadioButton("Insets = 40", icon),
new JRadioButton("Insets = 30"),
new JRadioButton("Insets = 20"),
new JRadioButton("Insets = 10")
};
JCheckBox cb1 = new JCheckBox("Insets = 15", icon);
JCheckBox cb2 = new JCheckBox("Insets = 15", icon);
cb1.setMargin(new Insets(15, 15, 15, 15));
cb2.setMargin(new Insets(15, 15, 15, 15));
rb1[0].setMargin(new Insets(10, 10, 10, 10));
rb1[1].setMargin(new Insets(20, 20, 20, 20));
rb1[2].setMargin(new Insets(30, 30, 30, 30));
rb1[3].setMargin(new Insets(40, 40, 40, 40));
JRadioButton []rb2 = {
new JRadioButton("Insets = 40", icon),
new JRadioButton("Insets = 30"),
new JRadioButton("Insets = 20"),
new JRadioButton("Insets = 10")
};
rb2[0].setMargin(new Insets(10, 10, 10, 10));
rb2[1].setMargin(new Insets(20, 20, 20, 20));
rb2[2].setMargin(new Insets(30, 30, 30, 30));
rb2[3].setMargin(new Insets(40, 40, 40, 40));
for (int i = 0; i < 4; i++) {
p1.add(rb1[i]);
p2.add(rb2[i]);
}
p1.add(cb1);
p2.add(cb2);
p1.validate();
p2.validate();
pack();
setSize(800, 400);
setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
}
public static void main(String argv[]) {
new rButton();
}
}
some reason does not work for the left inset. As demo with the following
program the buttons/checkboxes always align to the left margin.
================================================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class rButton extends JFrame {
rButton() {
Container c = getContentPane();
c.setLayout(new FlowLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p2.setLayout(new BoxLayout(p2, BoxLayout.Y_AXIS));
c.add(p1);
c.add(p2);
ImageIcon icon = new ImageIcon("./red-ball.gif");
JRadioButton []rb1 = {
new JRadioButton("Insets = 40", icon),
new JRadioButton("Insets = 30"),
new JRadioButton("Insets = 20"),
new JRadioButton("Insets = 10")
};
JCheckBox cb1 = new JCheckBox("Insets = 15", icon);
JCheckBox cb2 = new JCheckBox("Insets = 15", icon);
cb1.setMargin(new Insets(15, 15, 15, 15));
cb2.setMargin(new Insets(15, 15, 15, 15));
rb1[0].setMargin(new Insets(10, 10, 10, 10));
rb1[1].setMargin(new Insets(20, 20, 20, 20));
rb1[2].setMargin(new Insets(30, 30, 30, 30));
rb1[3].setMargin(new Insets(40, 40, 40, 40));
JRadioButton []rb2 = {
new JRadioButton("Insets = 40", icon),
new JRadioButton("Insets = 30"),
new JRadioButton("Insets = 20"),
new JRadioButton("Insets = 10")
};
rb2[0].setMargin(new Insets(10, 10, 10, 10));
rb2[1].setMargin(new Insets(20, 20, 20, 20));
rb2[2].setMargin(new Insets(30, 30, 30, 30));
rb2[3].setMargin(new Insets(40, 40, 40, 40));
for (int i = 0; i < 4; i++) {
p1.add(rb1[i]);
p2.add(rb2[i]);
}
p1.add(cb1);
p2.add(cb2);
p1.validate();
p2.validate();
pack();
setSize(800, 400);
setVisible(true);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
}
public static void main(String argv[]) {
new rButton();
}
}
- duplicates
-
JDK-4677071 JCK1.4, interactive: api/java_swing/interactive/JRadioButtonTests.html#JRadioBut
- Closed
-
JDK-4126679 JRadioButtons with Icons don't size themselves correctly.
- Closed
-
JDK-4307595 After AbstractButton.setBorderPainted(true) call button's label looks incorrectl
- Closed
-
JDK-4308381 Borders not correctly painted with JRadioButtons & JCheckBoxes
- Closed
-
JDK-4765284 JRadioButton still does not obey border setting
- Closed
-
JDK-4373752 RFE:reopen bug 4187481, Radio and Checkbox buttons not laying out correctly
- Closed
(1 duplicates)