i’m making an Jlist in Netbeans and i have written a code but the code dissapears not in my Jlist
/** Creates new form Toetsenbordd */
public Toetsenbordd() {
initComponents();
initCustomComponents();
}
private void initCustomComponents(){
JList Lijstje;
JScrollPane Lijst;
String filename[]= {"Ard ","Astronauts",
"Behind the Scene Movie credits","DNA Research -- the Human Genome Project",
"Extract from The Adventures of Pinocchio","History of Photography",
"Hubble Space Telescope","Legends of Abraham Lincoln","Netiquette",
"Observations of the Father of Computing (1791 - 1871)","Rules of Baseball (from 1889)",
"Speeding up the strategy process","Stinging Insects","The Eight Tools for Creating New Values",
"The Life of Calamity Jane","The Little Match Girl (adapted)","The Tail of Peter Rabbit",
"Thoughts of Banjamin Franklin","What is the Cast","Yosemite National Park"
};
{
Lijstje = new JList(filename);
Lijstje.setFont(new Font("Arial",Font.PLAIN,15));
Lijst =new JScrollPane(Lijstje);
Lijst.setSize(410,200);
Lijst.setLocation(70,75);
Lijstje.setVisibleRowCount(6);
Lijstje.setSelectedIndex(0);
Lijstje.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//seting the border for filescroll
Lijst.setBorder(BorderFactory.createTitledBorder("CHOOSE TEST"));
add(Lijst);
}
}
It stands in the middle of my selfmade Jframe:

But i want it there where it says item 1,2,3
First of all please don’t start your variable names with capital letters, this is against the Java naming conventions.
setLocationin your code implies that you want yourLijstto have an absolute position. This is only possible when you are not using a LayoutManager, refer to this tutorial. To do that you need to set layout manager tonullexplicitly becauseBorderLayoutis the default:But it’s not recommended to go with a
nulllayout manager, and you really should consider using the one from the list