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

Different Swing Components on Windows and Solaris

 
Desiree Rguez.
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I made an swing application. I developed it on Windows and it works and looks fine, but when I run it on Solaris it works fine but the swing components doesn't look the same. The JButtons have a different size (smaller). Does anyone know why this is happening or how to fix it?


Thank yo very much.

(I've been told that it's because of the font but I use icons in the buttons)
 
Lionel Badiou
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

It sounds like your application uses the system look and feel (this means that components will be drawn on screen as close as possible to platform components).

You migh try to set manually the look and feel to the cross platform one (also know as java look and feel).

See here for details.

Hope that helps,
 
Desiree Rguez.
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I'm using the system look and feel (I think, because I don't specify it anywhere)

By Java Look and Feel you mean Metal Look and Feel?


thank you very much for answering.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could be also that you are not using a layout manager and are positioning all your components statically with setBounds(). Different OS's compute pixels differently and so that would explain why your buttons, etc are not the same size. Layout managers will help eleviate that.
 
Lionel Badiou
Ranch Hand
Posts: 140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

Java l&f is the default l&f used when no other l&f is specified, either on command line, code, or swing.defaultlaf property.

In your case, the swing.defaultlaf property is propably different on Windows and Solaris platform.

(As far as I know, the java look and feel was indeed also called 'metal' until java 1.4)

Best regards,
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now on to some business...

drf, we don't have too many rules around here but we do have a Naming Policy. Please adjust your display name accordingly.

Thanks and welcome to Javaranch.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lionel Badiou:
Hi again,

Java l&f is the default l&f used when no other l&f is specified, either on command line, code, or swing.defaultlaf property.

In your case, the swing.defaultlaf property is propably different on Windows and Solaris platform.

(As far as I know, the java look and feel was indeed also called 'metal' until java 1.4)

Best regards,


The default look and feel until 1.5 is metal. In 1.5 it's ocean.
 
Desiree Rguez.
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't be the layout null, I'm using Gridbaglayout and components appear in their right positions, it's just sizes (JButtons appear smaller and JTextFields bigger than they should).

I'll try the Look&Feel, thank you very much guys !





(I changed my name)
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Desiree:
(I changed my name)


Yes you did, and you are almost there. Notice anything different about my display name and yours? You need a first and last name. We realize that not everyone in the world has both a first and last name but we still require it. If you don't have one it's ok to make one up as long as it sounds real and you don't publically state that it is fake.
 
Desiree Rguez.
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy now?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Desiree Rguez.:
Happy now?


You have no idea. Thanks. We appreciate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic