Change java lookandfeel without changing application

Is it possible to change java lookandfeel without changing the program in a real environment?

I know that the theoretical answer is yes. I also created demo applications and changed the lookandfeel even while working, and it worked. But when I created a real application with a lot of controls, the changes in lookandfeel didn’t really work:

  • Different lookandfeels have different errors (or strange functions). For example, some of them create the same style for JTextField and JFormattedTextField, some of them use different styles. This change can be quite frustrating for users.
  • The control sizes do not match (using different fonts, different borders), so sometimes the window looks ugly after a change.
  • Key shortcuts can also be different.
  • ...

In my applications, after changing the lookandfeel (in fact, instead of changing the lookandfeel, I tried to use the same lookandfeel with different skins), I should always change the application. Not a very large modification, but many small modifications that make it difficult to change the lookandfeel.

I was just very unlucky with the lookandfeels I tried (currently using skinlf ), or is changing the look not as easy as in a small demo application?

UPDATE: I use Swing, and switching to another GUI library is now impossible for me.

UPDATE2: , . , lookandfeel. : , lookandfeel ( lookandfeel) ? , lookandfeel, 2 3 , , lookandfeel. dhiller skinlf lookandfeel. -, ?

+3
5

, . - . . script , ,

java -jar yourapp.jar

java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -jar yourapp.jar

-Dswing.defaultlaf = com.sun.java.swing.plaf.gtk.GTKLookAndFeel GTKLookAndFeel.

swing.properties Java. . this.

+2

, , , , , . .

  UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );

, . (java-), .

: , ?

+1

UIManager? . , , , , LayoutManagers . - . - ( ). Swing lookAndFeels. " " , . .

, , , . Mac . .., .

, , Java , .

+1

, purouse : , . , "Java" ( - ), , , (, , Java). , , , , " " , ( Windows, , gui, Mac , ).

0

If your ultimate goal is the look and feel for each target OS, you can watch SWT . This will provide your own OS widgets, which will change along with the appearance of the OS.

Thus, the user does not need to change the settings for your application, all they need to do is change their OS theme, and the changes will automatically be applied to your application.

0
source

Source: https://habr.com/ru/post/1699708/


All Articles