Skip to main content

Setup Java Look and Feel on IntelliJ IDEA GUI Forms

This involves 2 main steps.

Step 1: Create method to set Look & Feel of your preferences. 

We use 'Nimbus' Look & Feel for this example.
private void initLookandFeel(){
try {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            UIManager.setLookAndFeel(info.getClassName());
            break;
        }
    }
} catch (Exception e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
}
}

Step 2: Setup and update the UI for new Look & Feel after all components have been initiated

When you have the class extended to JFrame class, do the following.
// constructor
public MyClass(){

   // IntelliJ IDEA GUI form components binding and initiation
   // to the given top panel name: 'mainPanel'
   setContentPane(mainPanel);

   // setting up Look and Feel and update UI
   initLookandFeel();
   SwingUtilities.updateComponentTreeUI(this)
}

If you are not sure how to get the IntelliJ IDEA forms be run, check here.


Comments

Popular posts from this blog

session_start(): Failed to initialize storage module: user (path: )

Error: session_start(): Failed to initialize storage module: user (path: ) Solution: When this error is given for the Codeigniter project you are running, that is specifically for not having a path recognised to store session data. Set config data as follows [file: your-project-folder/application/config/config.php] : $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_save_path'] = APPPATH.'cache/'; $config['sess_match_ip'] = TRUE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE;