Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- public class ChessFoo {
- public static void main(String[] args) {
- String bishopPath = "https://upload.wikimedia.org/wikipedia/commons/9/9b/Chess_blt60.png";
- try {
- URL bishopUrl = new URL(bishopPath);
- BufferedImage bishopImg = ImageIO.read(bishopUrl);
- Icon bishopIcon = new ImageIcon(bishopImg);
- JOptionPane.showMessageDialog(null, bishopIcon, "Plain Icon", JOptionPane.PLAIN_MESSAGE);
- JPanel panel = new JPanel(new GridBagLayout());
- panel.setBackground(Color.BLACK);
- panel.setPreferredSize(new Dimension(80, 80));
- panel.add(new JLabel(bishopIcon));
- JPanel wrapperPanel = new JPanel();
- wrapperPanel.add(panel);
- JOptionPane.showMessageDialog(null, wrapperPanel, "Black Background", JOptionPane.PLAIN_MESSAGE);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment