利用JTable类直接创建表格(不带滑轮)
作者:互联网
public class ExampleFrame_02 extends JFrame{ public static void main(String[] args) { // TODO Auto-generated method stub ExampleFrame_02 exampleFrame_02 = new ExampleFrame_02(); exampleFrame_02.setVisible(true); } public ExampleFrame_02() { // TODO Auto-generated constructor stub super(); setTitle("创建不可滚动的表格"); setBounds(100,100,240,150); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Vector<String> columnNameV = new Vector<>(); columnNameV.add("A"); columnNameV.add("B"); Vector<Vector<String>>tableValueV = new Vector<>(); for(int i=1;i<6;i++){ Vector<String>iV = new Vector<>(); iV.add("A"+ i); iV.add("B"+ i); tableValueV.add(iV); } JTable table = new JTable(tableValueV,columnNameV); getContentPane().add(table, BorderLayout.CENTER); JTableHeader tableHeader = table.getTableHeader(); getContentPane().add(tableHeader, BorderLayout.NORTH); } }
标签:02,创建表格,columnNameV,JTable,add,Vector,ExampleFrame,new,滑轮 来源: https://www.cnblogs.com/dulute/p/10674898.html