List of usage examples for javax.swing ImageIcon ImageIcon
public ImageIcon(byte[] imageData)
From source file:ImageTest.java
public ImageLabel(String img) { this(new ImageIcon(img)); }
From source file:Main.java
public Main() throws Exception { URL imageURL = getClass().getClassLoader().getResource("images/k.jpeg"); buttonIcon = new ImageIcon(imageURL); button = new JButton("Click to Buh!", buttonIcon); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (buhClip != null) { buhClip.setFramePosition(0); buhClip.start();//from ww w .j av a 2s .co m } else System.out.println("Couldn't load sound"); } }); getContentPane().add(button); URL soundURL = getClass().getClassLoader().getResource("sounds/b.aiff"); Line.Info linfo = new Line.Info(Clip.class); Line line = AudioSystem.getLine(linfo); buhClip = (Clip) line; AudioInputStream ais = AudioSystem.getAudioInputStream(soundURL); buhClip.open(ais); }
From source file:GrabAndDragDemo.java
public GrabAndDragDemo() { super("Grab and drag Demo"); ImageIcon ii = new ImageIcon("largeJava2sLogo.jpg"); JScrollPane jsp = new JScrollPane(new GrabAndScrollLabel(ii)); getContentPane().add(jsp);// w w w. j a v a 2s . co m setSize(300, 250); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); }
From source file:Main.java
public Main() { images = new ImageIcon[totalImages]; for (int i = 0; i < images.length; ++i) images[i] = new ImageIcon("images/java" + i + ".gif"); startAnimation();/*from w w w .j av a 2 s .c o m*/ }
From source file:MatteExample.java
public MatteExample() { super(true);//from ww w. j a v a 2 s .c om this.setLayout(new GridLayout(1, 2, 5, 5)); JLabel label1 = new JLabel("Matte Border"); JLabel label2 = new JLabel("Matte Border (Icon)"); label1.setHorizontalAlignment(JLabel.CENTER); label2.setHorizontalAlignment(JLabel.CENTER); Icon icon = new ImageIcon("yourFile.gif"); MatteBorder matte = new MatteBorder(35, 35, 35, 35, Color.blue); MatteBorder matteicon = new MatteBorder(35, 35, 35, 35, icon); label1.setBorder(matte); label2.setBorder(matteicon); add(label1); add(label2); }
From source file:ConvolveIt.java
public Image getImage(String imageFile) { ImageIcon icon = new ImageIcon(imageFile); return icon.getImage(); }
From source file:Main.java
public Main() throws Exception { super();//w w w . j a v a 2s. com ImageIcon ii = new ImageIcon(new URL("http://www.java2s.com/style/download.png")); GrabAndScrollLabel label = new GrabAndScrollLabel(ii); label.setPreferredSize(new Dimension(300, 300)); JScrollPane jsp = new JScrollPane(label); getContentPane().add(jsp); setSize(300, 250); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); }
From source file:Main.java
public Main() { super("JSpinner Icon Test"); setSize(300, 80);//from w ww . jav a 2 s .c om setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new GridLayout(0, 2)); Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"), new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") }; JSpinner s1 = new JSpinner(new SpinnerListModel(nums)); s1.setEditor(new IconEditor(s1)); System.out.println(s1.getEditor()); c.add(new JLabel(" Icon Spinner")); c.add(s1); setVisible(true); }
From source file:MainClass.java
public MainClass() { super("JSpinner Icon Test"); setSize(300, 80);//from w w w . ja va2s .com setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new GridLayout(0, 2)); Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"), new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") }; JSpinner s1 = new JSpinner(new SpinnerListModel(nums)); s1.setEditor(new IconEditor(s1)); c.add(new JLabel(" Icon Spinner")); c.add(s1); setVisible(true); }
From source file:BasicDraw.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; AffineTransform tx = new AffineTransform(); double radians = -Math.PI / 4; tx.rotate(radians);/*w w w . ja v a2 s . c o m*/ g2d.setTransform(tx); g2d.drawImage(new ImageIcon("a.png").getImage(), tx, this); }