List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:MainClass.java
public void init() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); DefaultMutableTreeNode subroot = new DefaultMutableTreeNode("SubRoot"); DefaultMutableTreeNode leaf1 = new DefaultMutableTreeNode("Leaf 1"); DefaultMutableTreeNode leaf2 = new DefaultMutableTreeNode("Leaf 2"); treeModel = new DefaultTreeModel(root); tree = new JTree(treeModel); treeModel.insertNodeInto(subroot, root, 0); subroot.add(leaf1);//from w w w. j a v a 2 s .c o m root.add(leaf2); tree.putClientProperty("JTree.lineStyle", "Angled"); getContentPane().add(tree, BorderLayout.CENTER); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); renderer.setClosedIcon(new ImageIcon("door.closed.gif")); renderer.setOpenIcon(new ImageIcon("door.open.gif")); renderer.setLeafIcon(new ImageIcon("world.gif")); }
From source file:Main.java
public MyPanel() { this.setLayout(new GridLayout()); this.setPreferredSize(new Dimension(W, H)); int w = W / 2; int h = H / 2; int r = w / 5; BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); g.setColor(Color.gray);/* w w w. ja va 2s . c o m*/ g.fillRect(0, 0, w, h); g.setColor(Color.blue); g.fillRect(w / 2 - r, h / 2 - r / 2, 2 * r, r); g.dispose(); this.add(new JLabel(new ImageIcon(bi), JLabel.CENTER)); }
From source file:LayeredPaneDemo2.java
public LayeredPaneDemo2() { super("Custom MDI: Part III"); setSize(570, 400);/* ww w. ja v a2s. c om*/ getContentPane().setBackground(new Color(244, 232, 152)); getLayeredPane().setOpaque(true); // VERY IMPORTANT!! 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:com.isencia.passerelle.hmi.action.ModelDebugger.java
/** * @param base//from w w w.j a v a2 s . co m */ public ModelDebugger(final HMIBase base) { super(base, HMIMessages.getString(HMIMessages.MENU_DEBUG), new ImageIcon(HMIBase.class.getResource("resources/debug.gif"))); }
From source file:FramewithComponents.java
public FramewithComponents() { super("JLayeredPane Demo"); setSize(256, 256);//from ww w .j a v a 2s. co m JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setOpaque(false); JLabel label1 = new JLabel("Username:"); label1.setForeground(Color.white); content.add(label1); JTextField field = new JTextField(15); content.add(field); JLabel label2 = new JLabel("Password:"); label2.setForeground(Color.white); content.add(label2); JPasswordField fieldPass = new JPasswordField(15); content.add(fieldPass); getContentPane().setLayout(new FlowLayout()); getContentPane().add(content); ((JPanel) getContentPane()).setOpaque(false); ImageIcon earth = new ImageIcon("largeJava2sLogo.png"); JLabel backlabel = new JLabel(earth); getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE)); backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight()); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); setVisible(true); }
From source file:Main.java
License:asdf
public Dimension getPreferredSize(JComponent c) { FontMetrics metrics = c.getFontMetrics(c.getFont()); String tipText = ((JToolTip) c).getTipText(); if (tipText == null) { tipText = ""; }/*w ww . j a va 2 s . co m*/ Image image = new ImageIcon("yourImage").getImage(); int width = SwingUtilities.computeStringWidth(metrics, tipText); int height = metrics.getHeight() + image.getHeight(c); if (width < image.getWidth(c)) { width = image.getWidth(c); } return new Dimension(width, height); }
From source file:facturas.Facture.java
/** * Creates new form Facture/*from ww w . j a v a 2 s. co m*/ */ public Facture() { initComponents(); setIconImage(new ImageIcon(getClass().getResource("/Images/icono.png")).getImage()); this.setTitle("Facture Application"); this.setLocationRelativeTo(null); getRootPane().setDefaultButton(jButtonPrecioTotal); //Hacemos que los campos jText Field siguientes no puedan ser editables jTextFieldIva.setEditable(false); jTextFieldIva.setForeground(Color.BLUE); jTextFieldIva1.setEditable(false); jTextFieldIva1.setForeground(Color.BLUE); jTextFieldIva2.setEditable(false); jTextFieldIva2.setForeground(Color.BLUE); jTextFieldIva3.setEditable(false); jTextFieldIva3.setForeground(Color.BLUE); jTextFieldTotal.setEditable(false); jTextFieldTotal.setForeground(Color.BLUE); jTextFieldTotal1.setEditable(false); jTextFieldTotal1.setForeground(Color.BLUE); jTextFieldTotal2.setEditable(false); jTextFieldTotal2.setForeground(Color.BLUE); jTextFieldTotal3.setEditable(false); jTextFieldTotal3.setForeground(Color.BLUE); jTextFieldTotalPrice.setEditable(false); jTextFieldTotalPrice.setForeground(Color.RED); jTextFieldTotalPrice.setBackground(Color.LIGHT_GRAY); }
From source file:Main.java
public Main() { 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);/* w ww.j a v a 2s.c o m*/ } catch (Exception ex) { ex.printStackTrace(); } } }; JRadioButtonMenuItem leftJustify = new JRadioButtonMenuItem("Left", new ImageIcon("1.gif")); leftJustify.setHorizontalTextPosition(JMenuItem.RIGHT); leftJustify .setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); leftJustify.addActionListener(actionPrinter); JRadioButtonMenuItem rightJustify = new JRadioButtonMenuItem("Right", new ImageIcon("2.gif")); rightJustify.setHorizontalTextPosition(JMenuItem.RIGHT); rightJustify .setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); rightJustify.addActionListener(actionPrinter); JRadioButtonMenuItem centerJustify = new JRadioButtonMenuItem("Center", new ImageIcon("3.gif")); centerJustify.setHorizontalTextPosition(JMenuItem.RIGHT); centerJustify .setAccelerator(KeyStroke.getKeyStroke('M', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); centerJustify.addActionListener(actionPrinter); JRadioButtonMenuItem fullJustify = new JRadioButtonMenuItem("Full", new ImageIcon("4.gif")); fullJustify.setHorizontalTextPosition(JMenuItem.RIGHT); fullJustify .setAccelerator(KeyStroke.getKeyStroke('F', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); fullJustify.addActionListener(actionPrinter); ButtonGroup group = new ButtonGroup(); group.add(leftJustify); group.add(rightJustify); group.add(centerJustify); group.add(fullJustify); justifyMenu.add(leftJustify); justifyMenu.add(rightJustify); justifyMenu.add(centerJustify); justifyMenu.add(fullJustify); menuBar.add(justifyMenu); menuBar.setBorder(new BevelBorder(BevelBorder.RAISED)); }
From source file:iqq.app.core.service.impl.ResourceServiceImpl.java
/** * ??// w w w.j ava 2s.c o m * * @param filename * @return */ @Override public ImageIcon getIcon(String filename) { return new ImageIcon(getFile(filename).getAbsolutePath()); }
From source file:Main.java
/** * Creates the image icon.//from w w w .j a v a2 s. c om * * @param path * the path * @param width * the width * @param height * the height * @return the image icon */ public static ImageIcon createImageIcon(String path, int width, int height) { return new ImageIcon(new ImageIcon(path).getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH)); }