TableModel dataModel = new AbstractTableModel() {
  String []title={"编号","账号","密码","权限"};
          public int getColumnCount() { return title.length; }
          public int getRowCount() { return LoginValidation.getVector().size();}
          public Object getValueAt(int row, int col) { 
           if(!LoginValidation.getVector().isEmpty()) 
           return ((Vector)LoginValidation.getVector().elementAt(row)).elementAt(col); 
           else 
           return null;
           }
          public String getColumnName(int col){
           return title[col];
          }
      };
    JTable table = new JTable(dataModel);
    JScrollPane scrollpane = new JScrollPane(table);
            jp2.add(table);
应该是jp2.add(table)有错误,他把scrollpane 屏蔽了 可是我真的不知道怎么该了

解决方案 »

  1.   

    JScrollPane.getViewPort().add(Component compo);
      

  2.   

    jp2.add(scrollpane);
    把整个滚动视图都加进去。否则是没有办法显示出来的
      

  3.   

    可以使用jp2.setViewportView(table); 
      

  4.   

    TableModel dataModel = new AbstractTableModel() { 
      String []title={"编号","账号","密码","权限"}; 
              public int getColumnCount() { return title.length; } 
              public int getRowCount() { return LoginValidation.getVector().size();} 
              public Object getValueAt(int row, int col) { 
              if(!LoginValidation.getVector().isEmpty()) 
              return ((Vector)LoginValidation.getVector().elementAt(row)).elementAt(col); 
              else 
              return null; 
              } 
              public String getColumnName(int col){ 
              return title[col]; 
              } 
          }; 
        JTable table = new JTable(dataModel); 
        JScrollPane scrollpane = new JScrollPane(table); 
    scrollpane.getViewPort().add(table);
                jp2.add(scrollpane); 你 试试行不?但愿可以呵呵! 我这网吧没工具呵呵