List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon()
From source file:tk.mystudio.ocr.OCRTest.java
public static void main(String[] args) { JFrame frame = new JFrame("??"); final JLabel label = new JLabel(new ImageIcon(), JLabel.CENTER); byte[] image = client.getCodeByte(Constants.LOGIN_CODE_URL); String randCodeByRob = OCR.read(image); label.setIcon(new ImageIcon(image)); label.setText(randCodeByRob);/* www .j a va 2 s . c o m*/ label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { byte[] image = client.getCodeByte(Constants.LOGIN_CODE_URL); String randCodeByRob = OCR.read(image); label.setIcon(new ImageIcon(image)); label.setText(randCodeByRob); System.out.println(randCodeByRob); } }); frame.add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static JFrame getImageJFrame(BufferedImage image) { ImageIcon icon = new ImageIcon(); icon.setImage(image);//w ww . java 2s . c o m JFrame frame = new JFrame(); frame.add(new JLabel(icon)); frame.pack(); return frame; }
From source file:Main.java
public static ImageIcon GetIconFromURL(String url) { BufferedImage image;// w w w . j a v a 2 s . co m try { image = ImageIO.read(new URL(url)); } catch (Exception e) { return new ImageIcon(); } return new ImageIcon(image); }
From source file:arlocros.Imshow.java
public Imshow(String title, int height, int width) { SizeCustom = true;//from www.ja v a 2 s . c om Height = height; Width = width; Window = new JFrame(); image = new ImageIcon(); label = new JLabel(); label.setIcon(image); Window.getContentPane().add(label); Window.setResizable(false); Window.setTitle(title); }
From source file:com.callidusrobotics.swing.SwingConsole.java
private void initConsole(final Font font, final int rows, final int cols) { frame = new JFrame(); icon = new ImageIcon(); label = new JLabel(icon); // Compute font metrics final DisplayMode displayMode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDisplayMode();/*from w w w.ja v a 2 s . co m*/ frame.setVisible(true); imageBuffer = frame.createImage(displayMode.getWidth(), displayMode.getHeight()); graphicsRenderer = imageBuffer.getGraphics(); graphicsRenderer.setFont(font); final FontMetrics fontMetrics = graphicsRenderer.getFontMetrics(font); charHeight = fontMetrics.getHeight(); charWidth = fontMetrics.getHeight(); charHOffset = 0; charVOffset = fontMetrics.getAscent(); // Compute console dimensions and initialize graphics renderer final int width = charWidth * cols; final int height = charHeight * rows; imageBuffer = frame.createImage(width, height); graphicsRenderer = imageBuffer.getGraphics(); graphicsRenderer.setFont(font); render(); label.setBackground(TrueColor.MAGENTA); label.setBounds(0, 0, width, height); label.setVisible(true); frame.setBounds(0, 0, width, height); frame.setBackground(TrueColor.MAGENTA); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(label); frame.setCursor(null); frame.pack(); frame.setLocationRelativeTo(null); frame.setResizable(false); frame.addKeyListener(this); }