Java Code Examples for javax.swing.JTable#addMouseMotionListener()
The following examples show how to use
javax.swing.JTable#addMouseMotionListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HyperlinkCellRenderer.java From littleluck with Apache License 2.0 | 5 votes |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (this.table == null) { this.table = table; HyperlinkMouseListener hyperlinkListener = new HyperlinkMouseListener(); table.addMouseMotionListener(hyperlinkListener); table.addMouseListener(hyperlinkListener); } int columnModelIndex = table.getColumnModel().getColumn(column).getModelIndex(); if (!columnModelIndeces.contains(columnModelIndex)) { columnModelIndeces.add(columnModelIndex); } if (value instanceof Link) { Link link = (Link) value; setText(link.getDisplayText()); setToolTipText(link.getDescription()); } else { setText(value != null ? value.toString() : ""); } setVisited(isCellLinkVisited(value, row, column)); setDrawUnderline(!underlineOnRollover || (row == hitRowIndex && column == hitColumnIndex)); if (!isSelected) { setBackground(rowColors[row % rowColors.length]); //setForeground(isCellLinkVisited(value, row, column)? // visitedForeground : foreground); setForeground(foreground); setVisitedForeground(visitedForeground); } else { setBackground(table.getSelectionBackground()); setForeground(table.getSelectionForeground()); setVisitedForeground(table.getSelectionForeground()); } //setBorder(hasFocus? focusBorder : noFocusBorder); //System.out.println("border insets="+getBorder().getBorderInsets(this)); return this; }
Example 2
Source File: HyperlinkCellRenderer.java From beautyeye with Apache License 2.0 | 5 votes |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (this.table == null) { this.table = table; HyperlinkMouseListener hyperlinkListener = new HyperlinkMouseListener(); table.addMouseMotionListener(hyperlinkListener); table.addMouseListener(hyperlinkListener); } int columnModelIndex = table.getColumnModel().getColumn(column).getModelIndex(); if (!columnModelIndeces.contains(columnModelIndex)) { columnModelIndeces.add(columnModelIndex); } if (value instanceof Link) { Link link = (Link) value; setText(link.getDisplayText()); setToolTipText(link.getDescription()); } else { setText(value != null ? value.toString() : ""); } setVisited(isCellLinkVisited(value, row, column)); setDrawUnderline(!underlineOnRollover || (row == hitRowIndex && column == hitColumnIndex)); if (!isSelected) { setBackground(rowColors[row % rowColors.length]); //setForeground(isCellLinkVisited(value, row, column)? // visitedForeground : foreground); setForeground(foreground); setVisitedForeground(visitedForeground); } else { setBackground(table.getSelectionBackground()); setForeground(table.getSelectionForeground()); setVisitedForeground(table.getSelectionForeground()); } //setBorder(hasFocus? focusBorder : noFocusBorder); //System.out.println("border insets="+getBorder().getBorderInsets(this)); return this; }
Example 3
Source File: TableCellDrag.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 4 votes |
public static void install(JTable table) { TableCellDrag tcellDrag = new TableCellDrag(); table.addMouseListener(tcellDrag); table.addMouseMotionListener(tcellDrag); }
Example 4
Source File: HeaderlessColumnResizer.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
public HeaderlessColumnResizer(JTable table) { this.table = table; table.addMouseListener(this); table.addMouseMotionListener(this); }
Example 5
Source File: HeaderlessColumnResizer.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public HeaderlessColumnResizer(JTable table) { this.table = table; table.addMouseListener(this); table.addMouseMotionListener(this); }
Example 6
Source File: PlacemarkManagerTopComponent.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
public void initUI() { setLayout(new BorderLayout()); placemarkTable = new JTable(placemarkTableModel); placemarkTable.setRowSorter(new TableRowSorter<>(placemarkTableModel)); placemarkTable.setName("placemarkTable"); placemarkTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); placemarkTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); placemarkTable.setRowSelectionAllowed(true); // IMPORTANT: We set ReorderingAllowed=false, because we export the // table model AS IS to a flat text file. placemarkTable.getTableHeader().setReorderingAllowed(false); ToolTipSetter toolTipSetter = new ToolTipSetter(); placemarkTable.addMouseMotionListener(toolTipSetter); placemarkTable.addMouseListener(toolTipSetter); placemarkTable.addMouseListener(new PopupListener()); placemarkTable.getSelectionModel().addListSelectionListener(new PlacemarkTableSelectionHandler()); updateTableModel(); final TableColumnModel columnModel = placemarkTable.getColumnModel(); columnModel.addColumnModelListener(new ColumnModelListener()); JScrollPane tableScrollPane = new JScrollPane(placemarkTable); JPanel mainPane = new JPanel(new BorderLayout(4, 4)); mainPane.add(tableScrollPane, BorderLayout.CENTER); buttonPane = new PlacemarkManagerButtons(this); JPanel content = new JPanel(new BorderLayout(4, 4)); content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); content.add(BorderLayout.CENTER, mainPane); content.add(BorderLayout.EAST, buttonPane); Component southExtension = getSouthExtension(); if (southExtension != null) { content.add(BorderLayout.SOUTH, southExtension); } content.setPreferredSize(new Dimension(420, 200)); setCurrentView(snapApp.getSelectedProductSceneView()); setProduct(snapApp.getSelectedProduct(VIEW)); snapApp.getSelectionSupport(ProductSceneView.class).addHandler(new ProductSceneViewSelectionChangeHandler()); snapApp.getProductManager().addListener(new ProductRemovedListener()); updateUIState(); add(content, BorderLayout.CENTER); }
Example 7
Source File: InnerPanelSupport.java From netbeans with Apache License 2.0 | 3 votes |
/** * Enhances a JTable, so it displays tooltips for cells which are cut * at the right side. * This feature is useful for tables with no horizontal scrollbar, since * the user may see full cell's contents when hovering above the row/cell. * <p/> * A tooltip is displayed above table, which hides itself whenever the user * moves mouse out of component or the tooltip or starts editing (if the table * is cell-editable). * <p/> * The tooltip's contents is painted by the configured CellRenderer. * * @param table table to enhance * @return the table; just use as part of new expression. */ public static JTable displayExtendedCells(JTable table) { CellExtensionSupport supp = new CellExtensionSupport(table); table.addMouseListener(supp); table.addMouseMotionListener(supp); table.getSelectionModel().addListSelectionListener(supp); return table; }