wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Question about drop down lists from JComboBox within an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Question about drop down lists from JComboBox within an applet" Watch "Question about drop down lists from JComboBox within an applet" New topic
Author

Question about drop down lists from JComboBox within an applet

Michael Nash
Greenhorn

Joined: Aug 14, 2012
Posts: 2
When I click on the down arrow of a standard JComboBox in an applet and the list of strings are displayed, if I then drag the browser window, the drop down list stays in the same place instead of either being closed or moving with the browser window. I started noticing this when I started using Java 7, but I think this also occurs with Java 6 and 5. When run within the applet viewer in Eclipse, moving the applet window there closes the drop-down during the process of moving the window. Anybody else noticing this ? If so are any suggestions for a possible solution. Ideally I'd want the list to move with the browser window without the drop-down closing.

My example code that demonstrates the problem is as follows:



... and the following html to load the applet:

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
I also see the behaviour (java 6).
this appears to occur because part of the popup is drawn outside the bounds of the applet area,
and, just a guess, some other painting process takes over (native?).

the workaround is to ensure the applet area is tall enough, changing (for the demo code)
height="70"
to
height="170"
but you also need to add the combo box to a JPanel, otherwise the comboBox will take up all the space,
and regardless of the height, the popup will still be drawn outside the area.

Michael Nash
Greenhorn

Joined: Aug 14, 2012
Posts: 2
Yes, that works on Java 6 but not with 7.

The application I'm maintaining isn't having the issue with 6 or lower, since it adds a combobox to a panel as suggested and that panel is well within the applet bounds.

I've corrected (or rather you've corrected !) the example so that this fails on Java 7 only:


... and the html :
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about drop down lists from JComboBox within an applet