File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about drop down lists from JComboBox within an applet

 
Michael Nash
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic