Mahesh Gupta
Mahesh Gupta

Reputation: 2748

Issue with JScrollPane

I've written a code which displays search results which are images in JTable..

The main problem is that even after adding JScrollbar, the scorll bar does not appear even when its needed...

Here is a snapshot of my code..

this.queryName = qname;

    JFrame frame = new JFrame(title);
    frame.setLayout(new GridLayout(2, 1)); //.. UPPER FOR QUERY AND LOWER FOR RESULT

    this.ijtable = new ImageJTable(result, Setting.getColumnCount());
    ijtable.setVisible(true);
    JScrollPane pane = new JScrollPane(ijtable);

    JLabel query = new JLabel(new ImageIcon(ImageResize.resize(queryName, Setting.getQueryWidth(), Setting.getQueryWidth())));
    query.setVisible(true);

    frame.add(query);
    frame.add(ijtable);
    frame.add(pane);

    frame.setSize(Setting.getFrameWidth(), Setting.getFrameHeight());
    frame.setVisible(true);

Upvotes: 2

Views: 312

Answers (2)

developmentalinsanity
developmentalinsanity

Reputation: 6229

frame.add(ijtable);

Try removing this line. By adding the table to the frame, you're removing it from the scroll pane.

Upvotes: 1

Morten Kristensen
Morten Kristensen

Reputation: 7613

It's probably because you are adding both ijtable and pane. Only add pane because that control has ijtable inside it.

Upvotes: 3

Related Questions