List of usage examples for javax.swing UIManager getSystemLookAndFeelClassName
public static String getSystemLookAndFeelClassName()
LookAndFeel
class that implements the native system look and feel if there is one, otherwise the name of the default cross platform LookAndFeel
class. From source file:brainflow.app.toplevel.BrainFlow.java
private void initLookAndFeel() { try {//from ww w . j a v a 2 s . c om String osname = System.getProperty("os.name"); System.out.println("os name is : " + osname); if (osname.toUpperCase().contains("WINDOWS")) { log.info("windows"); com.jidesoft.plaf.LookAndFeelFactory.installDefaultLookAndFeel(); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.OFFICE2007_STYLE); //((Office2003Painter) Office2003Painter.getInstance()).setColorName("Metallic"); //UIManager.setLookAndFeel(new NimbusLookAndFeel()); //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); } else if (osname.toUpperCase().contains("LINUX")) { //UIManager.setLookAndFeel(new com.jgoodies.looks.plastic.Plastic3DLookAndFeel()); UIManager.setLookAndFeel(new NimbusLookAndFeel()); //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); } else if (osname.toUpperCase().contains("MAC")) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "BrainFlow"); System.setProperty("com.apple.macos.useScreenMenuBar", "true"); System.setProperty("apple.awt.graphics.UseQuartz", "true"); System.setProperty("apple.awt.brushMetalLook", "true"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //UIManager.setLookAndFeel(new NimbusLookAndFeel()); //LookAndFeelFactory.installJideExtension(LookAndFeelFactory.XERTO_STYLE); LookAndFeelFactory.installJideExtension(1); } } catch (UnsupportedLookAndFeelException e) { log.severe("could not createSource look and feel"); } catch (Throwable ex) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); LookAndFeelFactory.installJideExtension(); } catch (Throwable ex2) { log.severe("could not createSource look and feel"); throw new RuntimeException("failed to initialize look and feel", ex2); } } }
From source file:com.freedomotic.jfrontend.MainWindow.java
private void setWindowedMode() { this.setVisible(false); this.dispose(); this.setUndecorated(false); this.setResizable(true); try {/*w ww .j a v a 2 s. co m*/ this.getContentPane().removeAll(); } catch (Exception e) { LOG.error("Set window mode exception {}", e.getMessage()); } try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { LOG.error("Cannot find system look&feel\n", ex.toString()); } catch (InstantiationException ex) { LOG.error("Cannot instantiate system look&feel\n", ex.toString()); } catch (IllegalAccessException ex) { LOG.error("Illegal access to system look&feel\n", ex.toString()); } catch (UnsupportedLookAndFeelException ex) { LOG.error("Unsupported system look&feel\n", ex.toString()); } setDefaultLookAndFeelDecorated(true); initComponents(); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setLayout(new BorderLayout()); desktopPane = new JDesktopPane(); lstClients = new PluginJList(this); frameClient = new JInternalFrame(); frameClient.setLayout(new BorderLayout()); JScrollPane clientScroll = new JScrollPane(lstClients); frameClient.add(clientScroll, BorderLayout.CENTER); frameClient.setTitle(i18n.msg("loaded_plugins")); frameClient.setResizable(true); frameClient.setMaximizable(true); frameMap = new JInternalFrame(); setMapTitle(""); frameMap.setMaximizable(true); frameMap.setResizable(true); desktopPane.add(frameMap); desktopPane.add(frameClient); frameClient.moveToFront(); frameClient.setVisible(auth.isPermitted("plugins:read")); desktopPane.moveToFront(this); this.getContentPane().add(desktopPane); try { frameClient.setSelected(true); } catch (PropertyVetoException ex) { LOG.error(Freedomotic.getStackTraceInfo(ex)); } EnvironmentLogic previousEnv = api.environments().findAll().get(0); if (drawer != null) { previousEnv = drawer.getCurrEnv(); } initializeRenderer(previousEnv); drawer = master.createRenderer(previousEnv); if (drawer != null) { setDrawer(drawer); ResourcesManager.clear(); } else { LOG.error("Unable to create a drawer to render the environment on the desktop frontend"); } this.setTitle("Freedomotic " + Info.getLicense() + " - www.freedomotic.com"); this.setSize(1100, 700); centerFrame(this); frameClient.moveToFront(); frameMap.moveToFront(); optimizeFramesDimension(); drawer.repaint(); lstClients.update(); frameClient.setVisible(auth.isPermitted("plugins:read")); frameMap.setVisible(auth.isPermitted("environments:read")); setEditMode(false); this.setVisible(true); isFullscreen = false; }
From source file:de.ailis.xadrian.utils.SwingUtils.java
/** * Prepares the theme. The theme can be overridden with the environment * variable XADRIAN_SYSTHEME. The default is the system look and feel. */// w ww .j a v a 2s.c o m public static void prepareTheme() { final String theme = Config.getInstance().getTheme(); if (theme != null) { try { UIManager.setLookAndFeel(theme); installGtkPopupBugWorkaround(); return; } catch (final Exception e) { LOG.warn("Can't set theme " + theme + ". Falling back to system look-and-feel. Reason: " + e, e); } } try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); installGtkPopupBugWorkaround(); } catch (final Exception e) { LOG.warn("Can't set system look-and-feel. " + "Falling back to default. Reason: " + e, e); } }
From source file:bdsup2sub.BDSup2Sub.java
private static void setupGUI() { try {// w ww.j a va 2s . c o m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // ignore } if (PlatformUtils.isLinux()) { applyGtkThemeWorkarounds(); } if (PlatformUtils.isMac()) { System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", Constants.APP_NAME); } }
From source file:com.imag.nespros.gui.plugin.GraphEditor.java
/** * create an instance of a simple graph with popup controls to create a * graph./*ww w .ja v a 2s . c o m*/ * */ private GraphEditor(Simulation s) { simu = s; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex); } // create a simple graph for the demo graph = Topology.getInstance().getGraph(); this.layout = new StaticLayout<Device, ComLink>(graph, new Transformer<Device, Point2D>() { @Override public Point2D transform(Device v) { Point2D p = new Point2D.Double(v.getX(), v.getY()); return p; } }, new Dimension(600, 600)); vv = new VisualizationViewer<Device, ComLink>(layout); vv.setBackground(Color.white); final Transformer<Device, String> vertexLabelTransformer = new Transformer<Device, String>() { @Override public String transform(Device d) { return d.getDeviceName(); } }; //vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Device, String>getInstance( // LazyMap.<Device, String>decorate(new HashMap<Device, String>(), new ToStringLabeller<Device>()))); vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<ComLink, String>() { @Override public String transform(ComLink link) { return (link.getID() + ", " + link.getLatency()); } }); //float dash[] = {0.1f}; //final Stroke edgeStroke = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 1.0f); final Stroke edgeStroke = new BasicStroke(3.0f); final Transformer<ComLink, Stroke> edgeStrokeTransformer = new Transformer<ComLink, Stroke>() { @Override public Stroke transform(ComLink l) { return edgeStroke; } }; Transformer<ComLink, Paint> edgePaint = new Transformer<ComLink, Paint>() { public Paint transform(ComLink l) { if (l.isDown()) { return Color.RED; } else { return Color.BLACK; } } }; vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderContext().setVertexIconTransformer(new CustomVertexIconTransformer()); vv.getRenderContext().setVertexShapeTransformer(new CustomVertexShapeTransformer()); vv.addPreRenderPaintable(new VisualizationViewer.Paintable() { @Override public void paint(Graphics grphcs) { for (Device d : Topology.getInstance().getGraph().getVertices()) { int size = d.getOperators().size(); MyLayeredIcon icon = d.getIcon(); //if(icon == null) continue; icon.removeAll(); if (size > 0) { // the vertex icon // Let's create the annotation image to be added to icon.. BufferedImage image = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); g.setColor(Color.ORANGE); g.fillOval(0, 0, 20, 20); g.setColor(Color.BLACK); g.drawString(size + "", 5, 13); g.dispose(); ImageIcon img = new ImageIcon(image); //Dimension id = new Dimension(icon.getIconWidth(), icon.getIconHeight()); //double x = vv.getModel().getGraphLayout().transform(d).getX(); //x -= (icon.getIconWidth() / 2); //double y = vv.getModel().getGraphLayout().transform(d).getY(); //y -= (icon.getIconHeight() / 2); //grphcs.drawImage(image, (int) Math.round(x), (int) Math.round(y), null); icon.add(img); } } } @Override public boolean useTransform() { return false; } }); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); Factory<Device> vertexFactory = DeviceFactory.getInstance(); Factory<ComLink> edgeFactory = ComLinkFactory.getInstance(); final EditingModalGraphMouse<Device, ComLink> graphMouse = new EditingModalGraphMouse<>( vv.getRenderContext(), vertexFactory, edgeFactory); // Trying out our new popup menu mouse plugin... PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin(); // Add some popup menus for the edges and vertices to our mouse plugin. JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame); JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu(frame); myPlugin.setEdgePopup(edgeMenu); myPlugin.setVertexPopup(vertexMenu); graphMouse.remove(graphMouse.getPopupEditingPlugin()); // Removes the existing popup editing plugin graphMouse.add(myPlugin); // Add our new plugin to the mouse // AnnotatingGraphMousePlugin<Device,ComLink> annotatingPlugin = // new AnnotatingGraphMousePlugin<>(vv.getRenderContext()); //graphMouse.add(annotatingPlugin); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created // graphMouse.setVertexLocations(vertexLocations); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); //final ImageAtEdgePainter<String, String> imageAtEdgePainter = // new ImageAtEdgePainter<String, String>(vv, edge, image); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton help = new JButton("Help"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); } }); JButton deploy = new JButton("Deploy"); deploy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // OPMapping algo here if (simu == null) { return; } GraphUtil<Device, ComLink> util = new GraphUtil<>(); for (EventProducer p : simu.getProducers()) { if (!p.isMapped()) { JOptionPane.showMessageDialog(frame, "Cannot map operators. Please deploy the producer: " + p.getName()); return; } } for (EventConsumer c : simu.getConsumers()) { if (!c.isMapped()) { JOptionPane.showMessageDialog(frame, "Cannot map operators. Please deploy the consumer: " + c.getName()); return; } System.out.println("-- Operator placement algorithm Greedy: " + c.getName() + " --"); Solution init = util.initialMapping(c.getGraph()); System.out.println(c.getGraph() + "\nInitial Mapping: " + init); OperatorMapping mapper = new OperatorMapping(); long T1, T2; System.out.println("--- OpMapping Algo Greedy --- "); T1 = System.currentTimeMillis(); Solution solution = mapper.opMapping(c.getGraph(), Topology.getInstance().getGraph(), init); T2 = System.currentTimeMillis(); System.out.println(solution); System.out.println("Solution founded in: " + (T2 - T1) + " ms"); } // Solution init = util.initialMapping(EPGraph.getInstance().getGraph()); // System.out.println("Initial Mapping: " + init); // OperatorMapping mapper = new OperatorMapping(); // long T1, T2; // System.out.println("--- OpMapping Algo Greedy --- "); // T1 = System.currentTimeMillis(); // Solution solution = mapper.opMapping(EPGraph.getInstance().getGraph(), // Topology.getInstance().getGraph(), init); // T2 = System.currentTimeMillis(); // System.out.println(solution); // System.out.println("Solution founded in: " + (T2 - T1) + " ms"); vv.repaint(); } }); JButton run = new JButton("Run"); run.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // run the simulation here System.out.println("Setting the simulation..."); for (EventConsumer c : simu.getConsumers()) { for (EPUnit op : c.getGraph().getVertices()) { if (op.isMapped()) { op.openIOchannels(); } else { JOptionPane.showMessageDialog(frame, "Cannot run, undeployed operators founded."); return; } } } //ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); System.out.println("Running the simulation..."); //scheduledExecutorService.execute(runner); for (Device device : Topology.getInstance().getGraph().getVertices()) { if (!device.isAlive()) { device.start(); } } for (ComLink link : Topology.getInstance().getGraph().getEdges()) { if (!link.isAlive()) { link.start(); } } for (EventConsumer c : simu.getConsumers()) { for (EPUnit op : c.getGraph().getVertices()) { if (op.isMapped() && op.getDevice() != null && !op.isAlive()) { op.start(); } } } } }); AnnotationControls<Device, ComLink> annotationControls = new AnnotationControls<Device, ComLink>( graphMouse.getAnnotatingPlugin()); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 30, 0); slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(30); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setLabelTable(slider.createStandardLabels(15)); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); if (!slider.getValueIsAdjusting()) { speedSimulation(slider.getValue()); } } }); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); controls.add(annotationControls.getAnnotationsToolBar()); controls.add(slider); controls.add(deploy); controls.add(run); controls.add(help); content.add(controls, BorderLayout.SOUTH); /* Custom JPanels can be added here */ // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //final GraphEditor demo = new GraphEditor(); }
From source file:QueryConnector.java
public static void updateAll(XComponentContext componentContext, XModel model) { QueryConnector connector = null;/*from w w w . ja va 2 s. co m*/ try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); connector = new QueryConnector(model, componentContext); connector.updateAll(); } catch (Exception ex) { if (connector != null) connector.enableEdit(); ExceptionDialog.show(null, ex); } }
From source file:gate.Main.java
/** * Reads the user config data and applies the required settings. * This must be called <b>after</b> {@link Gate#init()} but <b>before</b> * any GUI components are created./* w w w. j a v a 2s .co m*/ */ public static void applyUserPreferences() { //look and feel String lnfClassName; if (System.getProperty("swing.defaultlaf") != null) { lnfClassName = System.getProperty("swing.defaultlaf"); } else { lnfClassName = Gate.getUserConfig().getString(GateConstants.LOOK_AND_FEEL); } if (lnfClassName == null) { //if running on Linux, default to Metal rather than GTK because GTK LnF //doesn't play nicely with most Gnome themes if (System.getProperty("os.name").toLowerCase().indexOf("linux") != -1) { //running on Linux lnfClassName = UIManager.getCrossPlatformLookAndFeelClassName(); } else { lnfClassName = UIManager.getSystemLookAndFeelClassName(); } } try { UIManager.setLookAndFeel(lnfClassName); } catch (Exception e) { System.err.print("Could not set your preferred Look and Feel. The error was:\n" + e.toString() + "\nReverting to using Java Look and Feel"); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e1) { //we just can't catch a break here. Let's forget about look and feel. System.err.print("Could not set the cross-platform Look and Feel either. The error was:\n" + e1.toString() + "\nGiving up on Look and Feel."); } } Gate.getUserConfig().put(GateConstants.LOOK_AND_FEEL, lnfClassName); //read the user config data OptionsMap userConfig = Gate.getUserConfig(); //text font Font font = userConfig.getFont(GateConstants.TEXT_COMPONENTS_FONT); if (font == null) { font = UIManager.getFont("TextPane.font"); } if (font != null) { OptionsDialog.setTextComponentsFont(font); } //menus font font = userConfig.getFont(GateConstants.MENUS_FONT); if (font == null) { font = UIManager.getFont("Menu.font"); } if (font != null) { OptionsDialog.setMenuComponentsFont(font); } //other gui font font = userConfig.getFont(GateConstants.OTHER_COMPONENTS_FONT); if (font == null) { font = UIManager.getFont("Button.font"); } if (font != null) { OptionsDialog.setComponentsFont(font); } }
From source file:com.adito.server.DefaultAditoServerFactory.java
public void createServer(final ClassLoader bootLoader, final String[] args) { // This is a hack to allow the Install4J installer to get the java // runtime that will be used if (args.length > 0 && args[0].equals("--jvmdir")) { System.out.println(SystemProperties.get("java.home")); System.exit(0);/* w w w .j a v a2 s .c o m*/ } this.bootLoader = bootLoader; useWrapper = System.getProperty("wrapper.key") != null; ContextHolder.setContext(this); if (useWrapper) { WrapperManager.start(this, args); } else { Integer returnCode = start(args); if (returnCode != null) { if (gui) { if (startupException == null) { startupException = new Exception("An exit code of " + returnCode + " was returned."); } try { if (SystemProperties.get("os.name").toLowerCase().startsWith("windows")) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (UnsupportedLookAndFeelException e) { } String mesg = startupException.getMessage() == null ? "No message supplied." : startupException.getMessage(); StringBuilder buf = new StringBuilder(); int l = 0; char ch; for (int i = 0; i < mesg.length(); i++) { ch = mesg.charAt(i); if (l > 50 && ch == ' ') { buf.append("\n"); l = 0; } else { if (ch == '\n') { l = 0; } else { l++; } buf.append(ch); } } mesg = buf.toString(); final String fMesg = mesg; try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JOptionPane.showMessageDialog(null, fMesg, "Startup Error", JOptionPane.ERROR_MESSAGE); } }); } catch (InterruptedException ex) { } catch (InvocationTargetException ex) { } } System.exit(returnCode); } else { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (!shuttingDown) { DefaultAditoServerFactory.this.stop(0); } } }); } } }
From source file:com.mgmtp.perfload.loadprofiles.ui.ctrl.ConfigController.java
public String getLookAndFeelClassName() { String lnfClassName = getAppProperties().getProperty("lnf.className"); if (isBlank(lnfClassName)) { lnfClassName = UIManager.getSystemLookAndFeelClassName(); getAppProperties().setProperty("lnf.className", lnfClassName); }/*from w ww .j a v a 2 s. c o m*/ return lnfClassName; }
From source file:com.github.benchdoos.weblocopener.updater.core.Main.java
private static void enableLookAndFeel() { try {/*from w ww . j a v a 2 s .c o m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ignore) { log.warn("Could not establish UI Look and feel."); } }