List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:MatteBorderSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Sample Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon diamondIcon = new ImageIcon("yourImage.gif"); Border matteBorder = new MatteBorder(5, 10, 5, 10, diamondIcon); JLabel aLabel = new JLabel("Bevel"); aLabel.setBorder(matteBorder);//from www. j a va2 s. c o m aLabel.setHorizontalAlignment(JLabel.CENTER); frame.add(aLabel); frame.setSize(400, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Icon Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon icon = new ImageIcon("logo.gif"); UIDefaults defaults = UIManager.getDefaults(); defaults.put("Slider.horizontalThumbIcon", icon); JSlider aJSlider = new JSlider(); aJSlider.setPaintTicks(true);/*w w w . ja v a2 s .co m*/ frame.add(aJSlider, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ColumnSample.java
public static void main(String args[]) { TableModel model = new AbstractTableModel() { Icon icon1 = new ImageIcon("TreeCollapsed.gif"); Icon icon2 = new ImageIcon("TreeExpanded.gif"); Object rowData[][] = { { "1", "ichi", Boolean.TRUE, new Date("01/01/2000"), icon1 }, { "2", "ni", Boolean.TRUE, new Date("04/15/1999"), icon2 }, { "3", "san", Boolean.FALSE, new Date("12/07/1941"), icon2 }, { "4", "shi", Boolean.TRUE, new Date("02/29/2000"), icon1 }, { "5", "go", Boolean.FALSE, new Date("05/23/1995"), icon1 }, }; String columnNames[] = { "English", "Japanese", "Boolean", "Date", "ImageIcon" }; public int getColumnCount() { return columnNames.length; }//from ww w .j a va2s .c om public String getColumnName(int column) { return columnNames[column]; } public int getRowCount() { return rowData.length; } public Object getValueAt(int row, int column) { return rowData[row][column]; } public Class getColumnClass(int column) { return (getValueAt(0, column).getClass()); } }; JFrame frame = new JFrame("Column Renderer Table"); JTable table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(400, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Image image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); JPanel gui = new JPanel(new BorderLayout()); JLabel clouds = new JLabel(new ImageIcon(new BufferedImage(250, 100, BufferedImage.TYPE_INT_RGB))); gui.add(clouds);// w ww . j a v a2s. c om JOptionPane.showConfirmDialog(null, gui, "Title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, new ImageIcon(image)); }
From source file:ButtonBorderTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Fourth Button"); Container contentPane = frame.getContentPane(); Icon icon = new ImageIcon("java2s.gif"); JButton b = new JButton("Button!"); Border bored = BorderFactory.createMatteBorder(10, 5, 10, 5, icon); b.setBorder(bored);// ww w .j a va 2 s .com contentPane.add(b, BorderLayout.CENTER); frame.setSize(350, 200); frame.show(); }
From source file:ComboBoxDialog.java
public static void main(String argv[]) { String[] plays = new String[] { "Hamlet", "King Lear", "Otello", "Romeo and Juliet" }; String input = (String) JOptionPane.showInputDialog(new JFrame(), "Please select your favorite Shakespeare play", "Title", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("java2sLogo.GIF"), plays, "Romeo and Juliet"); System.out.println("User's input: " + input); }
From source file:Main.java
public static void main(String... args) throws Exception { JPanel panel = new JPanel(); panel.setOpaque(true);// w ww . jav a 2 s. c o m panel.setBackground(Color.RED); java.net.URL url = new java.net.URL("http://www.java2s.com/style/download.png"); ImageIcon image = new ImageIcon(url); JLabel label = new JLabel("LABEL", image, JLabel.RIGHT); panel.add(label); JOptionPane.showMessageDialog(null, panel, "Modified JOptionPane : ", JOptionPane.PLAIN_MESSAGE); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JToolBar toolbar = new JToolBar(); ImageIcon icon = new ImageIcon("icon.gif"); Action action = new AbstractAction("Button Label", icon) { public void actionPerformed(ActionEvent evt) { }//w w w . ja v a 2 s .c o m }; JButton c1 = new JButton(action); c1.setText(null); c1.setMargin(new Insets(0, 0, 0, 0)); toolbar.add(c1); JToggleButton c2 = new JToggleButton(action); c2.setText(null); c2.setMargin(new Insets(0, 0, 0, 0)); toolbar.add(c2); JComboBox c3 = new JComboBox(new String[] { "A", "B", "C" }); c3.setPrototypeDisplayValue("XXXXXXXX"); // Set a desired width c3.setMaximumSize(c3.getMinimumSize()); toolbar.add(c3); }
From source file:ScrollSample.java
public static void main(String args[]) { String title = (args.length == 0 ? "JScrollPane Sample" : args[0]); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Icon icon = new ImageIcon("dog.jpg"); JLabel dogLabel = new JLabel(icon); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(dogLabel); // scrollPane.getViewport().setView(dogLabel); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200);/*from www. j a v a 2s . co m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextPane textPane = new JTextPane(); StyledDocument doc = (StyledDocument) textPane.getDocument(); Style style = doc.addStyle("StyleName", null); StyleConstants.setIcon(style, new ImageIcon("imagefile")); doc.insertString(doc.getLength(), "ignored text", style); }