import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class Inter extends JFrame 
{
private JLabel label1, label2, label3;

public Inter()
{
super( "Testing JLabe" );

Container container = getContentPane();
container.setLayout ( new FlowLayout());

label1 = new JLabel( "Label with text" );
label1.setToolTipText( "This is label1" );
container.add( label2 );

Icon bug = new ImageIcon( "bug1.gif" );
label2 = new JLabel( "Label1 and text with icon", bug, SwingConstants.LEFT );
label2.setToolTipText("This is label2");

label3 = new JLabel();
label3.setText("Label with icon and text at bottom");
label3.setIcon(bug);
label3.setHorizontalTextPosition(SwingConstants.CENTER);
label3.setVerticalTextPosition(SwingConstants.BOTTOM);
label3.setToolTipText("This is label3");
container.add(label3);

setSize(275, 170);
setVisible(true);
}
public static void main( String args[] )
{
Inter application = new Inter();

application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Eclipse错误:
java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:621)
at java.awt.Container.add(Container.java:307)
at Inter.<init>(Inter.java:18)
at Inter.main(Inter.java:37)
Exception in thread "main"