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

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

    XMLWordPrintable

    Details

      Backports

        Description

        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;
            526
            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 };
            546
            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 }
            552
            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");

              aToggleButton2.setContentAreaFilled(false);
              aToggleButton2.setOpaque(true);
              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) {
                aToggleButton1.setEnabled(!aToggleButton1.isEnabled());
                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));
              frame.setVisible(true);
             }
        }
        -----------------------------

        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:
        =====================
        /java/re/jck/1.5/promoted/beta/b09/binaries/JCK-runtime-15/tests/api/javax_swing/interactive/JToggleButtonTests.java

        jtr file location:
        ==================
        /net/jtgb4u4c.sfbay/export/sail15/results.2/tiger/b31/jck15/x86/sol10_x86_cde_server_linux-18/workDir/api-interactive/javax_swing/interactive/JToggleButtonTests_JToggleButton.jtr

        How to reproduce:
        =================
        Run the following script (you may need to change its variables)
        --- script start ---
        #!/bin/bash

        #Paths in Java Software:
        JDK="/java/re/jdk/1.5.0/promoted/all/b31/binaries/solaris-i586"
        JCK="/java/re/jck/1.5/promoted/beta/b09/binaries/JCK-runtime-15"

        #Alternative paths outside Java Software:
        #JDK="/net/koori.sfbay/onestop/jdk/1.5.0/promoted/all/b31/binaries/solaris-i586"
        #JCK="/net/koori.sfbay/onestop/jck/1.5/promoted/beta/b08/binaries/JCK-runtime-15"

        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)

        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                alexp Alexander Potochkin (Inactive)
                Reporter:
                irasunw Ira Ira (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: