List of usage examples for javax.swing UIManager getCrossPlatformLookAndFeelClassName
public static String getCrossPlatformLookAndFeelClassName()
LookAndFeel
class that implements the default cross platform look and feel -- the Java Look and Feel (JLF). From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
@SuppressWarnings("unchecked") protected void changeLookAndFeel() { final JDialog dialog = new JDialog(mainFrame, "Design ndern"); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); Collection<TwoObjectsX<String, String>> lookAndFeels = FunctionsX.asList( new TwoObjectsX<String, String>("Metal", UIManager.getCrossPlatformLookAndFeelClassName()), new TwoObjectsX<String, String>("Betriebssystem Standard", UIManager.getSystemLookAndFeelClassName()), new TwoObjectsX<String, String>("Nimbus", NimbusLookAndFeel.class.getName())); dialog.setLayout(new GridLayout(0, 1)); ButtonGroup b = new ButtonGroup(); for (final TwoObjectsX<String, String> lookAndFeel : lookAndFeels) { JRadioButton rb = new JRadioButton(lookAndFeel.getObjectA()); if (iliasProperties.getLookAndFeel().equals(lookAndFeel.getObjectB())) { rb.setSelected(true);/*from w ww.j a va 2 s . co m*/ } rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { UIManager.setLookAndFeel(lookAndFeel.getObjectB()); iliasProperties.setLookAndFeel(lookAndFeel.getObjectB()); saveProperties(iliasProperties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { showError("Fehler beim ndern des Designs", e1); } SwingUtilities.updateComponentTreeUI(mainFrame); SwingUtilities.updateComponentTreeUI(dialog); } }); b.add(rb); dialog.add(rb); } dialog.pack(); dialog.setLocationRelativeTo(mainFrame); dialog.setVisible(true); }
From source file:ffx.ui.MainPanel.java
/** * <p>//from www . j a va 2 s .co m * oceanLookAndFeel</p> */ public void oceanLookAndFeel() { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this)); } catch (Exception e) { return; } }
From source file:jeplus.JEPlusFrameMain.java
private void jMenuItemDefaultLaFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemDefaultLaFActionPerformed try {/*from ww w . ja va 2 s . c o m*/ switch (jMenuItemDefaultLaF.getActionCommand()) { case "default": UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.put("swing.boldMetal", Boolean.FALSE); SwingUtilities.updateComponentTreeUI(this); jMenuItemDefaultLaF.setActionCommand("platform"); jMenuItemDefaultLaF.setText("Switch to system Look and Feel (OS)"); this.pack(); break; case "platform": UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(this); jMenuItemDefaultLaF.setActionCommand("default"); jMenuItemDefaultLaF.setText("Switch to defaul Look and Feel (Metal)"); this.pack(); break; } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { logger.error("Error setting Look-and-Feel.", ex); } }
From source file:library.Form_Library.java
License:asdf
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed try {//ww w.j a va 2 s. c o m // Set cross-platform Java L&F (also called "Metal") UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (UnsupportedLookAndFeelException e) { // handle exception } catch (ClassNotFoundException e) { // handle exception } catch (InstantiationException e) { // handle exception } catch (IllegalAccessException e) { // handle exception } }
From source file:op.OPDE.java
/** * Hier ist die main Methode von OPDE. In dieser Methode wird auch festgestellt, wie OPDE gestartet wurde. * <ul>//from ww w . ja v a 2s .c om * <li>Im Standard Modus, das heisst mit graphischer Oberflche. Das drfte der hufigste Fall sein.</li> * <li>Im DFNImport Modus. Der wird meist auf dem Datenbankserver gebraucht um Nachts die Durchfhrungsnachweise anhand der * DFNImport Tabelle zu generieren. Das alles gehrt zu der Pflegeplanung.</li> * <li>Im BHPImport Modus. Auch dieser Modus wird auf dem DB-Server gebraucht um die Behandlungspflege Massnahmen * anhand der rztlichen Verordnungen zu generieren.</li> * </ul> * * @param args Hier stehen die Kommandozeilen Parameter. Diese werden mit */ public static void main(String[] args) throws Exception { /*** * * ____ * ,' , `. * ,-+-,.' _ | ,--, * ,-+-. ; , || ,--.'| ,---, * ,--.'|' | ;| | |, ,-+-. / | * | | ,', | ': ,--.--. `--'_ ,--.'|' | * | | / | | || / \ ,' ,'| | | ,"' | * ' | : | : |,.--. .-. | ' | | | | / | | * ; . | ; |--' \__\/: . . | | : | | | | | * | : | | , ," .--.; | ' : |__ | | | |/ * | : ' |/ / / ,. | | | '.'|| | |--' * ; | |`-' ; : .' \; : ;| |/ * | ;/ | , .-./| , / '---' * '---' `--`---' ---`-' * */ uptime = SYSCalendar.now(); // arial14 = new Font("Arial", Font.PLAIN, 14); // arial28 = new Font("Arial", Font.PLAIN, 28); /*** * _ ____ _ _ * | | __ _ _ __ __ _ _ _ __ _ __ _ ___ | __ ) _ _ _ __ __| | | ___ * | | / _` | '_ \ / _` | | | |/ _` |/ _` |/ _ \ | _ \| | | | '_ \ / _` | |/ _ \ * | |__| (_| | | | | (_| | |_| | (_| | (_| | __/ | |_) | |_| | | | | (_| | | __/ * |_____\__,_|_| |_|\__, |\__,_|\__,_|\__, |\___| |____/ \__,_|_| |_|\__,_|_|\___| * |___/ |___/ */ lang = ResourceBundle.getBundle("languageBundle", Locale.getDefault()); validatorFactory = Validation.buildDefaultValidatorFactory(); /*** * ____ _ _ _ _ _ _ * / ___|__ _| |_ ___| |__ __ _| | | _ __ ___ __ _ _ _ ___ _____ _____ ___ _ __ | |_(_) ___ _ __ ___ * | | / _` | __/ __| '_ \ / _` | | | | '__/ _ \ / _` | | | |/ _ \ / _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __| * | |__| (_| | || (__| | | | | (_| | | | | | | (_) | (_| | |_| | __/ | __/> < (_| __/ |_) | |_| | (_) | | | \__ \ * \____\__,_|\__\___|_| |_| \__,_|_|_| |_| \___/ \__, |\__,_|\___| \___/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/ * |___/ |_| */ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { OPDE.fatal(e); } }); localProps = new SortedProperties(); props = new Properties(); /*** * _ _ ___ __ * _ __ ___ __ _ __| | / \ _ __ _ __|_ _|_ __ / _| ___ * | '__/ _ \/ _` |/ _` | / _ \ | '_ \| '_ \| || '_ \| |_ / _ \ * | | | __/ (_| | (_| | / ___ \| |_) | |_) | || | | | _| (_) | * |_| \___|\__,_|\__,_| /_/ \_\ .__/| .__/___|_| |_|_| \___/ * |_| |_| */ appInfo = new AppInfo(); /*** * ____ _ _ _ ___ _ _ * / ___|___ _ __ ___ _ __ ___ __ _ _ __ __| | | | (_)_ __ ___ / _ \ _ __ | |_(_) ___ _ __ ___ * | | / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` | | | | | '_ \ / _ \ | | | | '_ \| __| |/ _ \| '_ \/ __| * | |__| (_) | | | | | | | | | | | (_| | | | | (_| | | |___| | | | | __/ | |_| | |_) | |_| | (_) | | | \__ \ * \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_| |_____|_|_| |_|\___| \___/| .__/ \__|_|\___/|_| |_|___/ * |_| */ Options opts = new Options(); opts.addOption("h", "hilfe", false, "Gibt die Hilfeseite fr OPDE aus."); opts.addOption("v", "version", false, "Zeigt die Versionsinformationen an."); opts.addOption("x", "experimental", false, "Schaltet experimentelle Programm-Module fr User frei, die Admin Rechte haben. VORSICHT !!!!"); opts.addOption("a", "anonym", false, "Blendet die Bewohnernamen in allen Ansichten aus. Spezieller Modus fr Schulungsmaterial zu erstellen."); opts.addOption("w", "workingdir", true, "Damit kannst Du ein anderes Arbeitsverzeichnis setzen. Wenn Du diese Option weglsst, dann ist das Dein Benutzerverzeichnis: " + System.getProperty("user.home")); opts.addOption("l", "debug", false, "Schaltet alle Ausgaben ein auf der Konsole ein, auch die, die eigentlich nur whrend der Softwareentwicklung angezeigt werden."); opts.addOption("t", "training", false, "Wird fr Einarbeitungsversionen bentigt. Frbt die Oberflche anders ein und zeigt eine Warnmeldung nach jeder Anmeldung."); Option optFTPserver = OptionBuilder.withLongOpt("ftpserver").withArgName("ip or hostname").hasArgs(1) .withDescription(lang.getString("cmdline.ftpserver")).create("f"); opts.addOption(optFTPserver); // opts.addOption("p", "pidfile", false, "Path to the pidfile which needs to be deleted when this application ends properly."); Option notification = OptionBuilder.withLongOpt("notification").hasOptionalArg() .withDescription("Schickt allen festgelegten Empfngern die jeweilige Benachrichtungs-Mail.") .create("n"); notification.setArgName( "Liste der Empfnger (durch Komma getrennt, ohne Leerzeichen. UID verwenden). Damit kannst Du die Benachrichtigungen einschrnken. Fehlt diese Liste, erhalten ALLE Empfnger eine Mail."); opts.addOption(notification); opts.addOption(OptionBuilder.withLongOpt("jdbc").hasArg().withDescription(lang.getString("cmdline.jdbc")) .create("j")); Option dfnimport = OptionBuilder //.withArgName("datum") .withLongOpt("dfnimport").hasOptionalArg() .withDescription("Startet OPDE im DFNImport Modus fr den aktuellen Tag.").create("d"); dfnimport.setArgName( "Anzahl der Tage (+ oder -) abweichend vom aktuellen Tag fr den der Import durchgefhrt werden soll. Nur in Ausnahmefllen anzuwenden."); opts.addOption(dfnimport); Option bhpimport = OptionBuilder.withLongOpt("bhpimport").hasOptionalArg() .withDescription("Startet OPDE im BHPImport Modus fr den aktuellen Tag.").create("b"); // bhpimport.setOptionalArg(true); bhpimport.setArgName( "Anzahl der Tage (+ oder -) abweichend vom aktuellen Tag fr den der Import durchgefhrt werden soll. Nur in Ausnahmefllen anzuwenden."); opts.addOption(bhpimport); BasicParser parser = new BasicParser(); CommandLine cl = null; String footer = "http://www.Offene-Pflege.de"; /*** * _ _ * | |__ ___| |_ __ ___ ___ _ __ ___ ___ _ __ * | '_ \ / _ \ | '_ \ / __|/ __| '__/ _ \/ _ \ '_ \ * | | | | __/ | |_) | \__ \ (__| | | __/ __/ | | | * |_| |_|\___|_| .__/ |___/\___|_| \___|\___|_| |_| * |_| */ try { cl = parser.parse(opts, args); } catch (ParseException ex) { HelpFormatter f = new HelpFormatter(); f.printHelp("OffenePflege.jar [OPTION]", "Offene-Pflege.de, Version " + appInfo.getVersion() + " Build:" + appInfo.getBuildnum(), opts, footer); System.exit(0); } // Alternative FTP-Server if (cl.hasOption("f")) { UPDATE_FTPSERVER = cl.getOptionValue("f"); } if (cl.hasOption("h")) { HelpFormatter f = new HelpFormatter(); f.printHelp("OffenePflege.jar [OPTION]", "Offene-Pflege.de, Version " + appInfo.getVersion() + " Build:" + appInfo.getBuildnum(), opts, footer); System.exit(0); } String homedir = System.getProperty("user.home"); // alternatice working dir if (cl.hasOption("w")) { File dir = new File(cl.getOptionValue("w")); if (dir.exists() && dir.isDirectory()) { homedir = dir.getAbsolutePath(); } } opwd = homedir + sep + AppInfo.dirBase; /*** * ___ * __ _ _ __ ___ _ __ _ _ _ __ ___ ___ _ _ ___ |__ \ * / _` | '_ \ / _ \| '_ \| | | | '_ ` _ \ / _ \| | | / __| / / * | (_| | | | | (_) | | | | |_| | | | | | | (_) | |_| \__ \ |_| * \__,_|_| |_|\___/|_| |_|\__, |_| |_| |_|\___/ \__,_|___/ (_) * |___/ */ if (cl.hasOption("a")) { // anonym Modus //localProps.put("anonym", "true"); anonym = true; anonymize = new HashMap[] { SYSConst.getNachnamenAnonym(), SYSConst.getVornamenFrauAnonym(), SYSConst.getVornamenMannAnonym() }; } else { anonym = false; } /*** * _ _ _ _ _ * (_)_ __ (_) |_ _ __ _ __(_)_ __ | |_ ___ _ __ ___ * | | '_ \| | __| | '_ \| '__| | '_ \| __/ _ \ '__/ __| * | | | | | | |_ | |_) | | | | | | | || __/ | \__ \ * |_|_| |_|_|\__| | .__/|_| |_|_| |_|\__\___|_| |___/ * |_| */ printers = new LogicalPrinters(); /*** * _ _ _ _ _ _ * | | ___ __ _ __| | | | ___ ___ __ _| | _ __ _ __ ___ _ __ ___ _ __| |_(_) ___ ___ * | |/ _ \ / _` |/ _` | | |/ _ \ / __/ _` | | | '_ \| '__/ _ \| '_ \ / _ \ '__| __| |/ _ \/ __| * | | (_) | (_| | (_| | | | (_) | (_| (_| | | | |_) | | | (_) | |_) | __/ | | |_| | __/\__ \ * |_|\___/ \__,_|\__,_| |_|\___/ \___\__,_|_| | .__/|_| \___/| .__/ \___|_| \__|_|\___||___/ * |_| |_| */ if (loadLocalProperties()) { // try { // FileAppender fileAppender = new FileAppender(layout, , true); // logger.addAppender(fileAppender); // } catch (IOException ex) { // fatal(ex); // } animation = localProps.containsKey("animation") && localProps.getProperty("animation").equals("true"); logger.info("######### START ########### " + OPDE.getAppInfo().getProgname() + ", v" + OPDE.getAppInfo().getVersion() + "/" + OPDE.getAppInfo().getBuildnum()); logger.info(System.getProperty("os.name").toLowerCase()); /*** * _ ____ _ ___ ___ * (_)___| _ \ ___| |__ _ _ __ _ |__ \__ \ * | / __| | | |/ _ \ '_ \| | | |/ _` | / / / / * | \__ \ |_| | __/ |_) | |_| | (_| | |_| |_| * |_|___/____/ \___|_.__/ \__,_|\__, | (_) (_) * |___/ */ if (cl.hasOption("l") || SYSTools.catchNull(localProps.getProperty("debug")).equalsIgnoreCase("true")) { debug = true; logger.setLevel(Level.DEBUG); } else { debug = false; logger.setLevel(Level.INFO); } Logger.getLogger("org.hibernate").setLevel(Level.OFF); if (cl.hasOption("x") || SYSTools.catchNull(localProps.getProperty("experimental")).equalsIgnoreCase("true")) { experimental = true; } else { experimental = false; } if (cl.hasOption("t") || SYSTools.catchNull(localProps.getProperty("training")).equalsIgnoreCase("true")) { training = true; } else { training = false; } /*** * _ _ _ _ _ _ _ ___ * __| | |____ _____ _ __ ___(_) ___ _ __ ___ ___ _ __ ___ _ __ __ _| |_(_) |__ | | ___ |__ \ * / _` | '_ \ \ / / _ \ '__/ __| |/ _ \| '_ \ / __/ _ \| '_ ` _ \| '_ \ / _` | __| | '_ \| |/ _ \ / / * | (_| | |_) \ V / __/ | \__ \ | (_) | | | | | (_| (_) | | | | | | |_) | (_| | |_| | |_) | | __/ |_| * \__,_|_.__/ \_/ \___|_| |___/_|\___/|_| |_| \___\___/|_| |_| |_| .__/ \__,_|\__|_|_.__/|_|\___| (_) * |_| */ url = cl.hasOption("j") ? cl.getOptionValue("j") : localProps.getProperty("javax.persistence.jdbc.url"); String hostkey = OPDE.getLocalProps().getProperty("hostkey"); String cryptpassword = localProps.getProperty("javax.persistence.jdbc.password"); DesEncrypter desEncrypter = new DesEncrypter(hostkey); Connection jdbcConnection = DriverManager.getConnection(url, localProps.getProperty("javax.persistence.jdbc.user"), desEncrypter.decrypt(cryptpassword)); if (appInfo.getDbversion() != getDBVersion(jdbcConnection)) { SYSFilesTools.print(lang.getString("cant.start.with.version.mismatch"), false); System.exit(1); } jdbcConnection.close(); /*** * _ ____ _ ____ _ _ * | | _ \ / \ | _ \ __ _| |_ __ _| |__ __ _ ___ ___ * _ | | |_) / _ \ | | | |/ _` | __/ _` | '_ \ / _` / __|/ _ \ * | |_| | __/ ___ \ | |_| | (_| | || (_| | |_) | (_| \__ \ __/ * \___/|_| /_/ \_\ |____/ \__,_|\__\__,_|_.__/ \__,_|___/\___| * */ Properties jpaProps = new Properties(); jpaProps.put("javax.persistence.jdbc.user", localProps.getProperty("javax.persistence.jdbc.user")); try { jpaProps.put("javax.persistence.jdbc.password", desEncrypter.decrypt(cryptpassword)); } catch (Exception e) { if (Desktop.isDesktopSupported()) { JOptionPane.showMessageDialog(null, SYSTools.xx("misc.msg.decryption.failure"), appInfo.getProgname(), JOptionPane.ERROR_MESSAGE); } else { OPDE.fatal(e); } System.exit(1); } jpaProps.put("javax.persistence.jdbc.driver", localProps.getProperty("javax.persistence.jdbc.driver")); jpaProps.put("javax.persistence.jdbc.url", url); // if (cl.hasOption("d") || cl.hasOption("d")) { // not for BHP or DFN // jpaProps.put("eclipselink.cache.shared.default", "false"); // } else { // jpaProps.put("eclipselink.cache.shared.default", "true"); // } jpaProps.put("eclipselink.cache.shared.default", "false"); jpaProps.put("eclipselink.session.customizer", "entity.JPAEclipseLinkSessionCustomizer"); emf = Persistence.createEntityManagerFactory("OPDEPU", jpaProps); /*** * __ __ _ * \ \ / /__ _ __ ___(_) ___ _ __ * \ \ / / _ \ '__/ __| |/ _ \| '_ \ * \ V / __/ | \__ \ | (_) | | | | * \_/ \___|_| |___/_|\___/|_| |_| * */ String header = SYSTools.getWindowTitle(""); if (cl.hasOption("v")) { System.out.println(header); System.out.println(footer); System.exit(0); } /*** * ____ _ ____ _____ _ _ * / ___| ___ _ __ ___ _ __ __ _| |_ ___ | _ \| ___| \ | |___ * | | _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \ | | | | |_ | \| / __| * | |_| | __/ | | | __/ | | (_| | || __/ | |_| | _| | |\ \__ \ * \____|\___|_| |_|\___|_| \__,_|\__\___| |____/|_| |_| \_|___/ * */ if (cl.hasOption("d")) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users rootUser = em.find(Users.class, "admin"); SYSLogin rootLogin = em.merge(new SYSLogin(rootUser)); OPDE.setLogin(rootLogin); initProps(); // create the new DFNs DFNTools.generate(em); // move over the floating ones that have not yet been clicked to the current day DFNTools.moveFloating(em); em.getTransaction().commit(); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } fatal(ex); } finally { em.close(); } System.exit(0); } /*** * ____ _ ____ _ _ ____ * / ___| ___ _ __ ___ _ __ __ _| |_ ___ | __ )| | | | _ \ ___ * | | _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \ | _ \| |_| | |_) / __| * | |_| | __/ | | | __/ | | (_| | || __/ | |_) | _ | __/\__ \ * \____|\___|_| |_|\___|_| \__,_|\__\___| |____/|_| |_|_| |___/ * */ if (cl.hasOption("b")) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users rootUser = em.find(Users.class, "admin"); SYSLogin rootLogin = em.merge(new SYSLogin(rootUser)); OPDE.setLogin(rootLogin); initProps(); BHPTools.generate(em); em.getTransaction().commit(); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } fatal(ex); } finally { em.close(); } System.exit(0); } /*** * _ _ _ _ __ _ _ _ * | \ | | ___ | |_(_)/ _(_) ___ __ _| |_(_) ___ _ __ * | \| |/ _ \| __| | |_| |/ __/ _` | __| |/ _ \| '_ \ * | |\ | (_) | |_| | _| | (_| (_| | |_| | (_) | | | | * |_| \_|\___/ \__|_|_| |_|\___\__,_|\__|_|\___/|_| |_| * */ if (cl.hasOption("n")) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users rootUser = em.find(Users.class, "admin"); SYSLogin rootLogin = em.merge(new SYSLogin(rootUser)); OPDE.setLogin(rootLogin); initProps(); EMailSystem.notify(cl.getOptionValue("n")); em.getTransaction().commit(); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } fatal(ex); } finally { em.close(); } System.exit(0); } // to speed things later. The first connection loads the while JPA system. EntityManager em1 = createEM(); em1.close(); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); setStandardFont(); try { css = SYSTools.readFileAsString(opwd + sep + AppInfo.dirTemplates + sep + AppInfo.fileStandardCSS); } catch (IOException ie) { css = ""; } // JideSoft Lm.verifyLicense("Torsten Loehr", "Open-Pflege.de", "G9F4JW:Bm44t62pqLzp5woAD4OCSUAr2"); WizardStyle.setStyle(WizardStyle.JAVA_STYLE); // JideSoft /*** * _____ __ __ _ ____ * | ___| __ _ __ ___ | \/ | __ _(_)_ __ / /\ \ * | |_ | '__| '_ ` _ \| |\/| |/ _` | | '_ \| | | | * | _|| | | | | | | | | | | (_| | | | | | | | | * |_| |_| |_| |_| |_|_| |_|\__,_|_|_| |_| | | | * \_\/_/ */ // JFrame frm = new JFrame(); // frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // frm.setLayout(new FlowLayout()); // // frm.getContentPane().add(new PnlBodyScheme(new Properties())); // // frm.setVisible(true); SYSTools.checkForSoftwareupdates(); mainframe = new FrmMain(); mainframe.setVisible(true); } }
From source file:org.eclipse.wb.internal.swing.laf.model.UndefinedLafInfo.java
/** * Try to find which LAF used as "undefined", i.e. when no LAF explicitly specified in main. *//*from www.j a va 2 s .c o m*/ private static synchronized String getClassName0() { // 1. Try to get system LAF class name from "swing.systemlaf" property name // in $(java.home)/lib/swing.properties file. if (m_swingProperties == null) { String javaHome = System.getProperty("java.home"); if (javaHome != null) { String propertiesFileName = javaHome + File.separator + "lib" + File.separator + "swing.properties"; m_swingProperties = new Properties(); File file = new File(propertiesFileName); if (file.exists()) { try { FileInputStream inputStream = new FileInputStream(file); try { m_swingProperties.load(inputStream); } finally { IOUtils.closeQuietly(inputStream); } } catch (Throwable e) { // Just ignore any exceptions. } } } } // 2. If no LAF defined in "swing.systemlaf" use cross-platform LAF like UIManager does. String systemLAFClassName = m_swingProperties.getProperty("swing.systemlaf"); if (systemLAFClassName == null) { systemLAFClassName = UIManager.getCrossPlatformLookAndFeelClassName(); } return systemLAFClassName; }
From source file:org.eclipse.wb.tests.designer.swing.model.property.FontPropertyEditorTest.java
@Override protected void setUp() throws Exception { super.setUp(); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); }
From source file:org.executequery.util.LookAndFeelLoader.java
public void loadCrossPlatformLookAndFeel() { try {//from w w w. j a va2 s . com UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { throw new ApplicationException(e); } }
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
/** * Sets the L&F to://from w w w .ja va2s. c o m * The default cross-platform look and feel if the passed string is (case-insensitive) "Default", * The system look and feel if the passed string is (case-insensitive) "System", * The first look and feel found containing (case-insensitive) the string in its name (e.g. "Nimbus"), if any. * If the L&F specified is the current L&F, nothing will be done. * @param lookAndFeel */ public void setLookAndFeel(String lookAndFeel) { boolean changed = false; try { if ("default".equals(lookAndFeel.toLowerCase()) && !UIManager.getLookAndFeel().getClass().getName() .equals(UIManager.getCrossPlatformLookAndFeelClassName())) { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); changed = true; } else if ("system".equals(lookAndFeel.toLowerCase()) && !UIManager.getLookAndFeel().getClass() .getName().equals(UIManager.getSystemLookAndFeelClassName())) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); changed = true; } else { LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for (int i = 0; i < lfs.length; i++) { if (lfs[i].getName().toLowerCase().contains(lookAndFeel.toLowerCase()) && !UIManager .getLookAndFeel().getName().toLowerCase().contains(lookAndFeel.toLowerCase())) { UIManager.setLookAndFeel(lfs[i].getClassName()); changed = true; break; } } } } catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen) { e.printStackTrace(); } if (changed) { SwingUtilities.updateComponentTreeUI(this); PuckConfiguration.getInstance().setProperty("look", lookAndFeel); } }
From source file:org.gcaldaemon.gui.ConfigEditor.java
private ConfigEditor(MainConfig config, ProgressMonitor monitor) throws Exception { this.config = config; try {/* w ww . j a v a2 s . c o m*/ // Init swing System.setProperty("sun.awt.noerasebackground", "false"); //$NON-NLS-1$ //$NON-NLS-2$ System.setProperty("swing.aatext", "true"); //$NON-NLS-1$ //$NON-NLS-2$ System.setProperty("swing.boldMetal", "false"); //$NON-NLS-1$ //$NON-NLS-2$ Locale locale = Locale.getDefault(); String code = null; try { code = config.getConfigProperty(Configurator.EDITOR_LANGUAGE, null); if (code != null) { locale = new Locale(code); } } catch (Exception invalidLocale) { log.warn(invalidLocale); } if (!Messages.setUserLocale(locale)) { locale = Locale.ENGLISH; Messages.setUserLocale(locale); code = null; } if (code == null) { config.setConfigProperty(Configurator.EDITOR_LANGUAGE, locale.getLanguage().toLowerCase()); } try { boolean lookAndFeelChanged = false; String oldLaf = UIManager.getLookAndFeel().getClass().getName(); String newLaf = config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, UIManager.getCrossPlatformLookAndFeelClassName()); lookAndFeelChanged = !oldLaf.equals(newLaf); if (lookAndFeelChanged) { UIManager.setLookAndFeel(newLaf); } if (config.getConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, null) == null) { config.setConfigProperty(Configurator.EDITOR_LOOK_AND_FEEL, newLaf); } if (lookAndFeelChanged) { new ConfigEditor(config, monitor); dispose(); return; } } catch (Exception invalidLaf) { log.warn(invalidLaf); } // Window settings setTitle(Messages.getString("config.editor") + " - " + config.getConfigPath()); //$NON-NLS-1$ //$NON-NLS-2$ setIconImage(TOOLKIT.getImage(ConfigEditor.class.getResource("/org/gcaldaemon/gui/icons/icon.gif"))); //$NON-NLS-1$ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); Container root = getContentPane(); root.setLayout(new BorderLayout()); root.add(folder, BorderLayout.CENTER); folder.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); folder.setTabPlacement(JTabbedPane.LEFT); folder.addChangeListener(this); status.setBorder(new BevelBorder(BevelBorder.LOWERED)); root.add(status, BorderLayout.SOUTH); // Create menu items fileMenu = new JMenu(Messages.getString("file")); //$NON-NLS-1$ saveMenu = new JMenuItem(Messages.getString("save"), getIcon("save")); //$NON-NLS-1$ //$NON-NLS-2$ exitMenu = new JMenuItem(Messages.getString("exit"), getIcon("exit")); //$NON-NLS-1$ //$NON-NLS-2$ viewMenu = new JMenu(Messages.getString("view")); //$NON-NLS-1$ langMenu = new JMenu(Messages.getString("language")); //$NON-NLS-1$ lafMenu = new JMenu(Messages.getString("look.and.feel")); //$NON-NLS-1$ transMenu = new JMenuItem(Messages.getString("translate")); //$NON-NLS-1$ logMenu = new JMenuItem(Messages.getString("log.viewer")); //$NON-NLS-1$ helpMenu = new JMenu(Messages.getString("help")); //$NON-NLS-1$ aboutMenu = new JMenuItem(Messages.getString("about")); //$NON-NLS-1$ // Build menu setJMenuBar(menuBar); menuBar.add(fileMenu); fileMenu.add(saveMenu); fileMenu.addSeparator(); fileMenu.add(exitMenu); menuBar.add(viewMenu); viewMenu.add(logMenu); viewMenu.addSeparator(); viewMenu.add(langMenu); viewMenu.add(lafMenu); langMenu.add(transMenu); menuBar.add(helpMenu); helpMenu.add(aboutMenu); // Build language menu Locale[] locales = Messages.getAvailableLocales(); String[] names = new String[locales.length]; String temp; int i; for (i = 0; i < locales.length; i++) { names[i] = locales[i].getDisplayLanguage(Locale.ENGLISH); if (names[i] == null || names[i].length() == 0) { names[i] = locales[i].getLanguage().toLowerCase(); } temp = locales[i].getDisplayLanguage(locale); if (temp != null && temp.length() > 0 && !temp.equals(names[i])) { names[i] = names[i] + " [" + temp + ']'; } } Arrays.sort(names, String.CASE_INSENSITIVE_ORDER); if (locales.length != 0) { langMenu.addSeparator(); } for (i = 0; i < locales.length; i++) { JMenuItem item = new JMenuItem(names[i]); item.setName('!' + names[i]); langMenu.add(item); item.addActionListener(this); } // Build look and feel menu LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels(); LookAndFeelInfo info; for (i = 0; i < infos.length; i++) { info = infos[i]; JMenuItem item = new JMenuItem(info.getName()); item.addActionListener(this); item.setName('#' + info.getClassName()); lafMenu.add(item); } // Action listeners addWindowListener(this); folder.addChangeListener(this); exitMenu.addActionListener(this); saveMenu.addActionListener(this); transMenu.addActionListener(this); logMenu.addActionListener(this); aboutMenu.addActionListener(this); // Add pages addPage("common.settings", new CommonPage(config, this)); //$NON-NLS-1$ addPage("http.settings", new HttpPage(config, this)); //$NON-NLS-1$ addPage("file.settings", new FilePage(config, this)); //$NON-NLS-1$ addPage("feed.settings", new FeedPage(config, this)); //$NON-NLS-1$ addPage("ldap.settings", new LdapPage(config, this)); //$NON-NLS-1$ addPage("notifier.settings", new NotifierPage(config, this)); //$NON-NLS-1$ addPage("sendmail.settings", new SendmailPage(config, this)); //$NON-NLS-1$ addPage("mailterm.settings", new MailtermPage(config, this)); //$NON-NLS-1$ // Set tab colors Iterator editors = disabledServices.iterator(); while (editors.hasNext()) { setServiceEnabled((BooleanEditor) editors.next(), false); } disabledServices = null; // Show GUI setResizable(true); Dimension size = TOOLKIT.getScreenSize(); int w = size.width - 50; int h = size.height - 70; w = Math.min(w, 1000); h = Math.min(h, 700); setSize(w, h); setLocation((size.width - w) / 2, (size.height - h) / 2); validate(); if (monitor != null) { monitor.dispose(); } setVisible(true); toFront(); } catch (Exception error) { if (monitor != null) { monitor.dispose(); } error(Messages.getString("error"), "Unable to start configurator: " + error, error); } }