Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to Java - Tell me what is wrong here?

Status
Not open for further replies.

Renidrag

Programmer
Jul 16, 2002
5
0
0
CA
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);
}
}
);
}
}
 
[1] Does the file compile?
[2] If the file compiles, then assuming the directory structure:

/some/path/Chap12
-> TestImage.java
-> TestImage.class

Then make sure $CLASSPATH contains /some/path, and run the process using:

java Chap12.TestImage

Cheers, Neil
 
No, it compiles and runs but the Icon does not display on the label component just the words do.
 
it is probably a size issue. make the JLabel component larger or your image smaller.
 
do you have the soure about jspsmartupload ?
my email: asun88@sina.com
thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top