Search in sources :

Example 6 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jdk8u_jdk by JetBrains.

the class Test8013442 method run.

@Override
public void run() {
    if (this.infos == null) {
        this.infos = UIManager.getInstalledLookAndFeels();
        Thread.currentThread().setUncaughtExceptionHandler(this);
    }
    if (this.infos.length == this.index) {
        // release main thread
        LATCH.countDown();
    } else if (this.chooser == null) {
        // change LaF before creation of Swing components
        LookAndFeelInfo info = this.infos[this.index];
        System.out.println(info.getName());
        try {
            UIManager.setLookAndFeel(info.getClassName());
        } catch (Exception exception) {
            throw new Error("could not change look and feel", exception);
        }
        // create and show new file chooser
        JFrame frame = new JFrame(getClass().getSimpleName());
        frame.add(this.chooser = new JFileChooser());
        frame.setSize(800, 600);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        SwingUtilities.invokeLater(this);
    } else {
        int count = this.chooser.getChoosableFileFilters().length;
        System.out.println("count = " + count + "; " + this.chooser.isAcceptAllFileFilterUsed());
        if (count == 0) {
            if (null != this.chooser.getFileFilter()) {
                throw new Error("file filter is selected");
            }
            // close window and stop testing file chooser for current LaF
            SwingUtilities.getWindowAncestor(this.chooser).dispose();
            this.chooser = null;
            this.index++;
        } else {
            if (null == this.chooser.getFileFilter()) {
                throw new Error("file filter is not selected");
            }
            if (count == 2) {
                // remove default file filter
                this.chooser.setAcceptAllFileFilterUsed(false);
            } else if (this.chooser.isAcceptAllFileFilterUsed()) {
                // remove add file filter
                this.chooser.addChoosableFileFilter(this);
            } else {
                // remove custom file filter
                this.chooser.removeChoosableFileFilter(this);
            }
        }
        SwingUtilities.invokeLater(this);
    }
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame)

Example 7 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project swing-paint-application by haxxorsid.

the class Draw method openPaint.

public void openPaint() {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            try {
                UIManager.setLookAndFeel(info.getClassName());
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            break;
        }
    }
    JFrame frame = new JFrame("Paint (" + width + "X" + height + ")");
    Container container = frame.getContentPane();
    container.setLayout(new BorderLayout());
    canvas = new Canvas();
    container.add(canvas, BorderLayout.CENTER);
    JPanel panel = new JPanel();
    JPanel panel1 = new JPanel();
    Box box = Box.createVerticalBox();
    Box box1 = Box.createHorizontalBox();
    panel1.setLayout(new FlowLayout());
    pencil = new JButton(pencilIcon);
    pencil.setPreferredSize(new Dimension(40, 40));
    pencil.addActionListener(listener);
    rectangle = new JButton(rect);
    rectangle.setPreferredSize(new Dimension(40, 40));
    rectangle.addActionListener(listener);
    thicknessSlider = new JSlider(JSlider.HORIZONTAL, 0, 50, 1);
    thicknessSlider.setMajorTickSpacing(25);
    thicknessSlider.setPaintTicks(true);
    thicknessSlider.setPreferredSize(new Dimension(40, 40));
    thicknessSlider.addChangeListener(thick);
    undoButton = new JButton(undo);
    undoButton.setPreferredSize(new Dimension(20, 20));
    undoButton.addActionListener(listener);
    redoButton = new JButton(redo);
    redoButton.setPreferredSize(new Dimension(20, 20));
    redoButton.addActionListener(listener);
    blackButton = new JButton();
    blackButton.setBackground(Color.BLACK);
    blackButton.setPreferredSize(new Dimension(40, 40));
    blackButton.addActionListener(listener);
    blueButton = new JButton();
    blueButton.setBackground(Color.BLUE);
    blueButton.setPreferredSize(new Dimension(40, 40));
    blueButton.addActionListener(listener);
    greenButton = new JButton();
    greenButton.setBackground(Color.GREEN);
    greenButton.setPreferredSize(new Dimension(40, 40));
    greenButton.addActionListener(listener);
    redButton = new JButton();
    redButton.setBackground(Color.RED);
    redButton.setPreferredSize(new Dimension(40, 40));
    redButton.addActionListener(listener);
    magentaButton = new JButton();
    magentaButton.setBackground(Color.MAGENTA);
    magentaButton.setPreferredSize(new Dimension(40, 40));
    magentaButton.addActionListener(listener);
    grayButton = new JButton();
    grayButton.setBackground(Color.GRAY);
    grayButton.setPreferredSize(new Dimension(40, 40));
    grayButton.addActionListener(listener);
    orangeButton = new JButton();
    orangeButton.setBackground(Color.ORANGE);
    orangeButton.setPreferredSize(new Dimension(40, 40));
    orangeButton.addActionListener(listener);
    yellowButton = new JButton();
    yellowButton.setBackground(Color.YELLOW);
    yellowButton.setPreferredSize(new Dimension(40, 40));
    yellowButton.addActionListener(listener);
    pinkButton = new JButton();
    pinkButton.setBackground(Color.PINK);
    pinkButton.setPreferredSize(new Dimension(40, 40));
    pinkButton.addActionListener(listener);
    cyanButton = new JButton();
    cyanButton.setBackground(Color.CYAN);
    cyanButton.setPreferredSize(new Dimension(40, 40));
    cyanButton.addActionListener(listener);
    lightGrayButton = new JButton();
    lightGrayButton.setBackground(Color.LIGHT_GRAY);
    lightGrayButton.setPreferredSize(new Dimension(40, 40));
    lightGrayButton.addActionListener(listener);
    saveButton = new JButton(save);
    saveButton.addActionListener(listener);
    saveAsButton = new JButton("Save As");
    saveAsButton.addActionListener(listener);
    loadButton = new JButton("Load");
    loadButton.addActionListener(listener);
    colorPicker = new JButton("Color Picker");
    colorPicker.addActionListener(listener);
    clearButton = new JButton("Clear");
    clearButton.addActionListener(listener);
    filenameBar = new JLabel("No file");
    thicknessStat = new JLabel("1");
    box.add(Box.createVerticalStrut(40));
    box1.add(thicknessSlider, BorderLayout.NORTH);
    box1.add(thicknessStat, BorderLayout.NORTH);
    box.add(box1, BorderLayout.NORTH);
    panel1.add(filenameBar, BorderLayout.SOUTH);
    box.add(Box.createVerticalStrut(20));
    box.add(undoButton, BorderLayout.NORTH);
    box.add(Box.createVerticalStrut(5));
    box.add(redoButton, BorderLayout.NORTH);
    /*box.add(Box.createVerticalStrut(5));
		box.add(pencil, BorderLayout.NORTH);
		box.add(Box.createVerticalStrut(5));
		box.add(rectangle, BorderLayout.NORTH);*/
    panel.add(greenButton);
    panel.add(blueButton);
    panel.add(blackButton);
    panel.add(redButton);
    panel.add(magentaButton);
    panel.add(grayButton);
    panel.add(orangeButton);
    panel.add(yellowButton);
    panel.add(pinkButton);
    panel.add(cyanButton);
    panel.add(lightGrayButton);
    panel.add(saveButton);
    panel.add(saveAsButton);
    panel.add(loadButton);
    panel.add(colorPicker);
    panel.add(clearButton);
    container.add(panel, BorderLayout.NORTH);
    container.add(panel1, BorderLayout.SOUTH);
    container.add(box, BorderLayout.WEST);
    frame.setVisible(true);
    frame.setSize(width + 79, height + 11);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
Also used : JPanel(javax.swing.JPanel) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Box(javax.swing.Box) Dimension(java.awt.Dimension) Container(java.awt.Container) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JSlider(javax.swing.JSlider)

Example 8 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project swing-paint-application by haxxorsid.

the class RequestFocusListener method showInput.

private void showInput() {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
            try {
                UIManager.setLookAndFeel(info.getClassName());
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            break;
        }
    }
    JPanel p = new JPanel(new BorderLayout(5, 5));
    JPanel labels = new JPanel(new GridLayout(0, 1, 2, 2));
    JPanel labels1 = new JPanel(new FlowLayout());
    labels.add(new JLabel("Width", SwingConstants.RIGHT));
    labels.add(new JLabel("Height", SwingConstants.RIGHT));
    labels1.add(new JLabel("Minimum Width:900, Height: 800"));
    p.add(labels, BorderLayout.WEST);
    p.add(labels1, BorderLayout.SOUTH);
    JPanel controls = new JPanel(new GridLayout(0, 1, 2, 2));
    JTextField widthField = new JTextField();
    controls.add(widthField);
    JTextField heightField = new JTextField();
    heightField.addAncestorListener(new RequestFocusListener(false));
    controls.add(heightField);
    p.add(controls, BorderLayout.CENTER);
    JOptionPane.showMessageDialog(null, p, "Enter Canvas Width and Height", JOptionPane.QUESTION_MESSAGE);
    try {
        width = Integer.parseInt(widthField.getText());
        height = Integer.parseInt(heightField.getText());
        if (width < 900 || height < 800) {
            JOptionPane.showMessageDialog(null, p, "W:900,H:800 Minimum required", JOptionPane.ERROR_MESSAGE);
        }
        draw.setWH(width, height);
        draw.openPaint();
    } catch (IllegalArgumentException e) {
        JOptionPane.showMessageDialog(null, p, "Please enter valid number!", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : JPanel(javax.swing.JPanel) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) FlowLayout(java.awt.FlowLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) GridLayout(java.awt.GridLayout) UnsupportedLookAndFeelException(javax.swing.UnsupportedLookAndFeelException) BorderLayout(java.awt.BorderLayout)

Example 9 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jgnash by ccavanaugh.

the class ThemeManager method buildLookAndFeelMenu.

/**
     * Loads the menu with the available look and feels for the application
     * 
     * @return l and f menu
     */
JMenu buildLookAndFeelMenu() {
    String activeLookAndFeelName = UIManager.getLookAndFeel().getName();
    // ButtonGroup buttonGroup = new ButtonGroup();
    JMenu lfMenu = new JMenu();
    lfMenu.setText(rb.getString("Menu.LookAndFeel.Name"));
    lfMenu.add(buildSubstanceMenu());
    List<String> lookAndFeels = new ArrayList<>();
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if (isLookAndFeelAvailable(info.getClassName())) {
            lookAndFeels.add(info.getClassName());
        }
    }
    for (String lookAndFeel : KNOWN) {
        if (isLookAndFeelAvailable(lookAndFeel)) {
            lookAndFeels.add(lookAndFeel);
        }
    }
    Collections.sort(lookAndFeels);
    for (String lookAndFeel : lookAndFeels) {
        try {
            Class<?> lnfClass = Class.forName(lookAndFeel);
            LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance();
            JRadioButtonMenuItem button = new JRadioButtonMenuItem();
            button.setText(newLAF.getName());
            button.setActionCommand(lookAndFeel);
            button.setName(newLAF.getName());
            button.addActionListener(e -> {
                Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
                pref.put(LF, e.getActionCommand());
                restartUI();
            });
            lfButtonGroup.add(button);
            lfMenu.add(button);
            if (newLAF.getName().equals(activeLookAndFeelName)) {
                button.setSelected(true);
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
        }
    }
    return lfMenu;
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) ArrayList(java.util.ArrayList) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) LookAndFeel(javax.swing.LookAndFeel) NimbusLookAndFeel(javax.swing.plaf.nimbus.NimbusLookAndFeel) SubstanceLookAndFeel(org.pushingpixels.substance.api.SubstanceLookAndFeel) MetalLookAndFeel(javax.swing.plaf.metal.MetalLookAndFeel) Preferences(java.util.prefs.Preferences) JMenu(javax.swing.JMenu)

Example 10 with LookAndFeelInfo

use of javax.swing.UIManager.LookAndFeelInfo in project jdk8u_jdk by JetBrains.

the class TableExample2 method main.

public static void main(String[] args) {
    if (args.length != 5) {
        System.err.println("Needs database parameters eg. ...");
        System.err.println("java TableExample2 \"jdbc:derby://localhost:1527/sample\" " + "org.apache.derby.jdbc.ClientDriver app app " + "\"select * from app.customer\"");
        return;
    }
    // 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 ex) {
        Logger.getLogger(TableExample2.class.getName()).log(Level.SEVERE, "Failed to apply Nimbus look and feel", ex);
    }
    new TableExample2(args[0], args[1], args[2], args[3], args[4]);
}
Also used : LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo)

Aggregations

LookAndFeelInfo (javax.swing.UIManager.LookAndFeelInfo)41 IOException (java.io.IOException)7 JPanel (javax.swing.JPanel)6 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)6 Dimension (java.awt.Dimension)5 JFrame (javax.swing.JFrame)5 JLabel (javax.swing.JLabel)4 BorderLayout (java.awt.BorderLayout)3 File (java.io.File)3 JFileChooser (javax.swing.JFileChooser)3 Color (java.awt.Color)2 FlowLayout (java.awt.FlowLayout)2 GridLayout (java.awt.GridLayout)2 JButton (javax.swing.JButton)2 JTextField (javax.swing.JTextField)2 PropertiesPreferences (com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences)1 MessagesService (com.igormaznitsa.sciareto.notifications.MessagesService)1 PrinterPlugin (com.igormaznitsa.sciareto.plugins.services.PrinterPlugin)1 MainFrame (com.igormaznitsa.sciareto.ui.MainFrame)1 SplashScreen (com.igormaznitsa.sciareto.ui.UiUtils.SplashScreen)1