Example usage for javax.swing ImageIcon getImage

List of usage examples for javax.swing ImageIcon getImage

Introduction

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

Prototype

@Transient
public Image getImage() 

Source Link

Document

Returns this icon's Image.

Usage

From source file:com.moss.greenshell.wizard.menu.AbstractMenuItem.java

public void setIcon(URL url) {
    this.iconResource = null;
    if (url != null) {
        ImageIcon icon = null;
        try {// www  .j a va 2 s  .  c  o  m
            icon = new ImageIcon(url);
            if (icon.getImage().getHeight(this) > 0)
                setIcon(icon);
            else
                useDefaultIcon();
        } catch (Exception ex) {
            ex.printStackTrace();
            useDefaultIcon();
        }
    } else
        useDefaultIcon();
}

From source file:teambootje.A2.java

public A2() {
    initComponents();/*from   ww  w  . j a  v  a2  s  . c  o m*/
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 2");
    ImageIcon icon = new ImageIcon("img/bootje.jpg");
    setIconImage(icon.getImage());

    // back BTN
    JButton back = new JButton("Back");
    add(back, BorderLayout.NORTH);

    back.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    // panel en Label
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String sql = "SELECT Datum, COUNT(*) AS Aantal FROM posts GROUP BY Datum";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(sql);
        while (rs.next()) {
            String datum = rs.getString("Datum");
            int aantal = rs.getInt("Aantal");
            String[] row = new String[rs.getMetaData().getColumnCount()];
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                row[i - 1] = rs.getString(i);
            }
            list.add(row);
            //chart
            JButton chart = new JButton("Chart");
            add(chart, BorderLayout.SOUTH);

            chart.addActionListener(new ActionListener() {
                String dat = datum;
                int a1 = aantal;

                @Override
                public void actionPerformed(ActionEvent e) {

                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                    pieDataset.setValue(dat, a1);
                    pieDataset.setValue("2015-04-06", new Integer(5));
                    pieDataset.setValue("2015-04-05", new Integer(5));
                    pieDataset.setValue("2015-04-04", new Integer(14));
                    pieDataset.setValue("2015-04-03", new Integer(4));
                    pieDataset.setValue("2015-04-02", new Integer(1));
                    pieDataset.setValue("2015-04-01", new Integer(32));
                    pieDataset.setValue("2015-03-31", new Integer(32));
                    pieDataset.setValue("2015-03-30", new Integer(9));
                    pieDataset.setValue("2015-03-29", new Integer(4));
                    pieDataset.setValue("2015-03-28", new Integer(1));
                    pieDataset.setValue("2015-03-27", new Integer(3));
                    pieDataset.setValue("2015-03-26", new Integer(6));
                    pieDataset.setValue("2015-03-25", new Integer(1));
                    pieDataset.setValue("2015-03-24", new Integer(1));
                    pieDataset.setValue("2015-03-23", new Integer(1));
                    pieDataset.setValue("2015-03-22", new Integer(1));
                    pieDataset.setValue("2015-03-21", new Integer(1));
                    pieDataset.setValue("2015-03-20", new Integer(1));
                    pieDataset.setValue("2015-03-19", new Integer(1));
                    pieDataset.setValue("2015-03-18", new Integer(2));
                    pieDataset.setValue("2015-03-17", new Integer(1));
                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal Posts per datum", pieDataset, true,
                            true, true);
                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                    ChartFrame pie = new ChartFrame("Aantal Posts per datum", chart);
                    pie.setVisible(true);
                    pie.setSize(500, 500);
                    pie.setLocationRelativeTo(null);

                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                }
            });

        }
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    }

    Object[][] array = new Object[list.size()][];
    Object columnNames[] = { "Datum", "Aantal" };
    list.toArray(array);

    JTable table = new JTable(array, columnNames);
    JScrollPane scroll = new JScrollPane(table);
    scroll.setPreferredSize(new Dimension(400, 400));
    ana.add(scroll);

}

From source file:mulavito.samples.GraphAlgorithmDemo.java

public GraphAlgorithmDemo() {
    super("MuLaViTo Algorithms Demo");

    // Set the frame icon.
    ImageIcon icon = Resources.getIconByName("/img/mulavito-logo.png");
    if (icon != null)
        setIconImage(icon.getImage());

    // Create toolbar.
    JToolBar toolbar = new JToolBar();
    getToolBarPane().add(toolbar);/*  ww w. j av  a 2 s  . c  om*/

    JButton btn;

    btn = new JButton("New Graph");
    btn.setActionCommand("graph");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Auto Size");
    btn.setActionCommand("autosize");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Eppstein");
    btn.setActionCommand("eppstein");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Yen");
    btn.setActionCommand("yen");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("Suurballe-Tarjan");
    btn.setActionCommand("suurballe-tarjan");
    btn.addActionListener(this);
    toolbar.add(btn);

    btn = new JButton("About");
    btn.setActionCommand("about");
    btn.addActionListener(this);
    toolbar.add(btn);

    normalOutput("Welcome to MuLaViTo demonstrator.\n");
    debugOutput("Click on \"New Graph\" to create a new graph.\n");
    warnOutput("Click Eppstein, Yen, or Suurballe-Tarjan to randomly "
            + "select source and destination and run the algorithm\n");
    notifyOutput("Have fun!!!\n");

    setPreferredSize(new Dimension(500, 600));
    setMinimumSize(new Dimension(500, 600));
    setVisible(true);
}

From source file:ru.codemine.pos.ui.windows.products.ProductWindow.java

@Override
public void showWindow(Product product) {
    if (!actionListenersInit)
        setupActionListeners();//  w  w  w  . ja va2  s  . c  om

    this.product = product;

    setTitle(" - " + product.getName());

    idField.setText(product.getId() == null ? "" : product.getId().toString());
    artikulField.setText(product.getArtikul());
    nameField.setText(product.getName());
    barcodeField.setText(product.getBarcode());
    priceField.setValue(product.getPrice());

    if (product.getId() == null) {
        artikulField.setEditable(true);
    } else {
        artikulField.setEditable(false);
    }

    List<Store> proxedStores = storeService.getAll();
    List<Store> stores = new ArrayList<>();
    for (Store s : proxedStores) {
        stores.add(storeService.unproxyStocks(s));
    }
    stocksTable.setModel(new ProductByStoresTableModel(product, stores));

    TableColumnModel columnModel = stocksTable.getColumnModel();
    columnModel.getColumn(0).setMaxWidth(10);

    File imgFile = new File("images/products/" + product.getArtikul() + ".jpg");
    String imgPath = "images/products/default.jpg";

    if (imgFile.exists() && !imgFile.isDirectory()) {
        imgPath = imgFile.getAbsolutePath();
    }

    ImageIcon ico = new ImageIcon(imgPath);
    if (ico.getIconHeight() > 0) {
        Image img = ico.getImage().getScaledInstance(200, 200, Image.SCALE_SMOOTH);
        imagePanel.setImage(img, true);
    }

    setVisible(true);
}

From source file:teambootje.A1.java

public A1() {
    initComponents();//from www. j a  v  a 2 s .co  m
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());
    setSize(500, 500);

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 1");
    ImageIcon icon = new ImageIcon("img/bootje.jpg");
    setIconImage(icon.getImage());

    // back BTN
    JButton back = new JButton("Back");
    add(back, BorderLayout.NORTH);

    back.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    // panel
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String nvt = "SELECT Geslacht, COUNT(*) AS Aantal FROM persoon GROUP BY geslacht";
    String male = "SELECT Geslacht AS male, COUNT(*) AS Aantal_Male FROM persoon WHERE Geslacht = 'man'";
    String Female = "SELECT Geslacht AS female, COUNT(*) AS Aantal_Female FROM persoon WHERE Geslacht = 'vrouw'";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(nvt);
        while (rs.next()) {
            String geslacht = rs.getString("Geslacht");
            int aantal = rs.getInt("Aantal");
            String[] row = new String[rs.getMetaData().getColumnCount()];
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                row[i - 1] = rs.getString(i);
            }
            list.add(row);

            try {
                rs = db.runSql(male);
                while (rs.next()) {
                    String man = rs.getString("male");
                    int am = rs.getInt("Aantal_Male");
                    String[] row1 = new String[rs.getMetaData().getColumnCount()];
                    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                        row1[i - 1] = rs.getString(i);
                    }

                    try {
                        rs = db.runSql(Female);
                        while (rs.next()) {
                            String vrouw = rs.getString("female");
                            int af = rs.getInt("Aantal_Female");
                            String[] row2 = new String[rs.getMetaData().getColumnCount()];
                            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                                row2[i - 1] = rs.getString(i);
                            }
                            Object[][] array = new Object[list.size()][];
                            Object columnNames[] = { "Geslacht", "Aantal" };
                            list.toArray(array);

                            JTable table = new JTable(array, columnNames);
                            JScrollPane scroll = new JScrollPane(table);
                            scroll.setPreferredSize(new Dimension(400, 400));
                            ana.add(scroll);

                            //chart
                            JButton chart = new JButton("Chart");
                            add(chart, BorderLayout.SOUTH);

                            chart.addActionListener(new ActionListener() {
                                String g1 = geslacht;
                                String m = man;
                                String v = vrouw;
                                int a1 = aantal;
                                int a2 = am;
                                int a3 = af;

                                @Override
                                public void actionPerformed(ActionEvent e) {

                                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                                    pieDataset.setValue("Niet vrij gegeven", a1);
                                    pieDataset.setValue("Man", a2);
                                    pieDataset.setValue("vrouw", a3);

                                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal mannen en vrouwen",
                                            pieDataset, true, true, true);
                                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                                    ChartFrame pie = new ChartFrame("Aantal mannen en vrouwen", chart);
                                    pie.setVisible(true);
                                    pie.setSize(500, 500);
                                    pie.setLocationRelativeTo(null);

                                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                                }
                            });
                        }
                    } catch (SQLException v) {
                        JOptionPane.showMessageDialog(null, v);
                    }
                }
            } catch (SQLException m) {
                JOptionPane.showMessageDialog(null, m);
            }

        }
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

From source file:gdt.jgui.console.JItemPanel.java

public void resetIcon() {
    if (icon$ != null) {
        byte[] ba = Base64.decodeBase64(icon$);
        ImageIcon icon = new ImageIcon(ba);
        Image image = icon.getImage().getScaledInstance(24, 24, 0);
        icon.setImage(image);/*  w  w  w . j a va2s  . c om*/
        title.setIcon(icon);
        title.repaint();
        title.revalidate();
    }
}

From source file:teambootje.A9.java

/**
 * Creates new form A9/*from  w  ww.  jav  a 2 s  .c o m*/
 */
public A9() {
    initComponents();
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 9");
    ImageIcon icon = new ImageIcon("img/bootje.jpg");
    setIconImage(icon.getImage());

    // back BTN
    JButton back = new JButton("Back");
    add(back, BorderLayout.NORTH);

    back.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    // panel en Label
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String sql = "SELECT persoon.Name, COUNT(post) AS Aantal FROM persoon, posts WHERE persoon.AID = posts.AID GROUP BY persoon.Name";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(sql);
        while (rs.next()) {
            String name = rs.getString("persoon.Name");
            int amount = rs.getInt("Aantal");
            String[] row = new String[rs.getMetaData().getColumnCount()];
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                row[i - 1] = rs.getString(i);
            }
            list.add(row);

            //chart
            JButton chart = new JButton("Chart");
            add(chart, BorderLayout.SOUTH);

            chart.addActionListener(new ActionListener() {
                String n1 = name;
                int a1 = amount;

                @Override
                public void actionPerformed(ActionEvent e) {
                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                    pieDataset.setValue(n1, a1);
                    pieDataset.setValue("WestCordHotels", new Integer(1));
                    pieDataset.setValue("Voetbalr", new Integer(2));
                    pieDataset.setValue("VeraBauman", new Integer(1));
                    pieDataset.setValue("TonWesselink", new Integer(2));
                    pieDataset.setValue("Stoomschip Rotterdam", new Integer(25));
                    pieDataset.setValue("shirleys86", new Integer(2));
                    pieDataset.setValue("SevereWeather_N", new Integer(2));
                    pieDataset.setValue("SalvatoreOrtisi", new Integer(4));
                    pieDataset.setValue("RuudvEck", new Integer(2));
                    pieDataset.setValue("RuudvandenBos", new Integer(1));
                    pieDataset.setValue("Roffa85", new Integer(1));
                    pieDataset.setValue("RichardPh0t0", new Integer(2));
                    pieDataset.setValue("RebekkaKadijk", new Integer(2));
                    pieDataset.setValue("ray_rademaker", new Integer(6));
                    pieDataset.setValue("PoushNL", new Integer(1));
                    pieDataset.setValue("popupsquare", new Integer(2));
                    pieDataset.setValue("Plan_78", new Integer(3));
                    pieDataset.setValue("Petrahoogenboom", new Integer(1));
                    pieDataset.setValue("PatriciaBenard", new Integer(2));
                    pieDataset.setValue("OVKatendrecht", new Integer(2));
                    pieDataset.setValue("OdileHemmen", new Integer(2));
                    pieDataset.setValue("NLMaritiem", new Integer(2));
                    pieDataset.setValue("Nellyvdvlies", new Integer(1));
                    pieDataset.setValue("meerkatting", new Integer(2));
                    pieDataset.setValue("MeerkatsNow", new Integer(2));
                    pieDataset.setValue("marygoossens1", new Integer(1));
                    pieDataset.setValue("MarjoleinNagel", new Integer(1));
                    pieDataset.setValue("MaaikeMaasdijk", new Integer(1));
                    pieDataset.setValue("KidsErOpUit", new Integer(2));
                    pieDataset.setValue("Katendrechtnr1", new Integer(25));
                    pieDataset.setValue("jpsoree", new Integer(2));
                    pieDataset.setValue("JolandaBolscher", new Integer(2));
                    pieDataset.setValue("jes4life", new Integer(1));
                    pieDataset.setValue("JaccoScheer", new Integer(1));
                    pieDataset.setValue("GwNpop", new Integer(2));
                    pieDataset.setValue("Gerarddegraaff", new Integer(1));
                    pieDataset.setValue("FR12Patrick", new Integer(3));
                    pieDataset.setValue("FlorentinaNow", new Integer(1));
                    pieDataset.setValue("FIVBWorldChamps", new Integer(2));
                    pieDataset.setValue("FIVBVolleyball", new Integer(2));
                    pieDataset.setValue("FeestdjNik", new Integer(1));
                    pieDataset.setValue("ensanne", new Integer(1));
                    pieDataset.setValue("elsekramer", new Integer(1));
                    pieDataset.setValue("EelcoBeijl", new Integer(1));
                    pieDataset.setValue("EdwindeKoning1", new Integer(2));
                    pieDataset.setValue("DMiddelman", new Integer(3));
                    pieDataset.setValue("de_rotterdam", new Integer(2));
                    pieDataset.setValue("CvanAdrighem", new Integer(2));
                    pieDataset.setValue("carolinedejager", new Integer(1));
                    pieDataset.setValue("CaatVanEnst", new Integer(1));
                    pieDataset.setValue("BotlekBusiness", new Integer(2));
                    pieDataset.setValue("AnneWallisDeVri", new Integer(2));
                    pieDataset.setValue("010byday", new Integer(4));
                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal posts per personen", pieDataset,
                            true, true, true);
                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                    ChartFrame pie = new ChartFrame("Aantal posts per personen", chart);
                    pie.setVisible(true);
                    pie.setSize(500, 500);
                    pie.setLocationRelativeTo(null);

                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                }
            });
        }
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    }

    Object[][] array = new Object[list.size()][];
    Object columnNames[] = { "Naam", "Aantal" };
    list.toArray(array);

    JTable table = new JTable(array, columnNames);
    JScrollPane scroll = new JScrollPane(table);
    scroll.setPreferredSize(new Dimension(400, 400));
    ana.add(scroll);

}

From source file:br.com.renatoccosta.regexrenamer.view.FrmAbout.java

@Override
protected JRootPane createRootPane() {
    final ImageIcon imageIcon = new ImageIcon(getClass().getResource("/background.png"));

    return new JRootPane() {

        Image image = imageIcon.getImage();

        {/*from w  w w .j av a2  s  . c  om*/
            setOpaque(false);
        }

        @Override
        protected void paintComponent(Graphics g) {
            g.drawImage(image, 0, 0, this);
            super.paintComponent(g);
        }

    };
}

From source file:es.emergya.ui.base.BasicWindow.java

private Image getImageIcon(String uri) {
    final URL resource = this.getClass().getResource(uri);
    if (resource != null) {
        final ImageIcon imageIcon = new ImageIcon(resource);
        if (imageIcon != null)
            return imageIcon.getImage();
    }/*ww w.j  a  va  2 s . co m*/
    LOG.error("No se pudo encontrar el icono " + uri);
    return null;
}

From source file:gdt.jgui.console.JItemPanel.java

/**
 * Create the item panel./*from  w w w . j  a  va  2  s. c  om*/
 * @param console the main console.
 * @param locator$ the item's locator.
 * @return the item panel.
 */
public JItemPanel instantiate(JMainConsole console, String locator$) {
    try {
        this.console = console;
        this.locator$ = locator$;
        this.removeAll();
        Properties locator = Locator.toProperties(locator$);
        if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKABLE))) {
            checkbox = new JCheckBox();
            add(checkbox);
            if (Locator.LOCATOR_TRUE.equals(locator.getProperty(Locator.LOCATOR_CHECKED)))
                if (checkbox != null)
                    checkbox.setSelected(true);
        }
        title = new JLabel(title$, JLabel.LEFT);
        //title.setIcon(null);
        title$ = locator.getProperty(Locator.LOCATOR_TITLE);
        if (title$ != null) {
            title.setText(title$);
            title.setOpaque(true);
            title.addMouseListener(new MousePopupListener());
            title.setAlignmentX(Component.LEFT_ALIGNMENT);
            add(title, BorderLayout.WEST);
            icon$ = locator.getProperty(Locator.LOCATOR_ICON);

            if (icon$ != null) {
                byte[] ba = Base64.decodeBase64(icon$);
                ImageIcon icon = new ImageIcon(ba);
                Image image = icon.getImage().getScaledInstance(24, 24, 0);
                icon.setImage(image);
                title.setIcon(icon);
            }
        } else
            LOGGER.info("title is null");
    } catch (Exception e) {
        LOGGER.severe(e.toString());
    }
    return this;
}