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

setBorder(null) requires updateUI() call to reset L&F border

XMLWordPrintable

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



      Name: diC59631 Date: 11/25/98


      I'm not sure if this is meant to act this way or if there is a bug of a missing property change listener....

      If I have a JComponent, like a JButton, where I call setBorder(newBorder), then call setBorder(null) to clear it out, this then has a null/empty Border. However, if I then call updateUI(), this then resets the border to the L&F border for the component.

      Is this correct?
      (Review ID: 43219)
      ======================================================================

      Name: krT82822 Date: 10/13/99


      10/13/99 eval1127@eng -- filed against 1.2.2, but still present as of 1.3 RA (build "I" of 1.3.0).

      JComponents with null borders receive borders after their UI is updated

      The bug is as follows: JComponents with null borders receive
      borders after their UI is updated. I suspect that whatever's
      causing this bug is also causing Bug #ID 4264798

      Below is source code which demonstrates the bug. Run the program
      and then press the "Click to cause bug" button. Pressing this
      button causes the look and feel to be updated on the JTextField.
      The bug which occurs is that the JTextField's border which prior
      to clicking the "Click to cause bug" button" was null, obtains a
      border.

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

      public class A extends JFrame
      {
         public A()
         {
            super();
            
            final JPanel p = new JPanel();
            
            setContentPane(p);
            
            p.setBackground(Color.red);
            
            final JButton btn = new JButton("Click to cause bug");
            
            p.add(btn);
            
            final JTextField tf = new JTextField(50);

            tf.setBorder(null);
            
            tf.setText("My border= " + tf.getBorder());
            
            p.add(tf);
                  
            btn.addActionListener(new ActionListener()
            {
               public void actionPerformed(ActionEvent ev)
               {
                  SwingUtilities.updateComponentTreeUI(tf);
                  
                  tf.setText("My border= " + tf.getBorder());
                  
                  btn.setEnabled(false);
               }
            });
         }
         
         public static void main(String args[] )
         {

            A a = new A();
            
            a.pack();

            a.setVisible(true);
         }
      }
      (Review ID: 96410)
      ======================================================================

            amfowler Anne Fowler (Inactive)
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: