package Chap12;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestImage extends JFrame {
private JLabel lbla;
/** Creates a new instance of TestImage */
public TestImage() {
super("Test Image and JLabel"
;
Container c = getContentPane();
c.setLayout(new FlowLayout());
Icon myIcon = new ImageIcon("myIcona.gif"
;
lbla = new JLabel("This is label with Image", myIcon, SwingConstants.LEFT);
int thissize;
c.add(lbla);
setSize(275, 170);
show();
}
public static void main(String[] args) {
TestImage app = new TestImage();
app.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TestImage extends JFrame {
private JLabel lbla;
/** Creates a new instance of TestImage */
public TestImage() {
super("Test Image and JLabel"
Container c = getContentPane();
c.setLayout(new FlowLayout());
Icon myIcon = new ImageIcon("myIcona.gif"
lbla = new JLabel("This is label with Image", myIcon, SwingConstants.LEFT);
int thissize;
c.add(lbla);
setSize(275, 170);
show();
}
public static void main(String[] args) {
TestImage app = new TestImage();
app.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
}