Subscribe

RSS Feed (xml)

Powered By

Place Your Ads Here

Swing Simplest Jlist in java


swing jlist is not similar to awt list..i create it as follows first of all do as in the image then i have declared DefaultListModel as dlm instance varible (class level) there after the following is the code


on button click

dlm=new DefaultListModel()
jList1.setModel(dlm);
for(int x=0;x<17;x++)
{
dlm.add(x, "i am "+x);
if(x==16){
dlm.add(17,"www.proamrishwa.blogspot.com");
}
else
{
//keep visiting www.proamrishwa.blogspot.com
}

}
and i got the following results


you can download full source code from here
Source code