image = ImageIO.read(new URL( "http://sstatic.net/stackoverflow/img/logo.png")); } catch (IOException e) { return new Dimension(image.getWidth(), image.getHeight()); int w = old.getWidth(); int h = old.getHeight(); BufferedImage img = new BufferedImage( w, h, BufferedImage.TYPE_INT_ARGB); String s = "Hello, world!"; FontMetrics fm = g2d.getFontMetrics(); int x = img.getWidth() - fm.stringWidth(s) - 5; int y = fm.getHeight(); g2d.drawString(s, x, y); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new TextOverlay()); f.pack(); f.setVisible(true);
import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; public class ImageInFrame { public static void main(String[] args) throws IOException { String path = "Image1.jpg"; File file = new File(path); BufferedImage image = ImageIO.read(file); JLabel label = new JLabel(new ImageIcon(image)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(label); f.pack(); f.setLocation(200,200); f.setVisible(true); } }
public static void main(String[] pArgs) throws IOException { BufferedImage image = ImageIO.read(new File("2006-Lamborghini-Gallardo-Spyder-Y-T-1600x1200.png")); new ResampleOp(image.getWidth() / 10, image.getHeight() / 10, ResampleOp.FILTER_QUADRATIC).filter(image, null); image = new ResampleOp(image.getWidth() / 4, image.getHeight() / 4, ResampleOp.FILTER_QUADRATIC).filter(image, null); long time = System.currentTimeMillis() - start; JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new JScrollPane(new JLabel(new BufferedImageIcon(image)))); frame.pack();
int w = bi.getWidth(); int h = bi.getHeight(); int step = w/3; JPanel p = new JPanel(new GridLayout(3,3)); g.drawRoundRect( 0, 0, iconPressed.getWidth(p)-1, iconPressed.getHeight(p)-1, 12, 12); g.dispose(); p.add(button); } else { JLabel label = new JLabel(new ImageIcon(icon)); p.add(label); center.add(p); JOptionPane.showMessageDialog(null, center); final BufferedImage bi = ImageIO.read(url); SwingUtilities.invokeLater(new Runnable(){ @Override
public static void main(String[] pArgs) throws IOException { BufferedImage image = ImageIO.read(new File("2006-Lamborghini-Gallardo-Spyder-Y-T-1600x1200.png")); JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new JScrollPane(new JLabel(new BufferedImageIcon(image)))); frame.pack();
JFrame frame = new JFrame("Image Example"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); image = ImageIO.read(MyPanel.class.getResource("/resources/images/planetbackground.jpg")); } catch (IOException ioe) { ioe.printStackTrace(); return image == null ? new Dimension(400, 300): new Dimension(image.getWidth(), image.getHeight());
import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class Test { public static void main(String[] args) { JFrame f = new JFrame(); try { f.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("test.jpg"))))); } catch (IOException e) { e.printStackTrace(); } f.pack(); f.setVisible(true); } }
public static String ratioAsString(String src) throws IOException { File file = new File(src); if (!file.exists()) { return null; } BufferedImage bufferedImage = ImageIO.read(file); int width = bufferedImage.getWidth(); int height = bufferedImage.getHeight(); return String.format("%s x %s", width, height); }
gui.add(quality, BorderLayout.WEST); dithering = new JCheckBox("Dithering", false); controls.add(antialiasing); controls.add(fractionalMetrics); ImageIO.read(new ByteArrayInputStream(outStream.toByteArray())); BufferedImage compressedImage = ImageIO.read(new ByteArrayInputStream(outStream.toByteArray())); return compressedImage; int width = originalImage.getWidth(); int height = originalImage.getHeight();
public static void main(String[] args) throws IOException { String path = "/Users/administrator/Desktop/images.jpeg"; BufferedImage image = ImageIO.read(new File(path)); LoadAndShow test = new LoadAndShow(image); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(test)); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); //showIcon(image); }
stopButton.setEnabled(false); try { Image stopIcon = ImageIO.read(getClass().getClassLoader().getResource("stop.png")); stopButton.setIcon(new ImageIcon(stopIcon)); } catch (Exception ignored) { } try { Image icon; icon = ImageIO.read(getClass().getClassLoader().getResource("comment.png")); optionLog.setIcon(new ImageIcon(icon)); icon = ImageIO.read(getClass().getClassLoader().getResource("time.png")); optionHistory.setIcon(new ImageIcon(icon)); icon = ImageIO.read(getClass().getClassLoader().getResource("list.png")); optionQueue.setIcon(new ImageIcon(icon)); icon = ImageIO.read(getClass().getClassLoader().getResource("gear.png")); optionConfiguration.setIcon(new ImageIcon(icon)); } catch (Exception e) { } gbc.gridy = 0; pane.add(ripPanel, gbc); gbc.gridy = 1; pane.add(statusPanel, gbc); gbc.gridy = 2; pane.add(progressPanel, gbc); gbc.gridy = 3; pane.add(optionsPanel, gbc); gbc.weighty = 1;
add(usrNameLabel, labCnst); add(usrNameFeild, txtCnst); add(passwordLabel, labCnst); add(passFeild, txtCnst); Rectangle2D txRect = new Rectangle2D.Double(0, 0, textureImg.getWidth(), textureImg.getHeight()); TexturePaint txPaint = new TexturePaint(textureImg, txRect); g2d.setPaint(txPaint); Graphics2D g2d = (Graphics2D) g.create(); if(gradientImage==null || gradientImage.getHeight() != getHeight()) MainContainer.textureImg = ImageIO.read(new URL("http://www.brewsterwallcovering.com/data/default/images/catalog/original/289-5757.jpg")); System.out.println("Loading finished. Starting the Demo!"); JFrame frame = new JFrame("Demo: LogIn Dialogue"); frame.add(new MainContainer()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);
JFrame frame = buildFrame(); final BufferedImage image = ImageIO.read(new File("C:\\Projects\\MavenSandbox\\src\\main\\resources\\img.jpg")); frame.add(pane); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(200, 200); frame.setVisible(true); return frame;
private JComponent getBanner() { try { BufferedImage img = ImageIO.read(getClass().getResource("splash.png")); JLabel title = new JLabel(new ImageIcon(img)); title.setPreferredSize(new Dimension(img.getWidth() + 10, img.getHeight())); title.setOpaque(true); title.setBackground(new Color(238, 238, 255)); return title; } catch (Exception ignore) { } return new JLabel(); }
public static void main(String[] args) throws IOException { String path = "/Users/administrator/Desktop/images.jpeg"; BufferedImage image = ImageIO.read(new File(path)); LoadImage test = new LoadImage(image); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(test)); f.setSize(400, 400); f.setLocation(200, 200); f.setVisible(true); //showIcon(image); } }
setTitle("BIMserver Starter"); try { setIconImage(ImageIO.read(getClass().getResource("logo_small.png"))); } catch (IOException e) { e.printStackTrace(); getContentPane().add(fields, BorderLayout.NORTH); getContentPane().add(scrollPane, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH);
ORIGINAL = ImageIO.read( ImageManipulationDemo.class.getResource("../resources/whitefro1.jpg")); ALTERED = config.createCompatibleImage( ORIGINAL.getWidth(), ORIGINAL.getHeight() + 20); Graphics2D g2 = ALTERED.createGraphics(); g2.setColor(Color.WHITE); g2.fillRect(0, 0, ALTERED.getWidth(), 20); g2.drawImage(ORIGINAL, 0, 20, null); g2.dispose(); final JFrame frame = new JFrame("Image Manipulation Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setBackground(Color.BLUE.darker()); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(new JLabel(new ImageIcon(ORIGINAL))); frame.getContentPane().add(new JLabel(new ImageIcon(ALTERED))); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
BufferedImage img = ImageIO.read(new File("/path/to/your/image/on/disk")); JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gbc.gridwidth = GridBagConstraints.REMAINDER; frame.add(new JLabel("Hello world"), gbc); frame.add(new JLabel("I'm on top"), gbc); frame.add(new JButton("Clickity-clackity"), gbc); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } catch (IOException exp) { exp.printStackTrace();