List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:ButtonScroll.java
public ButtonScroll() { super("Scrolling Programmatically"); setSize(400, 400);/*from www. j ava 2s.co m*/ getContentPane().setLayout(new BorderLayout()); ImageIcon shuttle = new ImageIcon("largeJava2sLogo.GIF"); pgVertical = shuttle.getIconHeight() / 5; pgHorzontal = shuttle.getIconWidth() / 5; JLabel lbl = new JLabel(shuttle); viewport = new JViewport(); viewport.setView(lbl); viewport.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { enableButtons(ButtonScroll.this.viewport.getViewPosition()); } }); getContentPane().add(viewport, BorderLayout.CENTER); JPanel pv = new JPanel(new BorderLayout()); upButton = createButton("up", 'u'); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { movePanel(0, -1); } }; upButton.addActionListener(lst); pv.add(upButton, BorderLayout.NORTH); downButton = createButton("down", 'd'); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { movePanel(0, 1); } }; downButton.addActionListener(lst); pv.add(downButton, BorderLayout.SOUTH); getContentPane().add(pv, BorderLayout.EAST); JPanel ph = new JPanel(new BorderLayout()); leftButton = createButton("left", 'l'); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { movePanel(-1, 0); } }; leftButton.addActionListener(lst); ph.add(leftButton, BorderLayout.WEST); rightButton = createButton("right", 'r'); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { movePanel(1, 0); } }; rightButton.addActionListener(lst); ph.add(rightButton, BorderLayout.EAST); getContentPane().add(ph, BorderLayout.SOUTH); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); movePanel(0, 0); }
From source file:StocksTable.java
public StocksTable() { super("Stocks Table"); setSize(600, 300);/* w w w.j ava2 s.co m*/ m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(false); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:SwingBar.java
public SwingBar() { fileMenu.add(fileExit);/*w w w.j ava 2 s . c om*/ menuBar.add(fileMenu); setJMenuBar(menuBar); frameContainer = getContentPane(); frameContainer.setLayout(new BorderLayout()); for (int i = 0; i < buttonLabels.length; ++i) { icons[i] = new ImageIcon(iconFiles[i]); buttons[i] = new JButton(icons[i]); buttons[i].setToolTipText(buttonLabels[i]); if (i == 3) toolBar.addSeparator(); toolBar.add(buttons[i]); } frameContainer.add("North", toolBar); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fileExit.addActionListener(new MenuItemHandler()); setSize(500, 500); setVisible(true); }
From source file:JSplash.java
private void init() { JPanel pnlImage = new JPanel(); ImageIcon image = new ImageIcon(getClass().getResource("img/logo.jpg")); JLabel lblBack = new JLabel(image); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); lblBack.setBounds(0, 0, image.getIconWidth(), image.getIconHeight()); getLayeredPane().add(lblBack, new Integer(Integer.MIN_VALUE)); pnlImage.setLayout(null);/*from w w w . j a v a 2s. c o m*/ pnlImage.setOpaque(false); pnlImage.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel)); pnlImage.add(this.lblVersion); this.lblVersion.setForeground(Color.white); this.lblVersion.setFont(new Font("Dialog", Font.PLAIN, 12)); this.lblVersion.setBounds(15, 69, 120, 20); setContentPane(pnlImage); setSize(image.getIconWidth(), image.getIconHeight()); }
From source file:Main.java
public ImagePanel(String img) { this(new ImageIcon(img).getImage()); }
From source file:com.jaeksoft.searchlib.util.ImageUtils.java
public static BufferedImage toBufferedImage(Image image) throws InterruptedException { if (image instanceof BufferedImage) return (BufferedImage) image; image = new ImageIcon(image).getImage(); int type = hasAlpha(image) ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB; BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); Graphics g = bimage.createGraphics(); g.drawImage(image, 0, 0, null);//from w w w . j a v a2s .com g.dispose(); return bimage; }
From source file:StocksTable2.java
public StocksTable2() { super("Stocks Table"); setSize(600, 300);//from w w w .jav a2 s . c o m m_data = new StockTableData(); m_title = new JLabel(m_data.getTitle(), new ImageIcon("money.gif"), SwingConstants.LEFT); m_title.setFont(new Font("TimesRoman", Font.BOLD, 24)); m_title.setForeground(Color.black); getContentPane().add(m_title, BorderLayout.NORTH); m_table = new JTable(); m_table.setAutoCreateColumnsFromModel(false); m_table.setModel(m_data); for (int k = 0; k < StockTableData.m_columns.length; k++) { DefaultTableCellRenderer renderer = new ColoredTableCellRenderer(); renderer.setHorizontalAlignment(StockTableData.m_columns[k].m_alignment); TableColumn column = new TableColumn(k, StockTableData.m_columns[k].m_width, renderer, null); m_table.addColumn(column); } JTableHeader header = m_table.getTableHeader(); header.setUpdateTableInRealTime(false); JScrollPane ps = new JScrollPane(); ps.getViewport().add(m_table); getContentPane().add(ps, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:com.isencia.passerelle.hmi.action.ModelExecutor.java
public ModelExecutor(final HMIBase base) { super(base, HMIMessages.getString(HMIMessages.MENU_EXECUTE), new ImageIcon(HMIBase.class.getResource("resources/run.gif"))); }
From source file:Main.java
public MyPanel() throws Exception { setLayout(new FlowLayout()); int size = 100; URL url = new URL("http://www.java2s.com/style/download.png"); BufferedImage bi = ImageIO.read(url); Image left = createImage(size, Color.YELLOW); Image merged = merge(left, bi); add(new JLabel(new ImageIcon(merged))); }
From source file:com.chris.brkopani.gui.analytics.Graph.java
public void createAndShowGui(JDesktopPane desk) throws SQLException { //? tabed pane ? WebLookAndFeel.install();/*from w w w . j a va2s . c o m*/ frame = new JInternalFrame("PieChart", true, true, true, true); frame.setFrameIcon(new ImageIcon("res/br.png")); frame.setBounds(530, 5, 520, 350); frame.getContentPane().getBackground(); // This will create the dataset PieDataset dataset = createDataset(); // based on the dataset we create the chart JFreeChart chart = createChart(dataset, "PieChart"); // we put the chart into a panel ChartPanel chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(Color.GRAY); // default size chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // add it to our application frame.add(chartPanel); frame.setVisible(true); desk.add(frame); }