示例#1
0
 @Override
 public void mouseMoved(MouseEvent e) {
   Point pt = e.getPoint();
   int prevRow = row;
   int prevCol = col;
   row = table.rowAtPoint(pt);
   col = table.columnAtPoint(pt);
   if (row < 0 || col < 0) {
     row = -1;
     col = -1;
   }
   // >>>> HyperlinkCellRenderer.java
   // @see
   // http://java.net/projects/swingset3/sources/svn/content/trunk/SwingSet3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java
   if (row == prevRow && col == prevCol) {
     return;
   }
   Rectangle repaintRect;
   if (row >= 0 && col >= 0) {
     Rectangle r = table.getCellRect(row, col, false);
     if (prevRow >= 0 && prevCol >= 0) {
       repaintRect = r.union(table.getCellRect(prevRow, prevCol, false));
     } else {
       repaintRect = r;
     }
   } else {
     repaintRect = table.getCellRect(prevRow, prevCol, false);
   }
   table.repaint(repaintRect);
   // <<<<
   // table.repaint();
 }
    @Nullable
    private SvnFileRevision getSelectedRevision(final MouseEvent e) {
      JTable table = (JTable) e.getSource();
      int row = table.rowAtPoint(e.getPoint());
      int column = table.columnAtPoint(e.getPoint());

      final Object value = table.getModel().getValueAt(row, column);
      if (value instanceof SvnFileRevision) {
        return (SvnFileRevision) value;
      }
      return null;
    }
示例#3
0
  private int getResizingRow(Point p, int row) {
    if (row == -1) {
      return -1;
    }
    int col = table.columnAtPoint(p);
    if (col == -1) return -1;
    Rectangle r = table.getCellRect(row, col, true);
    r.grow(0, -3);
    if (r.contains(p)) return -1;

    int midPoint = r.y + r.height / 2;
    int rowIndex = (p.y < midPoint) ? row - 1 : row;

    return rowIndex;
  }
 @Override
 public void mouseClicked(MouseEvent e) {
   int col = table.columnAtPoint(new Point(e.getX(), e.getY()));
   String header = table.getColumnName(col);
   if (columnHeader.contains(header)) {
     int row = table.rowAtPoint(new Point(e.getX(), e.getY()));
     TableModel tableModel = table.getModel();
     Object val =
         tableModel.getValueAt(
             table.convertRowIndexToModel(row), table.convertColumnIndexToModel(col));
     if (val != null) {
       String text = val.toString();
       textDialog.setText(text);
       textDialog.setVisible(true);
     }
   }
 }