List of usage examples for javax.swing UIManager get
public static Object get(Object key)
From source file:au.org.ala.delta.editor.DeltaEditor.java
private void updateFont(Font newFont) { FontUIResource fontResource = new FontUIResource(newFont); Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, fontResource); }/*w w w . j a v a2 s . c o m*/ } }
From source file:net.sf.jabref.JabRef.java
private void setLookAndFeel() { try {/* w w w . j a va 2 s. c o m*/ String lookFeel; String systemLnF = UIManager.getSystemLookAndFeelClassName(); if (Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL)) { // Use system Look & Feel by default lookFeel = systemLnF; } else { lookFeel = Globals.prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); } // At all cost, avoid ending up with the Metal look and feel: if ("javax.swing.plaf.metal.MetalLookAndFeel".equals(lookFeel)) { Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel(); Plastic3DLookAndFeel.setCurrentTheme(new SkyBluer()); com.jgoodies.looks.Options.setPopupDropShadowEnabled(true); UIManager.setLookAndFeel(lnf); } else { try { UIManager.setLookAndFeel(lookFeel); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { // specified look and feel does not exist on the classpath, so use system l&f UIManager.setLookAndFeel(systemLnF); // also set system l&f as default Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLnF); // notify the user JOptionPane.showMessageDialog(JabRef.jrf, Localization.lang( "Unable to find the requested Look & Feel and thus the default one is used."), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE); } } } catch (Exception e) { LOGGER.warn("Look and feel could not be set", e); } // In JabRef v2.8, we did it only on NON-Mac. Now, we try on all platforms boolean overrideDefaultFonts = Globals.prefs.getBoolean(JabRefPreferences.OVERRIDE_DEFAULT_FONTS); if (overrideDefaultFonts) { int fontSize = Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE); UIDefaults defaults = UIManager.getDefaults(); Enumeration<Object> keys = defaults.keys(); Double zoomLevel = null; for (Object key : Collections.list(keys)) { if ((key instanceof String) && ((String) key).endsWith(".font")) { FontUIResource font = (FontUIResource) UIManager.get(key); if (zoomLevel == null) { // zoomLevel not yet set, calculate it based on the first found font zoomLevel = (double) fontSize / (double) font.getSize(); } font = new FontUIResource(font.getName(), font.getStyle(), fontSize); defaults.put(key, font); } } if (zoomLevel != null) { GUIGlobals.zoomLevel = zoomLevel; } } }
From source file:com.sshtools.sshterm.SshTermSessionPanel.java
private SessionChannelClient createNewSession(boolean addEventListener) throws IOException { SessionChannelClient session = manager.openSession(); session.addEventListener(dataListener); // Add the callers event listener? if (eventListener != null) { session.addEventListener(eventListener); }/* w w w . j a v a 2 s .c o m*/ if (addEventListener) { session.addEventListener(new ChannelEventAdapter() { public void onChannelClose(Channel channel) { closeSession(); } }); } if (getCurrentConnectionProfile().getAllowAgentForwarding()) { if (!session.requestAgentForwarding()) { JOptionPane.showMessageDialog(SshTermSessionPanel.this, "The server failed to open an agent listener", "Allow Agent Forwarding", JOptionPane.OK_OPTION, (Icon) UIManager.get("OptionPane.informationIcon")); } } // Request a pseudo terminal if (getCurrentConnectionProfile().requiresPseudoTerminal()) { if (!session.requestPseudoTerminal(emulation)) { JOptionPane.showMessageDialog(SshTermSessionPanel.this, "The server refused to allocate a pseudo terminal!", "Request Pseudo Terminal", JOptionPane.OK_OPTION); } } return session; }
From source file:com.jtstand.swing.StatsPanel.java
public JFreeChart getChartDistribution(boolean horizontal) { // System.out.println("Min: " + minValue()); // System.out.println("Max: " + maxValue()); XYIntervalSeriesCollection datasetDistribution = createIntervalXYDatasetDistribution(horizontal); XYSeriesCollection dataset2 = createXYDatasetGauss(horizontal); // create the chart... NumberAxis xAxis = new NumberAxis(getValueString()); xAxis.setAutoRangeIncludesZero(false); // NumberAxis yAxis = new NumberAxis("Distribution"); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(true); //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer = new MyBarRenderer(); XYPlot plot = new XYPlot(datasetDistribution, xAxis, yAxis, renderer); plot.setOrientation(horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, isGrouping()); chart.setBackgroundPaint((Paint) UIManager.get("Panel.background")); // plot.setBackgroundPaint(Color.white); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); StandardXYItemLabelGenerator itemlabels = new StandardXYItemLabelGenerator(); renderer.setBaseItemLabelGenerator(itemlabels); renderer.setBaseItemLabelsVisible(true); plot.setDataset(1, dataset2);//from w w w .ja va2 s .c om plot.mapDatasetToRangeAxis(1, 1); // ValueAxis domainAxis = plot.getDomainAxis(); //domainAxis.setCategoryLabelPositions(horizontal?CategoryLabelPositions.STANDARD:CategoryLabelPositions.UP_90); ValueAxis axis2 = new NumberAxis("Gaussian"); plot.setRangeAxis(1, axis2); axis2.setVisible(false); final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); //renderer2.setShapesVisible(false); //renderer2.setSeriesVisibleInLegend(false); renderer2.setBaseSeriesVisibleInLegend(false); //renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setRenderer(1, renderer2); renderer.setUseYInterval(true); renderer.setBaseSeriesVisibleInLegend(false); /* coloring */ Color c; if (isMultipleCategorization()) { // TreeMap<String, Color> cmap = new TreeMap<String, Color>(); int i = 0; for (Iterator<String> it = catstats.keySet().iterator(); it.hasNext(); i++) { String groupName = it.next(); c = ChartCategories.getColor(i); for (int j = 0; j < datasetDistribution.getSeriesCount(); j++) { XYIntervalSeries s = datasetDistribution.getSeries(j); if (s.getKey().equals(groupName)) { GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker()); renderer.setSeriesPaint(j, gp); } } for (int j = 0; j < dataset2.getSeriesCount(); j++) { XYSeries s = dataset2.getSeries(j); if (s.getKey().equals(groupName)) { renderer2.setSeriesPaint(j, c); renderer2.setSeriesShapesVisible(j, false); renderer2.setSeriesStroke(j, myStroke); } } } c = Color.black; } else { c = ChartCategories.getColor(0); GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker()); renderer.setSeriesPaint(0, gp); } renderer2.setSeriesPaint(0, c); renderer2.setSeriesShapesVisible(0, false); renderer2.setSeriesStroke(0, myStroke); placeLimitMarkers(plot, false); // renderer.setAutoPopulateSeriesOutlinePaint(true); // renderer.setBaseOutlinePaint(Color.black); // renderer.setSeriesOutlinePaint(0, Color.black, true); // renderer.setDrawBarOutline(true); renderer.setHighlightedItem(0, 0); yAxis.setAutoRange(false); yAxis.setAutoRange(true); xAxis.setRange(leftValue(0), rightValue(numberOfCategories - 1)); chart.setTextAntiAlias(false); return chart; }
From source file:com.t3.client.TabletopTool.java
public static void main(String[] args) { if (MAC_OS_X) { // On OSX the menu bar at the top of the screen can be enabled at any time, but the // title (ie. name of the application) has to be set before the GUI is initialized (by // creating a frame, loading a splash screen, etc). So we do it here. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About TabletopTool..."); System.setProperty("apple.awt.brushMetalLook", "true"); }// www .ja v a 2s . c om // Before anything else, create a place to store all the data try { AppUtil.getAppHome(); } catch (Throwable t) { t.printStackTrace(); // Create an empty frame so there's something to click on if the dialog goes in the background JFrame frame = new JFrame(); SwingUtil.centerOnScreen(frame); frame.setVisible(true); String errorCreatingDir = "Error creating data directory"; log.error(errorCreatingDir, t); JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE); System.exit(1); } verifyJavaVersion(); configureLogging(); // System properties System.setProperty("swing.aatext", "true"); // System.setProperty("sun.java2d.opengl", "true"); final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion()); splash.showSplashScreen(); // Protocol handlers // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?) RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory(); factory.registerProtocol("asset", new AssetURLStreamHandler()); URL.setURLStreamHandlerFactory(factory); MacroEngine.initialize(); configureJide(); //TODO find out how to not call this twice without destroying error windows final Toolkit tk = Toolkit.getDefaultToolkit(); tk.getSystemEventQueue().push(new T3EventQueue()); // LAF try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); configureJide(); if (WINDOWS) LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); else LookAndFeelFactory.installJideExtension(); if (MAC_OS_X) { macOSXicon(); } menuBar = new AppMenuBar(); } catch (Exception e) { TabletopTool.showError("msg.error.lafSetup", e); System.exit(1); } /** * This is a tweak that makes the Chinese version work better. * <p> * Consider reviewing <a * href="http://en.wikipedia.org/wiki/CJK_characters" * >http://en.wikipedia.org/wiki/CJK_characters</a> before making * changes. And http://www.scarfboy.com/coding/unicode-tool is also a * really cool site. */ if (Locale.CHINA.equals(Locale.getDefault())) { // The following font name appears to be "Sim Sun". It can be downloaded // from here: http://fr.cooltext.com/Fonts-Unicode-Chinese Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12); FontUIResource fontRes = new FontUIResource(f); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fontRes); } } // Draw frame contents on resize tk.setDynamicLayout(true); EventQueue.invokeLater(new Runnable() { @Override public void run() { initialize(); EventQueue.invokeLater(new Runnable() { @Override public void run() { clientFrame.setVisible(true); splash.hideSplashScreen(); EventQueue.invokeLater(new Runnable() { @Override public void run() { postInitialize(); } }); } }); } }); // new Thread(new HeapSpy()).start(); }
From source file:net.rptools.maptool.client.MapTool.java
public static void main(String[] args) { if (MAC_OS_X) { // On OSX the menu bar at the top of the screen can be enabled at any time, but the // title (ie. name of the application) has to be set before the GUI is initialized (by // creating a frame, loading a splash screen, etc). So we do it here. System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "About MapTool..."); System.setProperty("apple.awt.brushMetalLook", "true"); }//from w w w.ja v a 2 s. c om // Before anything else, create a place to store all the data try { AppUtil.getAppHome(); } catch (Throwable t) { t.printStackTrace(); // Create an empty frame so there's something to click on if the dialog goes in the background JFrame frame = new JFrame(); SwingUtil.centerOnScreen(frame); frame.setVisible(true); String errorCreatingDir = "Error creating data directory"; log.error(errorCreatingDir, t); JOptionPane.showMessageDialog(frame, t.getMessage(), errorCreatingDir, JOptionPane.ERROR_MESSAGE); System.exit(1); } verifyJavaVersion(); configureLogging(); // System properties System.setProperty("swing.aatext", "true"); // System.setProperty("sun.java2d.opengl", "true"); final SplashScreen splash = new SplashScreen(SPLASH_IMAGE, getVersion()); splash.showSplashScreen(); // Protocol handlers // cp:// is registered by the RPTURLStreamHandlerFactory constructor (why?) RPTURLStreamHandlerFactory factory = new RPTURLStreamHandlerFactory(); factory.registerProtocol("asset", new AssetURLStreamHandler()); URL.setURLStreamHandlerFactory(factory); final Toolkit tk = Toolkit.getDefaultToolkit(); tk.getSystemEventQueue().push(new MapToolEventQueue()); // LAF try { // If we are running under Mac OS X then save native menu bar look & feel components // Note the order of creation for the AppMenuBar, this specific chronology // allows the system to set up system defaults before we go and modify things. // That is, please don't move these lines around unless you test the result on windows and mac String lafname; if (MAC_OS_X) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); menuBar = new AppMenuBar(); lafname = "net.rptools.maptool.client.TinyLookAndFeelMac"; UIManager.setLookAndFeel(lafname); macOSXicon(); } // If running on Windows based OS, CJK font is broken when using TinyLAF. // else if (WINDOWS) { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // menuBar = new AppMenuBar(); // } else { lafname = "de.muntjak.tinylookandfeel.TinyLookAndFeel"; UIManager.setLookAndFeel(lafname); menuBar = new AppMenuBar(); } // After the TinyLAF library is initialized, look to see if there is a Default.theme // in our AppHome directory and load it if there is. Unfortunately, changing the // search path for the default theme requires subclassing TinyLAF and because // we have both the original and a Mac version that gets cumbersome. (Really // the Mac version should use the default and then install the keystroke differences // but what we have works and I'm loathe to go playing with it at 1.3b87 -- yes, 87!) File f = AppUtil.getAppHome("config"); if (f.exists()) { File f2 = new File(f, "Default.theme"); if (f2.exists()) { if (Theme.loadTheme(f2)) { // re-install the Tiny Look and Feel UIManager.setLookAndFeel(lafname); // Update the ComponentUIs for all Components. This // needs to be invoked for all windows. //SwingUtilities.updateComponentTreeUI(rootComponent); } } } com.jidesoft.utils.Lm.verifyLicense("Trevor Croft", "rptools", "5MfIVe:WXJBDrToeLWPhMv3kI2s3VFo"); LookAndFeelFactory.addUIDefaultsCustomizer(new LookAndFeelFactory.UIDefaultsCustomizer() { public void customize(UIDefaults defaults) { // Remove red border around menus defaults.put("PopupMenu.foreground", Color.lightGray); } }); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); /**************************************************************************** * For TinyLAF 1.3.04 this is how the color was changed for a * button. */ // Theme.buttonPressedColor[Theme.style] = new ColorReference(Color.gray); /**************************************************************************** * And this is how it's done in TinyLAF 1.4.0 (no idea about the * intervening versions). */ Theme.buttonPressedColor = new SBReference(Color.GRAY, 0, -6, SBReference.SUB3_COLOR); configureJide(); } catch (Exception e) { MapTool.showError("msg.error.lafSetup", e); System.exit(1); } /** * This is a tweak that makes the Chinese version work better. * <p> * Consider reviewing <a * href="http://en.wikipedia.org/wiki/CJK_characters" * >http://en.wikipedia.org/wiki/CJK_characters</a> before making * changes. And http://www.scarfboy.com/coding/unicode-tool is also a * really cool site. */ if (Locale.CHINA.equals(Locale.getDefault())) { // The following font name appears to be "Sim Sun". It can be downloaded // from here: http://fr.cooltext.com/Fonts-Unicode-Chinese Font f = new Font("\u65B0\u5B8B\u4F53", Font.PLAIN, 12); FontUIResource fontRes = new FontUIResource(f); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) UIManager.put(key, fontRes); } } // Draw frame contents on resize tk.setDynamicLayout(true); EventQueue.invokeLater(new Runnable() { public void run() { initialize(); EventQueue.invokeLater(new Runnable() { public void run() { clientFrame.setVisible(true); splash.hideSplashScreen(); EventQueue.invokeLater(new Runnable() { public void run() { postInitialize(); } }); } }); } }); // new Thread(new HeapSpy()).start(); }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
private SessionChannelClient createNewSession(boolean addEventListener) throws IOException { SessionChannelClient session = ssh.openSessionChannel(); session.addEventListener(dataListener); if (addEventListener) { session.addEventListener(new ChannelEventAdapter() { public void onChannelClose(Channel channel) { if (ssh != null) { if (performVerifiedDisconnect(false)) { ssh.disconnect(); }// w ww .ja v a 2 s .c om } } }); } if (getCurrentConnectionProfile().getApplicationPropertyBoolean(PREF_X11_FORWARDING, com.sshtools.sshterm.XForwardingTab.XON_DEFAULT)) { int displayNumber = getCurrentConnectionProfile() .getApplicationPropertyInt(SshTerminalPanel.PREF_X11_FORWARDING_LOCAL_DISPLAY, 0); String d = getCurrentConnectionProfile().getApplicationProperty(PREF_X11_FORWARDING_LOCAL_DISPLAY, ""); if (d.equals("")) { d = ConfigurationLoader.checkAndGetProperty("sshterm.xForwarding.localDisplay", null); } XDisplay display; try { display = (d == null) ? new XDisplay() : new XDisplay(d); } catch (IllegalArgumentException e) { display = new XDisplay("localhost:0.0"); } X11Util.X11Cookie cookie = X11Util.getCookie(display); if (!session.requestX11Forwarding(displayNumber, cookie)) { JOptionPane.showMessageDialog(SshTerminalPanel.this, "The server refused to start start X11 forwarding!", "Start X11 Forwarding", JOptionPane.OK_OPTION); } ssh.getForwardingClient().enableX11Forwarding(display, cookie); } if (getCurrentConnectionProfile().getAllowAgentForwarding()) { if (!session.requestAgentForwarding()) { JOptionPane.showMessageDialog(SshTerminalPanel.this, "The server failed to open an agent listener", "Allow Agent Forwarding", JOptionPane.OK_OPTION, (Icon) UIManager.get("OptionPane.informationIcon")); } } // Request a pseudo terminal if (getCurrentConnectionProfile().requiresPseudoTerminal()) { if (!session.requestPseudoTerminal(emulation)) { JOptionPane.showMessageDialog(SshTerminalPanel.this, "The server refused to allocate a pseudo terminal!", "Request Pseudo Terminal", JOptionPane.OK_OPTION); } } return session; }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
/** * @param args the command line arguments * @throws Exception//from www . j ava2 s . c o m */ public static void main(String args[]) throws Exception { QLog.initial(args, 3); Locale.setDefault(Locales.getInstance().getLangCurrent()); //? ? , ? final Thread tPager = new Thread(() -> { FAbout.loadVersionSt(); String result = ""; try { final URL url = new URL(PAGER_URL + "/qskyapi/getpagerdata?qsysver=" + FAbout.VERSION_); final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Java bot"); conn.connect(); final int code = conn.getResponseCode(); if (code == 200) { try (BufferedReader in = new BufferedReader( new InputStreamReader(conn.getInputStream(), "utf8"))) { String inputLine; while ((inputLine = in.readLine()) != null) { result += inputLine; } } } conn.disconnect(); } catch (Exception e) { System.err.println("Pager not enabled. " + e); return; } final Gson gson = GsonPool.getInstance().borrowGson(); try { final Answer answer = gson.fromJson(result, Answer.class); forPager = answer; if (answer.getData().size() > 0) { forPager.start(); } } catch (Exception e) { System.err.println("Pager not enabled but working. " + e); } finally { GsonPool.getInstance().returnGson(gson); } }); tPager.setDaemon(true); tPager.start(); Uses.startSplash(); // plugins Uses.loadPlugins("./plugins/"); // ?. FLogin.logining(QUserList.getInstance(), null, true, 3, FLogin.LEVEL_ADMIN); Uses.showSplash(); java.awt.EventQueue.invokeLater(() -> { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager .getInstalledLookAndFeels()) { System.out.println(info.getName()); /*Metal Nimbus CDE/Motif Windows Windows Classic //GTK+*/ if ("Windows".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } if ("/".equals(File.separator)) { final FontUIResource f = new FontUIResource(new Font("Serif", Font.PLAIN, 10)); final Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); final Object value = UIManager.get(key); if (value instanceof FontUIResource) { final FontUIResource orig = (FontUIResource) value; final Font font1 = new Font(f.getFontName(), orig.getStyle(), f.getSize()); UIManager.put(key, new FontUIResource(font1)); } } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } try { form = new FAdmin(); if (forPager != null) { forPager.showData(false); } else { form.panelPager.setVisible(false); } form.setVisible(true); } catch (Exception ex) { QLog.l().logger().error(" ? ?? . ", ex); } finally { Uses.closeSplash(); } }); }
From source file:com.pironet.tda.TDA.java
/** * set the ui SANS_SERIF for all tda stuff (needs to be done for create of objects) * * @param f the SANS_SERIF to user//from w w w . j a va2 s.com */ private void setUIFont(FontUIResource f) { // // sets the default SANS_SERIF for all Swing components. // ex. // setUIFont (new javax.swing.plaf.FontUIResource("Serif",Font.ITALIC,12)); // Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, f); } } }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Set up the GUI to launch contextual help for the next widget that is * clicked on by the user//from w w w. ja v a 2s . co m */ @Action public void btnContextHelp() { // Get the HelpOnItemCursor. This is installed by the java help library. Cursor onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor"); getMainFrame().setCursor(onItemCursor); // display the (default) glasspane. This is used to intercept mouse // events and determine how to handle help // for the component that has been clicked on. See the lister defined // for the default glasspane in the // startup() method getMainFrame().getGlassPane().setVisible(true); }