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:TopLevelTransferHandlerDemo.java
private static void createAndShowGUI(String[] args) { try {// w w w . j a va 2 s. co m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } TopLevelTransferHandlerDemo test = new TopLevelTransferHandlerDemo(); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); if (DEMO) { test.setSize(493, 307); } else { test.setSize(800, 600); } test.setLocationRelativeTo(null); test.setVisible(true); test.list.requestFocus(); }
From source file:archive_v1.Archive_Form.java
/** * @param args the command line arguments *///w w w . j a v a 2 s . com 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 { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Archive_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Archive_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Archive_Form.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Archive_Form.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() { new Archive_Form().setVisible(true); } }); }
From source file:QueryConnector.java
public static void modify(XComponentContext componentContext, XModel model) { QueryConnector connector = null;/*from ww w . ja v a 2 s. c om*/ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); connector = new QueryConnector(model, componentContext); connector.modify(); } catch (Exception ex) { if (connector != null) connector.enableEdit(); ExceptionDialog.show(null, ex); } }
From source file:es.ubu.XRayDetector.interfaz.PanelAplicacion.java
/** * Initialize the contents of the frame. */// w w w.j av a 2s. c om private void initialize() { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (ClassNotFoundException e) { MyLogHandler.writeException(e); e.printStackTrace(); } catch (InstantiationException e) { MyLogHandler.writeException(e); e.printStackTrace(); } catch (IllegalAccessException e) { MyLogHandler.writeException(e); e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { MyLogHandler.writeException(e); e.printStackTrace(); } getJFramePrincipal(); JPanel panelControl = getPanelControl(); getBtnAbrirImagen(panelControl); getBtnEntrenar(panelControl); getBtnAnalizar(panelControl); JPanel panelProgreso = getPanelProgreso(); getProgressBar(panelProgreso); getBtnStop(panelProgreso); JPanel panelImagen = getPanelImagen(); getImgPanel(panelImagen); JPanel panelLog = getPanelLog(); txtLog = getTxtLog(panelLog); getBotonExportarLog(); getBotonLimpiarLog(); JPanel panelSlider = getPanelSlider(); getSlider(panelSlider); getPanelTabla(); getTablaResultados(panelTabla_1); imgPanel.setFocusable(true); JPanel panelAnalizarResultados = getPanelAnalizarResultados(); getButtonGuardarImagenAnalizada(panelAnalizarResultados); getButtonGuardarImagenBinarizada(panelAnalizarResultados); getButtonPrecisionRecall(panelAnalizarResultados); selectionCopy = new Rectangle(); try { File fichero = new File("./res/ayuda/ayuda.hs"); URL hsURL = fichero.toURI().toURL(); HelpSet hs = new HelpSet(null, hsURL); HelpBroker hb = hs.createHelpBroker(); hb.enableHelpKey(frmXraydetector.getContentPane(), "ventanaentrenamientodeteccion", hs); } catch (MalformedURLException e) { MyLogHandler.writeException(e); e.printStackTrace(); } catch (HelpSetException e) { MyLogHandler.writeException(e); e.printStackTrace(); } }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
public static void main(String args[]) { try {//from w w w. j a v a2s . c om UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exception) { exception.printStackTrace(); } ThumbnailDemo1 thumbnaildemo1 = new ThumbnailDemo1("JFreeChart: ThumbnailDemo1.java"); thumbnaildemo1.pack(); RefineryUtilities.centerFrameOnScreen(thumbnaildemo1); thumbnaildemo1.setVisible(true); }
From source file:de.mendelson.comm.as2.client.AS2Gui.java
/** * Creates new form NewJFrame/*from w w w. j av a2 s.co m*/ */ public AS2Gui(Splash splash, String host) { this.host = host; //Set System default look and feel try { //support the command line option -Dswing.defaultlaf=... if (System.getProperty("swing.defaultlaf") == null) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (Exception e) { this.logger.warning(this.getClass().getName() + ":" + e.getMessage()); } //load resource bundle try { this.rb = (MecResourceBundle) ResourceBundle.getBundle(ResourceBundleAS2Gui.class.getName()); } catch (MissingResourceException e) { throw new RuntimeException("Oops..resource bundle " + e.getClassName() + " not found."); } initComponents(); this.jButtonNewVersion.setVisible(false); this.jPanelRefreshWarning.setVisible(false); //set preference values to the GUI this.setBounds(this.clientPreferences.getInt(PreferencesAS2.FRAME_X), this.clientPreferences.getInt(PreferencesAS2.FRAME_Y), this.clientPreferences.getInt(PreferencesAS2.FRAME_WIDTH), this.clientPreferences.getInt(PreferencesAS2.FRAME_HEIGHT)); //ensure to display all messages this.getLogger().setLevel(Level.ALL); LogConsolePanel consolePanel = new LogConsolePanel(this.getLogger()); //define the colors for the log levels consolePanel.setColor(Level.SEVERE, LogConsolePanel.COLOR_BROWN); consolePanel.setColor(Level.WARNING, LogConsolePanel.COLOR_BLUE); consolePanel.setColor(Level.INFO, LogConsolePanel.COLOR_BLACK); consolePanel.setColor(Level.CONFIG, LogConsolePanel.COLOR_DARK_GREEN); consolePanel.setColor(Level.FINE, LogConsolePanel.COLOR_DARK_GREEN); consolePanel.setColor(Level.FINER, LogConsolePanel.COLOR_DARK_GREEN); consolePanel.setColor(Level.FINEST, LogConsolePanel.COLOR_DARK_GREEN); this.jPanelServerLog.add(consolePanel); this.setTitle(AS2ServerVersion.getProductName() + " " + AS2ServerVersion.getVersion()); //initialize the help system if available this.initializeJavaHelp(); this.jTableMessageOverview.getSelectionModel().addListSelectionListener(this); this.jTableMessageOverview.getTableHeader().setReorderingAllowed(false); //icon columns TableColumn column = this.jTableMessageOverview.getColumnModel().getColumn(0); column.setMaxWidth(20); column.setResizable(false); column = this.jTableMessageOverview.getColumnModel().getColumn(1); column.setMaxWidth(20); column.setResizable(false); this.jTableMessageOverview.setDefaultRenderer(Date.class, new TableCellRendererDate(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT))); //add row sorter RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(this.jTableMessageOverview.getModel()); jTableMessageOverview.setRowSorter(sorter); sorter.addRowSorterListener(this); this.jPanelFilterOverview.setVisible(this.showFilterPanel); this.jMenuItemHelpForum.setEnabled(Desktop.isDesktopSupported()); //destroy splash, possible login screen for the client should come up if (splash != null) { splash.destroy(); } this.setButtonState(); this.jTableMessageOverview.addMouseListener(this); //popup menu issues this.jPopupMenu.setInvoker(this.jScrollPaneMessageOverview); this.jPopupMenu.addPopupMenuListener(this); super.addMessageProcessor(this); //perform the connection to the server //warning! this works for localhost only so far int clientServerCommPort = this.clientPreferences.getInt(PreferencesAS2.CLIENTSERVER_COMM_PORT); if (splash != null) { splash.destroy(); } this.browserLinkedPanel.cyleText(new String[] { "For additional EDI software to convert and process your data please contact <a href='http://www.mendelson-e-c.com'>mendelson-e-commerce GmbH</a>", "To buy a commercial license please visit the <a href='http://shop.mendelson-e-c.com/'>mendelson online shop</a>", "Most trading partners demand a trusted certificate - Order yours at the <a href='http://ca.mendelson-e-c.com'>mendelson CA</a> now!", "Looking for additional secure data transmission software? Try the <a href='http://oftp2.mendelson-e-c.com'>mendelson OFTP2</a> solution!", "You want to send EDIFACT data from your SAP system? Ask <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20SAP%20integration%20solutions'>mendelson-e-commerce GmbH</a> for a solution.", "You need a secure FTP solution? <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20SFTP%20solution'>Ask us</a> for the mendelson SFTP software.", "Convert flat files, EDIFACT, SAP IDos, VDA, inhouse formats? <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20converter%20solution'>Ask us</a> for the mendelson EDI converter.", "For commercial support of this software please buy a license at <a href='http://as2.mendelson-e-c.com'>the mendelson AS2</a> website.", "Have a look at the <a href='http://www.mendelson-e-c.com/products_mbi.php'>mendelson business integration</a> for a powerful EDI solution.", "The <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20RosettaNet%20solution'>mendelson RosettaNet solution</a> supports RNIF 1.1 and RNIF 2.0.", "The <a href='http://www.mendelson-e-c.com/products_ide.php'>mendelson converter IDE</a> is the graphical mapper for the mendelson converter.", "To process any XML data and convert it to EDIFACT, VDA, flat files, IDocs and inhouse formats use <a href='http://www.mendelson-e-c.com/products_converter.php'>the mendelson converter</a>.", "To transmit your EDI data via HTTP/S please <a href='mailto:info@mendelson.de?subject=Please%20inform%20me%20about%20your%20HTTPS%20solution'>ask us</a> for the mendelson HTTPS solution.", "If you have questions regarding this product please refer to the <a href='http://community.mendelson-e-c.com/'>mendelson community</a>.", }); this.connect(new InetSocketAddress(host, clientServerCommPort), 5000); Runnable dailyNewsThread = new Runnable() { @Override public void run() { while (true) { long lastUpdateCheck = Long.valueOf(clientPreferences.get(PreferencesAS2.LAST_UPDATE_CHECK)); //check only once a day even if the system is started n times a day if (lastUpdateCheck < (System.currentTimeMillis() - TimeUnit.HOURS.toMillis(23))) { clientPreferences.put(PreferencesAS2.LAST_UPDATE_CHECK, String.valueOf(System.currentTimeMillis())); jButtonNewVersion.setVisible(false); String version = (AS2ServerVersion.getVersion() + " " + AS2ServerVersion.getBuild()) .replace(' ', '+'); Header[] header = htmlPanel.setURL( "http://www.mendelson.de/en/mecas2/client_welcome.php?version=" + version, AS2ServerVersion.getProductName() + " " + AS2ServerVersion.getVersion(), new File("start/client_welcome.html")); if (header != null) { String downloadURL = null; String actualBuild = null; for (Header singleHeader : header) { if (singleHeader.getName().equals("x-actual-build")) { actualBuild = singleHeader.getValue().trim(); } if (singleHeader.getName().equals("x-download-url")) { downloadURL = singleHeader.getValue().trim(); } } if (downloadURL != null && actualBuild != null) { try { int thisBuild = AS2ServerVersion.getBuildNo(); int availableBuild = Integer.valueOf(actualBuild); if (thisBuild < availableBuild) { jButtonNewVersion.setVisible(true); } downloadURLNewVersion = downloadURL; } catch (Exception e) { //nop } } } } else { htmlPanel.setPage(new File("start/client_welcome.html")); } try { //check once a day for new update Thread.sleep(TimeUnit.DAYS.toMillis(1)); } catch (InterruptedException e) { //nop } } } }; Executors.newSingleThreadExecutor().submit(dailyNewsThread); this.as2StatusBar.setConnectedHost(this.host); }
From source file:com.netscape.admin.certsrv.Console.java
/** * common initialization routine.//from w ww .ja v a 2s .c om * * @param language language string. For example, "en" for english */ protected static void common_init(String language) { Locale.setDefault(new Locale(language, Locale.getDefault().getCountry())); try { // bug 115085: init calls needs to be inside the try block as, on Unix, during // initialization any call to java.awt.* will cause an exception to be thrown // if Xserver is not accessable. The jvm prints correctly the error message about // unaccessable Xserver but exception stack trace makes it less readable if (_info == null) _info = new ConsoleInfo(); PreferenceManager.setLocalStorageFlag(_preferences.getBoolean(PREFERENCE_LOCAL, false)); if (!_useJavaLookAndFeel) { SuiLookAndFeel nmclf = new SuiLookAndFeel(); UIManager.setLookAndFeel(nmclf); // With JDK1.4 on Unix, the first instance of JFileChooser // has an incorrect layout for some of the buttons. Create // and discard an instance. if (!_isWindows) { new JFileChooser(); } } FontFactory.initializeLFFonts(); // load default customized fonts for login/splash } catch (InternalError ie) { System.err.println("Console: " + ie.getMessage()); System.exit(1); } catch (Exception e) { Debug.println("Console.common_init: Cannot init " + e); } }
From source file:com.stacksync.desktop.Environment.java
private Environment() { String homePath = ""; // Check must-haves if (System.getProperty("stacksync.home") == null) { if (System.getProperty("user.dir") != null) { homePath = System.getProperty("user.dir"); } else {/*from w w w . j a v a 2 s . c o m*/ throw new RuntimeException("Property 'stacksync.home' must be set."); } } else { homePath = System.getProperty("stacksync.home"); File tryPath = new File(homePath + File.separator + "res"); if (!tryPath.exists()) { homePath = System.getProperty("user.dir"); } } // Architecture if ("32".equals(System.getProperty("sun.arch.data.model"))) { architecture = "i386"; } else if ("64".equals(System.getProperty("sun.arch.data.model"))) { architecture = "amd64"; } else { throw new RuntimeException("Stacksync only supports 32bit and 64bit systems, not '" + System.getProperty("sun.arch.data.model") + "'."); } // Do initialization! defaultUserHome = System.getProperty("user.home") + File.separator; String osName = System.getProperty("os.name").toLowerCase(); if (osName.contains("linux")) { operatingSystem = OperatingSystem.Linux; defaultUserConfDir = new File(defaultUserHome + "." + Constants.APPLICATION_NAME.toLowerCase()); } else if (osName.contains("windows")) { operatingSystem = OperatingSystem.Windows; if (osName.contains("xp")) {//windows xp defaultUserConfDir = new File(defaultUserHome + "Application Data" + File.separator + Constants.APPLICATION_NAME.toLowerCase()); } else { //windows 7, 8 defaultUserConfDir = new File(defaultUserHome + "AppData" + File.separator + "Roaming" + File.separator + Constants.APPLICATION_NAME.toLowerCase()); } } else if (osName.contains("mac os x")) { operatingSystem = OperatingSystem.Mac; defaultUserConfDir = new File(defaultUserHome + "." + Constants.APPLICATION_NAME.toLowerCase()); } else { throw new RuntimeException( "Your system is not supported at the moment: " + System.getProperty("os.name")); } // Common values defaultUserConfigFile = new File( defaultUserConfDir.getAbsoluteFile() + File.separator + Constants.CONFIG_FILENAME); appDir = new File(homePath); appBinDir = new File(defaultUserConfDir.getAbsoluteFile() + File.separator + "bin"); appBinDir.mkdirs(); appResDir = new File(defaultUserConfDir.getAbsoluteFile() + File.separator + "res"); appResDir.mkdirs(); appConfDir = new File(defaultUserConfDir.getAbsoluteFile() + File.separator + "conf"); appConfDir.mkdirs(); try { File binFolder, resFolder, confFolder; if (operatingSystem == OperatingSystem.Mac || operatingSystem == OperatingSystem.Linux || operatingSystem == OperatingSystem.Windows) { binFolder = appBinDir; resFolder = appResDir; confFolder = appConfDir; } else { binFolder = resFolder = confFolder = defaultUserConfDir; } URL resource = Environment.class.getResource("/bin"); copyResourcesRecursively(resource, binFolder); resource = Environment.class.getResource("/res"); copyResourcesRecursively(resource, resFolder); resource = Environment.class.getResource("/conf"); copyResourcesRecursively(resource, confFolder); } catch (Exception ex) { throw new RuntimeException("Could not copy resources from JAR: " + ex); } // Errors if (!appDir.exists()) { throw new RuntimeException("Could not find application directory at " + appDir); } if (!appResDir.exists()) { throw new RuntimeException("Could not find application resources directory at " + appResDir); } String defaultDeviceName; try { defaultDeviceName = InetAddress.getLocalHost().getHostName(); if (defaultDeviceName.length() > 10) { defaultDeviceName = InetAddress.getLocalHost().getHostName().substring(0, 9); } } catch (UnknownHostException ex) { logger.error("aplicationstarter#ERROR: cannot find host", ex); defaultDeviceName = "(unknown)"; } if (defaultUserConfigFile.exists()) { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(defaultUserConfigFile); ConfigNode self = new ConfigNode(doc.getDocumentElement()); Device device = new Device(); device.load(self.findChildByName("device")); deviceName = device.getName(); if (deviceName == null || deviceName.isEmpty()) { deviceName = defaultDeviceName; } } catch (Exception ex) { logger.error("ERROR: cant set machineName", ex); deviceName = defaultDeviceName; } } else { deviceName = defaultDeviceName.replace("-", "_"); } userName = System.getProperty("user.name"); // GUI try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //java.util.Enumeration keys = UIManager.getDefaults().keys(); /*while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get (key); if (value instanceof FontUIResource) { FontUIResource f = (FontUIResource) value; f = new FontUIResource(f.getFamily(), f.getStyle(), f.getSize()-2); System.out.println(key +" = "+value); UIManager.put (key, f); } }*/ } catch (Exception ex) { logger.error("aplicationstarter#Couldn't set native look and feel.", ex); } }
From source file:de.topobyte.livecg.LiveCG.java
private void setLookAndFeel(String lookAndFeel) { try {/*from w w w .ja v a 2 s .com*/ UIManager.setLookAndFeel(lookAndFeel); } catch (Exception e) { logger.error("error while setting look and feel '" + lookAndFeel + "': " + e.getClass().getSimpleName() + ", message: " + e.getMessage()); } for (Window window : JFrame.getWindows()) { SwingUtilities.updateComponentTreeUI(window); // window.pack(); } }
From source file:QueryConnector.java
public static void update(XComponentContext componentContext, XModel model) { QueryConnector connector = null;//from www .j ava 2s . com try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); connector = new QueryConnector(model, componentContext); connector.update(); } catch (Exception ex) { if (connector != null) connector.enableEdit(); ExceptionDialog.show(null, ex); } }