Name: jl125535 Date: 04/26/2004
FULL PRODUCT VERSION :
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
java version "1.4.1_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
I've a few JRadioButtons in my panel. One JRadioButton has associated text which is longer and can't be displayed in one line. So I pass html string in as setText argument for the JRadioButton.
Enabling/disabling of radiobuttons is determines by the state of a JCheckBox.
To appropriately display enabling /disabling of JRadioButtons, I have to call JRadioButton.setText with html string having different colors.
Repeated selecion change of JCheckbox shows some flickering in radio ButtonGroup. The radiobuttons text seems to jump one line above beween transitions.
I have observed that the problem appears only if one JRadioButton in buttonGroup has more than one line of text and html has some font color settings.If either of these conditions is missing, the issue doesn't appear.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code below:
Repeatedly click on JCheckBox.
Some flickering will be seen in radio ButtonGroup. The radiobuttons text seems to jump one line above beween transitions.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The JRadioButtons text shouldn't jump.
ACTUAL -
Some flickering isseen in JRadioButtons ButtonGroup. The radiobuttons text seems to jump one line above beween transitions.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.event.*;
import javax.swing.*;
public class RadioTest extends JFrame implements ActionListener
{
public static void main(String[] args)
{
RadioTest test = new RadioTest();
test.getContentPane().setLayout(new BorderLayout());
test.init();
test.setSize(200,300);
test.setVisible(true);
}
public void init()
{
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
longString = "Some very long text that requires wrapping onto different lines." ;
String htmlstart =
"<HTML><BODY><FONT COLOR=\"#000000\">";
String htmlend = "</FONT></BODY></HTML>";
String html = htmlstart +longString + htmlend;
button1 = new JRadioButton(html);
button2 = new JRadioButton(htmlstart + "Some text" + htmlend);
button3 = new JRadioButton(htmlstart + "Some more text" + htmlend);
ButtonGroup b = new ButtonGroup();
b.add(button1);
b.add(button2);
b.add(button3);
panel.add(button1);
panel.add(button2);
panel.add(button3);
box = new JCheckBox("Enable all radios");
box.addActionListener(this);
panel.add(box);
getContentPane().add(BorderLayout.CENTER, panel);
}
public void actionPerformed(ActionEvent e)
{
_updateControls();
}
private void _updateControls()
{
boolean enableRadioButtons = (box.isSelected() == true)
? false : true;
String htmlstart =
"<HTML><BODY><FONT COLOR=\"#000000\">";
if(!enableRadioButtons)
htmlstart =
"<HTML><BODY><FONT COLOR=\"#666666\">";
String htmlend = "</FONT></BODY></HTML>";
button1.setText(htmlstart + longString + htmlend);
button2.setText(htmlstart + "Some text" + htmlend);
button3.setText(htmlstart + "Some more text " + htmlend);
// enable/disable the radio buttons
button1.setEnabled(enableRadioButtons);
button2.setEnabled(enableRadioButtons);
button3.setEnabled(enableRadioButtons);
if(enableRadioButtons)
{
button1.setSelected(true);
}
else
{
button2.setSelected(true);
}
}
JCheckBox box;
JRadioButton button1;
JRadioButton button2;
JRadioButton button3;
String longString;
}
---------- END SOURCE ----------
(Incident Review ID: 255087)
======================================================================