PngIcon.java Source code

Java tutorial

Introduction

Here is the source code for PngIcon.java

Source

import java.awt.BorderLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class PngIcon {

    public PngIcon() {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JButton bt = new JButton(new ImageIcon("dtmail.png"));
        JLabel lab = new JLabel(new ImageIcon("dtterm.png"));
        bt.setFocusPainted(false);

        frame.add(bt, BorderLayout.NORTH);
        frame.add(lab, BorderLayout.SOUTH);
        frame.setBounds(50, 50, 200, 200);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        new PngIcon();
    }
}