public void changeLAF(int iLAFIndex) { try { // Change LAF if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1; UIManager.setLookAndFeel( (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance()); // Update UI ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true); SwingUtilities.updateComponentTreeUI(this); SwingUtilities.updateComponentTreeUI(mnuMain); WindowManager.updateLookAndField(); // Store config try { Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG); prt.put("LAF", String.valueOf(iLAFIndex)); Global.storeHashtable(prt, Global.FILE_CONFIG); } catch (Exception e) { } } catch (Exception e) { e.printStackTrace(); MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE); } }
public MacRenderer() { renderer = new JLabel(); renderer.setOpaque(Preferences.getBoolean("jeti", "bmw", true)); renderer.setBackground(UIManager.getColor("Tree.selectionBackground")); renderer.setForeground(UIManager.getColor("Tree.textForeground")); renderer.setFont(UIManager.getFont("Tree.font")); }
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } new TabbedDialog(); }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Color color = UIUtil.getTableFocusCellBackground(); Component component; final Module module = value instanceof Module ? (Module) value : null; try { UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground()); component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (module != null) { setText( module.getName() + " (" + FileUtil.toSystemDependentName(module.getModuleFilePath()) + ")"); } if (component instanceof JLabel) { ((JLabel) component).setBorder(noFocusBorder); } } finally { UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color); } component.setEnabled(ProcessedModulesTable.this.isEnabled()); if (component instanceof JLabel) { final Icon icon = module != null ? ModuleType.get(module).getIcon() : null; JLabel label = (JLabel) component; label.setIcon(icon); label.setDisabledIcon(icon); } component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground()); return component; }
public static void main(String[] args) throws Exception { if (args.length > 0) { DATABASE_FILE = Paths.get(args[0]); } UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); launch(args); }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final Color color = UIUtil.getTableFocusCellBackground(); Component component; T t = (T) value; try { UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, table.getSelectionBackground()); component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); setText(t != null ? getItemText(t) : ""); if (component instanceof JLabel) { ((JLabel) component).setBorder(noFocusBorder); } } finally { UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color); } final MyTableModel model = (MyTableModel) table.getModel(); component.setEnabled( ElementsChooser.this.isEnabled() && (myColorUnmarkedElements ? model.isElementMarked(row) : true)); final ElementProperties properties = myElementToPropertiesMap.get(t); if (component instanceof JLabel) { final Icon icon = properties != null ? properties.getIcon() : t != null ? getItemIcon(t) : null; JLabel label = (JLabel) component; label.setIcon(icon); label.setDisabledIcon(icon); } component.setForeground( properties != null && properties.getColor() != null ? properties.getColor() : (isSelected ? table.getSelectionForeground() : table.getForeground())); return component; }
/** * Main method. Begins the GUI, and the rest of the program. * * @param args the command line arguments */ public static void main(String args[]) { // playSound(); try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { Logger.getLogger(mainForm.class.getName()).log(Level.SEVERE, null, ex); } // </editor-fold> /* Create and display the form */ EventQueue.invokeLater( new Runnable() { @Override public void run() { new mainForm().setVisible(true); } }); }
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.err.println("Look and feel not set."); } new gui(); }
/* * (non-Javadoc) * * @see javax.swing.JPanel#updateUI() */ @Override public void updateUI() { if (UIManager.get(getUIClassID()) != null) { setUI((BandControlPanelUI) UIManager.getUI(this)); } else { setUI(new BasicFlowBandControlPanelUI()); } }
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { String message = "ExceptionWhileSettingSystemLookAndFeel"; Logging.logger().log(java.util.logging.Level.WARNING, message, e); } start("World Wind - elevations demo", AppFrame.class); }
/** Sets current LAF. The method doesn't update component hierarchy. */ @Override public void setCurrentLookAndFeel(UIManager.LookAndFeelInfo lookAndFeelInfo) { if (findLaf(lookAndFeelInfo.getClassName()) == null) { LOG.error("unknown LookAndFeel : " + lookAndFeelInfo); return; } // Set L&F if (IdeaLookAndFeelInfo.CLASS_NAME.equals( lookAndFeelInfo.getClassName())) { // that is IDEA default LAF IdeaLaf laf = new IdeaLaf(); MetalLookAndFeel.setCurrentTheme(new IdeaBlueMetalTheme()); try { UIManager.setLookAndFeel(laf); } catch (Exception e) { Messages.showMessageDialog( IdeBundle.message( "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return; } } else if (DarculaLookAndFeelInfo.CLASS_NAME.equals(lookAndFeelInfo.getClassName())) { DarculaLaf laf = new DarculaLaf(); try { UIManager.setLookAndFeel(laf); JBColor.setDark(true); IconLoader.setUseDarkIcons(true); } catch (Exception e) { Messages.showMessageDialog( IdeBundle.message( "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return; } } else { // non default LAF try { LookAndFeel laf = ((LookAndFeel) Class.forName(lookAndFeelInfo.getClassName()).newInstance()); if (laf instanceof MetalLookAndFeel) { MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme()); } UIManager.setLookAndFeel(laf); } catch (Exception e) { Messages.showMessageDialog( IdeBundle.message( "error.cannot.set.look.and.feel", lookAndFeelInfo.getName(), e.getMessage()), CommonBundle.getErrorTitle(), Messages.getErrorIcon()); return; } } myCurrentLaf = ObjectUtils.chooseNotNull(findLaf(lookAndFeelInfo.getClassName()), lookAndFeelInfo); checkLookAndFeel(lookAndFeelInfo, false); }
private ActionMap getActionMap() { ActionMap actionMap = (ActionMap) UIManager.get("Grid.actionMap"); if (actionMap == null) { actionMap = createActionMap(); if (actionMap != null) { UIManager.put("Grid.actionMap", actionMap); } } return actionMap; }
@Override protected void installDefaults() { UIManager.put("TabbedPane.selected", Color.BLACK); UIManager.put("TabbedPane.tabsOverlapBorder", true); super.installDefaults(); tabInsets = new Insets(0, 0, 0, 0); contentBorderInsets = new Insets(0, 0, 0, 0); tabAreaInsets = new Insets(0, 0, 0, 0); selectedTabPadInsets = new Insets(0, 0, 0, 0); }
public MultiLabel(String str, int horizontalAlignment, int textAlignment, int verticalAlignment) { this.setForeground(UIManager.getColor("Label.foreground")); this.setBackground(UIManager.getColor("Label.background")); this.setFont(UIManager.getFont("Label.font")); setText(str); this.horizontalAlignment = horizontalAlignment; this.textAlignment = textAlignment; this.verticalAlignment = verticalAlignment; }
/** Invoked via reflection. */ LafManagerImpl() { myListenerList = new EventListenerList(); List<UIManager.LookAndFeelInfo> lafList = ContainerUtil.newArrayList(); if (SystemInfo.isMac) { if (Registry.is("ide.mac.yosemite.laf") && isIntelliJLafEnabled() && SystemInfo.isJavaVersionAtLeast("1.8")) { lafList.add(new UIManager.LookAndFeelInfo("Default", IntelliJLaf.class.getName())); } else { lafList.add( new UIManager.LookAndFeelInfo("Default", UIManager.getSystemLookAndFeelClassName())); } } else { if (isIntelliJLafEnabled()) { lafList.add(new IntelliJLookAndFeelInfo()); } else { lafList.add(new IdeaLookAndFeelInfo()); } for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { String name = laf.getName(); if (!"Metal".equalsIgnoreCase(name) && !"CDE/Motif".equalsIgnoreCase(name) && !"Nimbus".equalsIgnoreCase(name) && !"Windows Classic".equalsIgnoreCase(name) && !name.startsWith("JGoodies")) { lafList.add(laf); } } } lafList.add(new DarculaLookAndFeelInfo()); myLaFs = lafList.toArray(new UIManager.LookAndFeelInfo[lafList.size()]); if (!SystemInfo.isMac) { // do not sort LaFs on mac - the order is determined as Default, Darcula. // when we leave only system LaFs on other OSes, the order also should be determined as // Default, Darcula Arrays.sort( myLaFs, new Comparator<UIManager.LookAndFeelInfo>() { @Override public int compare(UIManager.LookAndFeelInfo obj1, UIManager.LookAndFeelInfo obj2) { String name1 = obj1.getName(); String name2 = obj2.getName(); return name1.compareToIgnoreCase(name2); } }); } myCurrentLaf = getDefaultLaf(); }
protected void installDefaults(JFileChooser fc) { installIcons(fc); installStrings(fc); usesSingleFilePane = UIManager.getBoolean("FileChooser.usesSingleFilePane"); readOnly = UIManager.getBoolean("FileChooser.readOnly"); TransferHandler th = fc.getTransferHandler(); if (th == null || th instanceof UIResource) { fc.setTransferHandler(defaultTransferHandler); } LookAndFeel.installProperty(fc, "opaque", Boolean.FALSE); }
/** PUBLIC: Open a browser on the profiles. */ public static void browseProfiles(List<Profile> profiles) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ProfileBrowser aProfileBrowserFrame; aProfileBrowserFrame = new ProfileBrowser(); aProfileBrowserFrame.setVisible(true); aProfileBrowserFrame.setProfiles(profiles); } catch (Throwable exception) { System.err.println("Exception occurred in main() of javax.swing.JPanel"); exception.printStackTrace(System.out); } }
public void launch() { try { long time = System.nanoTime(); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); monitor = new ProgressMonitor(); monitor.setMaximum(5); updateState(BootstrapState.UPDATE_CHECK); { CountDownLatch latch = new CountDownLatch(2); runTask(TaskBootstrapUpdateCheck.class, latch); runTask(TaskInstallerUpdateCheck.class, latch); latch.await(); } updateState(BootstrapState.LOAD_DEPENDENCIES); { runTask(TaskLoadDependencies.class); } updateState(BootstrapState.DOWNLOAD); { runTask(TaskDownload.class); } updateState(BootstrapState.SETUP_ENVIRONMENT); { runTask(TaskCheckJavaVersion.class); runTask(TaskBuildClasspath.class); } System.out.println( "Took " + ((System.nanoTime() - time) / 1000000f) + "ms to launch installer"); updateState(BootstrapState.START_INSTALLER); { runTask(TaskLaunchInstaller.class); } updateState(BootstrapState.FINISHED); } catch (BootstrapException ex) { handleException(ex); System.exit(2); } catch (Exception ex) { handleException(ex); System.exit(-1); } finally { monitor.close(); } }
private InputMap getInputMap(int condition) { if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { return (InputMap) UIManager.get("Grid.ancestorInputMap"); } else { return null; } }
@Override public String convertValueToText( Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { String s = super.convertValueToText(value, selected, expanded, leaf, row, hasFocus); String newProp = jEdit.getProperty(HIGHLIGHT_PROP); if (newProp == null || newProp.isEmpty()) return s; DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; while (node != null && !(node.getUserObject() instanceof HyperSearchOperationNode)) { node = (DefaultMutableTreeNode) node.getParent(); } if (node == null) return s; if (!newProp.equals(prop)) { prop = newProp; Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font"); styleTag = HtmlUtilities.style2html(prop, f); } SearchMatcher matcher = ((HyperSearchOperationNode) node.getUserObject()).getSearchMatcher(); int i = s.indexOf(": "); if (i > 0) i += 2; else i = 0; Match m; List<Integer> matches = new ArrayList<Integer>(); while ((m = matcher.nextMatch(s.substring(i), true, true, true, false)) != null) { matches.add(i + m.start); matches.add(i + m.end); i += m.end; } return HtmlUtilities.highlightString(s, styleTag, matches); }
@SuppressWarnings("HardCodedStringLiteral") private boolean togglePopup(KeyEvent e) { final KeyStroke stroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()); final Object action = ((InputMap) UIManager.get("ComboBox.ancestorInputMap")).get(stroke); if ("selectNext".equals(action)) { if (!isPopupShowing()) { return true; } else { return false; } } else if ("togglePopup".equals(action)) { if (isPopupShowing()) { closePopup(); } else { suggestCompletion(true, true); } return true; } else { final Keymap active = KeymapManager.getInstance().getActiveKeymap(); final String[] ids = active.getActionIds(stroke); if (ids.length > 0 && IdeActions.ACTION_CODE_COMPLETION.equals(ids[0])) { suggestCompletion(true, true); } } return false; }
public void actionPerformed(ActionEvent ae) { String cname = nameF.getText().trim(); int state = conditions[stateC.getSelectedIndex()]; try { if (isSpecialCase(cname)) { handleSpecialCase(cname, state); } else { JComponent comp = (JComponent) Class.forName(cname).newInstance(); ComponentUI cui = UIManager.getUI(comp); cui.installUI(comp); results.setText("Map entries for " + cname + ":\n\n"); if (inputB.isSelected()) { loadInputMap(comp.getInputMap(state), ""); results.append("\n"); } if (actionB.isSelected()) { loadActionMap(comp.getActionMap(), ""); results.append("\n"); } if (bindingB.isSelected()) { loadBindingMap(comp, state); } } } catch (ClassCastException cce) { results.setText(cname + " is not a subclass of JComponent."); } catch (ClassNotFoundException cnfe) { results.setText(cname + " was not found."); } catch (InstantiationException ie) { results.setText(cname + " could not be instantiated."); } catch (Exception e) { results.setText("Exception found:\n" + e); e.printStackTrace(); } }
@Override public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source == highlight) { String prop = jEdit.getProperty(HIGHLIGHT_PROP); Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font"); SyntaxStyle style = new StyleEditor( jEdit.getActiveView(), HtmlUtilities.parseHighlightStyle(prop, f), "hypersearch") .getStyle(); if (style != null) jEdit.setProperty(HIGHLIGHT_PROP, GUIUtilities.getStyleString(style)); updateHighlightStatus(); } else if (source == clear) { removeAllNodes(); } else if (source == multi) { multiStatus = !multiStatus; updateMultiStatus(); if (!multiStatus) { for (int i = resultTreeRoot.getChildCount() - 2; i >= 0; i--) { resultTreeModel.removeNodeFromParent((MutableTreeNode) resultTreeRoot.getChildAt(i)); } } } else if (source == stop) { jEdit.setTemporaryProperty("hyperSearch-stopButton", "true"); } }
private synchronized void dispose() { timer.stop(); UIManager.removePropertyChangeListener(this); synchronized (AnimationController.class) { AppContext.getAppContext().put(ANIMATION_CONTROLLER_KEY, null); } }
/** * Update the Look and Feel of the game * * @param lnf fully qualified look and feel class name */ private void changeLnF(String lnf) { try { UIManager.setLookAndFeel(lnf); SwingUtilities.updateComponentTreeUI(this); } catch (Exception e) { } }
public static void createAndShowGUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("@title@"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
@SuppressWarnings("OverridableMethodCallInConstructor") Notepad() { super(true); // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ignored) { } setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); // create the embedded JTextComponent editor = createEditor(); // Add this as a listener for undoable edits. editor.getDocument().addUndoableEditListener(undoHandler); // install the command table commands = new HashMap<Object, Action>(); Action[] actions = getActions(); for (Action a : actions) { commands.put(a.getValue(Action.NAME), a); } JScrollPane scroller = new JScrollPane(); JViewport port = scroller.getViewport(); port.add(editor); String vpFlag = getProperty("ViewportBackingStore"); if (vpFlag != null) { Boolean bs = Boolean.valueOf(vpFlag); port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE); } JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); panel.add("Center", scroller); add("Center", panel); add("South", createStatusbar()); }
@Override public String getAccessibleActionDescription(int i) { if (i == 0) { return UIManager.getString("AbstractButton.clickText"); } else { return null; } }
/** * Resets the UI property to a value from the current look and feel. * * @see JComponent#updateUI */ public void updateUI() { setUI((SliderUI) UIManager.getUI(this)); // The labels preferred size may be derived from the font // of the slider, so we must update the UI of the slider first, then // that of labels. This way when setSize is called the right // font is used. updateLabelUIs(); }
/** Switch to a new Look&Feel */ private void newLookAndFeel(String landf) { try { UIManager.setLookAndFeel(landf); SwingUtilities.updateComponentTreeUI(this); } catch (Exception e) { System.err.println(e); } }