JDK-4140417 : JComboBox.setLightWeightPopupEnabled does not always work on Solaris
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1998-05-20
  • Updated: 1998-06-01
  • Resolved: 1998-06-01
Related Reports
Duplicate :  
Description

Name: rk38400			Date: 05/20/98


As you will be able to see from the following code,
setting the popup flag in this instance of a
JComboBox does not produce the desired result on
Solaris.

import java.awt.*;
import java.awt.swing.*;

public class SunTest4  {

 	public static void main(String argv[]) 
	{
		JFrame frame = new JFrame();
		frame.getContentPane().setLayout(new BorderLayout());
		frame.getContentPane().add(setUpNorthPanel(),BorderLayout.NORTH);
		frame.getContentPane().add(setUpCenterPanel(),BorderLayout.CENTER);
		frame.setVisible(true);
		frame.setSize(400,400);
	}
	private static JPanel setUpNorthPanel()
	{
	
		JPanel p = new JPanel();
	
		JMenuBar mb = new JMenuBar();
		JMenu menu = new JMenu("File");
		menu.add("One");
		menu.add("Two");
		menu.add("Three");
		menu.add("Four");
		menu.add("Five");
		mb.add(menu); 
		
		String s[] = {"One","Two","Three","Four","Five"};
		JComboBox c = new JComboBox(s);
		c.setLightWeightPopupEnabled(false);
		
		p.add(mb);
		p.add(c);
		return p;
		
	}
	private static Panel setUpCenterPanel()
	{
		Panel p = new Panel();
		
		p.add(new JLabel("Light Weight JLabel on Heavy Weight Panel"));
		return p;
	}
}



(Review ID: 30704)
======================================================================


Comments
EVALUATION tom.santos@eng 1998-05-25 This bug is happening because JPopupMenu is trying to make a medium-weight popup. The medium-weight is not appearing. If I change the code in JPopupMenu to create a Heavy-weight instead, it works fine. If the first occurence of MEDIUM_WEIGHT_POPUP is changed to HEAVY_WEIGHT_POPUP his program works fine. This code was taken from setVisble() in the file JPopupMenu.java. if(popupFit(popupRect)) { if(lightWeightPopupEnabled) newPopupType = LIGHT_WEIGHT_POPUP; else newPopupType = MEDIUM_WEIGHT_POPUP; } else { if(shouldDowngradeHeavyWeight) newPopupType = MEDIUM_WEIGHT_POPUP; else newPopupType = HEAVY_WEIGHT_POPUP; } =================================== This looks like the mediumweight solaris bug.
11-06-2004