import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class MainClass extends JPanel {
public MainClass() {
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
JLabel jl = new JLabel(new MyIcon(), JLabel.CENTER);
add(jl);
}
});
} catch (Exception exc) {
System.out.println("Can't create because of " + exc);
}
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.getContentPane().add(new MainClass());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setVisible(true);
}
}
|