Example usage for javax.swing ImageIcon ImageIcon

List of usage examples for javax.swing ImageIcon ImageIcon

Introduction

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

Prototype

public ImageIcon(byte[] imageData) 

Source Link

Document

Creates an ImageIcon from an array of bytes which were read from an image file containing a supported image format, such as GIF, JPEG, or (as of 1.3) PNG.

Usage

From source file:teambootje.A2.java

public A2() {
    initComponents();/*w w  w .ja  v a 2  s.  co  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:com.mirth.connect.client.ui.StatusBar.java

/** Creates new form StatusBar */
public StatusBar() {
    initComponents();//from w ww. j  a v  a2 s. c o m
    workingText.setText("");
    StringBuilder statusBarText = new StringBuilder();
    statusBarText.append("Connected to: ");

    if (!StringUtils.isBlank(PlatformUI.SERVER_NAME)) {
        statusBarText.append(PlatformUI.SERVER_NAME + " | ");
    }
    statusBarText.append(PlatformUI.SERVER_URL);
    serverLabel.setText(statusBarText.toString());
    serverLabel
            .setIcon(new ImageIcon(com.mirth.connect.client.ui.Frame.class.getResource("images/server.png")));
    progressBar.setEnabled(false);
    progressBar.setForeground(UIConstants.JX_CONTAINER_BACKGROUND_COLOR);

    this.setBorder(new BevelBorder(BevelBorder.LOWERED));
}

From source file:ufmotionsuite.SpiralGraph.java

public SpiralGraph() {
    initComponents();/*from   w  w  w  .  j  a v a  2s . co  m*/
    // Sets corner icon
    ImageIcon img = new ImageIcon(
            "C:/Users/Gabrielle/Documents/NetBeansProjects/UFMotionSuite/Resources/Images/Logo/icon.png");
    this.setIconImage(img.getImage());

}

From source file:com.imag.nespros.network.devices.SacomutDevice.java

public SacomutDevice(String name, double cpuSpeed, int totalMemory) {
    super(name, cpuSpeed, totalMemory, DeviceType.SACOMUT);
    try {//from   www.j a  v  a 2  s .  co  m
        byte[] imageInByte;
        imageInByte = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("image/sacomut.jpg"));
        icon = new MyLayeredIcon(new ImageIcon(imageInByte).getImage());
    } catch (IOException ex) {
        Logger.getLogger(AMIDevice.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.imag.nespros.network.devices.UtilityDevice.java

public UtilityDevice(String name, double cpuSpeed, int totalMemory) {
    super(name, cpuSpeed, totalMemory, DeviceType.UTILITY);
    //icon= new MyLayeredIcon(new ImageIcon("icons"+File.separator+"utility.jpg").getImage());
    try {//  www . j a v  a 2 s.c o m
        byte[] imageInByte;
        imageInByte = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("image/utility.jpg"));
        icon = new MyLayeredIcon(new ImageIcon(imageInByte).getImage());
    } catch (IOException ex) {
        Logger.getLogger(AMIDevice.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:vic.collaborativeClouds.forms.Login.java

/**
 * Creates new form Login/*from  www  . java  2s.  co m*/
 */
public Login() {
    initComponents();
    //this.setExtendedState(Login.MAXIMIZED_BOTH);
    this.setAlwaysOnTop(true);

    setLayout(new BorderLayout());
    ImageLocator mImage = new ImageLocator();
    //System.err.println(mImage.login_dash);
    JLabel background = new JLabel(new ImageIcon(mImage.login_dash));
    this.add(background);
    background.setLayout(new FlowLayout());

    Toolkit tk = Toolkit.getDefaultToolkit();
    int xSize = ((int) tk.getScreenSize().getWidth());
    int ySize = ((int) tk.getScreenSize().getHeight());
    this.setSize(xSize, ySize);
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation(dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2);
    heading.setLocation((xSize / 2) - 100, (ySize / 4) - 100);
    username.setLocation((xSize / 2) - 150, (ySize / 4));
    password.setLocation((xSize / 2) - 150, (ySize / 4) + 50);
    login.setLocation((xSize / 2) - 150, (ySize / 4) + 100);
    cancel.setLocation((xSize / 2) + 120, (ySize / 4) + 100);
    username.setOpaque(false);

}

From source file:Main.java

public void drawImage() {
    Graphics2D g = img.createGraphics();
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHints(hints);/*from ww w.  ja v a  2  s. co  m*/

    g.setColor(Color.RED);
    int x = (int) mouse.getX();
    int y = (int) mouse.getY();
    g.setStroke(new BasicStroke(2));
    int s = 3;
    g.drawLine(x - s, y, x + s, y);
    g.drawLine(x, y - s, x, y + s);
    l.setIcon(new ImageIcon(img));

    g.dispose();
}

From source file:com.imag.nespros.network.devices.HTACoordDevice.java

public HTACoordDevice(String name, double cpuSpeed, int totalMemory) {
    super(name, cpuSpeed, totalMemory, DeviceType.HTA_COORD);
    try {//from   w w  w . ja  v a 2 s  .  co  m
        byte[] imageInByte;
        imageInByte = IOUtils
                .toByteArray(getClass().getClassLoader().getResourceAsStream("image/htaCoord.jpg"));
        icon = new MyLayeredIcon(new ImageIcon(imageInByte).getImage());
    } catch (IOException ex) {
        Logger.getLogger(AMIDevice.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:LayeredPaneDemo.java

public LayeredPaneDemo() {
    super("Custom MDI: Part II");
    setSize(570, 400);// www  .  j a  v a2 s . c om
    getContentPane().setBackground(new Color(244, 232, 152));

    getLayeredPane().setOpaque(true);

    InnerFrame[] frames = new InnerFrame[5];
    for (int i = 0; i < 5; i++) {
        frames[i] = new InnerFrame("InnerFrame " + i);
        frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200);
        getLayeredPane().add(frames[i]);
    }

    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };

    Dimension dim = getToolkit().getScreenSize();
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);

    ImageIcon image = new ImageIcon("spiral.gif");
    setIconImage(image.getImage());
    addWindowListener(l);
    setVisible(true);
}

From source file:iqq.app.core.service.impl.ResourceServiceImpl.java

/**
 * ???/*from   w  ww  .j a  v  a2 s.c  o  m*/
 *
 * @param filename
 * @param width
 * @param height
 * @return
 */
@Override
public ImageIcon getIcon(String filename, int width, int height) {
    return new ImageIcon(getIcon(filename).getImage().getScaledInstance(width, height, 100));
}