Hi,
This is my first post,
I usually find solution by searching this forums
However, I been working on my problem for 6 hours with no solution.
Here what I'm trying to do
I have a class that extends as JPanle
also it implements ActionListener
I'm trying to add JScrollPane to it,
here is the code
public class Shelf extends JPanel implements ActionListener {
Driver dv = new Driver(); //this is the main frame
private JPanel p;
private JScrollPane sc;
public Shelf() {
//I'm sure the code should go here
//I tried everything, first
//s=new JScrollPane(thi);
//and also tried do the SetPerf... to diminoson..
//but no results
}
@Override
public void actionPerformed(ActionEvent e) {
dv.getFrame().getContentPane().removeAll();
dv.getFrame().getContentPane().add(this.p);
this.removeAll();
ArrayList<Mybook> books = new ArrayList<Mybook>();
books = Library.getMydb().getAllBooks();
for (Mybook bk : books) {
JButton text = new JButton(bk.getTitle());
this.p.add(text);
}
dv.getFrame().validate();
dv.getFrame().repaint();
}
}