This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes extending an extended class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "extending an extended class" Watch "extending an extended class" New topic
Author

extending an extended class

samifox
Greenhorn

Joined: Sep 03, 2001
Posts: 5
Hi
I have to use a scrolled list several times among my program so I create a class named ScrolledList that extends Jpanel and an inner class that extends ScrolledLIst.
The problem shows up when I�m trying to add an item inside the inner class, the code pass compilation, it even enter the addItem() but its dont add item
What I�m doing wrong(code example please)?

here is the class i use whenever i need this scrolled list:

what im doing wrong(code example please)?
Thanks
[This message has been edited by Shay Gaghe (edited October 05, 2001).]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
samifox (aka Shay Gaghe?)
Please do not use this ID any more. It does not fit the at "JavaRanch Naming Policy"
Two comments on your question. You have a DefaultListModel that you are adding to, but you never hook it up to your JList.
You could try repainting.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Colin Kenworthy
Ranch Hand

Joined: Aug 06, 2001
Posts: 88
Shay,
You need to amend your code as follows:
in ScrolledList make your JList like this
JList list = new JList(dlm);
(otherwise how does the JList know what to display)
and in innerClass add your innerClass object like this
innerClass ic = new innerClass();
ic.addItem("Shay");
frame.getContentPane().add(ic,
BorderLayout.CENTER);
(your way adds 'Shay' to a different innerClass object to the one that is added to the window!)
Hope this helps,
Colin.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: extending an extended class
 
Similar Threads
Problem on extending an extended class
Panel on Splitpane: Fully occupy the Pane
Remove JList
Unable to delete a list entry at runtime
adding/removing from JListBox