Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Why glass pane requires setLightWeightPopupEnabled(false)?

800351Dec 10 2007 — edited Dec 13 2007
In the code below, the glass pane is a JPanel which everybody knows is a Swing lightweight component. Then why JComboBox requires setLightWeightPopupEnabled(false) for its proper functioning? What on earth does the method, in the first place? Why glass pane? What oddity in the hell does the glass pane have that other Swing component doesn't, never?
import javax.swing.*;
import java.awt.*;

public class GlassPaneOddity{

  public static void main(String[] args){

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel gp = new JPanel(new BorderLayout());
    frame.setGlassPane(gp);

    JComboBox cb 
      = new JComboBox(new String[]{"alpha", "beta", "gamma", "delta"});
    cb.setLightWeightPopupEnabled(false); // why this line is so critical?
    gp.add(cb, BorderLayout.NORTH);

    frame.setSize(300, 300);
    frame.setVisible(true);
    gp.setVisible(true);
  }
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2008
Added on Dec 10 2007
8 comments
444 views