Example usage for javax.swing UIManager getLookAndFeelDefaults

List of usage examples for javax.swing UIManager getLookAndFeelDefaults

Introduction

In this page you can find the example usage for javax.swing UIManager getLookAndFeelDefaults.

Prototype

public static UIDefaults getLookAndFeelDefaults() 

Source Link

Document

Returns the UIDefaults from the current look and feel, that were obtained at the time the look and feel was installed.

Usage

From source file:de.juwimm.cms.Main.java

public Main(String[] argv) {
    // Bugfix [CH], use the "old" Java 5 RepaintManager (no-arg constructor creates one) for current thread group
    // instead of setting the system property "swing.bufferPerWindow" to false (does not work with JavaWebStart)
    PerformanceUtils.start();//from  w  w  w.  ja  va 2 s  .c o m
    RepaintManager.setCurrentManager(new RepaintManager());

    System.setProperty("swing.aatext", "true");
    try {
        InputStream in = this.getClass().getResourceAsStream("/pom.xml");
        String pom = IOUtils.toString(in);
        Document doc = XercesHelper.string2Dom(pom);

        String version = XercesHelper.getNodeValue(doc, "/project/version");
        System.setProperty("tizzit.version", version);

        Constants.CMS_VERSION = "V " + version;

        logSys("Starting Tizzit Version " + Constants.CMS_VERSION);
    } catch (Exception e) {
    }
    //SplashShell splash = new SplashShell();
    FrmVersion splash = new FrmVersion();
    int screenHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    int screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    int frameHeight = 300;
    int frameWidth = 450;
    splash.setLocation((screenWidth / 2) - (frameWidth / 2), (screenHeight / 2) - (frameHeight / 2));
    splash.setIconImage(new ImageIcon(getClass().getResource("/images/cms_16x16.gif")).getImage());
    splash.setSize(frameWidth, frameHeight);
    splash.setVisible(true);

    String host = "";
    if (argv.length >= 2 && argv[0].equals("URL_HOST")) {
        try {
            URL url = new URL(argv[1]);
            Constants.URL_HOST = url.toString();
            host = url.getHost();
            Constants.SERVER_SSL = url.getProtocol().equalsIgnoreCase("https");
            if (Constants.SERVER_SSL) {
                JOptionPane.showMessageDialog(null,
                        "Fehler beim Erstellen der SSL Verbindung!\nBitte wenden Sie sich an den Tizzit Support.",
                        "Tizzit", JOptionPane.ERROR_MESSAGE);
                System.exit(-1);
            }
            Constants.SERVER_PORT = (url.getPort() == -1) ? ((Constants.SERVER_SSL) ? 443 : 80) : url.getPort();
        } catch (Exception exe) {
            log.error(exe);
        }
    } else if (argv.length == 1) {
        host = argv[0];
    } else {
        return;
    }
    if ("".equalsIgnoreCase(host)) {
        return;
    }

    logSys("CONNECTING HOST " + host + " " + argv[1] + " with SSL " + Constants.SERVER_SSL);
    Constants.SERVER_HOST = host;
    Constants.SVG_CACHE = Constants.DB_PATH + "svgcache_" + Constants.SERVER_HOST
            + System.getProperty("file.separator");
    UIConstants.setMainFrame(this);

    logSys("Setting SAX/DOM XML Parser to Apache Xerces");
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
            "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    System.setProperty("javax.xml.parsers.DocumentBuilder", "org.apache.xerces.jaxp.DocumentBuilderImpl"); // needed?
    System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
    System.setProperty("javax.xml.parsers.SAXParser", "org.apache.xerces.jaxp.SAXParserImpl"); //needed?
    System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser"); //needed?
    initLog4J(host, argv);
    PerformanceUtils.mark("Initial stage");
    String testUrl = ((Constants.SERVER_SSL) ? "https://" : "http://") + Constants.SERVER_HOST + ":"
            + Constants.SERVER_PORT + "/admin/juwimm-cms-client.jnlp";
    try {
        URI desturi = new URI(testUrl);
        ProxyHelper helper = new ProxyHelper();
        helper.init(desturi, false);

    } catch (IllegalArgumentException ex) {
        logSys("could not initialize the proxy settings for host " + host + ": " + ex);
    } catch (URISyntaxException ex) {
        logSys("could not initialize the proxy settings because URI from host " + host + ": " + ex);
        // log.error("could not initialize the proxy settings because URI from host " + host + " : ", ex);
    }
    PerformanceUtils.mark("Initialising proxy server");
    try {
        UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader());
        LookAndFeel.switchTo(LookAndFeel.determineLookAndFeel());
    } catch (Exception exe) {
        log.error("Can't switch to Default LookAndFeel");
    }
    PerformanceUtils.mark("Initialising look and feel");
    splash.setStatusInfo("Invoking Bean Framework...");
    Application.initializeContext();
    PerformanceUtils.mark("Initialising spring context");
    splash.setStatusInfo("Getting Locale Settings...");

    try {
        Constants.rb = ResourceBundle.getBundle("CMS", Constants.CMS_LOCALE);
    } catch (Exception ex) {
        log.warn("Could not find ResourceBundle for language: " + Constants.CMS_LOCALE + " - loading default");
        Constants.rb = ResourceBundle.getBundle("CMS", Constants.CMS_LOCALE);
    }
    PerformanceUtils.mark("Loading resource bundle");
    splash.setStatusInfo(Constants.rb.getString("splash.checkingSSL"));
    HttpClientWrapper httpClientWrapper = HttpClientWrapper.getInstance();

    try {
        httpClientWrapper.testAndConfigureConnection(testUrl);
    } catch (HttpException exe) {
        JOptionPane.showMessageDialog(null, exe.getMessage(), Constants.rb.getString("dialog.title"),
                JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }
    PerformanceUtils.mark("Initialising client wrapper");
    splash.setStatusInfo(Constants.rb.getString("splash.configBrowserSettings"));
    Browser.init(); // only needs to be called once.
    splash.setStatusInfo(Constants.rb.getString("splash.gettingTemplates"));
    comm = ((Communication) getBean(Beans.COMMUNICATION));
    splash.setStatusInfo(Constants.rb.getString("splash.locadingLocalCachingDatabase"));
    comm.getDbHelper(); // check if there is already a programm running
    ActionHub.addActionListener(this);
    rb = Constants.rb;
    PerformanceUtils.mark("Initialising dbHelper");
    splash.setStatusInfo(Constants.rb.getString("splash.initUI"));
    try {
        this.getContentPane().setLayout(new BorderLayout());
        panLogin = new PanLogin();
        setCenterPanel(panLogin);
        Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_LOGIN;
        screenHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
        screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        frameWidth = Constants.CMS_SCREEN_WIDTH;
        frameHeight = Constants.CMS_SCREEN_HEIGHT;
        this.setSize(frameWidth, frameHeight);
        this.setLocationRelativeTo(null);
        this.setIconImage(UIConstants.CMS.getImage());
        this.setTitle(rb.getString("dialog.title") + " " + Constants.CMS_VERSION);
        this.addWindowListener(new MyWindowListener());
        this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

        if (screenHeight <= frameHeight && screenWidth <= frameWidth) {
            this.setExtendedState(MAXIMIZED_BOTH);
        }

        this.setVisible(true);
        // splash.disposeMe(true);
        splash.dispose();

        // unimportant stuff
        UIConstants.loadImages();

    } catch (Exception exe) {
        log.error("Tizzit will exit", exe);
        JOptionPane.showMessageDialog(this, exe.getMessage() + "\nCMS will exit.", "CMS",
                JOptionPane.ERROR_MESSAGE);
    } finally {
        //splash.disposeMe();
        splash.dispose();
    }
    PerformanceUtils.mark("Initialising main window");
}

From source file:com.haulmont.cuba.desktop.App.java

protected void initLookAndFeelDefaults() {
    InputMapUIResource inputMap = (InputMapUIResource) UIManager.getLookAndFeelDefaults()
            .get("FormattedTextField.focusInputMap");
    inputMap.remove(KeyStroke.getKeyStroke("ESCAPE"));
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

public static void main(String[] args) {

    // Initialize globales
    m_application_data_folder = Utilities.appDataFolder();
    favorite_meds_set = new HashSet<String>();
    favorite_data = new DataStore(m_application_data_folder);
    favorite_meds_set = favorite_data.load(); // HashSet containing registration numbers

    // Register toolkit
    Toolkit tk = Toolkit.getDefaultToolkit();
    tk.addAWTEventListener(WindowSaver.getInstance(m_application_data_folder), AWTEvent.WINDOW_EVENT_MASK);

    // Specify command line options
    Options options = new Options();
    addOption(options, "help", "print this message", false, false);
    addOption(options, "version", "print the version information and exit", false, false);
    addOption(options, "port", "starts AmiKo-server at given port", true, false);
    addOption(options, "width", "sets window width", true, false);
    addOption(options, "height", "sets window height", true, false);
    addOption(options, "lang", "use given language", true, false);
    addOption(options, "type", "start light or full app", true, false);
    addOption(options, "title", "display medical info related to given title", true, false);
    addOption(options, "eancode", "display medical info related to given 13-digit ean-code", true, false);
    addOption(options, "regnr", "display medical info related to given 5-digit registration number", true,
            false);/*from   www  .j  a v a 2s. co  m*/
    // Activate command line parser
    commandLineParse(options, args);

    // Initialize language files
    if (Utilities.appLanguage().equals("de"))
        m_rb = ResourceBundle.getBundle("amiko_de_CH", new Locale("de", "CH"));
    else if (Utilities.appLanguage().equals("fr"))
        m_rb = ResourceBundle.getBundle("amiko_fr_CH", new Locale("fr", "CH"));

    if (Utilities.appCustomization().equals("desitin")) {
        new SplashWindow(Constants.APP_NAME, 5000);
    } else if (Utilities.appCustomization().equals("meddrugs")) {
        new SplashWindow(Constants.APP_NAME, 5000);
    } else if (Utilities.appCustomization().equals("zurrose")) {
        new SplashWindow(Constants.APP_NAME, 3000);
    }
    // Load javascript
    String jscript_str = FileOps.readFromFile(Constants.JS_FOLDER + "main_callbacks.js");
    m_jscript_str = "<script language=\"javascript\">" + jscript_str + "</script>";

    // Load css style sheet
    m_css_str = "<style>" + FileOps.readFromFile(Constants.CSS_SHEET) + "</style>";

    // Load main database
    m_sqldb = new MainSqlDb();
    // Attempt to load alternative database. if db does not exist, load
    // default database
    // These databases are NEVER zipped!
    if (m_sqldb.loadDBFromPath(m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_DB_BASE
            + Utilities.appLanguage() + ".db") == 0) {
        System.out.println("Loading default amiko database");
        if (Utilities.appLanguage().equals("de"))
            m_sqldb.loadDB("de");
        else if (Utilities.appLanguage().equals("fr"))
            m_sqldb.loadDB("fr");
    }

    // Load rose database
    if (Utilities.appCustomization().equals("zurrose")) {
        m_rosedb = new RoseSqlDb();
        if (m_rosedb.loadDBFromPath(m_application_data_folder + "\\" + Constants.DEFAULT_ROSE_DB) == 0) {
            System.out.println("Loading default rose db");
            m_rosedb.loadDB();
        }
    }

    // Initialize update class
    m_maindb_update = new UpdateDb(m_sqldb);

    // Create shop folder in application data folder
    File wdir = new File(m_application_data_folder + "\\shop");
    if (!wdir.exists())
        wdir.mkdirs();

    // Load interaction cart
    m_interactions_cart = new InteractionsCart();

    // Create shopping cart and load related files
    m_shopping_cart = new ShoppingCart();
    loadAuthors();
    m_emailer = new Emailer(m_rb);

    // Create comparison cart and load related files
    m_comparison_cart = new ComparisonCart();

    // Preferences
    m_prefs = Preferences.userRoot().node(SettingsPage.class.getName());

    // UIUtils.setPreferredLookAn dFeel();
    NativeInterface.open();
    NativeSwing.initialize();

    // Setup font size based on screen size
    UIManager.getLookAndFeelDefaults().put("defaultFont", new Font("Dialog", Font.PLAIN, 14));
    UIManager.put("Label.font", new Font("Dialog", Font.PLAIN, 12));
    UIManager.put("CheckBox.font", new Font("Dialog", Font.PLAIN, 12));
    UIManager.put("Button.font", new Font("Dialog", Font.BOLD, 14));
    UIManager.put("ToggleButton.font", new Font("Dialog", Font.BOLD, 14));
    UIManager.put("ToggleButton.select", m_selected_but_color);
    UIManager.put("Menu.font", new Font("Dialog", Font.PLAIN, 12));
    UIManager.put("MenuBar.font", new Font("Dialog", Font.PLAIN, 12));
    UIManager.put("MenuItem.font", new Font("Dialog", Font.PLAIN, 12));
    UIManager.put("ToolBar.font", new Font("Dialog", Font.PLAIN, 12));

    // Schedule a job for the event-dispatching thread:
    // creating and showing this application's GUI
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (!commandLineOptionsProvided()) {
                System.out.println("No relevant command line options provided... creating full GUI");
                createAndShowFullGUI();
            } else if (CML_OPT_TYPE.equals("full")) {
                System.out.println("Creating full GUI");
                createAndShowFullGUI();
            } else if (CML_OPT_TYPE.equals("light")) {
                System.out.println("Creating light GUI");
                createAndShowLightGUI();
            }
        }
    });

    NativeInterface.runEventPump();
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTimeField.java

protected int getDigitWidth() {
    UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults();
    if (lafDefaults.getDimension("TimeField.digitWidth") != null) { // take it from desktop theme
        return (int) lafDefaults.getDimension("TimeField.digitWidth").getWidth();
    }//  ww  w .jav  a 2  s.c om
    return DEFAULT_DIGIT_WIDTH;
}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

public static void setDefaultSize(int size) {
    Set<Object> keySet = UIManager.getLookAndFeelDefaults().keySet();
    Object[] keys = keySet.toArray(new Object[keySet.size()]);

    for (Object key : keys) {
        if (key != null && key.toString().toLowerCase().contains("font")) {
            Font font = UIManager.getDefaults().getFont(key);
            if (font != null) {
                font = font.deriveFont((float) size);
                UIManager.put(key, font);
            }/*from ww w.  j a  v a 2 s .  c  om*/
        }
    }
}

From source file:dataviewer.DataViewer.java

/**
 * @param args the command line arguments
 *//*from w w  w .j  a  va2s. c o m*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */

    try {

        /*System.setProperty(
         "Quaqua.tabLayoutPolicy", "wrap"
         );*/
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                UIManager.getLookAndFeelDefaults().put("Panel.background", new Color(245, 245, 245));
                UIManager.getLookAndFeelDefaults().put("OptionPane.background", new Color(245, 245, 245));
                break;
            }
        }
        /*UIManager.setLookAndFeel(
         ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel()
         );*/

    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(DataViewer.class.getName()).log(java.util.logging.Level.SEVERE, null,
                ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Utilities.createFolder("output");
                Utilities.createFolder("db");

                DataViewer dv = new DataViewer();
                dv.setIconImage(ImageIO.read(getClass().getResource("/images/dataviewer.png")));
                dv.setLocationRelativeTo(null);
                dv.setVisible(true);
            } catch (Exception ex) {
                System.err.println(ex.getMessage());
            }
        }
    });
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopDateField.java

protected Dimension getDefaultDimension() {
    UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults();
    if (lafDefaults.getDimension("DateField.dimension") != null) { // take it from desktop theme
        return lafDefaults.getDimension("DateField.dimension");
    }//from  www.j a v a  2  s. c om
    return new Dimension(110, DesktopComponentsHelper.FIELD_HEIGHT);
}

From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java

public void init(String[] args) {

    // copy ARGs//from ww w.  j  a va  2  s. c  o m
    this.parseCommandLine(args);

    // Usefull for debugging
    this.myLogger.debug("java.version: " + System.getProperty("java.version"));
    this.myLogger.debug("java.vendor: " + System.getProperty("java.vendor"));
    this.myLogger.debug("java.vendor.url: " + System.getProperty("java.vendor.url"));
    this.myLogger.debug("os.name: " + System.getProperty("os.name"));
    this.myLogger.debug("os.arch: " + System.getProperty("os.arch"));
    this.myLogger.debug("os.version: " + System.getProperty("os.version"));

    if (this.paramDBconfig.length() != 0) {
        this.WDB_DB_CONFIG_FILE = this.paramDBconfig;
    }

    WDBearManager_API myAPI = new WDBearManager_API(this.WDB_DB_CONFIG_FILE);

    // Create all tables
    // -> Needed for the updata script <-
    // -> Otherwise it may crash with an empty database
    try {
        myAPI.getCountOfTable("creaturecache");
        myAPI.getCountOfTable("gameobjectcache");
        myAPI.getCountOfTable("itemcache");
        myAPI.getCountOfTable("itemnamecache");
        myAPI.getCountOfTable("itemtextchaxhe");
        myAPI.getCountOfTable("npccache");
        myAPI.getCountOfTable("pagetextcache");
        myAPI.getCountOfTable("questcache");
    } catch (Exception ex) {
        // ignore
        ex.printStackTrace();
        System.exit(0);
    }

    // Check, if database must be re-newed
    DBUpdater myDBU = new DBUpdater();
    myDBU.checkForUpdate(myAPI);

    WDBearManager_I myWoWWDBearManager_API = myAPI;

    //
    // print out some statistics
    //

    if (this.useGUI == false) {

        boolean paramSpec = false;
        // ASSERT
        DTO_Interface myDTO = null;

        if (this.paramWdbfile.length() != 0) {
            paramSpec = true;
            // Open WDB
            try {
                this.items = myWoWWDBearManager_API.readWDBfile(this.paramWdbfile);
            } catch (Exception ex) {
                this.myLogger.error("Error reading the WDB file");
                return;
            }
            // first dto -> to identify the data
            Iterator itWDBS = this.items.iterator();
            if (itWDBS.hasNext()) {
                myDTO = (DTO_Interface) itWDBS.next();
            }
        }
        // Create CSV?
        if (this.paramCSVFolder.length() != 0) {
            if (myDTO == null) {
                // NO WDB specified -> exit
                this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n");
                usage(this.options);
                return;
            }
            File csvFile = new File(this.paramCSVFolder, myDTO.getTableName() + ".csv");
            if (this.useVerbose) {
                this.myLogger.info("Creating CSV file: " + csvFile.getAbsolutePath());
            }
            try {
                WriteCSV.writeCSV(new File(this.paramCSVFolder), this.items);
                this.myLogger.info("CSV file written: " + csvFile.getAbsolutePath());
            } catch (Exception ex) {
                ex.printStackTrace();
                this.myLogger.error("Error writing the CSV file");
                return;
            }
        }
        // Create TXT?
        if (this.paramTXTFolder.length() != 0) {
            if (myDTO == null) {
                // NO WDB specified -> exit
                this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n");
                usage(this.options);
                return;
            }
            if (this.useVerbose) {
                String table = myDTO.getTableName();
                File txtFile = new File(this.paramTXTFolder, table + ".txt");
                this.myLogger.info("Creating TXT file: " + txtFile.getAbsolutePath());
            }
            try {
                WriteTXT.writeTXT(new File(this.paramTXTFolder), this.items);
            } catch (Exception ex) {
                //ex.printStackTrace();
                this.myLogger.error("Error writing the TXT file: " + ex.getMessage());
                return;
            }
        }
        // Store inside SQL database?
        if (this.writeSQL == true) {
            paramSpec = true;
            if (myDTO == null) {
                // NO WDB specified -> exit
                this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n");
                usage(this.options);
                return;
            }
            if (this.useVerbose) {
                this.myLogger.info("Storing data inside SQL database");
            }
            SQLManager myWriteSQL = null;
            try {
                myWriteSQL = new SQLManager(this.WDB_DB_CONFIG_FILE);
                ObjectsWritten myOWr = myWriteSQL.insertOrUpdateToSQLDB(this.items, this.doUpdate);
                this.myLogger.info("Operation successfull");
                if (this.useVerbose) {
                    this.myLogger.info("DB statistics");
                    this.myLogger.info("INSERT: " + myOWr.getNumInsert());
                    this.myLogger.info("UPDATE: " + myOWr.getNumUpdate());
                    this.myLogger.info("Error INSERT: " + myOWr.getNumErrorInsert());
                    this.myLogger.info("Error UPDATE: " + myOWr.getNumErrorUpdate());
                    if (this.doUpdate == false) {
                        this.myLogger.info("Objects skipped: " + myOWr.getNumSkipped());
                        System.out.println("If you want to overwrite/update objects, use 'update' param");
                    }
                    this.myLogger.info(WDBearManager.VERSION_INFO);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                this.myLogger.error("Error importing to database");
                this.myLogger.error(ex.getMessage());
                return;
            }
        } // writeSQL

        // Patch *.SCP with contents of database
        if (this.paramSCPname.length() != 0) {
            if (this.paramPatchSCP.length() == 0) {
                this.myLogger.error("Error: You did not specify -" + WDBearManager.PATCH_SCP + "\n");
                usage(this.options);
                return;
            }

            paramSpec = true;
            this.myLogger.info("Patch scp file with the contents of the database");
            try {

                SCPWritten mySCPW = myWoWWDBearManager_API.patchSCP(this.paramSCPname, this.paramPatchSCP,
                        this.patchUTF8, this.paramLocale);
                if (this.useVerbose) {
                    this.myLogger.info("Merge statistics");
                    System.out.println("Entries in database:    " + mySCPW.getNumInDB());
                    this.myLogger.info("Merged with SCP: " + mySCPW.getNumPatched());
                    this.myLogger.info("Patched IDs:      " + mySCPW.getPatchedIDs());
                }
                this.myLogger.info("Patched file: " + this.paramSCPname + "_patch");
            } catch (WDBMgr_IOException ex) {
                this.myLogger.error("The destination SCP file could not be created");
                this.myLogger.error(ex.getMessage());
                return;
            } catch (WDBMgr_NoDataAvailableException ex) {
                this.myLogger.info("Merging impossible");
                this.myLogger.info("There are no entries inside the database");
            } catch (Exception ex) {
                this.myLogger.error("Error while merging quests.scp with database");
                this.myLogger.error(ex.getMessage());
                return;
            }
        } // PatchSCP

        // Call jython script?
        if (this.paramScript.length() != 0) {
            paramSpec = true;
            this.myLogger.info("Calling Jython script");
            this.myLogger.info("---");
            PythonInterpreter interp = new PythonInterpreter();

            interp.set("wdbmgrapi", myWoWWDBearManager_API);
            // set parameters
            Set setKeys = this.paramJython.keySet();
            Iterator itKeys = setKeys.iterator();
            String jyParam = "";
            while (itKeys.hasNext()) {
                jyParam = (String) itKeys.next();
                interp.set(jyParam, (String) this.paramJython.get(jyParam));
            }
            interp.execfile(this.paramScript);

            this.myLogger.info("---");
            System.out.println("Jython script executed, " + WDBearManager.VERSION_INFO);
            return;
        } // paramScript

        if (paramSpec == false) {
            usage(this.options);
            return;
        }

        // Exit
        return;
    } // Command Line Version

    //
    // GUI
    //
    PlasticLookAndFeel.setMyCurrentTheme(new DesertBlue());
    try {
        UIManager.put("ClassLoader", LookUtils.class.getClassLoader());
        UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
    } catch (Exception e) {
    }
    //    try {
    //      com.incors.plaf.kunststoff.KunststoffLookAndFeel kunststoffLnF = new com.incors.plaf.kunststoff.KunststoffLookAndFeel();
    //      KunststoffLookAndFeel
    //          .setCurrentTheme(new com.incors.plaf.kunststoff.KunststoffTheme());
    //      UIManager.setLookAndFeel(kunststoffLnF);
    //    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    //      // handle exception or not, whatever you prefer
    //    }
    //     this line needs to be implemented in order to make JWS work properly
    UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader());

    this.setTitle(WDBearManager.VERSION_INFO);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.getContentPane().setLayout(new BorderLayout());

    // construct GUI to display the stuff
    // Menu
    //  Where the GUI is created:
    JMenuBar menuBar;
    JMenu menu; //, submenu;
    JMenuItem menuItem;
    //JRadioButtonMenuItem rbMenuItem;
    //JCheckBoxMenuItem cbMenuItem;

    //    Create the menu bar.
    menuBar = new JMenuBar();

    //    Build the first menu.
    menu = new JMenu("File");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("Process WDB files");
    menuBar.add(menu);

    // Exit
    menuItem = new JMenuItem(MENU_EXIT, KeyEvent.VK_T);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Exit program");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //    Build the first menu.
    menu = new JMenu("About");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("Whassup?");
    menuBar.add(menu);
    // Help
    menuItem = new JMenuItem(MENU_HELP, KeyEvent.VK_H);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Help me...");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    // JavaDocs
    menuItem = new JMenuItem(MENU_JDOCS, KeyEvent.VK_J);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Show API docs...");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    // separator
    menu.addSeparator();
    // CheckForUpdate
    menuItem = new JMenuItem(MENU_CHECKUPDATE, KeyEvent.VK_U);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Check for update...");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    // separator
    menu.addSeparator();
    // ABOUT
    menuItem = new JMenuItem(MENU_ABOUT, KeyEvent.VK_T);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Ueber...");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    this.setJMenuBar(menuBar);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridLayout(0, 1));

    JTabbedPane tabbedPane = new JTabbedPane();
    ImageIcon wowIcon = createImageIcon("images/fromdisk.gif");

    JComponent panel1 = new WDB_Panel(myWoWWDBearManager_API);
    tabbedPane.addTab("WDB-Module", wowIcon, panel1, "Handle WDB files");
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

    ImageIcon panelIcon = createImageIcon("images/hsql.gif");
    JComponent panel2 = null;
    try {
        panel2 = new SQL_Panel(myWoWWDBearManager_API);
    } catch (Throwable ex) {
        System.err.println("Error while instantiating SQL Panel: ");
        System.err.println(ex.getMessage());
        ex.printStackTrace();
        System.exit(0);
    }
    tabbedPane.addTab("DB-Module", panelIcon, panel2, "Handle database");
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    panelIcon = createImageIcon("images/pythonpoweredsmall.gif");
    JComponent panel3 = new Python_Panel(myWoWWDBearManager_API);
    tabbedPane.addTab("Scripts", panelIcon, panel3, "Scripting");
    tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    // maybe user PLUGIN availabe
    // -> check for folders below "plugins"
    File filUserPanels = new File("plugins");
    // 1) find user plugins (scan for directories)
    // 2) scan for <name>.properties, where <name> is the name of the directory
    // 3) load the properties file and get the plugin running
    String[] strUserPlugins = filUserPanels.list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return (new File(dir, name).isDirectory());
        }
    });
    if (strUserPlugins != null) {
        ArrayList urlJars = new ArrayList();

        //URL[] urlJars = new URL[strUserPlugins.length];
        String strCurrJar = "";
        String strPlugins[] = new String[strUserPlugins.length];
        try {
            for (int i = 0; i < strUserPlugins.length; i++) {
                File baseFile = new File("plugins", strUserPlugins[i]);
                File filProperties = new File(baseFile, strUserPlugins[i] + ".properties");
                if (filProperties.exists()) {
                    // set plugin folder and .properties name
                    strPlugins[i] = strUserPlugins[i];
                    this.myLogger.info("Found 'plugin' : " + baseFile.getAbsolutePath());
                    this.myLogger.info("                 Trying to load .jar file");

                    // Scan for JAR files and include them
                    //System.out.println(baseFile.getAbsolutePath());
                    String[] strJars = baseFile.list(new FilenameFilter() {
                        public boolean accept(File dir, String name) {
                            return name.endsWith(".jar");
                        }
                    });
                    for (int j = 0; j < strJars.length; j++) {
                        File filJAR = new File(baseFile, strJars[j]);
                        strCurrJar = filJAR.getAbsolutePath();

                        this.myLogger.info("Loading external 'plugin' JAR: " + strCurrJar);
                        URL jarfile = new URL("jar", "", "file:" + strCurrJar + "!/");
                        urlJars.add(jarfile);
                    }

                } else {
                    // print warning - a directory inside plugins, but there is no plugin
                    this.myLogger.warn("Found directory inside plugins folder, but no .properties file");
                    this.myLogger.warn("      Name of directory: " + strUserPlugins[i]);
                    this.myLogger.warn("      Please review the directory!");
                }
            } // for... all user plugins
        } catch (Exception ex) {
            this.myLogger.error("Plugin: Error loading " + strCurrJar);
            this.myLogger.error("Please check your 'plugin' folder");
        }
        URLClassLoader cl = null;
        try {
            //      File file = new File("plugins", strUserJars[i]);
            //      this.myLogger.info("Lade externes JAR: " + file.getAbsolutePath());
            //      URL jarfile = new URL("jar", "", "file:" + file.getAbsolutePath() + "!/");
            URL[] loadURLs = new URL[urlJars.toArray().length];
            for (int j = 0; j < urlJars.toArray().length; j++) {
                loadURLs[j] = (URL) urlJars.get(j);
            }
            cl = URLClassLoader.newInstance(loadURLs);

            Thread.currentThread().setContextClassLoader(cl);

            //      String lcStr = "Test";
            //      Class loadedClass = cl.loadClass(lcStr);
            //      this.myLogger.info("Smooth...");

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        // 2) load properties and instantiate the plugin
        //      String[] strPlugins = filUserPanels.list(new FilenameFilter() {
        //        public boolean accept(File dir, String name) {
        //          return (name.endsWith("_plugin.properties"));
        //        }
        //      });
        String strPluginName = "";
        String strPluginClass = "";
        String strPluginImage = "";
        WDBearPlugin pluginPanel = null;
        for (int i = 0; i < strPlugins.length; i++) {
            //this.myLogger.info(strPlugins[i]);
            Properties prpPlugin = null;
            try {
                prpPlugin = ReadPropertiesFile.readProperties(
                        new File("plugins", strPlugins[i] + "/" + strPlugins[i]).getAbsolutePath()
                                + ".properties");
            } catch (Exception ex) {
                this.myLogger.error("Error with plugin: " + strPlugins[i]);
                this.myLogger.error("Could not load properties file");
                continue;
            }
            if ((strPluginClass = prpPlugin.getProperty(this.PLUGIN_CLASS)) == null) {
                this.myLogger.error("Error with plugin: " + strPlugins[i]);
                this.myLogger.error("Property '" + this.PLUGIN_CLASS + "' not found");
                continue;
            }
            if ((strPluginName = prpPlugin.getProperty(this.PLUGIN_NAME)) == null) {
                this.myLogger.error("Error with plugin: " + strPlugins[i]);
                this.myLogger.error("Property '" + this.PLUGIN_NAME + "' not found");
                continue;
            }
            if ((strPluginImage = prpPlugin.getProperty(this.PLUGIN_IMAGE)) == null) {
                this.myLogger.error("Error with plugin: " + strPlugins[i]);
                this.myLogger.error("Property '" + this.PLUGIN_IMAGE + "' not found");
                continue;
            }

            File filPlgImg = new File("plugins", strPlugins[i] + "/" + strPluginImage);
            panelIcon = createImageIcon(filPlgImg.getAbsolutePath());
            if (panelIcon == null) {
                this.myLogger.error("Error with plugin: " + strPlugins[i]);
                this.myLogger.error("Could not read image '" + strPluginImage + "'");
                continue;
            }
            try {
                pluginPanel = (WDBearPlugin) (cl.loadClass(strPluginClass).newInstance());
                pluginPanel.runPlugin(myAPI);
            } catch (Exception ex) {
                this.myLogger.error("Error with plugin: " + strPlugins[i]);
                this.myLogger.error("Could not instantiate '" + strPluginClass + "'");
                ex.printStackTrace();
                continue;
            }
            tabbedPane.addTab(strPluginName, panelIcon, pluginPanel, strPluginName);
        } // Plugins
    } // plugins folder found

    mainPanel.add(tabbedPane);

    this.getContentPane().add(mainPanel, BorderLayout.CENTER);

    this.setSize(1024, 768);
    //this.pack();
    this.show();

}

From source file:com.pironet.tda.TDA.java

/**
 * tries the native look and feel on mac and windows and metal on unix (gtk still
 * isn't looking that nice, even in 1.6)
 *//*  w  ww  .j  a  v a 2s. c om*/
private void setupLookAndFeel() {
    try {
        String plaf = "Mac,Windows,Metal";
        if (System.getProperty("os.name").startsWith("Linux")) {
            plaf = "GTK,Mac,Windows,Metal";
        }

        // this line needs to be implemented in order to make L&F work properly
        UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader());

        // query list of L&Fs
        UIManager.LookAndFeelInfo[] plafs = UIManager.getInstalledLookAndFeels();

        if (!Strings.isNullOrEmpty(plaf)) {

            String[] instPlafs = plaf.split(",");
            UIManager.LookAndFeelInfo currentLAFI = null;
            search: for (final String instPlaf : instPlafs) {
                for (final UIManager.LookAndFeelInfo plaf1 : plafs) {
                    currentLAFI = plaf1;
                    if (currentLAFI.getName().startsWith(instPlaf)) {
                        UIManager.setLookAndFeel(currentLAFI.getClassName());
                        // setup SANS_SERIF
                        setUIFont(new FontUIResource("SansSerif", Font.PLAIN, Const.FONT_SIZE));
                        break search;
                    }
                }
            }
        }

        if (plaf.startsWith("GTK")) {
            setFontSizeModifier(2);
        }
    } catch (Exception except) {
        setUIFont(new FontUIResource("SansSerif", Font.PLAIN, 12));
    }
}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

public static void main(String args[]) {

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                Color SELECTED_COLOR = new Color(184, 204, 217);
                Color BASE_COLOR = new Color(220, 231, 243, 50);
                Color ALT_COLOR = new Color(220, 231, 243, 115);

                //                    Insets MENU_INSETS = new Insets(1,12,2,5);//default values
                //                    Font MENU_FONT = new Font("SansSerif ", Font.PLAIN, 12);//default values

                //                    UIManager.put("nimbusBase", BASE_COLOR);
                UIManager.put("nimbusSelection", SELECTED_COLOR);
                UIManager.put("nimbusSelectionBackground", SELECTED_COLOR);
                UIManager.put("Menu[Enabled+Selected].backgroundPainter", SELECTED_COLOR);

                //override defaults
                for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                    if (info.getName().equals("Nimbus")) {
                        UIManager.setLookAndFeel(info.getClassName());
                        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
                        defaults.put("Table.gridColor", Color.lightGray);
                        defaults.put("Table.disabled", false);
                        defaults.put("Table.showGrid", true);
                        defaults.put("Table.intercellSpacing", new Dimension(1, 1));
                        break;
                    }//from  w w w .  j  a v  a  2  s  .  co  m
                }

                //                    UIManager.put("TitledBorder.position", TitledBorder.TOP);

                //                    UIManager.put("Table.showGrid", true);
                //                    UIManager.put("Table.gridColor", Color.RED);
                //                    UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
            } catch (UnsupportedLookAndFeelException ulafe) {
                //                    logger.fatal("Substance failed to set", ulafe);
            } catch (Exception ex) {
                //                    logger.fatal(ex.getMessage(), ex);
            }

            JFrame frame = new Jmetrik();

            //            set window to maximum size but account for taskbar
            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Rectangle rect = env.getMaximumWindowBounds();
            int width = Double.valueOf(rect.getWidth() - 1.0).intValue();
            int height = Double.valueOf(rect.getHeight() - 1.0).intValue();
            frame.setMaximizedBounds(new Rectangle(0, 0, width, height));
            frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            frame.pack();
            //            frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            frame.setVisible(true);

            //check for updates to jmetrik
            ((Jmetrik) frame).checkForUpdates();
        }
    });

}