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

JSlider widget isn't rendered when layout manager is turned off.

XMLWordPrintable

    • generic, x86, sparc
    • generic, solaris_2.6, windows_98, windows_nt

      If you turn off the layout manager and explicitly size and position the JSlider widget, it never gets rendered, even though it responds correctly to mouse events.

      The problem only occurs with JDK1.2 beta4 and occurs on both Solaris and Windows 95.

      A sample program is attached. Follow these steps to see the problem:

      1. Run the program: "java LayoutTest"
      2. Note that the frame and panel is blank.
      3. Also note that a mouse click in the upper fourth of
      the panel generates events for the slider, so the slider
      appears to be active, but

      Name: krT82822 Date: 06/19/99


      JSlider does not draw itself when the toplevel Frame has a null LayoutManager. The Frame has a null layout, and contains a Panel with a BorderLayout which contains the JSlider in the Center position. The Panel is explicitly sized.

      The JSlider does receive keyboard and mouse events even though it is not visible.

      Here is a sample application demonstrating the problem:

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

      public class Slider {
      public static void main(String args[]) {
      java.awt.Frame frm = new java.awt.Frame();
      frm.setSize(200, 100);
      frm.setVisible(true);

      // Comment out this line and everything works:
      frm.setLayout(null);

      java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
      frm.add(panel);
      panel.setSize(200, 80);
      final JSlider slider = new JSlider();
      slider.setSize(panel.getSize());
      slider.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
      System.out.println("change " + slider.getValue());
      }
      });

      panel.add(slider, java.awt.BorderLayout.CENTER);

      frm.validate();

      frm.list();
      }
      }
      (Review ID: 54212)
      ======================================================================

            tsantossunw Tom Santos (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: