我有一個奇怪的問題,我似乎無法解決。我有一個JList
必須能夠滾動,如果有更多的項目,然後可以顯示。但是,如果我把JList
在JScrollPane
,它不利用BorderLayout
它在的EAST
部分的整個高度JScrollPane中的JList打亂JPanel高度
例無JScrollPane
:
public UsersPanel(){
String[] userList = new String[]{"Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar"};
JList users = new JList(userList);
add(users);
}
例如用JScrollPane
:
public UsersPanel(){
String[] userList = new String[]{"Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar","Foo","Bar"};
JList users = new JList(userList);
JScrollPane sp = new JScrollPane(users);
add(sp);
}
我想JList
利用的BorderLayout
它在東部區域的全部可用的高度。我已經試過我的包裹裏面JList
另一個JPanel
,但這並不無論是解決我的問題。