File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extending an extended class

 
samifox
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Colin Kenworthy
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic