我想做一个表格,用来显示信息,要带滚动条的??public class NewMain8 { static String[] name = {"one", "two", "three", "four", "five", "six"};
static String[][] arr = {{"one", "two", "three", "four", "five", "six"}, {"one", "two", "three", "four", "five", "six"},
{"one", "two", "three", "four", "five", "six"}, {"one", "two", "three", "four", "five", "six"},
{"one", "two", "three", "four", "five", "six"}, {"one", "two", "three", "four", "five", "six"}}; public static void main(String[] args) {
JScrollPane jp=new JScrollPane();
JFrame jf = new JFrame("table");
jf.setBounds(200, 200, 300, 300);
JTable tb = new JTable(arr, name);
tb.setBounds(0, 0, 80,80);
jp.setViewportView(tb);
jf.getContentPane().add(tb);
jf.pack();
jf.setVisible(true);
}
}这代码哪里错了,显示不出滚动条
static String[][] arr = {{"one", "two", "three", "four", "five", "six"}, {"one", "two", "three", "four", "five", "six"},
{"one", "two", "three", "four", "five", "six"}, {"one", "two", "three", "four", "five", "six"},
{"one", "two", "three", "four", "five", "six"}, {"one", "two", "three", "four", "five", "six"}}; public static void main(String[] args) {
JScrollPane jp=new JScrollPane();
JFrame jf = new JFrame("table");
jf.setBounds(200, 200, 300, 300);
JTable tb = new JTable(arr, name);
tb.setBounds(0, 0, 80,80);
jp.setViewportView(tb);
jf.getContentPane().add(tb);
jf.pack();
jf.setVisible(true);
}
}这代码哪里错了,显示不出滚动条
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货