This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler 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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "extending an extended class" Watch "extending an extended class" New topic

extending an extended class


Joined: Sep 03, 2001
Posts: 5
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)?
[This message has been edited by Shay Gaghe (edited October 05, 2001).]
Cindy Glass
"The Hood"

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
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();
(your way adds 'Shay' to a different innerClass object to the one that is added to the window!)
Hope this helps,
I agree. Here's the link:
subject: extending an extended class
jQuery in Action, 3rd edition