Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java swing and NetBeans

843805Nov 23 2006 — edited Aug 13 2007
Hello everyone,
I'm new to java, and have got stuck on doing something rather simple.

I have created a jFrame using netbeans.
At the moment its a simple windows, with just a jList inside a jScrollPane.

Now, how in the world do I add or delete items from the List.

I have found countless examples of how to do this, but NONE of them take into count that "you didnt create the gui", (ie, they create/init the swing components manually). In my case Netbeans wrote the gui code and also a private void initComponents() ; Which I dont wish to touch.

All I've done is created a jFrame, and added a jList into jScrollPane.
Thats it, nothing else.

How do I write the...
public void addElememt(String element){}
and
public void delLastElememt(String element){}

Netbeans create my variables at the bottom of the screen...
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JList jList1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration

Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2007
Added on Nov 23 2006
15 comments
667 views