Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Swing Combox List Width - difference between Windows and OSX  RSS feed

 
David Garratt
Ranch Hand
Posts: 216
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running Java 1.8.0_60 on Windows and OS X and I have found that since moving from Java 7 the behaviour of the drop down (popup) list is different between operating systems. OS X works as before and is the "desirable" outcome where the list seems to size itself to accommodate the width of the items within it, whereas on Windows the width of the list now seems to be the same as the parent combo box control.

Has anyone else noticed this and is it a bug in Java on Windows or Java on OS X or are the controls simply trying to emulate the look and feel of the OS ?

Obviously I'm going to have to put in a custom control somewhere to work around it but not sure how to at present.

Dave




 
Brian Cole
Author
Ranch Hand
Posts: 932
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using the same Look&Feel on the Windows run and on the OSX run? Or are you using a native system Look&Feel on one or both?

Different Look&Feels are of course allowed to size their drop-down lists differently, but I'm not aware (not that I have necessarily been paying attention) to Look&Feel changes between Java7 and Java8.

A short, self-contained, compilable example that exhibits the problem would probably make it easier for us to help you.
 
David Garratt
Ranch Hand
Posts: 216
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the Metal look and feel across both platforms.

I googled for a solution and found the code below which works for my problem, but it's interesting none the less that Windows is doing something a little different to OS X

 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the Metal look and feel across both platforms.


whereas on Windows the width of the list now seems to be the same as the parent combo box control.


This has been the look of the Metal LAF on Windows for as long as I can remember.

As you can see from Combo Box Popup, this issue was addressed many years (and Java versions) ago. You may find the solution simpler since you can install the listener on any combo box.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!