List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:MenuActionExample.java
public MenuActionExample() { super(true);// ww w. j av a2 s .c om // Create a menu bar and give it a bevel border. menuBar = new JMenuBar(); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); // Create a menu and add it to the menu bar. JMenu menu = new JMenu("Menu"); menuBar.add(menu); // Create a toolbar and give it an etched border. toolBar = new JToolBar(); toolBar.setBorder(new EtchedBorder()); // Instantiate a sample action with the NAME property of // "Download" and the appropriate SMALL_ICON property. SampleAction exampleAction = new SampleAction("Download", new ImageIcon("action.gif")); // Finally, add the sample action to the menu and the toolbar. // These methods are no longer preferred: // menu.add(exampleAction); // toolBar.add(exampleAction); // Instead, you should create actual menu items and buttons: JMenuItem exampleItem = new JMenuItem(exampleAction); JButton exampleButton = new JButton(exampleAction); menu.add(exampleItem); toolBar.add(exampleButton); }
From source file:LayeredPaneDemo4.java
public LayeredPaneDemo4() { super("Custom MDI: Part V"); setSize(570, 400);/*from w w w . j av 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:SplashScreen.java
public void showSplash() { JPanel content = (JPanel) getContentPane(); content.setBackground(Color.white); // Set the window's bounds, centering the window int width = 450; int height = 115; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - width) / 2; int y = (screen.height - height) / 2; setBounds(x, y, width, height);/*from w ww . j ava2s . c o m*/ // Build the splash screen JLabel label = new JLabel(new ImageIcon("1.gif")); JLabel copyrt = new JLabel("Copyright 2002, O'Reilly & Associates", JLabel.CENTER); copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12)); content.add(label, BorderLayout.CENTER); content.add(copyrt, BorderLayout.SOUTH); Color oraRed = new Color(156, 20, 20, 255); content.setBorder(BorderFactory.createLineBorder(oraRed, 10)); // Display it setVisible(true); // Wait a little while, maybe while loading resources try { Thread.sleep(duration); } catch (Exception e) { } setVisible(false); }
From source file:ProxyTester.java
private void ensureImageLoaded() { if (image == null) { System.out.println("Loading " + name); image = new ImageIcon(name); }//from w w w.j ava 2 s .c o m }
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(); {/* w w w . ja va2 s . co m*/ setOpaque(false); } @Override protected void paintComponent(Graphics g) { g.drawImage(image, 0, 0, this); super.paintComponent(g); } }; }
From source file:teambootje.A9.java
/** * Creates new form A9//from w w w . ja v 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:room.utilization.BarGraph.java
private void createBarGraph() { Container contentPane = getContentPane(); contentPane.setBackground(Color.WHITE); setSize(700, 500);/* ww w. j a v a 2s .c om*/ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLocation(500, 250); setIconImage(new ImageIcon( "C:\\Users\\Olasubomi\\Documents\\NetBeansProjects\\Room Utilization\\src\\room\\utilization\\icon.png") .getImage()); contentPane.add(createPanel()); setVisible(true); }
From source file:CheckBoxMenuItemExample.java
public CheckBoxMenuItemExample() { menuBar = new JMenuBar(); JMenu justifyMenu = new JMenu("Justify"); ActionListener actionPrinter = new ActionListener() { public void actionPerformed(ActionEvent e) { try { pane.getStyledDocument().insertString(0, "Action [" + e.getActionCommand() + "] performed!\n", null);//from w w w . ja v a2s . c o m } catch (Exception ex) { ex.printStackTrace(); } } }; JCheckBoxMenuItem leftJustify = new JCheckBoxMenuItem("Left", new ImageIcon("1.gif")); leftJustify.setHorizontalTextPosition(JMenuItem.RIGHT); leftJustify .setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); leftJustify.addActionListener(actionPrinter); JCheckBoxMenuItem rightJustify = new JCheckBoxMenuItem("Right", new ImageIcon("2.gif")); rightJustify.setHorizontalTextPosition(JMenuItem.RIGHT); rightJustify .setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); rightJustify.addActionListener(actionPrinter); JCheckBoxMenuItem centerJustify = new JCheckBoxMenuItem("Center", new ImageIcon("3.gif")); centerJustify.setHorizontalTextPosition(JMenuItem.RIGHT); centerJustify .setAccelerator(KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); centerJustify.addActionListener(actionPrinter); JCheckBoxMenuItem fullJustify = new JCheckBoxMenuItem("Full", new ImageIcon("4.gif")); fullJustify.setHorizontalTextPosition(JMenuItem.RIGHT); fullJustify .setAccelerator(KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fullJustify.addActionListener(actionPrinter); justifyMenu.add(leftJustify); justifyMenu.add(rightJustify); justifyMenu.add(centerJustify); justifyMenu.add(fullJustify); menuBar.add(justifyMenu); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); }
From source file:ComboBox.java
public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { JComboBox combo = (JComboBox) e.getSource(); int index = combo.getSelectedIndex(); display.setIcon(new ImageIcon(ClassLoader.getSystemResource(images[index]))); }// w w w . j a v a 2 s. c om }
From source file:gui.statistics.PieChartTest.java
/** * Creates new form PieChartTest/* w w w . j a v a2s .co m*/ */ public PieChartTest(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); Date a = new Date(2014 - 1900, 11, 1); Date b = new Date(2014 - 1900, 11, 31); DefaultPieDataset data = new DefaultPieDataset(); HashMap<String, BigDecimal> map = Database.getInstance().getTotalExpensesByCategory(a, b); for (String key : map.keySet()) { data.setValue(key, map.get(key).doubleValue()); } JFreeChart pieChart = ChartFactory.createPieChart("PIE CHART", data, true, false, Locale.GERMAN); PiePlot plot = (PiePlot) pieChart.getPlot(); plot.setLabelGenerator(null); BufferedImage pie = pieChart.createBufferedImage(500, 400); setSize(600, 500); jLabel1.setIcon(new ImageIcon(pie)); }