List of usage examples for javax.swing UIManager getLookAndFeel
public static LookAndFeel getLookAndFeel()
null
. From source file:de.nmichael.efa.Daten.java
public static void iniGUI() { if (Logger.isTraceOn(Logger.TT_CORE, 9) || Logger.isDebugLoggingActivatedByCommandLine()) { Logger.log(Logger.DEBUG, Logger.MSG_CORE_STARTUPINITIALIZATION, "iniGUI()"); }//from w w w . j av a2 s . c o m if (!isGuiAppl()) { return; } iniScreenSize(); // Look&Feel if (Daten.efaConfig != null) { // is null for applDRV try { if (Daten.efaConfig.getValueLookAndFeel().length() == 0) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { UIManager.setLookAndFeel(Daten.efaConfig.getValueLookAndFeel()); } } catch (Exception e) { Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTSETLOOKANDFEEL, International.getString("Konnte Look&Feel nicht setzen") + ": " + e.toString()); } } // Look&Feel specific Work-Arounds try { lookAndFeel = UIManager.getLookAndFeel().getClass().toString(); if (!lookAndFeel.endsWith("MetalLookAndFeel")) { // to make PopupMenu's work properly and not swallow the next MousePressed Event, see: // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753637 Dialog.getUiDefaults().put("PopupMenu.consumeEventOnClose", false); } Color buttonFocusColor = (Daten.efaConfig != null ? Daten.efaConfig.getLafButtonFocusColor() : null); if (buttonFocusColor != null) { // colored square around text of selected button Dialog.getUiDefaults().put("Button.focus", new ColorUIResource(buttonFocusColor)); } // allow users to press buttons by hitting ENTER (and not just SPACE) Dialog.getUiDefaults().put("Button.focusInputMap", new javax.swing.UIDefaults.LazyInputMap(new Object[] { "ENTER", "pressed", "released ENTER", "released", "SPACE", "pressed", "released SPACE", "released" })); } catch (Exception e) { Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTSETLOOKANDFEEL, "Failed to apply LookAndFeel Workarounds: " + e.toString()); } // Font Size if (applID == APPL_EFABH) { try { Dialog.setGlobalFontSize(Daten.efaConfig.getValueEfaDirekt_fontSize(), Daten.efaConfig.getValueEfaDirekt_fontStyle()); } catch (Exception e) { Logger.log(Logger.WARNING, Logger.MSG_WARN_CANTSETFONTSIZE, International.getString("Schriftgre konnte nicht gendert werden") + ": " + e.toString()); } } }
From source file:edu.ku.brc.ui.UIHelper.java
/** * @return a Triple containing the platform specific Focus Border, Empty Border and Focus Color *//* w w w . ja v a2 s. c om*/ public static Triple<Border, Border, Color> getFocusBorders(final Component comp) { Triple<Border, Border, Color> focusInfo = new Triple<Border, Border, Color>(); if (focusInfo.first == null) { if (UIHelper.isMacOS()) { focusInfo.first = new MacBtnBorder(); Insets fbInsets = focusInfo.first.getBorderInsets(comp); focusInfo.second = new EmptyBorder(fbInsets); } else { if (UIManager.getLookAndFeel() instanceof PlasticLookAndFeel) { focusInfo.third = PlasticLookAndFeel.getFocusColor(); } else { focusInfo.third = UIManager.getColor("Button.focus"); } if (focusInfo.third == null) // Shouldn't happen { focusInfo.third = Color.YELLOW; } focusInfo.first = new LineBorder(focusInfo.third, 1, true); focusInfo.second = new EmptyBorder(focusBorder.getBorderInsets(comp)); } } return focusInfo; }
From source file:ome.formats.importer.gui.FileQueueChooser.java
/** * Main for testing (debugging only)// ww w . j ava2s. c o m * * @param args * @throws Exception */ public static void main(String[] args) { String laf = UIManager.getSystemLookAndFeelClassName(); //laf = "ch.randelshofer.quaqua.QuaquaLookAndFeel"; //laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; //laf = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; //laf = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; //laf = "javax.swing.plaf.metal.MetalLookAndFeel"; System.err.println(laf); try { UIManager.setLookAndFeel(laf); } catch (Exception e) { System.err.println(laf + " not supported."); } System.err.println("laf: " + UIManager.getLookAndFeel()); FileQueueChooser c = new FileQueueChooser(null, null); JFrame f = new JFrame(); c.setMultiSelectionEnabled(true); f.getContentPane().add(c); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * @return true if look and feel is motif *///from w ww . ja v a 2 s . com public static boolean isMotif() { String laf = UIManager.getLookAndFeel().getClass().getName(); if (laf.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel")) return true; else return false; }
From source file:org.allcolor.yahp.converter.CClassLoader.java
/** * destroy the loader tree/*from ww w . j a v a 2s . c om*/ */ public static final void destroy() { if (CClassLoader.rootLoader == null) { return; } System.out.println("Destroying YAHP ClassLoader Tree"); CClassLoader.urlLoader = null; try { Field f = Class.forName("java.lang.Shutdown").getDeclaredField("hooks"); f.setAccessible(true); ArrayList l = (ArrayList) f.get(null); for (Iterator it = l.iterator(); it.hasNext();) { Object o = it.next(); if ((o != null) && (o.getClass().getClassLoader() != null) && (o.getClass().getClassLoader().getClass() == CClassLoader.class)) { it.remove(); } } } catch (Throwable ignore) { } try { Field f = Class.forName("java.lang.ApplicationShutdownHooks").getDeclaredField("hooks"); f.setAccessible(true); IdentityHashMap l = (IdentityHashMap) f.get(null); for (Iterator it = l.entrySet().iterator(); it.hasNext();) { Entry e = (Entry) it.next(); Thread o = (Thread) e.getKey(); if ((o != null) && (o.getClass().getClassLoader() != null) && (o.getClass().getClassLoader().getClass() == CClassLoader.class)) { it.remove(); continue; } o = (Thread) e.getValue(); if ((o != null) && (o.getClass().getClassLoader() != null) && (o.getClass().getClassLoader().getClass() == CClassLoader.class)) { it.remove(); } } } catch (Throwable ignore) { } try { if ((UIManager.getLookAndFeel() != null) && (UIManager.getLookAndFeel().getClass().getClassLoader() != null) && (UIManager.getLookAndFeel().getClass().getClassLoader().getClass() == CClassLoader.class)) { UIManager.setLookAndFeel((LookAndFeel) null); } Field f = UIManager.class.getDeclaredField("currentLAFState"); f.setAccessible(true); Object lafstate = f.get(null); if (lafstate != null) { Field fmultiUIDefaults = lafstate.getClass().getDeclaredField("multiUIDefaults"); fmultiUIDefaults.setAccessible(true); Object multiUIDefaults = fmultiUIDefaults.get(lafstate); Method clear = multiUIDefaults.getClass().getDeclaredMethod("clear", (Class[]) null); clear.setAccessible(true); clear.invoke(multiUIDefaults, (Object[]) null); Field tbl = lafstate.getClass().getDeclaredField("tables"); tbl.setAccessible(true); Hashtable[] tables = (Hashtable[]) tbl.get(lafstate); if (tables != null) { for (int i = 0; i < tables.length; i++) { Hashtable element = tables[i]; if (element != null) { element.clear(); } } } } } catch (Throwable ignore) { } try { Hashtable tb = UIManager.getDefaults(); Object cl = tb.get("ClassLoader"); if (cl.getClass() == CClassLoader.class) { tb.put("ClassLoader", CClassLoader.rootLoader.getParent()); } } catch (Throwable ignore) { } Method logFactoryRelease = null; try { logFactoryRelease = CClassLoader.rootLoader.loadClass("org.apache.commons.logging.LogFactory") .getMethod("release", new Class[] { ClassLoader.class }); } catch (final Throwable ignore) { } CClassLoader.rootLoader._destroy(logFactoryRelease); CClassLoader.mandatoryLoadersMap.clear(); CClassLoader.rootLoader = null; // deregister any sql driver loaded try { final List deregisterList = new ArrayList(); for (final Enumeration it = DriverManager.getDrivers(); it.hasMoreElements();) { final Driver d = (Driver) it.nextElement(); if ((d != null) && (d.getClass().getClassLoader() != null) && (d.getClass().getClassLoader().getClass() == CClassLoader.class)) { deregisterList.add(d); } } for (int i = 0; i < deregisterList.size(); i++) { final Driver driver = (Driver) deregisterList.get(i); DriverManager.deregisterDriver(driver); } } catch (final Throwable ignore) { } // stop dandling thread created with this classloader // tested only on sun jdk ThreadGroup tg = Thread.currentThread().getThreadGroup(); while ((tg != null) && (tg.getParent() != null)) { tg = tg.getParent(); } List ltg = new ArrayList(); ltg.add(tg); CClassLoader.getThreadGroups(tg, ltg); for (int ii = 0; ii < ltg.size(); ii++) { try { final ThreadGroup g = (ThreadGroup) ltg.get(ii); final Field fthreads = ThreadGroup.class.getDeclaredField("threads"); fthreads.setAccessible(true); final List toStop = new ArrayList(); Object threads[] = null; if (fthreads.getType() == Vector.class) { // in gnu classpath threads = ((Vector) fthreads.get(g)).toArray(); } else { // sun threads = (Object[]) fthreads.get(g); } for (int i = 0; i < threads.length; i++) { if (threads[i] == null) { continue; } if ((threads[i] != null) && (((Thread) threads[i]).getContextClassLoader() != null) && (((Thread) threads[i]).getContextClassLoader().getClass() == CClassLoader.class)) { ((Thread) threads[i]).setContextClassLoader(null); } if ((threads[i] != null) && (threads[i].getClass().getClassLoader() != null) && (threads[i].getClass().getClassLoader().getClass() == CClassLoader.class)) { toStop.add((Thread) threads[i]); } // remove any object in threadLocal referring an object // loaded // by this classloader tree try { final Field fthreadLocals = Thread.class.getDeclaredField("threadLocals"); fthreadLocals.setAccessible(true); final Object threadLocals = fthreadLocals.get(threads[i]); if (threadLocals != null) { final Field ftable = threadLocals.getClass().getDeclaredField("table"); ftable.setAccessible(true); final Object table[] = (Object[]) ftable.get(threadLocals); for (int kk = 0; kk < table.length; kk++) { final Object element = table[kk]; if (element != null) { final Field fvalue = element.getClass().getDeclaredField("value"); fvalue.setAccessible(true); final Object value = fvalue.get(element); if ((value != null) && (value.getClass().getClassLoader() != null) && (value .getClass().getClassLoader().getClass() == CClassLoader.class)) { fvalue.set(element, null); } if (value instanceof Map) { clearMap((Map) value); } else if (value instanceof List) { clearList((List) value); } else if (value instanceof Set) { clearSet((Set) value); } else if (value instanceof Object[]) { clearArray((Object[]) value); } fvalue.setAccessible(false); } } ftable.setAccessible(false); } fthreadLocals.setAccessible(false); } catch (final Throwable ignore) { ignore.printStackTrace(); } // remove any object in threadLocal referring an object // loaded // by this classloader tree try { final Field fthreadLocals = Thread.class.getDeclaredField("inheritableThreadLocals"); fthreadLocals.setAccessible(true); final Object threadLocals = fthreadLocals.get(threads[i]); if (threadLocals != null) { final Field ftable = threadLocals.getClass().getDeclaredField("table"); ftable.setAccessible(true); final Object table[] = (Object[]) ftable.get(threadLocals); for (int kk = 0; kk < table.length; kk++) { final Object element = table[kk]; if (element != null) { final Field fvalue = element.getClass().getDeclaredField("value"); fvalue.setAccessible(true); final Object value = fvalue.get(element); if ((value != null) && (value.getClass().getClassLoader() != null) && (value .getClass().getClassLoader().getClass() == CClassLoader.class)) { fvalue.set(element, null); } if (value instanceof Map) { clearMap((Map) value); } else if (value instanceof List) { clearList((List) value); } else if (value instanceof Set) { clearSet((Set) value); } else if (value instanceof Object[]) { clearArray((Object[]) value); } fvalue.setAccessible(false); } } ftable.setAccessible(false); } fthreadLocals.setAccessible(false); } catch (final Throwable ignore) { ignore.printStackTrace(); } // remove any protection domain referring this loader tree try { final Field finheritedAccessControlContext = Thread.class .getDeclaredField("inheritedAccessControlContext"); finheritedAccessControlContext.setAccessible(true); final Object inheritedAccessControlContext = finheritedAccessControlContext.get(threads[i]); if (inheritedAccessControlContext != null) { final Field fcontext = AccessControlContext.class.getDeclaredField("context"); fcontext.setAccessible(true); final Object context[] = (Object[]) fcontext.get(inheritedAccessControlContext); if (context != null) { for (int k = 0; k < context.length; k++) { if (context[k] == null) continue; final Field fclassloader = ProtectionDomain.class .getDeclaredField("classloader"); fclassloader.setAccessible(true); final Object classloader = fclassloader.get(context[k]); if ((classloader != null) && (classloader.getClass() == CClassLoader.class)) { context[k] = null; } fclassloader.setAccessible(false); } } fcontext.setAccessible(false); } finheritedAccessControlContext.setAccessible(false); } catch (final Throwable ignore) { ignore.printStackTrace(); } } fthreads.setAccessible(false); for (int i = 0; i < toStop.size(); i++) { try { final Thread t = (Thread) toStop.get(i); final Method stop = t.getClass().getMethod("stop", (Class[]) null); stop.invoke(t, (Object[]) null); } catch (final Throwable ignore) { } } } catch (final Throwable ignore) { } } try { CThreadContext.destroy(); } catch (Throwable ignore) { } System.runFinalization(); System.gc(); Introspector.flushCaches(); System.out.println("Destroying YAHP ClassLoader Tree : done"); }
From source file:org.domainmath.gui.MainFrame.java
public void deleteText() { RSyntaxTextArea textArea = commandArea; boolean beep = true; if ((textArea != null) && (textArea.isEditable())) { try {/* w w w .java 2 s . com*/ Document doc = textArea.getDocument(); Caret caret = textArea.getCaret(); int dot = caret.getDot(); int mark = caret.getMark(); if (dot != mark) { doc.remove(Math.min(dot, mark), Math.abs(dot - mark)); beep = false; } else if (dot < doc.getLength()) { int delChars = 1; if (dot < doc.getLength() - 1) { String dotChars = doc.getText(dot, 2); char c0 = dotChars.charAt(0); char c1 = dotChars.charAt(1); if (c0 >= '\uD800' && c0 <= '\uDBFF' && c1 >= '\uDC00' && c1 <= '\uDFFF') { delChars = 2; } } doc.remove(dot, delChars); beep = false; } } catch (Exception bl) { } } if (beep) { UIManager.getLookAndFeel().provideErrorFeedback(textArea); } textArea.requestFocusInWindow(); }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * {@inheritDoc}/*from w w w.java 2s . c o m*/ */ public String getSystemModifierSpec() { String keyStrokeSpec = CompSystemConstants.MODIFIER_CONTROL; if (!(UIManager.getLookAndFeel().getID().equals(METAL_LAF_ID))) { if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == java.awt.Event.META_MASK) { keyStrokeSpec = CompSystemConstants.MODIFIER_META; } else if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == java.awt.Event.ALT_MASK) { keyStrokeSpec = CompSystemConstants.MODIFIER_ALT; } } return keyStrokeSpec; }
From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * {@inheritDoc}//from w w w.j av a 2 s .com */ public String getSystemModifierSpec() { String keyStrokeSpec = CompSystemConstants.MODIFIER_CONTROL; if (!(UIManager.getLookAndFeel().getID().equals(METAL_LAF_ID))) { if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == Event.META_MASK) { keyStrokeSpec = CompSystemConstants.MODIFIER_META; } else if (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() == Event.ALT_MASK) { keyStrokeSpec = CompSystemConstants.MODIFIER_ALT; } } return keyStrokeSpec; }
From source file:org.eclipse.wb.internal.swing.laf.ui.LafSelectionItem.java
public void lookAndFeelsListChanged() { LafInfo selectedLAF = LafSupport.getSelectedLAF(m_componentInfo); m_toolItem.setText(selectedLAF.getName()); AstEditor activeEditor = EditorState.getActiveJavaInfo().getEditor(); if (m_componentInfo.getEditor() == activeEditor) { try {/*from w ww . j a v a2s . c o m*/ boolean needRefresh = !selectedLAF.getClassName() .equals(UIManager.getLookAndFeel().getClass().getName()); update(); // refresh if getSelectedLAF() returns another LAF (in case of deleting the currently selected LAF) if (needRefresh) { m_componentInfo.getRoot().refresh(); } } catch (Throwable ex) { handleException(ex); } } }
From source file:org.eclipse.wb.internal.swing.preferences.laf.LafPreferencePage.java
public LafPreferencePage() { m_currentLookAndFeel = UIManager.getLookAndFeel(); m_defaultLAF = LafSupport.getDefaultLAF(); }