Search in sources :

Example 66 with ImageIcon

use of javax.swing.ImageIcon in project voltdb by VoltDB.

the class FontDialogSwing method creatFontDialog.

/**
     * Create and display FontDialogSwing Dialog.
     *
     */
public static void creatFontDialog(DatabaseManagerSwing owner) {
    if (isRunning) {
        frame.setVisible(true);
    } else {
        CommonSwing.setSwingLAF(frame, CommonSwing.Native);
        fOwner = owner;
        frame.setIconImage(CommonSwing.getIcon("Frame"));
        isRunning = true;
        frame.setSize(600, 100);
        CommonSwing.setFramePositon(frame);
        ckbitalic = new JCheckBox(new ImageIcon(CommonSwing.getIcon("ItalicFont")));
        ckbitalic.putClientProperty("is3DEnabled", Boolean.TRUE);
        ckbitalic.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setStyle();
            }
        });
        ckbbold = new JCheckBox(new ImageIcon(CommonSwing.getIcon("BoldFont")));
        ckbbold.putClientProperty("is3DEnabled", Boolean.TRUE);
        ckbbold.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setStyle();
            }
        });
        fgColorButton = new JButton("Foreground", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
        fgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
        fgColorButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setColor(FOREGROUND);
            }
        });
        bgColorButton = new JButton("Background", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
        bgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
        bgColorButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setColor(BACKGROUND);
            }
        });
        closeButton = new JButton("Close", new ImageIcon(CommonSwing.getIcon("Close")));
        closeButton.putClientProperty("is3DEnabled", Boolean.TRUE);
        closeButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                frame.setVisible(false);
            }
        });
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        String[] fontNames = ge.getAvailableFontFamilyNames();
        Dimension fontsComboBoxDimension = new Dimension(160, 25);
        fontsComboBox = new JComboBox(fontNames);
        fontsComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
        fontsComboBox.setMaximumSize(fontsComboBoxDimension);
        fontsComboBox.setPreferredSize(fontsComboBoxDimension);
        fontsComboBox.setMaximumSize(fontsComboBoxDimension);
        fontsComboBox.setEditable(false);
        fontsComboBox.setSelectedItem(defaultFont);
        fontsComboBox.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                setFont();
            }
        });
        // weconsultants@users 20050215 - Added for Compatbilty fix for  JDK 1.3
        fontSizesComboBox = new JComboBox(fontSizes);
        Dimension spinnerDimension = new Dimension(45, 25);
        fontSizesComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
        fontSizesComboBox.setMinimumSize(spinnerDimension);
        fontSizesComboBox.setPreferredSize(spinnerDimension);
        fontSizesComboBox.setMaximumSize(spinnerDimension);
        fontSizesComboBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent evt) {
                if (evt.getStateChange() == ItemEvent.SELECTED) {
                    setFontSize((String) evt.getItem());
                }
            }
        });
        // weconsultants@users 20050215 - Commented out for Compatbilty fix for  JDK 1.3
        //            Dimension spinnerDimension = new Dimension(50, 25);
        //            spinnerFontSizes = new JSpinner();
        //            spinnerFontSizes.putClientProperty("is3DEnabled", Boolean.TRUE);
        //            spinnerFontSizes.setMinimumSize(spinnerDimension);
        //            spinnerFontSizes.setPreferredSize(spinnerDimension);
        //            spinnerFontSizes.setMaximumSize(spinnerDimension);
        //            spinnerModelSizes = new SpinnerNumberModel(12, 8, 72, 1);
        //            spinnerFontSizes.setModel(spinnerModelSizes);
        //            spinnerFontSizes.addChangeListener(new ChangeListener() {
        //                public void stateChanged(ChangeEvent e) {
        //                    setFontSize();
        //                }
        //            });
        Container contentPane = frame.getContentPane();
        contentPane.setLayout(new FlowLayout());
        contentPane.add(fontsComboBox);
        // weconsultants@users 20050215 - Commented out for Compatbilty fix for 1.3
        // contentPane.add(spinnerFontSizes);
        // weconsultants@users 20050215 - Added for Compatbilty fix for 1.3
        contentPane.add(fontSizesComboBox);
        contentPane.add(ckbbold);
        contentPane.add(ckbitalic);
        contentPane.add(fgColorButton);
        contentPane.add(bgColorButton);
        contentPane.add(closeButton);
        frame.pack();
        frame.setVisible(false);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) ItemEvent(java.awt.event.ItemEvent) FlowLayout(java.awt.FlowLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener)

Example 67 with ImageIcon

use of javax.swing.ImageIcon in project voltdb by VoltDB.

the class DatabaseManagerSwing method createToolBar.

protected JToolBar createToolBar() {
    // Build jtoolbar and jtoolbar Buttons
    JToolBar jtoolbar = new JToolBar();
    jtoolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
    // I'm dropping "Statement" from  "Execute SQL Statement", etc.,
    // because it may or may not be "one statement", but it is SQL.
    // Build jbuttonClear Buttons - blaine
    jbuttonClear = new JButton("Clear SQL", new ImageIcon(CommonSwing.getIcon("Clear")));
    jbuttonClear.putClientProperty("is3DEnabled", Boolean.TRUE);
    tipMap.put(jbuttonClear, "Clear SQL");
    jbuttonClear.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            if (sqlScriptBuffer == null && txtCommand.getText().length() < 1) {
                CommonSwing.errorMessage("No SQL to clear");
                return;
            }
            clear();
        }
    });
    jbuttonExecute = new JButton("Execute SQL", new ImageIcon(CommonSwing.getIcon("Execute")));
    tipMap.put(jbuttonExecute, "Execute SQL");
    jbuttonExecute.putClientProperty("is3DEnabled", Boolean.TRUE);
    jbuttonExecute.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            executeCurrentSQL();
        }
    });
    jtoolbar.addSeparator();
    jtoolbar.add(jbuttonClear);
    jtoolbar.addSeparator();
    jtoolbar.add(jbuttonExecute);
    jtoolbar.addSeparator();
    jbuttonClear.setAlignmentY(0.5F);
    jbuttonClear.setAlignmentX(0.5F);
    jbuttonExecute.setAlignmentY(0.5F);
    jbuttonExecute.setAlignmentX(0.5F);
    return jtoolbar;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar)

Example 68 with ImageIcon

use of javax.swing.ImageIcon in project robo4j by Robo4J.

the class SSD1306DeviceTest method main.

public static void main(String[] args) throws IOException {
    final SSD1306Device oled = new SSD1306Device(OLEDVariant.Type128x32, RaspiPin.GPIO_25);
    Graphics2D gc = oled.getGraphicsContext();
    gc.setColor(Color.white);
    gc.setBackground(Color.black);
    gc.clearRect(0, 0, 127, 31);
    gc.drawLine(0, 0, 127, 31);
    gc.drawString("Hello World!", 0, 32);
    gc.setBackground(Color.white);
    gc.fillOval(127 - 16, -16, 32, 32);
    oled.pushImage();
    JFrame frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            try {
                oled.setEnabled(false);
            } catch (IOException e1) {
                e1.printStackTrace();
            //TODO: is it possible ?
            } finally {
                System.exit(0);
            }
        }
    });
    frame.setSize(256, 256);
    frame.getContentPane().add(new JLabel(new ImageIcon(oled.getImage())));
    frame.setVisible(true);
}
Also used : ImageIcon(javax.swing.ImageIcon) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JLabel(javax.swing.JLabel) IOException(java.io.IOException) Graphics2D(java.awt.Graphics2D)

Example 69 with ImageIcon

use of javax.swing.ImageIcon in project SIMRacingApps by SIMRacingApps.

the class HeaderForm method loadImage.

/**
    * Helper method to load an image file from the CLASSPATH
    * @param imageName the package and name of the file to load relative to the CLASSPATH
    * @return an ImageIcon instance with the specified image file
    * @throws IllegalArgumentException if the image resource cannot be loaded.
    */
public ImageIcon loadImage(String imageName) {
    try {
        ClassLoader classloader = getClass().getClassLoader();
        java.net.URL url = classloader.getResource(imageName);
        if (url != null) {
            ImageIcon icon = new ImageIcon(url);
            return icon;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    throw new IllegalArgumentException("Unable to load image: " + imageName);
}
Also used : ImageIcon(javax.swing.ImageIcon)

Example 70 with ImageIcon

use of javax.swing.ImageIcon in project SIMRacingApps by SIMRacingApps.

the class JreForm method loadImage.

/**
    * Helper method to load an image file from the CLASSPATH
    * @param imageName the package and name of the file to load relative to the CLASSPATH
    * @return an ImageIcon instance with the specified image file
    * @throws IllegalArgumentException if the image resource cannot be loaded.
    */
public ImageIcon loadImage(String imageName) {
    try {
        ClassLoader classloader = getClass().getClassLoader();
        java.net.URL url = classloader.getResource(imageName);
        if (url != null) {
            ImageIcon icon = new ImageIcon(url);
            return icon;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    throw new IllegalArgumentException("Unable to load image: " + imageName);
}
Also used : ImageIcon(javax.swing.ImageIcon)

Aggregations

ImageIcon (javax.swing.ImageIcon)427 JButton (javax.swing.JButton)109 ActionEvent (java.awt.event.ActionEvent)83 ActionListener (java.awt.event.ActionListener)70 JLabel (javax.swing.JLabel)67 Dimension (java.awt.Dimension)62 BufferedImage (java.awt.image.BufferedImage)51 JPanel (javax.swing.JPanel)48 Insets (java.awt.Insets)42 Image (java.awt.Image)31 BorderLayout (java.awt.BorderLayout)28 IOException (java.io.IOException)28 URL (java.net.URL)26 GridBagLayout (java.awt.GridBagLayout)23 JMenuItem (javax.swing.JMenuItem)23 Color (java.awt.Color)21 Point (java.awt.Point)21 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)20 JToggleButton (javax.swing.JToggleButton)20 JScrollPane (javax.swing.JScrollPane)19