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

AWT Scrollbar doesn't get grayed out if disabled

XMLWordPrintable

    • b09
    • generic
    • linux
    • Verified

      Disabled Scrollbar looks the same as ordinary Scrollbar under XAWT. As a result some components that includes Scrollbars in it suffer from that issue. In particular, ScrollPane.
      List is also affected but mostly due to a typo in its peer. See 6362024 suggested fix.

      Run following test and find that Scrollbars looks the same as well as ScrollPanes.

      import java.awt.*;

      public class ConfusionInTextArea {
              public Frame frame=null;
              public TextArea ta1=null,ta2=null,ta3=null;
              public List lst1=null, lst2=null;
              public Button b=null;
          public Scrollbar sb1, sb2;
          public ScrollPane sp1, sp2;

              ConfusionInTextArea(){
                  
                      frame = new Frame("Confusion in TextArea");
                      Panel taPanel = new Panel();
                      
                      sb1 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300);
                      sb1.setEnabled(false);
                      sb2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 60, 0, 300);

                      sp1 = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
                      sp1.setEnabled(false);
                      sp2 = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
                      sp1.add(new Button("DISABLED"){
                              public Dimension getPreferredSize(){
                                  return new Dimension(500, 500);
                              }});
                      sp2.add(new Button("ENABLED"){
                              public Dimension getPreferredSize(){
                                  return new Dimension(500, 500);
                              }});

                      taPanel.add(sb1);
                      taPanel.add(sb2);

                      taPanel.add(sp1);
                      taPanel.add(sp2);
          //taPanel.setLayout(new java.awt.BorderLayout());
                      taPanel.add(ta1 = new TextArea(10,10));
                      //taPanel.add(ta2 = new TextArea(10,10));
                      taPanel.add(ta3 = new TextArea(10,10));
                      for(int i=0 ;i<100;i++)
                      ta1.append("AWT is Cool. Disabled TextArea \n");
                      //for(int i=0 ;i<100;i++)
                      //ta2.append("AWT is Cool. UnEditabled TextArea \n");
                      for(int i=0 ;i<100;i++)
                      ta3.append("AWT is Cool. Editabled TextArea \n");
                      ta1.setEnabled(false);
                      //ta2.setEditable(false);
                      frame.add("North" , taPanel);

                      System.out.println("ta1 font = "+ta1.getFont());
                      //System.out.println("ta2 font = "+ta2.getFont());


                      Panel lstPanel = new Panel();
                      //lstPanel.setLayout(new java.awt.BorderLayout());
                      lst1 = new List();
                      lst1.add("Praveen Mohan");
                      lst1.add("Lawrence Prem Kumar");
                      lst1.add("Girish Ramachandran");
                      lst1.add("Girish.Girish");
                      lst1.add("Raju");
                      lst1.add("Cheran");
                      lst1.add("Vinay");
                      lst1.add("Srini");
                      lst1.add("Blessan");
                      lst1.add("Asha");
                      lst1.add("Tao");
                      lst1.add("Yin");

                      lst1.setEnabled(false);

                      lst2 = new List();
                      lst2.add("Praveen Mohan");
                      lst2.add("Lawrence Prem Kumar");
                      lst2.add("Girish Ramachandran");
                      lst2.add("Girish.Girish");
                      lst2.add("Raju");
                      lst2.add("Cheran");
                      lst2.add("Vinay");
                      lst2.add("Srini");
                      lst2.add("Blessan");
                      lst2.add("Asha");
                      lst2.add("Tao");
                      lst2.add("Yin");

                      lstPanel.add("North",lst1);
                      lstPanel.add("South",lst2);

                      frame.add("Center",b = new Button("getFont"));
                      b.addActionListener(new java.awt.event.ActionListener(){
                              public void actionPerformed(java.awt.event.ActionEvent ae){
                                      System.out.println("ta1 font = "+ta1.getFont());
                                      System.out.println("ta2 font = "+ta3.getFont());

                              }
                      });

                      frame.add("South",lstPanel);
                      frame.pack();
                      frame.setVisible(true);
              }

              public static void main(String []args){
                      new ConfusionInTextArea();
              }
      }

            dav Andrei Dmitriev (Inactive)
            dav Andrei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: