List of usage examples for javax.swing JFrame setDefaultLookAndFeelDecorated
public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
JFrame
s should have their Window decorations (such as borders, widgets to close the window, title...) provided by the current look and feel. From source file:edu.ku.brc.ui.UIHelper.java
/** * Tries to do the login, if doAutoLogin is set to true it will try without displaying a dialog * and if the login fails then it will display the dialog * @param userName single signon username (for application) * @param password single signon password (for application) * @param usrPwdProvider the provider/*from ww w. j av a2s. co m*/ * @param engageUPPrefs indicates whether the username and password should be loaded and remembered by local prefs * @param doAutoLogin whether to try to automatically log the user in * @param doAutoClose whether it should automatically close the window when it is logged in successfully * @param useDialog use a Dialog or a Frame * @param listener a listener for when it is logged in or fails * @param iconName name of icon to use * @param title name * @param appName name * @param appIconName application icon name * @param helpContext help context for Help button on dialog */ public static DatabaseLoginPanel doLogin(final String userName, final String password, final boolean engageUPPrefs, final MasterPasswordProviderIFace usrPwdProvider, final boolean doAutoClose, final boolean useDialog, final DatabaseLoginListener listener, final String iconName, final String title, final String appName, final String appIconName, final String helpContext, final boolean appCanUpdateSchema) //frame's icon name { ImageIcon icon = IconManager.getIcon("AppIcon", IconManager.IconSize.Std32); if (StringUtils.isNotEmpty(appIconName)) { ImageIcon imgIcon = IconManager.getIcon(appIconName); if (imgIcon != null) { icon = imgIcon; } } if (useDialog) { JDialog.setDefaultLookAndFeelDecorated(false); DatabaseLoginDlg dlg = new DatabaseLoginDlg((Frame) UIRegistry.getTopWindow(), userName, password, engageUPPrefs, listener, iconName, helpContext); JDialog.setDefaultLookAndFeelDecorated(true); dlg.setDoAutoClose(doAutoClose); dlg.setModal(true); if (StringUtils.isNotEmpty(title)) { dlg.setTitle(title); } dlg.setIconImage(icon.getImage()); UIHelper.centerAndShow(dlg); return dlg.getDatabaseLoginPanel(); } // else class DBListener implements DatabaseLoginListener { protected JFrame frame; protected DatabaseLoginListener frameDBListener; protected boolean doAutoCloseOfListener; public DBListener(JFrame frame, DatabaseLoginListener frameDBListener, boolean doAutoCloseOfListener) { this.frame = frame; this.frameDBListener = frameDBListener; this.doAutoCloseOfListener = doAutoCloseOfListener; } public void loggedIn(final Window window, final String databaseName, final String userNameArg) { log.debug("UIHelper.doLogin[DBListener]"); if (doAutoCloseOfListener) { frame.setVisible(false); } frameDBListener.loggedIn(window, databaseName, userNameArg); } public void cancelled() { frame.setVisible(false); frameDBListener.cancelled(); } } JFrame.setDefaultLookAndFeelDecorated(false); JFrame frame = new JFrame(title); DatabaseLoginPanel panel; if (StringUtils.isNotEmpty(title)) { panel = new DatabaseLoginPanel(userName, password, engageUPPrefs, usrPwdProvider, new DBListener(frame, listener, doAutoClose), false, true, title, appName, iconName, helpContext); } else { panel = new DatabaseLoginPanel(userName, password, engageUPPrefs, usrPwdProvider, new DBListener(frame, listener, doAutoClose), false, true, null, null, iconName, helpContext); } panel.setAppCanUpdateSchema(appCanUpdateSchema); panel.setAutoClose(doAutoClose); panel.setWindow(frame); frame.setContentPane(panel); frame.setIconImage(icon.getImage()); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); UIHelper.centerAndShow(frame); return panel; }
From source file:com.lfv.lanzius.server.LanziusServer.java
public static void start() { server = new LanziusServer(); // Make sure we have nice window decorations. // Only if workspace is not fullscreen if (!Config.SERVER_SIZE_FULLSCREEN) JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { server.init();//from w ww.j a va 2 s .c om } }); }
From source file:base.BasePlayer.Main.java
private static void createAndShowGUI() { try {//from w ww . j a v a 2 s.co m /* if(System.getProperty("os.name").toLowerCase().contains("nux")) { } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } */ // SystemUtils.IS_OS_WINDOWS // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JFrame.setDefaultLookAndFeelDecorated(false); frame = new JFrame("BasePlayer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(true); JComponent newContentPane = new Main(); newContentPane.setOpaque(true); frame.setContentPane(newContentPane); frame.pack(); frame.setVisible(true); }
From source file:net.team2xh.crt.gui.util.GUIToolkit.java
/** * Activeate Substance Look&Feel.// w w w . j a v a2 s .c o m * * Must be called before opening any window. * * @param laf Desired Substance Look&Feel class */ public static void setSubstanceLAF(String laf) { try { UIManager.setLookAndFeel(laf); UIManager.put(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, Boolean.FALSE); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); // Substance forgot to put a border for JTextArea, // So we give it the same border that TextField has Object border = UIManager.get("TextField.border"); UIManager.put("TextArea.border", border); // Plain title font // SubstanceLookAndFeel.setFontPolicy(new FontPolicy() { // public FontSet getFontSet(String arg0, UIDefaults arg1) { // FontSet fontSet = new FontSet() { // public FontUIResource getWindowTitleFont() { // return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); //this is where the title font changes // } // // public FontUIResource getTitleFont() { // return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); // } // // public FontUIResource getSmallFont() { // return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); // } // // public FontUIResource getMessageFont() { // return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); // } // // public FontUIResource getMenuFont() { // return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); // } // // public FontUIResource getControlFont() { // return new FontUIResource(new Font("Source Sans Pro", Font.PLAIN, 14)); // } // }; // return fontSet; // } // }); } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) { Logger.getLogger(GUIToolkit.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.executequery.util.LookAndFeelLoader.java
public void decorateDialogsAndFrames(boolean decorateDialogs, boolean decorateFrames) { JDialog.setDefaultLookAndFeelDecorated(decorateDialogs); JFrame.setDefaultLookAndFeelDecorated(decorateFrames); }
From source file:org.gridchem.client.GridChem.java
public static void main(String[] args) { Trace.entry();/*from w w w.j a v a 2 s . c o m*/ try { setCommandLineOptions(); parseCommandLine(args); } catch (Exception e) { System.out.println("Invalid command line option given: " + e.getMessage()); } //JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); // Edited by Shashank & Sandeep @ CCS,UKY April 10 2005 JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); /*MetalTheme theme = new G03Input.ColorTheme(); MetalLookAndFeel.setCurrentTheme(theme); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); SwingUtilities.updateComponentTreeUI(frame); } catch(Exception e) { System.out.println(e); }*/ // Use the native look and feel since Java's is pretty lame. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // Ignore exceptions, which only result in the wrong look and feel. System.out.println("GridChem.main: an exception related to the" + " look and feel was ignored."); } init(); frame.setTitle("GridChem " + Env.getVersion()); frame.getContentPane().add(oc); frame.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent arg0) { } public void windowClosed(WindowEvent arg0) { } public void windowClosing(WindowEvent arg0) { if (Settings.authenticated) { GMS3.logout(); } } public void windowDeactivated(WindowEvent arg0) { } public void windowDeiconified(WindowEvent arg0) { } public void windowIconified(WindowEvent arg0) { } public void windowOpened(WindowEvent arg0) { } }); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); // Centering the frame on the screen Toolkit kit = frame.getToolkit(); Dimension screenSize = kit.getScreenSize(); int screenWidth = screenSize.width; int screenHeight = screenSize.height; Dimension windowSize = frame.getSize(); int windowWidth = windowSize.width; int windowHeight = windowSize.height; int upperLeftX = (screenWidth - windowWidth) / 2; int upperLeftY = (screenHeight - windowHeight) / 2; frame.setLocation(upperLeftX, upperLeftY); frame.setVisible(true); Trace.exit(); }
From source file:org.notebook.gui.widget.LookAndFeelSelector.java
/** * Sets the look and feel./*from www . ja v a2s. co m*/ * * @param theme * the new look and feel */ public void setLookAndFeel(String theme) { try { log.info("Updating skin '" + theme + "'"); if (skins.containsKey(theme)) { UIManager.setLookAndFeel(skins.get(theme)); } else { log.error("Not found skin '" + theme + "'"); return; } /** fix font bug start */ if (SwingUtilities.isEventDispatchThread()) { fixFontBug(); } else { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { fixFontBug(); } }); } } catch (Exception e) { log.error(e.toString(), e); } /** * ?????? * tiptool */ if (!isDefaultLookAndFeel(theme)) { // Get border color try { Color c = SubstanceLookAndFeel.getCurrentSkin().getMainActiveColorScheme().getMidColor(); UIManager.put("ToolTip.border", BorderFactory.createLineBorder(c)); UIManager.put("ToolTip.background", new ColorUIResource(Color.WHITE)); UIManager.put("ToolTip.foreground", new ColorUIResource(Color.BLACK)); SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin(); SubstanceColorScheme scheme = skin.getMainActiveColorScheme(); GuiUtils.putLookAndFeelColor("borderColor", scheme.getMidColor()); GuiUtils.putLookAndFeelColor("lightColor", scheme.getLightColor()); GuiUtils.putLookAndFeelColor("lightBackgroundFillColor", scheme.getLightBackgroundFillColor()); GuiUtils.putLookAndFeelColor("darkColor", scheme.getDarkColor()); GuiUtils.putLookAndFeelColor("backgroundFillColor", scheme.getBackgroundFillColor()); GuiUtils.putLookAndFeelColor("lineColor", scheme.getLineColor()); GuiUtils.putLookAndFeelColor("selectionForegroundColor", scheme.getSelectionForegroundColor()); GuiUtils.putLookAndFeelColor("selectionBackgroundColor", scheme.getSelectionBackgroundColor()); GuiUtils.putLookAndFeelColor("foregroundColor", scheme.getForegroundColor()); GuiUtils.putLookAndFeelColor("focusRingColor", scheme.getFocusRingColor()); } catch (Exception e) { log.info("This is not a SubstanceLookAndFeel skin."); } UIManager.put(LafWidget.ANIMATION_KIND, LafConstants.AnimationKind.NONE); UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND, SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); } }
From source file:picocash.Picocash.java
@Override protected void initialize(String[] arg0) { ServiceDiscover.getAll(IPicocashPersistenceManager.class); Services.setSelectedPersistenceMan(ServiceDiscover.getSingleton(IPicocashPersistenceManager.class)); Services.getSelectedPersistenceMan().setDatabaseName("test.mmoc"); try {/*from w ww. ja v a 2 s . c o m*/ Services.getSelectedPersistenceMan().initDB(); } catch (Exception ex) { log.fatal("Exception while restarting database:", ex); exit(); } PicocashIcons.init(); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); addExitListener(new ExitListener() { @Override public boolean canExit(EventObject event) { if (changesAvailable) { int retValue = JOptionPane.showConfirmDialog(getMainFrame(), "Das sollte der Title sein", "und die Message", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (retValue == JOptionPane.OK_OPTION) { save(); } return retValue == JOptionPane.OK_OPTION || retValue == JOptionPane.CANCEL_OPTION; } return true; } @Override public void willExit(EventObject event) { Services.getSelectedPersistenceMan().close(); } }); super.initialize(arg0); }
From source file:pl.edu.icm.visnow.system.main.VisNow.java
public static void main(final String[] args) { /*// w w w . j a va 2s .co m * try { for (javax.swing.UIManager.LookAndFeelInfo info : * javax.swing.UIManager.getInstalledLookAndFeels()) { if * ("Nimbus".equals(info.getName())) { * javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } * } catch (ClassNotFoundException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } catch (InstantiationException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } catch (IllegalAccessException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { * java.util.logging.LOGGER.getLogger(VisNow.class.getName()).log(java.util.logging.Level.SEVERE, * null, ex); } */ EventQueue.invokeLater(new Runnable() { @Override public void run() { for (int i = 0; i < args.length; i++) { if (args[i].equals("-debug")) { debug = true; } if (args[i].equals("-substancedebug")) { substancedebug = true; } if (args[i].equals("-easy")) { libraryLevel = SIMPLE_LIBRARY; VERSION = VERSION_BASE + "-Simple"; allowGUISwitch = false; } if (args[i].equals("-full")) { guiLevel = EXPERT_GUI; libraryLevel = FULL_LIBRARY; VERSION = VERSION_BASE + "-Pro"; } } Locale.setDefault(Locale.US); renderSplashFrame(0.1f, "Initializing logging..."); //TODO: test it see #initConfigDir // initConfigDir(); initLogging(); startupInfo(); renderSplashFrame(0.2f, "Initializing Java3D..."); initJava3D(); if (substancedebug) { try { Class substance = Class.forName("org.jvnet.substance.SubstanceLookAndFeel"); Class selectedSkinClass; if (guiLevel == SIMPLE_GUI) { selectedSkinClass = Class.forName("org.jvnet.substance.skin.BusinessBlackSteelSkin"); } else { @SuppressWarnings("unchecked") Map<String, Object> skinInfoMap = (Map<String, Object>) substance .getMethod("getAllSkins").invoke(null); List<String> skinClassNameArray = new ArrayList<String>(); for (Object object : skinInfoMap.values()) { String cn = (String) object.getClass().getMethod("getClassName").invoke(object); LOGGER.info("Adding substance skin class: " + cn); skinClassNameArray.add(cn); } int skinClassIdx = 0; if (guiLevel == SIMPLE_GUI) { skinClassIdx = 2; } else { skinClassIdx = new Random().nextInt(skinClassNameArray.size()); } LOGGER.info("Selected skin: " + skinClassNameArray.get(skinClassIdx)); selectedSkinClass = Class.forName(skinClassNameArray.get(skinClassIdx)); } // selectedSkinClass =Class.forName("org.jvnet.substance.skin.BusinessBlackSteelSkin"); javax.swing.UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); Class skinClass = Class.forName("org.jvnet.substance.api.SubstanceSkin"); @SuppressWarnings("unchecked") Method m = substance.getMethod("setSkin", skinClass); m.invoke(null, selectedSkinClass.newInstance()); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); } catch (Exception ex) { LOGGER.error("Failed to set lf: " + ex.getMessage()); } } //resize borders from tabbedPane //TODO: needs refactoring - initPresentation, initL&F or sth like that try { UIManager.getDefaults().put("TabbedPane.contentBorderInsets", new Insets(4, 0, 0, 0)); } catch (Exception ex) { //this causes exception on MacOS X } try { visnow = new VisNow(); int argsCount = 0; for (int i = 0; i < args.length; i++) { if (!args[i].startsWith("-")) { argsCount++; } } String[] args2 = new String[argsCount]; int c = 0; for (int i = 0; i < args.length; i++) { if (!args[i].startsWith("-")) { args2[c++] = args[i]; } } visnow.init(args2); } catch (VNSystemException ex) { Displayer.display(1010101010, ex, null, "Initialization failed."); return; } visnow.initUserMessages(); } }); }
From source file:qic.Main.java
public static void reloadLookAndFeel() { if (Config.getBooleanProperty(Config.LOOK_AND_FEEL_DECORATED, false)) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); System.setProperty("sun.awt.noerasebackground", "true"); }/*from w w w .j ava 2 s . c o m*/ try { String lookAndFeel = Config.getPropety(Config.LOOK_AND_FEEL, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); if (lookAndFeel.startsWith("Substance")) { lookAndFeel = "org.pushingpixels.substance.api.skin." + lookAndFeel; } UIManager.setLookAndFeel(lookAndFeel); } catch (Exception e) { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception ex) { throw new RuntimeException(ex); } } for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } }