Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4970355

JCK1.5-runtime api/javax_swing/interactive/JToggleButtonTests.html#JToggleButton





        Name: iaR10016 Date: 12/18/2003

        Filed By : J2SE-SQA [###@###.###
        JDK : JDK1.5.0-b31, JDK1.5.0-b30, JDK1.4.2-b28
        JCK : JCK1.5-runtime (b09)
        Platform[s] : all
        switch/Mode : default
        JCK test owner: http://javaweb.eng/jck/usr/owners.jto
        Falling test : api/javax_swing/interactive/JToggleButtonTests.html#JToggleButton[JToggleButtonTest0003]

        Selected JToggleButton label becomes invisible after setEnabled(false) method call if
        ContentAreaFilled is set to false.

        JCK1.5-runtime api/javax_swing/interactive/JToggleButtonTests.html#JToggleButton[JToggleButtonTest0003]
        test Description reads:
        This test verifies the behavior of the setEnabled() method.
        Seven togglebuttons and an "Enabled" checkbox are displayed below.
        The icon of disabled icon togglebuttons is a yellow ball.
        Please select/de-select the "Enabled" checkbox.
        De-selecting the enabled checkbox should cause the seven togglebuttons to become disabled,
        and should cause the icon of the icon togglebuttons be set to a yellow ball.
        Selecting the "Enabled" checkbox should cause the seven togglebuttons to become enabled,
        and should cause the icon of the icon togglebuttons to be re-set to their prior state.

        This Description does not concretize what should happen with JToggleButton label after setEnabled()
        method call.

        Please, run the script from "How to reproduce" section and play with the tested togglebuttons:
        if the button was selected, then the button label becomes invisible unexpectedly after the
        setEnabled(false) method call.

        Here test source code fragment:

        --------- JToggleButtonTests.java ---------
            522 // Create togglebuttons under test
            523 JToggleButton[] createTogglebuttons() {
            524 Toolkit toolkit = Toolkit.getDefaultToolkit();
            525 Image redball = null;
            527 try {
            528 redball = toolkit.getImage(new URL(testdirurl
            529 + "images/red-ball.gif"));
            530 } catch (java.net.MalformedURLException e) {
            531 throw new RuntimeException(e.getMessage());
            532 }
            533 ImageIcon redballicon = new ImageIcon(redball);
            534 JToggleButton togglebutton1 = new JToggleButton();
            535 JToggleButton togglebutton2 = new JToggleButton(redballicon);
            536 JToggleButton togglebutton3 = new JToggleButton(redballicon, true);
            537 JToggleButton togglebutton4 = new JToggleButton("Javalicious!");
            538 JToggleButton togglebutton5 = new JToggleButton("Javalicious!", true);
            539 JToggleButton togglebutton6 = new JToggleButton("Javalicious!", redballicon);
            540 JToggleButton togglebutton7 = new JToggleButton("Javalicious!", redballicon, true);
            541 JToggleButton[] allTogglebuttons = { togglebutton1, togglebutton2,
            542 togglebutton3, togglebutton4,
            543 togglebutton5, togglebutton6,
            544 togglebutton7
            545 };
            547 for (int i = 0; i < allTogglebuttons.length; i++) {
            548 allTogglebuttons[i].setContentAreaFilled(false);
            549 allTogglebuttons[i].setOpaque(true);
            550 //allTogglebuttons[i].setBackground(Color.lightGray);
            551 }
            553 return allTogglebuttons;
            554 }

        "ContentAreaFilled" is set to false and "Opaque" is set to true for the tested togglebuttons
        (see lines 548, 549).

        If ContentAreaFilled is set to true (this is default value) described failure is not
        reproducible and togglebutton label is always visible.

        The following test example demonstrates the bug:

        --------- test.java ---------
        import java.awt.*;
        import javax.swing.*;
        import java.awt.event.*;

        public class test extends JFrame {

            public test() {
              super("JToggleButton test");

              final JToggleButton aToggleButton1 = new JToggleButton("I am JToggleButton 1");
              final JToggleButton aToggleButton2 = new JToggleButton("I am JToggleButton 2");

              getContentPane().add(aToggleButton1, BorderLayout.EAST);
              getContentPane().add(aToggleButton2, BorderLayout.WEST);

              final Button aButton = new Button("Enable/Disable");
              aButton.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                aToggleButton2.setEnabled(!aToggleButton2.isEnabled()); }
              getContentPane().add(aButton, BorderLayout.NORTH);

            public static void main(String[] args) {
              JFrame frame = new test();
              frame.setSize(new Dimension(400, 100));

        Please, compile and run it. Please, select both togglebuttons in the tested frame and then
        click "Enable/Disable" button: "I am ToggleButton 1" label is visible whereas "I am
        ToggleButton 2" label becomes invisible.

        Test source location:

        jtr file location:

        How to reproduce:
        Run the following script (you may need to change its variables)
        --- script start ---

        #Paths in Java Software:

        #Alternative paths outside Java Software:

        export CLASSPATH="$JCK/classes:$JCK/lib/javatest.jar"
        $JDK/bin/java javasoft.sqe.tests.api.javax.swing.interactive.JToggleButton.JToggleButtonTests -TestCaseID JToggleButtonTest0003 -TestDirURL file://$JCK/tests/api/javax_swing/interactive/JToggleButtonTests.html#JToggleButton"
        --- script end ---

        Specific machine info:
        Hostname: linux-18
        OS: Solaris 10 (x86) (CDE)
        Hostname: linux-2
        OS: Suse Linux 8.2 (GNOME2)



            Issue Links



                alexp Alexander Potochkin (Inactive)
                irasunw Ira Ira (Inactive)
                0 Vote for this issue
                0 Start watching this issue