import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class Draw extends JFrame { private static final long serialVersionUID = -1627995325677358600L; public Draw() { try { setContentPane(new JLabel(new ImageIcon(getImage()))); } catch (final MalformedURLException e) { e.printStackTrace(); } catch (final IOException e) { e.printStackTrace(); } pack(); setLocationRelativeTo(null); } public BufferedImage getImage() throws MalformedURLException, IOException { final BufferedImage bi = ImageIO .read(new URL( "http://static.ccm2.net/codes-sources.commentcamarche.net/_skin/_local/img/log_cs_beta2.png")); final Graphics2D g2 = (Graphics2D) bi.getGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.BLACK); g2.fillOval(5, 5, 50, 50); return bi; } public static void main(final String[] args) { new Draw().setVisible(true); } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question