SWING 表格

blic class StudentNameCell extends DefaultTableCellRenderer   
  
  private static final long serialVersionUID = 1L;   
     
  public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column)   
  {   
      if(row%2 == 0){   
          setBackground(new Color(250,250,250));   
      }   
       else if(row%2 == 1){   
           setBackground(new Color(230,230,230));   
       }   
       super.getTableCellRendererComponent(table, obj, isSelected, hasFocus, row, column);   
       setBorder(null);   
       String name = null;   
       if(obj != null && (obj instanceof Student))   
       {   
           Student stu = (Student)obj;   
           name = stu.getName();   
       } else if(obj != null && (obj instanceof String))   
       {   
           name = (String)obj;   
       }   
       setText(name);   
       setToolTipText(name);   
       return this;   
   }  

 

 

设计swing可以用可视化设计工具 jigloo简单方便还可以设计SWT

你可能感兴趣的:(java,swing)