List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:teambootje.A6.java
/** * Creates new form A6/* www . j ava2 s .com*/ */ public A6() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 6"); 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 Locatie.land, locatie.stad, count(persoon.LID) as Aantal FROM persoon, Locatie WHERE persoon.LID = locatie.LID GROUP BY stad"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String city = rs.getString("locatie.stad"); 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 c1 = city; int a1 = amount; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(c1, a1); pieDataset.setValue("Rotterdam", new Integer(1)); pieDataset.setValue("Bergen op zoom", new Integer(1)); JFreeChart chart = ChartFactory.createPieChart3D("Waar komen bezoekers vandaan", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Waar komen bezoekers vandaan", 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[] = { "Land", "stad", "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:LayeredPaneDemo3.java
public LayeredPaneDemo3() { super("Custom MDI: Part IV"); setSize(570, 400);/*from w ww . j a v a 2 s. co m*/ getContentPane().setBackground(new Color(244, 232, 152)); setLayeredPane(new MDIPane()); ImageIcon ii = new ImageIcon("earth.jpg"); 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); frames[i].getContentPane().add(new JScrollPane(new JLabel(ii))); 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:teambootje.A3.java
/** * Creates new form A3//w w w . j ava 2s . c o m */ public A3() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 3"); 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 locatie.land, locatie.stad, COUNT(posts.PID) AS Aantal FROM persoon, locatie, posts WHERE persoon.LID = locatie.LID AND persoon.AID = posts.AID GROUP BY locatie.land ORDER BY count(posts.PID)"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String land = rs.getString("locatie.land"); String stad = rs.getString("locatie.stad"); 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 l1 = land; String s1 = stad; int a1 = aantal; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(s1, a1); JFreeChart chart = ChartFactory.createPieChart3D("Aantal Posts per locatie", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal Posts per locatie", 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[] = { "Land", "Stad", "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:teambootje.A7.java
/** * Creates new form A7// w w w.j av a 2s .co m */ public A7() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 7"); 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 doelgroep.doelgroep, COUNT(*) AS Aantal FROM doelgroep GROUP BY doelgroep.doelgroep"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String ta = rs.getString("doelgroep.Doelgroep"); 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 dd = ta; int a1 = amount; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(dd, a1); pieDataset.setValue("Bedrijfsleven", new Integer(1)); pieDataset.setValue("50+", new Integer(1)); pieDataset.setValue("40+", new Integer(1)); pieDataset.setValue("30+", new Integer(1)); JFreeChart chart = ChartFactory.createPieChart3D("Aantal mensen per Doelgroep", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal mensen per Doelgroep", 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[] = { "Doelgroep", "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:teambootje.A8.java
/** * Creates new form A8//from w ww. j a v a 2 s . c om */ public A8() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 8"); 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 doelgroep.Doelgroep, COUNT(posts.post) AS Aantal FROM doelgroep, posts WHERE posts.DID = doelgroep.DID GROUP BY doelgroep.Doelgroep"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String ta = rs.getString("doelgroep.Doelgroep"); 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 dd = ta; int a1 = amount; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(dd, a1); pieDataset.setValue("50+", new Integer(0)); pieDataset.setValue("Tiener", new Integer(0)); pieDataset.setValue("40+", new Integer(0)); pieDataset.setValue("30+", new Integer(0)); JFreeChart chart = ChartFactory.createPieChart3D("Aantal Posts per doelgroep", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal Posts per doelgroep", 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[] = { "Doelgoep", "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.imag.nespros.network.devices.PADevice.java
public PADevice(String name, double cpuSpeed, int totalMemory) { super(name, cpuSpeed, totalMemory, DeviceType.PA); try {//from w ww .ja va 2 s. c o m byte[] imageInByte; imageInByte = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("image/pa.jpg")); icon = new MyLayeredIcon(new ImageIcon(imageInByte).getImage()); } catch (IOException ex) { Logger.getLogger(AMIDevice.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ToolBarExample.java
public ToolBarExample() { menuBar = new JMenuBar(); // Create a set of actions to use in both the menu and toolbar DemoAction leftJustifyAction = new DemoAction("Left", new ImageIcon("1.gif"), "Left justify text", 'L'); DemoAction rightJustifyAction = new DemoAction("Right", new ImageIcon("2.gif"), "Right justify text", 'R'); DemoAction centerJustifyAction = new DemoAction("Center", new ImageIcon("3.gif"), "Center justify text", 'M'); DemoAction fullJustifyAction = new DemoAction("Full", new ImageIcon("4.gif"), "Full justify text", 'F'); JMenu formatMenu = new JMenu("Justify"); formatMenu.add(leftJustifyAction);// ww w . ja v a 2s. co m formatMenu.add(rightJustifyAction); formatMenu.add(centerJustifyAction); formatMenu.add(fullJustifyAction); menuBar.add(formatMenu); toolBar = new JToolBar("Formatting"); toolBar.add(leftJustifyAction); toolBar.add(rightJustifyAction); toolBar.add(centerJustifyAction); toolBar.add(fullJustifyAction); toolBar.addSeparator(); JLabel label = new JLabel("Font"); toolBar.add(label); toolBar.addSeparator(); JComboBox combo = new JComboBox(fonts); combo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { pane.getStyledDocument().insertString(0, "Font [" + ((JComboBox) e.getSource()).getSelectedItem() + "] chosen!\n", null); } catch (Exception ex) { ex.printStackTrace(); } } }); toolBar.add(combo); // Disable one of the Actions fullJustifyAction.setEnabled(false); }
From source file:com.imag.nespros.network.devices.DCDevice.java
public DCDevice(String name, double cpuSpeed, int totalMemory) { super(name, cpuSpeed, totalMemory, DeviceType.DC); try {// w w w . j av a2 s .c o m byte[] imageInByte; imageInByte = IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream("image/dc.jpeg")); icon = new MyLayeredIcon(new ImageIcon(imageInByte).getImage()); } catch (IOException ex) { Logger.getLogger(AMIDevice.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.panels.ServerDisplay.java
public ServerDisplay(JSONObject server) { JLabel game = new JLabel(server.getString("gametype")); JLabel statusImg = new JLabel( new ImageIcon(CHGManager.getInstance().getSettings().getWorkingDirectory().toString() + File.separator + "img" + File.separator + "icons" + File.separator + "ball_green.gif")); JLabel statusDetail = new JLabel("284/500"); JLabel ip = new JLabel(server.getString("ip") + ":" + server.getString("port")); JButton console = new JButton( new ImageIcon(CHGManager.getInstance().getSettings().getWorkingDirectory().toString() + File.separator + "img" + File.separator + "icons" + File.separator + "console.gif")); JButton restart = new JButton( new ImageIcon(CHGManager.getInstance().getSettings().getWorkingDirectory().toString() + File.separator + "img" + File.separator + "icons" + File.separator + "restart.gif")); JButton stop = new JButton( new ImageIcon(CHGManager.getInstance().getSettings().getWorkingDirectory().toString() + File.separator + "img" + File.separator + "icons" + File.separator + "stop.gif")); JButton edit = new JButton( new ImageIcon(CHGManager.getInstance().getSettings().getWorkingDirectory().toString() + File.separator + "img" + File.separator + "icons" + File.separator + "edit.gif")); GroupLayout gl_panel = new GroupLayout(this); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup().addContainerGap().addComponent(game).addGap(18) .addComponent(statusImg).addGap(18).addComponent(statusDetail).addGap(18).addComponent(ip) .addPreferredGap(ComponentPlacement.RELATED, 178, Short.MAX_VALUE).addComponent(console) .addPreferredGap(ComponentPlacement.RELATED).addComponent(restart) .addPreferredGap(ComponentPlacement.RELATED).addComponent(stop) .addPreferredGap(ComponentPlacement.RELATED).addComponent(edit))); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel.createSequentialGroup().addContainerGap() .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(edit) .addComponent(stop).addComponent(restart).addComponent(console)) .addContainerGap(23, Short.MAX_VALUE)) .addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup().addContainerGap(15, Short.MAX_VALUE) .addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(game) .addComponent(statusImg).addComponent(statusDetail).addComponent(ip)) .addGap(14))); this.setLayout(gl_panel); }
From source file:mupomat.view.PodrskaLozinka.java
/** * Creates new form PodrskaLozinka// www . j ava 2 s. c o m */ public PodrskaLozinka() { initComponents(); setTitle("MUPomat: Zaboravljena lozinka"); ikona = new ImageIcon(getClass().getResource("/mupomat/pictures/balloonerror.png")); centrirajZaslon(); dodajIkonu(); obradaKorisnik = new ObradaKorisnik(); }