简体   繁体   中英

how to create Nimbus L&F live template in Intellij IDEA

i want to create a live template in Intellij IDEA to add Nimbus Look and Feel in my Code when use "nmbs+Tab" abbreviation.

here is the code :

try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(CURRENT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(CURRENT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(CURRENT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(CURRENT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }

because this live template is based on current class name to work correctly, the problem is how can i get and replace current class name with the "CURRENT" word in the code ?

Thanks.

You should create the live template and paste your code into it, but replace CURRENT with $CURRENT$ . Once you've done this, the Edit Variables option becomes available. Then, you should click this. You want to define an expression, such as className() for you $CURRENT$ variable.

The whole process is described in the IntelliJ documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM