twaver 选取行数据

1、

table.addElementDoubleClickedActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e) {
    Person person = (Person)e.getSource();
    JOptionPane.showMessageDialog(leftPanel,
      "<html>I am <font color=blue><b>" + person.getFullName() + "</b></font>"
      + " at <font color=red><b>" + person.getAge() + "</b></font> years </html>"); 
   }
  });

 

2、

public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
    Component component = super.prepareRenderer(renderer, row, col);
    if(alternateButton.isSelected()){
     setAlternateRowColor(component, row, col);
    }else{
     setGradientRowColor(component, row, col);
    }
    Person person = (Person) table.getElementByRowIndex(row);
    if(person != null && !person.isSelected()){
     if(person.getAge() == 20 || person.getAge() == 80){
      component.setBackground(Color.green);
     }
    }
    return component;
   }

 

3、

    Person p = (Person)telmt_table.getElementByRowIndex(telmt_table.getSelectedRow());
    System.out.println(p.getName());
    System.out.println(p.getAge());

你可能感兴趣的:(twaver 选取行数据)