final Component editor = getEditorComponent(); if (editor == null || !(editor instanceof JTextComponent)) { return result;
/** * @see DataProvider#getData() */ @Override public String getData() { String data = null; final Component editorComponent = table.getEditorComponent(); if (editorComponent instanceof JTextComponent) { data = ((JTextComponent) editorComponent).getText(); } return data; } }
/** * @see DataProvider#getData() */ @Override public Integer getData() { Integer selectedIndex = null; // Get the combobox editor from the table, if any final Component editorComponent = table.getEditorComponent(); if (editorComponent instanceof JComboBox) { // Get the selected index from the combobox selectedIndex = ((JComboBox) editorComponent).getSelectedIndex(); } else { LOGGER.warn("Table editor component is not a JComboBox: " + editorComponent); } return selectedIndex; } }
public Component getSwingEditorComponentAt(int row, int column) { jTable.editCellAt(row, column); return jTable.getEditorComponent(); }
private static void autoEdit(JTable tab) { if (tab.editCellAt(tab.getSelectedRow(), tab.getSelectedColumn(), null) && tab.getEditorComponent() != null) { JTextField field = (JTextField) tab.getEditorComponent(); field.setCaretPosition(field.getText().length()); field.requestFocusInWindow(); field.selectAll(); } }
private void setDispatchComponent(MouseEvent e) { Component editorComponent = table.getEditorComponent(); Point p = e.getPoint(); Point p2 = SwingUtilities.convertPoint(table, p, editorComponent); dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y); }
private void setDispatchComponent(MouseEvent e) { Component editorComponent=table.getEditorComponent(); Point p=e.getPoint(); Point p2=SwingUtilities.convertPoint(table, p, editorComponent); dispatchComponent=SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y); }
private void setDispatchComponent(MouseEvent e) { Component editorComponent = table.getEditorComponent(); Point p = e.getPoint(); Point p2 = SwingUtilities.convertPoint(table, p, editorComponent); dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y); }
private void setDispatchComponent(MouseEvent e) { Component editorComponent = table.getEditorComponent(); Point p = e.getPoint(); Point p2 = SwingUtilities.convertPoint(table, p, editorComponent); dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y); }
JTable table = new JTable(); table.getEditingColumn(); table.getEditingRow(); table.getEditorComponent();
public static void main(String[] args) throws Exception { final JTable t = new JTable(4, 4); t.setCellSelectionEnabled(true); ListSelectionListener l = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (t.editCellAt(t.getSelectedRow(), t.getSelectedColumn())) t.getEditorComponent().requestFocus(); } }; t.getSelectionModel().addListSelectionListener(l); t.getColumnModel().getSelectionModel().addListSelectionListener(l); JFrame frame = new JFrame("Test"); frame.add(t); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setVisible(true); }
/** * {@inheritDoc} */ @Override public void edit(JComponent component) { JComponent editableChild = findFirstEditableComponent(component); if (editableChild instanceof JTable) { JTable table = (JTable) editableChild; if (table.getSelectedRow() >= 0) { table.editCellAt(table.getSelectedRow(), 0); Component editor = table.getEditorComponent(); if (editor instanceof JComponent) { focus((JComponent) editor); } } } }
private void editCellInAWT() { if (table.editCellAt(row1, column1)) { Component editor = table.getEditorComponent(); editor.requestFocusInWindow(); if (editor instanceof JTextField && field == null) { addMoveCellAction((JTextField) editor); } } }
public void run() { final JTable table = getTable(); table.editCellAt(row, column); Component editorComponent = table.getEditorComponent(); editorComponent.requestFocus(); } });
private void addNew() { add(new UpdateSite(makeUniqueSiteName("New"), "", "", "", null, null, 0l)); table.changeSelection( table.getRowCount()-1, 2, false, false); if (table.editCellAt(table.getRowCount()-1, 2)) { Component editor = table.getEditorComponent(); editor.requestFocusInWindow(); } }
public static void commitChanges(JTable table) { if (table.isEditing()) { String text = ((JTextComponent) table.getEditorComponent()).getText(); table.setValueAt(text, table.getEditingRow(), table.getEditingColumn()); table.getCellEditor().cancelCellEditing(); } }
private void paintCell(final Graphics g, final Rectangle cellRect, final int row, final int column) { if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { Component component = table.getEditorComponent(); component.setBounds(cellRect); component.validate(); } else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); } } private void paintCells(final Graphics g, final int rMin, final int rMax, final int cMin, final int cMax) {
private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { if (table.isEditing() && table.getEditingRow()==row && table.getEditingColumn()==column) { Component component = table.getEditorComponent(); component.setBounds(cellRect); component.validate(); } else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); } }
/** * DOCUMENT ME! * * @param context DOCUMENT ME! * @param g DOCUMENT ME! * @param cellRect DOCUMENT ME! * @param row DOCUMENT ME! * @param column DOCUMENT ME! */ private void paintCell(SeaGlassContext context, Graphics g, Rectangle cellRect, int row, int column) { if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { Component component = table.getEditorComponent(); component.setBounds(cellRect); component.validate(); } else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); } }
@Override public void focusLost(FocusEvent e) { final int editingRow = table.getEditingRow(); final int editingColumn = table.getEditingColumn(); CellEditor ce = null; if (editingRow != -1 && editingColumn != -1) { ce = table.getCellEditor(editingRow,editingColumn); } Component editor = table.getEditorComponent(); if(ce != null && (editor == null || editor != e.getOppositeComponent())) { ce.stopCellEditing(); } else if(editor != null) { editor.addFocusListener(this); } this.firePropertyChange(); }