Search code examples
javaexelook-and-feel

JAR to EXE(working with look and feel)


I have used a different look and feel desing in my project but how can I convert it to an EXE and maintain the design created? I used Launch4j to turn it to a EXE but it keeps the "Metal" look and feel.


Solution

  • You could set the command line argument in launch4j. That would be something along the line of -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel.

    The problem with this approach is that it isn't really crossplatform. I suspect you want the system l&f. That can be done per code:

    try {
         UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
    }
    catch(Exception e) {...}
    

    Just put that on the first line of your program.

    Note that you can also specify other l&f's.


    Edit #1

    Of course you can specify your own l&f aswell if that is what you are looking for. Just pass the class name:

    UIManager.setLookAndFeel("com.someproject.somepackage.MyAwesomeLookAndFeel");