List of usage examples for javax.swing UIManager setLookAndFeel
@SuppressWarnings("deprecation") public static void setLookAndFeel(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
From source file:QueryConnector.java
public static void updateAll(XComponentContext componentContext, XModel model) { QueryConnector connector = null;//from w w w. java 2 s . c o m try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); connector = new QueryConnector(model, componentContext); connector.updateAll(); } catch (Exception ex) { if (connector != null) connector.enableEdit(); ExceptionDialog.show(null, ex); } }
From source file:it.ventuland.ytd.ui.GUIClient.java
protected void initialize(Configuration pConfig) { mSavedConfiguration = YtdConfigManager.getInstance(); mAppContext = pConfig;// w w w .j a va 2 s. c o m mIsDebug = mAppContext.getBoolean("youtube-downloader.debug", false); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { shutdown(); } }); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { initializeUI(); initializeThreads(); } catch (java.awt.HeadlessException he) { System.exit(1); } } }); } catch (java.lang.InternalError ie) { System.exit(1); } catch (Throwable e) { e.printStackTrace(); } }
From source file:gate.Main.java
/** * Reads the user config data and applies the required settings. * This must be called <b>after</b> {@link Gate#init()} but <b>before</b> * any GUI components are created./*from ww w . j av a2 s . c om*/ */ public static void applyUserPreferences() { //look and feel String lnfClassName; if (System.getProperty("swing.defaultlaf") != null) { lnfClassName = System.getProperty("swing.defaultlaf"); } else { lnfClassName = Gate.getUserConfig().getString(GateConstants.LOOK_AND_FEEL); } if (lnfClassName == null) { //if running on Linux, default to Metal rather than GTK because GTK LnF //doesn't play nicely with most Gnome themes if (System.getProperty("os.name").toLowerCase().indexOf("linux") != -1) { //running on Linux lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName(); } else { lnfClassName = UIManager.getSystemLookAndFeelClassName(); } } try { UIManager.setLookAndFeel(lnfClassName); } catch (Exception e) { System.err.print("Could not set your preferred Look and Feel. The error was:\n" + e.toString() + "\nReverting to using Java Look and Feel"); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e1) { //we just can't catch a break here. Let's forget about look and feel. System.err.print("Could not set the cross-platform Look and Feel either. The error was:\n" + e1.toString() + "\nGiving up on Look and Feel."); } } Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName); //read the user config data OptionsMap userConfig = Gate.getUserConfig(); //text font Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT); if (font == null) { font = UIManager.getFont("TextPane.font"); } if (font != null) { OptionsDialog.setTextComponentsFont(font); } //menus font font = userConfig.getFont(GateConstants.MENUS_FONT); if (font == null) { font = UIManager.getFont("Menu.font"); } if (font != null) { OptionsDialog.setMenuComponentsFont(font); } //other gui font font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT); if (font == null) { font = UIManager.getFont("Button.font"); } if (font != null) { OptionsDialog.setComponentsFont(font); } }
From source file:com.adito.server.DefaultAditoServerFactory.java
public void createServer(final ClassLoader bootLoader, final String[] args) { // This is a hack to allow the Install4J installer to get the java // runtime that will be used if (args.length > 0 && args[0].equals("--jvmdir")) { System.out.println(SystemProperties.get("java.home")); System.exit(0);// w ww . j ava 2s . c o m } this.bootLoader = bootLoader; useWrapper = System.getProperty("wrapper.key") != null; ContextHolder.setContext(this); if (useWrapper) { WrapperManager.start(this, args); } else { Integer returnCode = start(args); if (returnCode != null) { if (gui) { if (startupException == null) { startupException = new Exception("An exit code of " + returnCode + " was returned."); } try { if (SystemProperties.get("os.name").toLowerCase().startsWith("windows")) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (UnsupportedLookAndFeelException e) { } String mesg = startupException.getMessage() == null ? "No message supplied." : startupException.getMessage(); StringBuilder buf = new StringBuilder(); int l = 0; char ch; for (int i = 0; i < mesg.length(); i++) { ch = mesg.charAt(i); if (l > 50 && ch == ' ') { buf.append("\n"); l = 0; } else { if (ch == '\n') { l = 0; } else { l++; } buf.append(ch); } } mesg = buf.toString(); final String fMesg = mesg; try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, fMesg, "Startup Error", JOptionPane.ERROR_MESSAGE); } }); } catch (InterruptedException ex) { } catch (InvocationTargetException ex) { } } System.exit(returnCode); } else { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (!shuttingDown) { DefaultAditoServerFactory.this.stop(0); } } }); } } }
From source file:FrameDemo2.java
/** * Create the GUI and show it. For thread safety, this method should be * invoked from the event-dispatching thread. */// w w w . j a va 2 s . co m private static void createAndShowGUI() { // Use the Java look and feel. try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { } // Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); // Instantiate the controlling class. JFrame frame = new JFrame("FrameDemo2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create and set up the content pane. FrameDemo2 demo = new FrameDemo2(); // Add components to it. Container contentPane = frame.getContentPane(); contentPane.add(demo.createOptionControls(), BorderLayout.CENTER); contentPane.add(demo.createButtonPane(), BorderLayout.PAGE_END); frame.getRootPane().setDefaultButton(defaultButton); // Display the window. frame.pack(); frame.setLocationRelativeTo(null); // center it frame.setVisible(true); }
From source file:com.github.benchdoos.weblocopener.updater.core.Main.java
private static void enableLookAndFeel() { try {/*from w w w. j a v a2 s .com*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignore) { log.warn("Could not establish UI Look and feel."); } }
From source file:QueryConnector.java
public static void info(XComponentContext componentContext, XModel model) { QueryConnector connector = null;//ww w. ja v a 2 s .c om try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); connector = new QueryConnector(model, componentContext); connector.info(); } catch (Exception ex) { if (connector != null) connector.enableEdit(); ExceptionDialog.show(null, ex); } }
From source file:GUI.AllForDealFrame.java
public AllForDealFrame() throws UnsupportedLookAndFeelException, ParseException, java.text.ParseException { UIManager.setLookAndFeel(new SyntheticaBlueLightLookAndFeel()); initComponents();//from ww w . j av a2 s . c o m loadAllVille(); loadAllCategories(); loadAllCollection(); // System.out.println(user_id); labelId.setVisible(false); accueillabel.setVisible(false); produitsLabel.setVisible(false); servicesLabel.setVisible(false); reclamationLabel.setVisible(false); btnProduits.setOpaque(false); btnProduits.setContentAreaFilled(false); btnProduits.setBorderPainted(false); btnAccueil.setOpaque(false); btnAccueil.setContentAreaFilled(false); btnAccueil.setBorderPainted(false); btnPanier.setOpaque(false); btnPanier.setContentAreaFilled(false); btnPanier.setBorderPainted(false); btnMessage.setOpaque(false); btnMessage.setContentAreaFilled(false); btnMessage.setBorderPainted(false); btnNotif.setOpaque(false); btnNotif.setContentAreaFilled(false); btnNotif.setBorderPainted(false); btnServices.setOpaque(false); btnServices.setContentAreaFilled(false); btnServices.setBorderPainted(false); btnReclam.setOpaque(false); btnReclam.setContentAreaFilled(false); btnReclam.setBorderPainted(false); btnProfile.setOpaque(false); btnProfile.setContentAreaFilled(false); btnProfile.setBorderPainted(false); msgEnvoyesLabel.setVisible(false); ecrireMsgLabel.setVisible(false); }
From source file:view.QuestionLab.java
/** * Creates new form QuestionLab/* w w w . java2 s.c o m*/ */ public QuestionLab(java.awt.Frame parent, boolean modal) { super(parent, modal); try { initComponents(); submitButton.setVisible(false); jCheckBox1.setEnabled(false); jCheckBox3.setEnabled(false); jCheckBox4.setEnabled(false); jCheckBox5.setEnabled(false); jCheckBox7.setEnabled(false); jCheckBox8.setEnabled(false); jCheckBox9.setEnabled(false); jCheckBox10.setEnabled(false); submitButton.setEnabled(false); backButton.setEnabled(false); controller = ServerConnector.getServerConnector().getStudentController(); studentObserverImpl = new StudentObserverImpl(this); controller.addObserve(studentObserverImpl); //controller.onlineNow(); //displayMessage(Integer.toString(onlineNow)); muteButton.setEnabled(false); setSize(Toolkit.getDefaultToolkit().getScreenSize()); UIManager.setLookAndFeel(new GraphiteLookAndFeel()); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); date = new Date(); System.out.println(dateFormat.format(date)); newDate = dateFormat.format(date); JButton buttonArrayListOne[][] = { { jButton1, jButton2, jButton3, jButton4, jButton5 }, { jButton6, jButton7, jButton8, jButton9, jButton10 }, { jButton11, jButton12, jButton13, jButton14, jButton15 }, { jButton16, jButton17, jButton18, jButton19, jButton20 }, { jButton21, jButton22, jButton23, jButton24, jButton25 }, { jButton26, jButton27, jButton28, jButton29, jButton30 }, { jButton31, jButton32, jButton33, jButton34, jButton35 }, { jButton36, jButton37, jButton38, jButton39, jButton40 }, { jButton41, jButton42, jButton43, jButton44, jButton45 }, { jButton46, jButton47, jButton48, jButton49, jButton50 }, { jButton51, jButton52, jButton53, jButton54, jButton55 }, { jButton56, jButton57, jButton58, jButton59, jButton60 } }; this.buttonArrayList = buttonArrayListOne; System.out.println("MyNIc" + PracticeExamLogIn.studentNic); new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int hour = secondsLeft / 3600; int min = secondsLeft / 60 - hour * 60; int second = secondsLeft % 60; if (hour == 0) { int seconds = secondsLeft % 60; jLabel7.setText(Integer.toString(seconds)); jLabel8.setText("Minutes"); // jLabel5.setText("Seconds"); jLabel6.setText(Integer.toString(min)); } else { jLabel6.setText(Integer.toString(hour)); jLabel7.setText(Integer.toString(min)); jLabel8.setText(Integer.toString(second)); } secondsLeft--; if ("0".equals(jLabel6.getText()) && "0".equals(jLabel7.getText())) { //check(); System.out.println("true"); } } }).start(); submitTextField.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); if (!((c >= 'a') && (c <= 'g') || (c == KeyEvent.VK_SPACE) || (c == KeyEvent.VK_TAB) || (c == KeyEvent.VK_SPACE))) { getToolkit().beep(); e.consume(); } } }); try { try { Exam exam = new Exam(PracticeExamLogIn.studentNic, date, anxCount); // ExamController examController = ServerConnector.getServerConnector().getExamController(); try { boolean addMarks = ServerConnector.getServerConnector().getExamController().addMarks(exam); // Exam exam = examController.addMarks(PracticeExamLogIn.studentNic, newDate, anxCount); // if (addMarks) { // JOptionPane.showMessageDialog(QuestionLab.this, "Student Registered successfully !!"); // this.dispose(); // new LogIn(null, true).setVisible(true); // } else { // JOptionPane.showMessageDialog(QuestionLab.this, "Student Registered failed !!"); // } } catch (ClassNotFoundException | SQLException ex) { Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex); } } catch (NotBoundException | MalformedURLException ex) { Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex); } } catch (RemoteException ex) { Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex); } } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (NotBoundException | MalformedURLException | RemoteException ex) { Logger.getLogger(QuestionLab.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.sf.firemox.Magic.java
/** * @param args// w w w . j a v a 2s . com * the command line arguments * @throws Exception */ public static void main(String[] args) throws Exception { Log.init(); Log.debug("MP v" + IdConst.VERSION + ", jre:" + System.getProperty("java.runtime.version") + ", jvm:" + System.getProperty("java.vm.version") + ",os:" + System.getProperty("os.name") + ", res:" + Toolkit.getDefaultToolkit().getScreenSize().width + "x" + Toolkit.getDefaultToolkit().getScreenSize().height + ", root:" + MToolKit.getRootDir()); System.setProperty("swing.aatext", "true"); System.setProperty(SubstanceLookAndFeel.WATERMARK_IMAGE_PROPERTY, MToolKit.getIconPath(Play.ZONE_NAME + "/hardwoodfloor.png")); final File substancelafFile = MToolKit.getFile(FILE_SUBSTANCE_PROPERTIES); if (substancelafFile == null) { Log.warn("Unable to locate '" + FILE_SUBSTANCE_PROPERTIES + "' file, you are using the command line with wrong configuration. See http://www.firemox.org/dev/project.html documentation"); } else { System.getProperties().load(new FileInputStream(substancelafFile)); } MToolKit.defaultFont = new Font("Arial", 0, 11); try { if (args.length > 0) { final String[] args2 = new String[args.length - 1]; System.arraycopy(args, 1, args2, 0, args.length - 1); if ("-rebuild".equals(args[0])) { XmlConfiguration.main(args2); } else if ("-oracle2xml".equals(args[0])) { Oracle2Xml.main(args2); } else if ("-batch".equals(args[0])) { if ("-server".equals(args[1])) { batchMode = BATCH_SERVER; } else if ("-client".equals(args[1])) { batchMode = BATCH_CLIENT; } } else { Log.error("Unknown options '" + Arrays.toString(args) + "'\nUsage : java -jar starter.jar <options>, where options are :\n" + "\t-rebuild -game <tbs name> [-x] [-d] [-v] [-h] [-f] [-n]\n" + "\t-oracle2xml -f <oracle file> -d <output directory> [-v] [-h]"); } System.exit(0); return; } if (batchMode == -1 && !"Mac OS X".equals(System.getProperty("os.name"))) { splash = new SplashScreen(MToolKit.getIconPath("splash.jpg"), null, 2000); } // language settings LanguageManager.initLanguageManager(Configuration.getString("language", "auto")); } catch (Throwable t) { Log.error("START-ERROR : \n\t" + t.getMessage()); System.exit(1); return; } Log.debug("MP Language : " + LanguageManager.getLanguage().getName()); speparateAvatar = Toolkit.getDefaultToolkit().getScreenSize().height > 768; // verify the java version, minimal is 1.5 if (new JavaVersion().compareTo(new JavaVersion(IdConst.MINIMAL_JRE)) == -1) { Log.error(LanguageManager.getString("wrongjava") + IdConst.MINIMAL_JRE); } // load look and feel settings lookAndFeelName = Configuration.getString("preferred", MUIManager.LF_SUBSTANCE_CLASSNAME); // try { // FileInputStream in= new FileInputStream("MAGIC.TTF"); // MToolKit.defaultFont= Font.createFont(Font.TRUETYPE_FONT, in); // in.close(); // MToolKit.defaultFont= MToolKit.defaultFont.deriveFont(Font.BOLD, 11); // } // catch (FileNotFoundException e) { // System.out.println("editorfont.ttf not found, using default."); // } // catch (Exception ex) { // ex.printStackTrace(); // } // Read available L&F final LinkedList<Pair<String, String>> lfList = new LinkedList<Pair<String, String>>(); try { BufferedReader buffReader = new BufferedReader( new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_THEME_SETTINGS))); String line; while ((line = buffReader.readLine()) != null) { line = line.trim(); if (!line.startsWith("#")) { final int index = line.indexOf(';'); if (index != -1) { lfList.add(new Pair<String, String>(line.substring(0, index), line.substring(index + 1))); } } } IOUtils.closeQuietly(buffReader); } catch (Throwable e) { // no place for resolve this problem Log.debug("Error reading L&F properties : " + e.getMessage()); } for (Pair<String, String> pair : lfList) { UIManager.installLookAndFeel(pair.key, pair.value); } // install L&F if (SkinLF.isSkinLF(lookAndFeelName)) { // is a SkinLF Look & Feel /* * Make sure we have a nice window decoration. */ SkinLF.installSkinLF(lookAndFeelName); } else { // is Metal Look & Feel if (!MToolKit.isAvailableLookAndFeel(lookAndFeelName)) { // preferred look&feel is not available JOptionPane.showMessageDialog(magicForm, LanguageManager.getString("preferredlfpb", lookAndFeelName), LanguageManager.getString("error"), JOptionPane.INFORMATION_MESSAGE); setDefaultUI(); } // Install the preferred LookAndFeel newLAF = MToolKit.geLookAndFeel(lookAndFeelName); frameDecorated = newLAF.getSupportsWindowDecorations(); /* * Make sure we have a nice window decoration. */ JFrame.setDefaultLookAndFeelDecorated(frameDecorated); JDialog.setDefaultLookAndFeelDecorated(frameDecorated); UIManager.setLookAndFeel(MToolKit.geLookAndFeel(lookAndFeelName)); } // Start main thread try { new Magic(); SwingUtilities.invokeLater(SkinLF.REFRESH_RUNNER); } catch (Throwable e) { Log.fatal("In main thread, occurred exception : ", e); ConnectionManager.closeConnexions(); return; } }