Topic: 关于JList的使用[求助]

  Print this page

1.关于JList的使用[求助] Copy to clipboard
Posted by: scwfeng
Posted on: 2006-04-08 17:00

请问怎么样在JList定义的列表中增加项目?比如增加“象棋”、“围棋”等。还有,JList有没有滚动条?

2.Re:关于JList的使用[求助] [Re: scwfeng] Copy to clipboard
Posted by: Jcat
Posted on: 2006-04-10 19:00


import javax.swing.*;

public class Jcat_Test {
static public void testJList() {
String[] data = {"象棋", "围棋", "军棋", "麻将", "象棋1", "围棋1", "军棋1", "麻将1"};
JList dataList = new JList(data);
JScrollPane jScrollPane = new JScrollPane(dataList);
JFrame jFrame = new JFrame();
jFrame.setSize(100, 100);
jFrame.add(jScrollPane);
jFrame.setVisible(true);
}

public static void main(String[] args) {
testJList();
}
}



   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923