path设置的是E:\java的所有\jdk1.6\bin;
CLASSPATH设置的是E:\java的所有\java source file;
代码入下:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class LabelTest extends JFrame {
private JLabel label1,label2;
public LabelTest(){
super("Testing JLabel");
Container container=getContentPane();
container.setLayout(new FlowLayout());
label1=new JLabel("Label with test");
label1.setToolTipText("this is label1");
container.add(label1);
Icon bug=new ImageIcon("5.jpeg");
label2=new JLabel("label with text and icon",bug,SwingConstants.LEFT);
label2.setToolTipText("this is label2");
container.add(label2);
container.setSize(275,170);
container.setVisible(true);
}
public static void main(String args[]){
LabelTest application=new LabelTest();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
CLASSPATH设置的是E:\java的所有\java source file;
代码入下:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;public class LabelTest extends JFrame {
private JLabel label1,label2;
public LabelTest(){
super("Testing JLabel");
Container container=getContentPane();
container.setLayout(new FlowLayout());
label1=new JLabel("Label with test");
label1.setToolTipText("this is label1");
container.add(label1);
Icon bug=new ImageIcon("5.jpeg");
label2=new JLabel("label with text and icon",bug,SwingConstants.LEFT);
label2.setToolTipText("this is label2");
container.add(label2);
container.setSize(275,170);
container.setVisible(true);
}
public static void main(String args[]){
LabelTest application=new LabelTest();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
container.setVisible(true);
==>
this.setSize(275,170);
this.setVisible(true);
--》
this.add(container);
application.pack();
application.setVisible(true);