Java Code Examples for javax.swing.JTable#getEditorComponent()
The following examples show how to use
javax.swing.JTable#getEditorComponent() .
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: StructureEditorUnlockedActions3Test.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testEditFieldOnComponent() throws Exception { init(complexStructure, pgmTestCat); setSelection(new int[] { 3 }); assertTrue(!model.isEditingField()); invoke(editFieldAction); JTable table = getTable(); Container component = (Container) table.getEditorComponent(); assertTrue(model.isEditingField()); assertEquals(3, model.getRow()); assertEquals(model.getDataTypeColumn(), model.getColumn()); JTextField textField = findComponent(component, JTextField.class); triggerText(textField, "Ab\b\b\t"); assertTrue(model.isEditingField()); assertEquals(3, model.getRow()); escape();// Remove the choose data type dialog. assertNotEditingField(); }
Example 2
Source File: PropertySheetTable.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent e) { JTable table = (JTable)e.getSource(); if (!table.hasFocus()) { CellEditor cellEditor = table.getCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } table.requestFocus(); return; } ListSelectionModel rsm = table.getSelectionModel(); int anchorRow = rsm.getAnchorSelectionIndex(); table.editCellAt(anchorRow, PropertySheetTableModel.VALUE_COLUMN); Component editorComp = table.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }
Example 3
Source File: MemoryMapPluginTest.java From ghidra with Apache License 2.0 | 5 votes |
private void editNameCell(final JTable table, String name) { final int nameColumn = MemoryMapModel.NAME; final int namedRow = getNamedRow(table, nameColumn, name); runSwing(() -> { table.getSelectionModel().setSelectionInterval(namedRow, namedRow); table.scrollRectToVisible(table.getCellRect(namedRow, nameColumn, true)); }); Rectangle rect = table.getCellRect(namedRow, nameColumn, true); Point tablePoint = table.getLocationOnScreen(); final int x = tablePoint.x + rect.x + (rect.width / 2); final int y = tablePoint.y + rect.y + (rect.height / 2); runSwing(() -> { MouseEvent editMouseEvent = new MouseEvent(table, MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), 0, x, y, 2, false); table.editCellAt(namedRow, nameColumn, editMouseEvent); }); assertEquals(true, table.isEditing()); Component editorComponent = table.getEditorComponent(); assertNotNull(editorComponent); assertTrue(editorComponent instanceof JTextField); final JTextField editorField = (JTextField) editorComponent; editorField.selectAll(); runSwing(() -> editorField.requestFocus()); waitForPostedSwingRunnables(); triggerText(editorField, ".myText\n"); assertEquals(".myText", table.getModel().getValueAt(namedRow, nameColumn)); }
Example 4
Source File: StructureEditorUnlockedActions3Test.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testEditFieldSetBitfieldDataType() throws Exception { init(complexStructure, pgmTestCat); DataTypeComponent dtc = model.getComponent(3); assertNotNull(dtc); assertTrue(!dtc.isBitFieldComponent()); setSelection(new int[] { 3 }); assertTrue(!model.isEditingField()); invoke(editFieldAction); JTable table = getTable(); Container component = (Container) table.getEditorComponent(); assertTrue(model.isEditingField()); assertEquals(3, model.getRow()); assertEquals(model.getDataTypeColumn(), model.getColumn()); JTextField textField = findComponent(component, JTextField.class); triggerText(textField, "char:2\n"); waitForSwing(); assertTrue(!model.isEditingField()); assertEquals(3, model.getRow()); assertNotEditingField(); dtc = model.getComponent(3); assertNotNull(dtc); assertTrue(dtc.isBitFieldComponent()); }