当前位置: 首页>>代码示例>>Java>>正文


Java JTable.rowAtPoint方法代码示例

本文整理汇总了Java中javax.swing.JTable.rowAtPoint方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.rowAtPoint方法的具体用法?Java JTable.rowAtPoint怎么用?Java JTable.rowAtPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.rowAtPoint方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: maybeShowPopup

import javax.swing.JTable; //导入方法依赖的package包/类
private void maybeShowPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                JTable source = (JTable)(e.getSource());

                if ( ! source.isEnabled () ) return;

                _inputTablePopupRow = 
                        source.rowAtPoint(new Point (e.getX(), e.getY()));
                _inputTablePopupColumn = 
                        source.columnAtPoint(new Point (e.getX(), e.getY()));
                // Make sure the row where click occurred is selected.
                if (_inputTablePopupRow != -1) {
                    source.setRowSelectionInterval (_inputTablePopupRow,
                                                    _inputTablePopupRow);
                }
//                 if  ( _inputTablePopupColumn != Criteria_COLUMN )
//                 {
//                     // return without showing popup
//                     return;
//                 }

                _inputTablePopup.show(e.getComponent(), e.getX(), e.getY());
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:QueryBuilderInputTable.java

示例2: isCellEditable

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean isCellEditable(EventObject anEvent) {
    if (anEvent.getSource() instanceof JTable) {
        JTable table = (JTable) anEvent.getSource();
        if (anEvent instanceof MouseEvent) {
            MouseEvent event = (MouseEvent) anEvent;
            Point p = event.getPoint();
            int row = table.rowAtPoint(p);
            int col = table.columnAtPoint(p);
            Rectangle rect = table.getCellRect(row, col, true);
            p.translate(-rect.x, -rect.y);
            System.out.println("isCellEditable("+anEvent+")");
            System.out.println("Point "+p+"in rectangle "+rect);
            if (p.x > rect.width - 24) {
                // last 24 points not editable
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TableRendererTest.java

示例3: RTable

import javax.swing.JTable; //导入方法依赖的package包/类
public RTable(Component source, JSONOMapConfig omapConfig, Point point, IJSONRecorder recorder) {
    super(source, omapConfig, point, recorder);
    JTable table = (JTable) source;
    if (table.isEditing()) {
        column = table.getEditingColumn();
        row = table.getEditingRow();
    } else {
        if (point != null) {
            row = table.rowAtPoint(point);
            column = table.columnAtPoint(point);
        } else {
            row = table.getSelectedRow();
            column = table.getSelectedColumn();
        }
    }
    if (row == -1 || column == -1) {
        row = column = -1;
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:RTable.java

示例4: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    int crow = table.rowAtPoint(pt);
    Object value = table.getValueAt(crow, ccol);
    if (value instanceof URL) {
        URL url = (URL) value;
        Desktop desktop = null;
        try {
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
        if (desktop != null) {
            try {
                desktop.browse(url.toURI());
            } catch (Exception exc) {
                // browsing failed; just don't do anything
            }
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:LibrariesTable.java

示例5: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    int crow = table.rowAtPoint(pt);
    Object value = table.getValueAt(crow, ccol);
    if (value instanceof URL) {
        URL url = (URL) value;
        try {
            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(url.toURI());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:ContributorsTable.java

示例6: maybeShowPopup

import javax.swing.JTable; //导入方法依赖的package包/类
private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
        JTable source = (JTable)(e.getSource());
        int row = source.rowAtPoint(e.getPoint());
        int column = source.columnAtPoint(e.getPoint());
        // Make sure the row where click occurred is selected.
        if (row != -1) {
            source.setRowSelectionInterval (row, row);
        }
        resultTablePopup.show(e.getComponent(), e.getX(), e.getY());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:QueryBuilderResultTable.java

示例7: mouseMoved

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int prev_row = this.row;
    int prev_col = this.col;
    this.row = table.rowAtPoint(pt);
    this.col = table.columnAtPoint(pt);
    if (this.row != prev_row || this.col != prev_col) {
        Rectangle r = table.getCellRect(this.row, this.col, false);
        r = r.union(table.getCellRect(prev_row, prev_col, false));
        table.repaint(r);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:15,代码来源:LibrariesTable.java

示例8: mouseDragged

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
    if (e.isAltDown() && startLocation != null) {
        isInDragOperation = true;
        JTable t = (JTable) e.getSource();
        int selRow = t.rowAtPoint(e.getPoint());
        int selColumn = t.columnAtPoint(e.getPoint());
        if (selRow != -1 && selColumn != -1) {
            rowsRColumns.add(new Integer[]{selRow, selColumn});
        }
    } else {
        isInDragOperation = false;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:TableCellDrag.java

示例9: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
	if (e.getClickCount() == 2) {
		JTableHeader header = (JTableHeader) e.getSource();
		TableColumn tableColumn = getResizingColumn(header, e.getPoint());

		if (tableColumn == null) {
			return;
		}

		JTable table = header.getTable();

		if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
			if (table instanceof ExtendedJTable) {
				((ExtendedJTable) table).pack();
				e.consume();
			}
		} else {
			int col = header.getColumnModel().getColumnIndex(tableColumn.getIdentifier());
			int width = (int) header.getDefaultRenderer()
					.getTableCellRendererComponent(table, tableColumn.getIdentifier(), false, false, -1, col)
					.getPreferredSize().getWidth();

			int firstRow = 0;
			int lastRow = table.getRowCount();

			if (table instanceof ExtendedJTable) {
				ExtendedJScrollPane scrollPane = ((ExtendedJTable) table).getExtendedScrollPane();
				if (scrollPane != null) {
					JViewport viewport = scrollPane.getViewport();
					Rectangle viewRect = viewport.getViewRect();
					if (viewport.getHeight() < table.getHeight()) {
						firstRow = table.rowAtPoint(new Point(0, viewRect.y));
						firstRow = Math.max(0, firstRow);
						lastRow = table.rowAtPoint(new Point(0, viewRect.y + viewRect.height - 1));
						lastRow = Math.min(lastRow, table.getRowCount());
					}
				}
			}

			for (int row = firstRow; row < lastRow; row++) {
				int preferedWidth = (int) table.getCellRenderer(row, col)
						.getTableCellRendererComponent(table, table.getValueAt(row, col), false, false, row, col)
						.getPreferredSize().getWidth();
				width = Math.max(width, preferedWidth);
			}
			header.setResizingColumn(tableColumn); // this line is very important
			tableColumn.setWidth(width + table.getIntercellSpacing().width);

			e.consume();
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:54,代码来源:ExtendedJTableColumnFitMouseListener.java


注:本文中的javax.swing.JTable.rowAtPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。