Example usage for javax.swing UIManager getSystemLookAndFeelClassName

List of usage examples for javax.swing UIManager getSystemLookAndFeelClassName

Introduction

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

Prototype

public static String getSystemLookAndFeelClassName() 

Source Link

Document

Returns the name of the LookAndFeel class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel class.

Usage

From source file:edu.gmu.isa681.client.Main.java

public static void main(String[] args) {
    log.info("Setting look and feel...");

    try {/*from www  .ja  v a  2s .c o  m*/
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }

    } catch (Exception ex1) {
        log.warn(ex1.getMessage(), ex1);
        log.warn("Nimbus is not available.");
        log.warn("Switching to system look and feel");
        log.warn("Some GUI discrepancies may occur!");

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex2) {
            log.error(ex2.getMessage(), ex2);
            log.error("Could not setup a look and feel.");
            System.exit(1);
        }
    }

    log.info("Initializing GUI...");

    final JFrame frame = new JFrame();
    frame.setTitle("GoForward");
    frame.setBackground(new Color(0, 100, 0));
    UIManager.put("nimbusBase", new Color(0, 100, 0));
    //UIManager.put("nimbusBlueGrey", new Color(0, 100, 0));
    UIManager.put("control", new Color(0, 100, 0));

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            frame.setPreferredSize(frame.getSize());
        }
    });

    Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    if (dim.width < 1366) {
        frame.setPreferredSize(new Dimension(800, 600));
    } else {
        frame.setPreferredSize(new Dimension(1200, 700));
    }

    //frame.setResizable(false);
    frame.setLocationByPlatform(true);
    frame.pack();

    Client client = new Client("localhost", Constants.SERVER_PORT);
    Controller controller = new Controller(client, frame);
    controller.applicationStarted();

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    log.info("Started");
}

From source file:aurelienribon.gdxsetupui.ui.Main.java

public static void main(String[] args) {
    parseArgs(args);/*from  w w w .j  a v  a2 s. c  o m*/

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException ex) {
            } catch (InstantiationException ex) {
            } catch (IllegalAccessException ex) {
            } catch (UnsupportedLookAndFeelException ex) {
            }

            SwingStyle.init();
            ArStyle.init();

            JFrame frame = new JFrame("LibGDX Project Setup (gdx-setup-ui)");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(new MainPanel());
            frame.setSize(1100, 600);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
}

From source file:appmain.AppMain.java

public static void main(String[] args) {

    try {// ww  w.  j  av a  2 s  .  c o m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.put("OptionPane.yesButtonText", "Igen");
        UIManager.put("OptionPane.noButtonText", "Nem");
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    try {

        AppMain app = new AppMain();
        app.init();

        File importFolder = new File(DEFAULT_IMPORT_FOLDER);
        if (!importFolder.isDirectory() || !importFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    "Az IMPORT mappa nem elrhet!\n"
                            + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: "
                            + importFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        File exportFolder = new File(DEFAULT_EXPORT_FOLDER);
        if (!exportFolder.isDirectory() || !exportFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    "Az EXPORT mappa nem elrhet!\n"
                            + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: "
                            + exportFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        List<File> xmlFiles = app.getXMLFiles(importFolder);
        if (xmlFiles == null || xmlFiles.isEmpty()) {
            JOptionPane.showMessageDialog(null,
                    "Nincs beolvasand XML fjl!\n" + "Mappa: " + importFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        StringBuilder fileList = new StringBuilder();
        xmlFiles.stream().forEach(xml -> fileList.append("\n").append(xml.getName()));
        int ret = JOptionPane.showConfirmDialog(null,
                "Beolvassra elksztett fjlok:\n" + fileList + "\n\nIndulhat a feldolgozs?",
                "Megtallt XML fjlok", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        if (ret == JOptionPane.OK_OPTION) {
            String csvName = "tranzakcio_lista_" + df.format(new Date()) + "_" + System.currentTimeMillis()
                    + ".csv";
            File csv = new File(DEFAULT_EXPORT_FOLDER + "/" + csvName);
            app.writeCSV(csv, Arrays.asList(app.getHeaderLine()));
            xmlFiles.stream().forEach(xml -> {
                List<String> lines = app.readXMLData(xml);
                if (lines != null)
                    app.writeCSV(csv, lines);
            });
            if (csv.isFile() && csv.exists()) {
                JOptionPane.showMessageDialog(null,
                        "A CSV fjl sikeresen elllt!\n" + "Fjl: " + csv.getAbsolutePath(),
                        "Informci", JOptionPane.INFORMATION_MESSAGE);
                app.openFile(csv);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Feldolgozs megszaktva!", "Informci",
                    JOptionPane.INFORMATION_MESSAGE);
        }

    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Nem kezelt kivtel!\n" + ExceptionUtils.getStackTrace(ex), "Hiba",
                JOptionPane.ERROR_MESSAGE);
    }

}

From source file:LookAndFeel.java

public static void main(String[] args) {
    if (args.length == 0)
        usageError();/*  w  w w  .  ja v  a 2  s  .co m*/
    if (args[0].equals("cross")) {
        try {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (args[0].equals("system")) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (args[0].equals("motif")) {
        try {
            UIManager.setLookAndFeel("com.sun.java." + "swing.plaf.motif.MotifLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else
        usageError();
    // Note the look & feel must be set before
    // any components are created.
    run(new LookAndFeel(), 300, 200);
}

From source file:de.ep3.ftpc.App.java

public static void main(String[] args) {
    try {//from  w  ww  . j  a va2  s.  c o  m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    Controller e = getContext().getBean("exceptionController", Controller.class);

    e.dispatch();

    Controller c = getContext().getBean("portalFrameController", Controller.class);

    c.dispatch();
}

From source file:inc.cygnus.app.MainSpring.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                // Implementasi Konfigurasi Spring framework
                @SuppressWarnings("resource")
                ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");

                // Initialize service
                setCustomerService((CustomerService) appContext.getBean("customerService"));
                setProductService((ProductService) appContext.getBean("productService"));
                setPurchaseService((PurchaseService) appContext.getBean("purchaseService"));

                try {
                    // After finish service initialize
                    // Show Form Menu Master
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                } catch (InstantiationException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex);
                }/* w  w w  .  j ava 2 s . com*/
                Menu mmv = new Menu();

                mmv.setVisible(true);

            } catch (BeansException e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:de.dakror.jagui.parser.NGuiParser.java

public static void main(String[] args) {
    try {//from   w w  w  .j  a v  a 2 s.  co m
        DIR.mkdirs();
        if (!new File(DIR, "convert.exe").exists())
            Helper.copyInputStream(NGuiParser.class.getResourceAsStream("/res/convert.exe"),
                    new FileOutputStream(new File(DIR, "convert.exe")));

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        JFileChooser jfc = new JFileChooser(
                new File(NGuiParser.class.getProtectionDomain().getCodeSource().getLocation().toURI()));
        jfc.setMultiSelectionEnabled(false);
        jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        jfc.setFileFilter(new FileNameExtensionFilter("Unity ngui Gui-Skin (*.guiskin)", "guiskin"));

        if (jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            p("Collecting GUIDs, Converting Resources");
            HashMap<String, File> guids = collectGUIDs(jfc.getCurrentDirectory());

            p("Parsing Guiskin file");
            String s = Helper.getFileContent(jfc.getSelectedFile());
            String[] lines = s.split("\n");
            ArrayList<String> l = new ArrayList<>(Arrays.asList(lines));
            String string = "";
            for (int i = 0; i < l.size(); i++)
                if (!l.get(i).startsWith("%") && !l.get(i).startsWith("---"))
                    string += l.get(i) + "\n";

            Yaml yaml = new Yaml();
            for (Iterator<Object> iter = yaml.loadAll(string).iterator(); iter.hasNext();) {
                JSONObject o = new JSONObject((Map<?, ?>) iter.next());
                p("Cconverting Guiskin");
                replaceGuidDeep(o, guids, jfc.getSelectedFile());
                p("Writing converted file");
                Helper.setFileContent(new File(jfc.getSelectedFile().getParentFile(),
                        jfc.getSelectedFile().getName() + ".json"), o.toString(4));
                p("DONE");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:aurelienribon.texturepackergui.Main.java

public static void main(String[] args) {
    Parameters params = new Parameters(args);
    Project project = params.project;//  ww w . j  a v  a 2s  .c o m

    if (project == null) {
        String str = "";
        str += "input=" + params.input + "\n";
        str += "output=" + params.output + "\n";
        str += params.settings;
        project = Project.fromString(str);
    }

    if (params.silent) {
        if (project.input.equals("") || project.output.equals("")) {
            System.err.println("Input and output directories have to be set");
        } else {
            try {
                project.pack();
            } catch (GdxRuntimeException ex) {
                System.err.println("Packing unsuccessful. " + ex.getMessage());
            }
        }
        return;
    }

    final Project prj = project;
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException ex) {
            } catch (InstantiationException ex) {
            } catch (IllegalAccessException ex) {
            } catch (UnsupportedLookAndFeelException ex) {
            }

            Canvas canvas = new Canvas();
            LwjglCanvas glCanvas = new LwjglCanvas(canvas, true);

            MainWindow mw = new MainWindow(prj, canvas, glCanvas.getCanvas());
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            mw.setSize(Math.min(1100, screenSize.width - 100), Math.min(670, screenSize.height - 100));
            mw.setLocationRelativeTo(null);
            mw.setVisible(true);
        }
    });
}

From source file:br.usp.poli.lta.cereda.wsn2spa.Main.java

public static void main(String[] args) {

    Utils.printBanner();/*w ww.ja v a 2 s .  com*/
    CommandLineParser parser = new DefaultParser();

    try {

        CommandLine line = parser.parse(Utils.getOptions(), args);

        if (line.hasOption("g")) {
            System.out.println("Flag '-g' found, overriding other flags.");
            System.out.println("Please, wait...");
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (Exception nothandled) {
            }
            SwingUtilities.invokeLater(() -> {
                Editor e = new Editor();
                e.setVisible(true);
            });
        } else {
            enableCLI(line);
        }
    } catch (ParseException nothandled) {
        Utils.printHelp();
    } catch (Exception exception) {
        Utils.printException(exception);
    }
}

From source file:havocx42.Program.java

public static void main(String[] args) throws ParseException {
    try {/*from w  w  w.j a v  a 2  s . c o m*/
        initRootLogger();
    } catch (SecurityException | IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        return;
    }
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e1) {
        LOGGER.log(Level.WARNING, "Unable to set Look and Feel", e1);
    }

    Options options = new Options();
    options.addOption("nogui", false,
            "run as a command line tool, must also supply -target and -source arguments");
    options.addOption("source", true, "source directory where the PR weapons folder has been extracted");
    options.addOption("target", true, "target file to write to");
    options.addOption("version", false, "print the version information and exit");
    options.addOption("help", false, "print this message");
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("version")) {
        System.out.println("PRStats " + VERSION);
        System.out.println("Written by havocx42");
        return;
    }

    if ((cmd.hasOption("nogui") && (!cmd.hasOption("source") || !cmd.hasOption("target")))
            || cmd.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("PRStats", options);
        return;
    }

    final String target;
    final String source;

    source = cmd.getOptionValue("source");
    target = cmd.getOptionValue("target");
    LOGGER.info("Source Argument: " + source);
    LOGGER.info("Target Argument: " + target);

    if (!cmd.hasOption("nogui")) {
        EventQueue.invokeLater(new Runnable() {
            @SuppressWarnings("unused")
            public void run() {
                try {
                    Gui window = new Gui(source, target);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        return;
    }

    File targetFile = new File(target);
    File sourceFile = new File(source);
    Controller controller = new Controller();
    controller.run(sourceFile, targetFile);

}