Example usage for javax.swing.plaf.synth SynthLookAndFeel load

List of usage examples for javax.swing.plaf.synth SynthLookAndFeel load

Introduction

In this page you can find the example usage for javax.swing.plaf.synth SynthLookAndFeel load.

Prototype

public void load(InputStream input, Class<?> resourceBase) throws ParseException 

Source Link

Document

Loads the set of SynthStyles that will be used by this SynthLookAndFeel.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    SynthLookAndFeel synth = new SynthLookAndFeel();
    try {//  www . j a  v  a2  s  . c o m
        Class aClass = MainClass.class;
        InputStream is = aClass.getResourceAsStream("config.xml");
        if (is == null) {
            System.err.println("Unable to find theme configuration");
            System.exit(-1);
        }
        synth.load(is, aClass);
    } catch (ParseException e) {
        System.err.println("Unable to load theme configuration");
        System.exit(-2);
    }
    try {
        UIManager.setLookAndFeel(synth);
    } catch (javax.swing.UnsupportedLookAndFeelException e) {
        System.err.println("Unable to change look and feel");
        System.exit(-3);
    }
    JFrame frame = new JFrame("Synth Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Hello, Synth");
    frame.add(button, BorderLayout.CENTER);
    JTextField textField = new JTextField();
    frame.add(textField, BorderLayout.SOUTH);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:SynthApplication.java

private static void initLookAndFeel() {
    // String lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();

    try {/*from w  w w .  j  a  va  2  s .  c  o m*/
        lookAndFeel.load(SynthApplication.class.getResourceAsStream(synthFile), SynthApplication.class);
        UIManager.setLookAndFeel(lookAndFeel);
    }

    catch (Exception e) {
        System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    }

}

From source file:lookandfeel.SynthDialog.java

private static void initLookAndFeel() {
    SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();

    try {// ww  w .  ja  va2s.  c  om

        // SynthLookAndFeel load() method throws a checked exception
        // (java.text.ParseException) so it must be handled
        lookAndFeel.load(SynthDialog.class.getResourceAsStream("synthDemo.xml"), SynthDialog.class);
        UIManager.setLookAndFeel(lookAndFeel);
    }

    catch (Exception e) {
        System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");
        System.err.println("Using the default look and feel.");
        e.printStackTrace();
    }

}

From source file:lookandfeel.SynthDialog.java

private static void initLookAndFeel() {
     SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
       //from   w w w.j  a va2s  . c om
 
        try {
               
           // SynthLookAndFeel load() method throws a checked exception
           // (java.text.ParseException) so it must be handled
           lookAndFeel.load(SynthDialog.class.getResourceAsStream("synthDemo.xml"),
                          SynthDialog.class);
            UIManager.setLookAndFeel(lookAndFeel);
        } 
            
        catch (Exception e) {
            System.err.println("Couldn't get specified look and feel ("
                               + lookAndFeel
                               + "), for some reason.");
            System.err.println("Using the default look and feel.");
            e.printStackTrace();
        }
        
}