Focus « JTable « Java Swing Q&A





1. how to control focus in JTable    stackoverflow.com

What I want to do is when user finish editing of data in table cell to move focus onto another cell depending of what user entered, and to turn that cell ...

2. Can a Jtable save data whenever a cell loses focus?    stackoverflow.com

The high level: I have a JTable that the user can use to edit data. Whenever the user presses Enter or Tab to finish editing, the data is saved (I'm asusming that ...

3. Focus traversal between two tables in a Panel    stackoverflow.com

I have two (5 * 1) tables to be shown as a single table on UI. How can I get a focus traversal mechanism for the two components(table) which mimicks the ...

4. Transfer focus in JTable    stackoverflow.com

I want to transfer the cell focus to a particular cell in the JTable like when the focus on cell (2,3) and after pressing the enter key, focus should be transferred ...

5. remove focus from JTable first row    stackoverflow.com

I have JTable and rows in it. By default first row is selected and focus is in it. How can I deselect first row and change focus to somewhere else that ...

6. Java JTable Goto Row Bug    stackoverflow.com

I have a find function that locates a string in a JTable with quite a few thousand entries. Michael Meyers was kind enough to help me out with the goto ...

7. How can I focus on a whole row of a JTable?    stackoverflow.com

I have a JTable that is showing some records in a Java Swing application. The user only works with whole rows, not with individual cells. Is there any way I can ...

8. Why not all Java Swing JTables have focus indicator    stackoverflow.com

I'm trying to figure out why some JTables in a large application have the focus indicator and some don't. To debug this issue, I added code:

UIManager.put("Table.focusCellHighlightBorder",new BorderUIResource(
    ...

9. Type of listener for updates to given cells/columns in JTable and incrementing focus    stackoverflow.com

I am trying to use a JTable with the first two columns predefined. User enters data into 3rd column only (quantity). Then I calculate final income by multiplying 2 ...





10. JTable cell not losing focus    forums.netbeans.org

Hello all, I would appreciate some help trying to resolve the behaviour of a cell edit in a JTable. Ive create a dummy RCP application with a JTable on a TopComponent. ...

11. JTable focus    coderanch.com

Hi, I am trying to highlight the first row of a table when the focus is changed to the table. Currently, when I tab from another component to the table, it doesn't highlight the row. Only when I press the arrow down key, the next row gets highlighted. Also, when the focus leaves the table (ie tab out...), I want to ...

13. Requesting Focus to next column in JTable    coderanch.com

Hi Leonard. Above solution working fine. But some times it's thorowing the below exception. In fact I am checking for cell != null before calling stopCellEditing() function. No idea why it's giving null pointer exception while calling this function. Could you please help on this? Exception occurred during event dispatching: java.lang.NullPointerException at javax.swing.JTable$GenericEditor.stopCellEditing(JTable.java:3295) at eve.EVEApplet.actionPerformed(EVEApplet.java:733) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1504) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:378) ...

14. JTable cell focus    coderanch.com

15. Focus listener in Table cell    coderanch.com





17. cell focus on JTable    coderanch.com

I am using a table to enter in values and when the user enters an invalid data entry, the program focuses on the particular cell with the changeSelection() method. I can run this locally from JBuilder but when I make a jar file and put it on the server, the focus does not work. I am not sure where to look ...

18. Jtable Focus Problem    coderanch.com

19. Disabling Cell Focusing in JTable    coderanch.com

First, Amaresh is not a valid user name... please re-read the JavaRanch User Name Guidelines and re-register with a valid username. User names must be in the format "First Name" + space + "Last Name". On to the question... How you will do this depends on the reason you are doing it... If you override isCellEditable() in your table model the ...

20. JTable Cell Focus    coderanch.com

21. Focus on a specified cell    coderanch.com

22. JTable cell focus    coderanch.com

I am tabbing through the editable cells in a customized JTable. I am using a custom editor and renderer as well. The tabbing part is fine. When the tab gives the cell focus, the editor comes up, but the cell doesn't "look" selected. Likewise, when the tab takes focus to the next editable cell, the previous editor remains, as opposed to ...

23. JTable focus problem    coderanch.com

24. How to set focus on JTable    coderanch.com

25. Not focusing cells in JTable    coderanch.com

26. Focus Problem in JTable    coderanch.com

i am facing problem because of Focus, actually in my current application i have to get all edited values in cells of selected row, on click of button. now problem is i m not getting new updated value of currenlt selected cell. if i m changing the focus then i m able to. can anyone help me on this Thnaks Darsha ...

27. How to add focus to a cell in a JTable    coderanch.com

Yeah. When I did this, I am getting the whole row selected. But I want the focus in the first column of the row so that the user can input before he clicks on it. Rather, I want the cursor in the cell and not that the whole row getting highlighted. When I add the row, the first cell should be ...

28. JTable cell focus    coderanch.com

29. JTable focus problem    coderanch.com

this might be one way import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; class Testing extends JFrame { public Testing() { setLocation(400,100); setDefaultCloseOperation(EXIT_ON_CLOSE); String colNames[] = {"Col 0", "Col 1"}; DefaultTableModel dtm = new DefaultTableModel(null,colNames); dtm.setRowCount(10); JTable table = new JTable(dtm); JScrollPane sp = new JScrollPane(table); sp.setPreferredSize(new Dimension(300,200)); getContentPane().add(new JTextField("Hello"),BorderLayout.NORTH); getContentPane().add(sp,BorderLayout.CENTER); getContentPane().add(new JTextField("World"),BorderLayout.SOUTH); pack(); Action tabOut = new AbstractAction(){ public void ...

30. how to focus into particular Cell    coderanch.com

this might be one way import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; class Testing extends JFrame { public Testing() { setLocation(400,100); setDefaultCloseOperation(EXIT_ON_CLOSE); String colNames[] = {"Name", "Age"}; Object[][] data = {{"joe","21"},{"fred","31"},{"mary","22"}}; DefaultTableModel dtm = new DefaultTableModel(data,colNames); JTable table = new JTable(dtm); JScrollPane sp = new JScrollPane(table); sp.setPreferredSize(new Dimension(300,100)); getContentPane().add(sp); pack(); InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0); Action ...

31. focus Got stuck in JTable    coderanch.com

when I clicked outside of table on other component, cell still remains selected and because of this i am not able to save value to model. so how can i remove focus from cell on clicking on other component except table. if any body have idea please help me out Thanks in advance.

32. how to set focus on cell of table    coderanch.com

33. how to traversal focus in JTable    coderanch.com

34. Set focus on JTable with no rows    coderanch.com

35. JTable within JDialog - Focus Problem    coderanch.com

36. lost focus in JTable    coderanch.com

the construction of my table follows this sun java tutorial: i've a custom model and also have two things tutorial refers: a combo inside table cells and also use TableSorter class in order to have sorting. I use Jtable to display database data, and also use it to have updates, using combo's selected value; i get the selected line, then get ...

38. Getting a JComponent inside a table cell to recieve focus    coderanch.com

Hi, I was wondering if anyone could help. I have been having problems with this for months now. I searched the internet and read a java book but got no direct help on what i am trying to do. I have a JTable which has 5 columns, the last column is not editable and the first column when clicked opens a ...

40. JTable focus issue    coderanch.com

Hi, I am using JTable, my requirement is that when focus is on the table and if I press TAB key then focus should be moved out of table to some other components. This is working fine for me. Problem is when table is in editing mode then I have to press TAB key twice (sometimes) to get focus out of ...

41. JTable: Lost Focus    coderanch.com

42. Loosing focus on entire column    coderanch.com

Hi everyone, I have a column in my table that I have made invisible to the user(because i need the information in it but I don't want the user to see the information). The problem is that it still gains focus. I know this because I display just above the table the description(which I need to do) of the particular column. ...

43. JTable handle Row lost focus event    coderanch.com

Hi ranchers I have swing screen with JTable of user's list and additional information besides the table that changes on each row selection. This data is additional user data that doesn't fit the table. When the moving from one row to another I am collecting all additional row data to map and I attach it as hidden filed to the JTable ...

44. JTable focus problem    coderanch.com

I have 2 jtables in one panel.My problem is that when I am at last column of last row in table, I am unable to move out of that table (and go to next jtable).ctrl+tab is default for this but it is not working.Focus is redirected to first column of first row by using ctrl+tab,and shift+tab redirects it to previous column.I ...

45. Focus on a JTable cell    coderanch.com

I have a JTable in which I am adding rows dynamically.If I add 3 rows and populate data in 2nd and 3rd row only,then when I am trying to save data a dialog box pops up for entering data in 1st row.But when i click ok tab I have to click on that column to edit.Is there a way so that ...

46. Focus traversal problem in JTable    coderanch.com

47. JTable Focus/Refresh    coderanch.com

49. How to keep a table cell "activated"/focused while validating its content in the table model?    coderanch.com

public void tableChanged(TableModelEvent event) { if (event.getType() == TableModelEvent.UPDATE) { int rowNumber = event.getFirstRow(); // JTable selection mode is "SINGLE_SELECTION" int columnNumber = event.getColumn(); String cellContent = getValueAt(rowNumber, columnNumber); int length = cellContent.length(); ... switch (columnNumber) { case 0: // Column 0 is not editable ---> nothing to do break; ... case 6: // Eight digits are valid, otherwise input is ...

50. getting focus in one cell in JTable    coderanch.com

selectedTable.setRowSelectionInterval(selectedRow, selectedRow); selectedTable.setColumnSelectionInterval(selectedColumn, selectedColumn); The way my program is so far, the program selects a single cell, but when the user starts typing something, what the user typed does not enter the cell. What I want is to have the program make the cell so that the border of the cell changes color and when the user types something, it enters ...

51. JTable Focus Subsystem and KeyBindings    coderanch.com

Hi there, I am trying to extend a JTable component with a specific focus and cell selection dynamics. The cell selection highlight should move from left to right upon Enter stroke and jump some columns over (these columns are fixed). When reaching the last focusable cell on a row it must jump to the leftmost focusable cell in the next row. ...

52. How to change the focus order of JTable    java-forums.org

I am to continue the thread of javaexplorer regarding the edit automatically upon the cell acquires the focus on the cell. I have observed that when you press the enter key while the JTable is in focus. The focus transfers to the next row of the JTable. My questions is, can we change the focus transfer horizontally, to the next column ...

53. JTable Focus Traversal    java-forums.org

54. JTable Cell Focus Listener    java-forums.org

public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) {} public void keyPressed(KeyEvent e) { int cols = 2; int rows = Xenon.getRowCount(); int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { int r =Xenon.getSelectedRow(); int c =Xenon.getSelectedColumn(); if(c < cols) { setSelectedCol(c + 1); return; } if(c == cols) { if(r

55. transferring focus in a JTabbedPane with JTables    forums.oracle.com

Hello, I am having trouble with moving the focus in a JTabbedPane that contains a JTable under each tab. The tabbed pane has custom tab components that each have a JTextField (normally uneditable) that displays the tab title, and a close button. Besides its normal tabs, the tabbed pane has a special "new tab" tab that also has a custom tab ...

56. JTable focus    forums.oracle.com

I have different components in a page. I can move through each of these components(like textboxes, combos etc). While moving through these components, when reaching a JTable , i need to highlit the first cell in a JTable.What is the solution. Thanks in advance for your generous consideration, Looking for speedy replies, Regards, Anees Ahamed

57. How can I disable jtable focus traversal    forums.oracle.com

58. jtable focus    forums.oracle.com

59. JTable, cells lost focus    forums.oracle.com

We should start a whole section for your JTable questions, lol! How is your project going anyway? Im not positive but I believe the cells in a JTable are components so you can use a FocusListener. Good luck. And for the Nth time... there is a Swing forum. Message was edited by: TuringPest

60. JTable focus on cells    forums.oracle.com