JScrollPane问题

时间:2011-03-13 12:24:57

标签: java swing jscrollpane

我编写了一个代码,显示了JTable中的图像搜索结果。

主要问题是,即使添加了JScrollbar,scorll bar也不会出现,即使它需要...

以下是我的代码的快照..

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);

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);

2 个答案:

答案 0 :(得分:3)

这可能是因为您要同时添加ijtablepane。只添加pane,因为该控件中包含ijtable

答案 1 :(得分:1)

frame.add(ijtable);

尝试删除此行。通过将表添加到框架,您可以将其从滚动窗格中删除。