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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty JList will not show

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I have a JList in an applet that is initially empty but elements are later added. For some reason, the JList is not drawn if it has nothing in it, even if I use setMinimumSize(). As soon as I add an item it magically appears. This is obviously not the desired affect, so how do I fix it?
 
What version of Java are you using?

Also, Are the other items on the page drawing? If not, did you call setVisible on the Frame
 
I'm using version 1.4 of Java. All of the other items on the page are being drawn. I forgot to mention that if the JList is shown and I remove all of its elements, it becomes invisible again.
 
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;
import java.util.*;
public class jl extends Applet
{
Vector v = new Vector();
JList myJL = new JList(v);
public jl() {}
public void init()
{
add(myJL);
setBackground(Color.black);
myJL.setVisible(true);
v.add("@123456789");
myJL.setFixedCellHeight(50);
myJL.setFixedCellWidth(200);
}
public void start()
{
v.remove("@123456789");
}
}
// myJL.setBounds(0,0,50,200); can also shown JList will empty data but you have to setBounds all objects in applet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top