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

TextField.setBackground(Color) fails when TextField.setEditable(false)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs
    • generic, x86
    • generic, linux, windows_nt



      Name: sl110371 Date: 07/31/2000


      MS-Windows 2000
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      SuSE 6.4 2.2.14-kernel
      java version "1.3.0beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta_refresh-b09)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode)

      Calling setBackground-methods of the TextField-Objects and the TextArea-Objects
      has no effect when they are set not editable: The preset background colour
      (here: gray) is set, whatever Color object you specify.

      Try following source code:
      import java.awt.Color;
      import java.awt.Font;
      import java.awt.Frame;
      import java.awt.GridLayout;
      import java.awt.TextArea;
      import java.awt.TextField;

      class Tf_ta_test extends Frame {
        TextField tfEditable;
        TextField tfNotEditable;
        TextArea taEditable;
        TextArea taNotEditable;

        Tf_ta_test() {
          this.setTitle("TextField/-Area-Test");
          this.setFont(new Font("SansSerif",Font.PLAIN,12));
          this.setBackground(Color.lightGray);
          this.setLayout(new GridLayout(4,1));
          this.addWindowListener(new FrameListener(this));
          tfEditable = new TextField("Dieses Feld ist editierbar!");
          tfEditable.setEditable(true);
          tfEditable.setForeground(Color.blue);
          tfEditable.setBackground(Color.orange);
          tfNotEditable = new TextField("Dieses Feld ist nicht editierbar!");
          tfNotEditable.setEditable(false);
          tfNotEditable.setForeground(Color.blue);
          tfNotEditable.setBackground(Color.orange);
          taEditable = new TextArea("Diese Fl?che ist editierbar\n" +
          "mit farbigem Hintergrund!", 2, 48);
          taEditable.setEditable(true);
          taEditable.setForeground(Color.blue);
          taEditable.setBackground(Color.orange);
          taNotEditable = new TextArea("Diese Fl?che ist nicht editierbar\n" +
          "ohne farbigen Hintergrund!", 2, 48);
          taNotEditable.setEditable(false);
          taNotEditable.setForeground(Color.blue);
          taNotEditable.setBackground(Color.orange);
          this.add(tfEditable);
          this.add(tfNotEditable);
          this.add(taEditable);
          this.add(taNotEditable);
          this.pack();
          this.show();
        } // Konstruktor


        void beenden() {
          System.exit(0);
        }

        public static void main(String[] unusedArgs) {
          new Tf_ta_test();
        }
      }

      import java.awt.event.WindowEvent;
      import java.awt.event.WindowListener;

      class FrameListener implements WindowListener {
         Tf_ta_test mFrame;
        
        public FrameListener(Tf_ta_test frame) {
          mFrame = frame;
        }
        
        public void windowClosing(WindowEvent e) {
          mFrame.beenden();
        }
        
        public void windowActivated(WindowEvent e) { }
        public void windowClosed(WindowEvent e) { }
        public void windowDeactivated(WindowEvent e) { }
        public void windowDeiconified(WindowEvent e) { }
        public void windowIconified(WindowEvent e) { }
        public void windowOpened(WindowEvent e) { }
        
      }
      (Review ID: 107775)
      ======================================================================

            ehawkessunw Eric Hawkes (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: