0

The problem I'm having is I've installed the Darkula plugin into Netbeans. This has changed the editor the way it should do. I have set it as preferred look and feel but when running the application it doesn't use Darkula theme only nimbus. I can only get it to use Nimbus or Windows.

In the below code I have changed Nimbus to say Darkula and it doesn't work.

try{
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Darkula".equals(info.getName())) {
              javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
           }
        }     

       //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch(ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException ex){
            System.out.println(ex.toString());                        
        }       
Cal-cium
  • 654
  • 12
  • 22

1 Answers1

2

The method UIManager.getInstalledLookAndFeels() will only return system known L&F. If you have an external L&F you need to call it by the class name. For your case:

UIManager.setLookAndFeel(new DraculaLaf());

or

UIManager.setLookAndFeel(DraculaLaf.class.getName());
Sergiy Medvynskyy
  • 11,160
  • 1
  • 32
  • 48
  • I'm quite new to netbeans, it doesn't recognise DraculaLaf, netbeans hints wants me to create a class for it – Cal-cium Oct 12 '17 at 12:54
  • 1
    You need to configure your project and add the jar-file for Dracula L&F to the class path. [Here](https://stackoverflow.com/questions/4879903/how-to-add-a-jar-in-netbeans) is an explanation how to do it. – Sergiy Medvynskyy Oct 12 '17 at 13:02
  • 1
    And [here](https://www.youtube.com/watch?v=jsS_cRbNv3o) is an animated example :) – Sergiy Medvynskyy Oct 12 '17 at 13:07