3

I have just found a nice look that I would like to use for my programs appearance however I'm unsure of how to integrate it. This is the look i'm after:

AcrylLookAndFeel

I have managed to find the website and download a jar file which I have included in my build path. I have also found the following line of code which I have included:

UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");

When I run it I don't get any errors, however it doesn't look anything like the image. Have I missed out steps? What do I need to do?

One other concern I have is that I'm currently working on a mac, however I want the appearance to be consistent regardless of whether I run my program on a mac or on windows. Is this even possible? If so please could you advise how to do this (if any changes are required)?

  • Where did you put the `UIManager` statement in your code? Also, the image isn't necessarily related to the question you're asking, but your code where you are setting that as your LAF is and is not present. – Brandon Buck Nov 11 '11 at 20:32
  • 1
    for some L&F is required add code line `SwingUtilities.updateComponentTreeUI(frame);` after UIManager.setLookAndFeel() – mKorbel Nov 12 '11 at 00:20
  • @mKorbel Good call on being the 1st to identify the solution to the root problem. I linked to an example in my comment to the accepted answer. – Andrew Thompson Nov 12 '11 at 01:20

3 Answers3

2

Setting the Swing look and feel in Java carries over between operating systems. I've always only ever done it before I created my Swing GUI.

public static void main(String[] args) {
    try {    
        UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
    } 
    // Probably want to break this into handling the various exceptions that can be thrown.
    catch (Exception e) {
       // handle exception
    }

    // Create Swing GUI and so forth
}
Brandon Buck
  • 7,177
  • 2
  • 30
  • 51
  • Thanks for your help - As it turned out it was the ordering of the code that was the issue. I needed to set the look and feel before creating the GUI components. –  Nov 11 '11 at 20:44
  • 3
    It does not matter where the code line is called, so long as the GUI is updated properly. See the [Nested Layout Example](http://stackoverflow.com/questions/5621338/about-swing-and-jtable/5630271#5630271) for a GUI that can change PLAF at run-time (as many times as the user wants to change it). – Andrew Thompson Nov 12 '11 at 01:18
0

Before you create your JFrame:

// setup the look and feel properties
Properties props = new Properties();

// set your theme
SmartLookAndFeel.setCurrentTheme(props);
// select the Look and Feel
UIManager.setLookAndFeel("com.jtattoo.plaf.smart.SmartLookAndFeel");
kleopatra
  • 51,061
  • 28
  • 99
  • 211
0
import org.jvnet.substance.SubstanceLookAndFeel;

public class Main {

    public static void main(String[] args) {
       /*Si no se tiene instalado la libreria Substance*/
       //formpadre fp= new formpadre();
       //fp.show();

        /*si la libreria substance esta instalada y configurada*/               
        EventQueue.invokeLater(new Runnable(){
        public void run(){
            try{
                JFrame.setDefaultLookAndFeelDecorated(true);                
                SubstanceLookAndFeel.setSkin("org.jvnet.substance.skin.BusinessBlueSteelSkin");            //SubstanceLookAndFeel.setCurrentTheme("org.jvnet.substance.theme.SubstanceAquaTheme");   
            }              
            catch(Exception e){
            }               
            new formpadre().setVisible(true);
        }
        });            
    }
}
competent_tech
  • 44,465
  • 11
  • 90
  • 113