Example usage for javax.swing UIDefaults UIDefaults

List of usage examples for javax.swing UIDefaults UIDefaults

Introduction

In this page you can find the example usage for javax.swing UIDefaults UIDefaults.

Prototype

public UIDefaults() 

Source Link

Document

Creates an empty defaults table.

Usage

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining
 * to a particular class.//from   w w  w .ja  va  2s . co  m
 *
 * @param className fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(String className) {
    UIDefaults retVal = new UIDefaults();
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    List<?> listKeys = Collections.list(defaults.keys());
    for (Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) {
                property = stringKey.substring(stringKey.indexOf(".") + 1);
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining to a particular class.
 * //from   ww  w. j  a  va2  s  .  c om
 * @param className
 *            fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(String className) {
    UIDefaults retVal = new UIDefaults();
    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    List<?> listKeys = Collections.list(defaults.keys());
    for (Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) { //$NON-NLS-1$
                property = stringKey.substring(stringKey.indexOf(".") + 1); //$NON-NLS-1$
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

From source file:Main.java

/**
 * Convenience method for retrieving a subset of the UIDefaults pertaining
 * to a particular class.//from  ww  w.j  a  v a 2s  .c  o m
 * 
 * @param className
 *            fully qualified name of the class of interest
 * @return the UIDefaults of the class named
 */
public static UIDefaults getUIDefaultsOfClass(final String className) {
    final UIDefaults retVal = new UIDefaults();
    final UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    final List<?> listKeys = Collections.list(defaults.keys());
    for (final Object key : listKeys) {
        if (key instanceof String && ((String) key).startsWith(className)) {
            final String stringKey = (String) key;
            String property = stringKey;
            if (stringKey.contains(".")) {
                property = stringKey.substring(stringKey.indexOf(".") + 1);
            }
            retVal.put(property, defaults.get(key));
        }
    }
    return retVal;
}

From source file:Main.java

public Main() {
    super(BoxLayout.Y_AXIS);
    try {//w  w w .j  ava2 s. co  m
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                System.out.println("set");
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    Object o = UIManager.get("TextArea[Enabled+NotInScrollPane].borderPainter");

    UIDefaults paneDefaults = new UIDefaults();
    paneDefaults.put("TextPane.borderPainter", o);

    JTextPane pane = new JTextPane();
    pane.setMargin(new Insets(10, 10, 10, 10));

    pane.putClientProperty("Nimbus.Overrides", paneDefaults);
    pane.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
    pane.setText("this \nis \na \ntest\n");
    add(pane);

}

From source file:com.NewJFrame.java

/**
 * Creates new form NewJFrame//ww  w. jav  a  2s.com
 */
public NewJFrame() {
    initComponents();

    textPane.setText("Hello");
    Color bgColor = Color.BLACK;
    UIDefaults defaults = new UIDefaults();
    defaults.put("TextPane[Enabled].backgroundPainter", bgColor);
    textPane.putClientProperty("Nimbus.Overrides", defaults);
    textPane.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    textPane.setBackground(bgColor);

}

From source file:UI.MainViewPanel.java

public JProgressBar getPanel7(Metric7 m7) {

    JProgressBar openPortBar = new JProgressBar(0, 100);
    openPortBar.setValue(m7.totalCriticalCount);
    openPortBar.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    UIDefaults defaults = new UIDefaults();

    Painter foregroundPainter = new MyPainter(new Color(230, 219, 27));
    Painter backgroundPainter = new MyPainter(chartBackgroundColor);
    defaults.put("ProgressBar[Enabled].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", foregroundPainter);
    defaults.put("ProgressBar[Enabled].backgroundPainter", backgroundPainter);

    openPortBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
    openPortBar.putClientProperty("Nimbus.Overrides", defaults);

    openPortBar.setString("" + m7.totalCriticalCount);
    openPortBar.setStringPainted(true);//  w ww  . jav  a  2  s .  c o  m

    return openPortBar;
}

From source file:ds.monte.carlo.Application.java

private void initProgressBar() {
    jProgressBar1.setMinimum(0);/*from  ww  w.jav a 2  s . c  o  m*/
    jProgressBar1.setMaximum(100);
    jProgressBar1.setValue(0);
    UIDefaults defaults = new UIDefaults();
    defaults.put("ProgressBar[Enabled].backgroundPainter", new MyPainter(new Color(210, 210, 210)));
    defaults.put("ProgressBar[Enabled].foregroundPainter", new MyPainter(new Color(92, 184, 92)));
    jProgressBar1.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.FALSE);
    jProgressBar1.putClientProperty("Nimbus.Overrides", defaults);
}

From source file:net.minelord.gui.panes.IRCPane.java

public void startClient(final String nick) {
    IRCLog = new ArrayList<String>();
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from w w  w  . j a v  a  2  s .  c o m
        public void run() {
            text = new JEditorPane("text/html", "<HTML>");
            text.setEditable(false);
            kit = new HTMLEditorKit();
            text.setEditorKit(kit);
            client.connect("irc.liberty-unleashed.co.uk", "#moomoohk", nick, instance);
            scroller = new JScrollPane(text);
            text.setEditable(false);
            connect();
            scroller.setBounds(20, 20, 810, 250);
            add(scroller);
            input = new JTextField();
            input.setBounds(20, 270, 810, 30);
            Color bgColor = Color.gray.darker().darker();
            UIDefaults defaults = new UIDefaults();
            defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
            text.putClientProperty("Nimbus.Overrides", defaults);
            text.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
            text.setBackground(bgColor);
            input.setBackground(Color.gray);
            input.setForeground(Color.gray.darker().darker().darker());
            input.setEnabled(false);
            text.addHyperlinkListener(new HyperlinkListener() {
                @Override
                public void hyperlinkUpdate(HyperlinkEvent event) {
                    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        if (event.getDescription().charAt(0) == '#') {
                            String[] params = { event.getDescription() };
                            IRCCommand.getCommand("/join").execute(client, params);
                        } else
                            OSUtils.browse(event.getURL().toString());
                    }
                }
            });
            text.addFocusListener(new FocusListener() {

                @Override
                public void focusLost(FocusEvent paramFocusEvent) {
                }

                @Override
                public void focusGained(FocusEvent paramFocusEvent) {
                    input.requestFocus();
                }
            });
            scroller.setViewportView(text);
            add(input);
            input.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent arg0) {
                }

                @Override
                public void keyReleased(KeyEvent arg0) {
                    if (arg0.getKeyCode() == 10) {
                        if (input.getText().length() > 0) {
                            lastCommandSelector = lastCommands.size();
                            lastCommands.add(input.getText());
                        }
                        sendMessage(input.getText());
                        input.setText("");
                    }
                    if (arg0.getKeyCode() == 27)
                        input.setText("");
                    if (arg0.getKeyCode() == 17) {
                        int before = input.getText().length();
                        if (input.getText().charAt(0) == '/') {
                            input.setText(completeNick(input.getText()));
                            input.select(
                                    input.getText().length() - completeNick(input.getText()).length() + before,
                                    input.getText().length());
                        } else {
                            input.setText(completeCommand(input.getText()));
                            input.select(input.getText().length() - completeCommand(input.getText()).length()
                                    + before, input.getText().length());
                        }
                    }
                    if (arg0.getKeyCode() == 38)
                        if (lastCommandSelector > 0) {
                            lastCommandSelector--;
                            input.setText(lastCommands.get(lastCommandSelector));
                        }
                    if (arg0.getKeyCode() == 40)
                        if (lastCommandSelector < lastCommands.size()) {
                            lastCommandSelector++;
                            if (lastCommandSelector == lastCommands.size())
                                input.setText("");
                            if (lastCommandSelector < lastCommands.size())
                                input.setText(lastCommands.get(lastCommandSelector));
                            return;
                        }
                }

                @Override
                public void keyPressed(KeyEvent arg0) {
                }
            });
        }
    });
}

From source file:Main.Interface_Main.java

private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed

    // for copying style
    JLabel label = new JLabel();
    Font font = label.getFont();// ww w  . j a  va2  s  .co  m

    // create some css from the label's font
    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
    style.append("font-size:" + font.getSize() + "pt;");

    // html content
    JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
            + "This application was designed by <A HREF=http://www.friedcircuits.us>FriedCircuits</A> for the USB Tester." //
            + "<br><br><center>App Version: " + appVersion + "<br>FW Version: " + FW_VERSION
            + "</center><br><br>*Connect once to get FW version.</body></html>");

    // handle link events
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                java.awt.Desktop desktop = java.awt.Desktop.getDesktop();

                URI uri;
                try {
                    uri = new java.net.URI("www.friedcircuits.us");
                    if (desktop.isSupported(Desktop.Action.BROWSE)) {
                        try {
                            desktop.browse(uri);
                        } catch (IOException ex) {
                            Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
                } catch (URISyntaxException ex) {
                    Logger.getLogger(Interface_Main.class.getName()).log(Level.SEVERE, null, ex);
                }

            } // roll your own link launcher or use Desktop if J6+
        }
    });
    Color bgColor = label.getBackground();
    UIDefaults defaults = new UIDefaults();
    defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
    ep.putClientProperty("Nimbus.Overrides", defaults);
    ep.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
    ep.setEditable(false);
    ep.setBackground(bgColor);

    // show
    ImageIcon myCustomIcon = new ImageIcon(getClass().getResource("/faviconbot2edit.png"));
    JOptionPane.showMessageDialog(plCurrent, ep, "About", JOptionPane.INFORMATION_MESSAGE, myCustomIcon);
}

From source file:ejemplo.grafica.java

public void cargarbarra() {
    UIDefaults defaults = new UIDefaults();
    defaults.put("ProgressBar[Enabled].foregroundPainter", new MyPainter(Color.BLUE));
    defaults.put("ProgressBar[Enabled+Finished].foregroundPainter", new MyPainter(Color.BLUE));
    progressBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE);
    progressBar.putClientProperty("Nimbus.Overrides", defaults);
    ActionListener updateProBar = new ActionListener() {

        public void actionPerformed(ActionEvent ae) {
            int max, min, maxD;
            min = 0;/*w  ww.  java 2  s  .  c  om*/
            max = Integer.parseInt(txtMaximaAgua.getText());
            maxD = Integer.parseInt(txtMaximoDetergente.getText());
            progressBar.setMinimum(min);
            progressBar.setMaximum(max);
            int nivelDeseado = Integer.parseInt(txtNivelAgua.getText());
            int nivelActual = progressBar.getValue();
            if (nivelDeseado > nivelActual) {
                if (nivelDeseado == nivelActual) {
                    timer.stop();
                }
                progressBar.setValue(++nivelActual);
            } else {
                if (nivelDeseado < nivelActual) {

                    if (nivelDeseado == nivelActual) {
                        timer.stop();
                    }
                    progressBar.setValue(--nivelActual);
                }
            }

        }

    };
    timer = new Timer(500, updateProBar);
    timer.start();
}