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
posted
0
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
posted
0
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.