Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4102 > unrolled thread
| Started by | "striderwho" <striderwho@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:48 +0000 |
| Last post | 2011-04-27 15:48 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.java.gui
JTable Tab Focus problem "striderwho" <striderwho@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
Re: JTable Tab Focus prob "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
Re: JTable Tab Focus prob "striderwho" <striderwho@THRWHITE.remove-dii-this> - 2011-04-27 15:48 +0000
| From | "striderwho" <striderwho@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:48 +0000 |
| Subject | JTable Tab Focus problem |
| Message-ID | <95b90cf3-2531-4251-9913-efe9b71f09f6@r15g2000prd.googlegroups.com> |
To: comp.lang.java.gui Hi there, I know this problem has propped up all over the place but the answers have not helped me to solve my problem entirely. I think this is because with each change of data in any cell in my table, the entire table needs to be reinitialised - that is, the data model is reloaded anew and the table revalidated. So, my table consists of multiple rows and columns, some editable and some not, and a few different CellEditors (JComboBoxes and JFormattedTextFields). In addition the table is part of a JPanel with another panel of JRadioButtons. I would like the "intuitive" (client's words, not mine) functionality to be able to Tab across cells and start typing to edit the fields, as well as to double-click on a cell to start editing. I have tried the KeyStroke thing and it doesn't work, I'm guessing because when the table is reinitialised the KeyEvent and focus is lost. I cannibalised the code and inserted it into the reinitialisation code to reselect the previously selected cell before reinitialisation, but this seems to work only under one condition - that the user DIDN'T double-click on a cell to start editing. And it doesn't actually work properly - the focus moves first through the radio buttons on top of the table before going to the next cell in the table. I guess there's a few questions here - why is it that if I double- click a cell to edit, the "Tab" KeyEvent seems to be lost (and the Action written for it is never reached), whereas if I single-click to select then start typing then "Tab" it works? And this reinitialisation probably ruins the focus traversal order, but how do I get it to go straight to the next cell after reinitialisation, and not to the radio buttons above the table? Reinitialisation should be completely invisible to the user. I hope you understood what I just typed. I'd be grateful for any help, it's driving me nuts. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Stefan Rybacki" <stefan.rybacki@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:48 +0000 |
| Subject | Re: JTable Tab Focus prob |
| Message-ID | <48b53f86$1@news.uni-rostock.de> |
| In reply to | #4102 |
To: comp.lang.java.gui striderwho@hotmail.com schrieb: > Hi there, I know this problem has propped up all over the place but > the answers have not helped me to solve my problem entirely. I think > this is because with each change of data in any cell in my table, the > entire table needs to be reinitialised - that is, the data model is > reloaded anew and the table revalidated. How does your table model handle changes to it? Usually you don't need to reload and revalidate everything but only changed values. Use the tableChanged method in the TableModelListener to tell the listener exactly what has changed. > > So, my table consists of multiple rows and columns, some editable and > some not, and a few different CellEditors (JComboBoxes and > JFormattedTextFields). In addition the table is part of a JPanel with > another panel of JRadioButtons. I would like the "intuitive" (client's > words, not mine) functionality to be able to Tab across cells and > start typing to edit the fields, as well as to double-click on a cell > to start editing. The thing is your TAB KeyStroke only works as long as the actual table is in focus. When you start editing the editing field (JTextField or whatever) is in focus. > >... Regards Stefan > > I hope you understood what I just typed. I'd be grateful for any help, > it's driving me nuts. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "striderwho" <striderwho@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:48 +0000 |
| Subject | Re: JTable Tab Focus prob |
| Message-ID | <25e7048d-577b-4473-b6b6-13d534436e4b@o40g2000prn.googlegroups.com> |
| In reply to | #4103 |
To: comp.lang.java.gui > How does your table model handle changes to it? Usually you don't need to reload > and revalidate everything but only changed values. Use the tableChanged method > in the TableModelListener to tell the listener exactly what has changed. Yes, my implementation is unusual. It is because there is a graphical representation of the data in the table that exists alongside and any update to either the graphical or the table representation results in an update of all representations as any change in some particular data may influence other data and there is no way at present to predict when this may occur. Therefore I've elected just to update everything on any change. The table model stores the data in an internal data structure. > The thing is your TAB KeyStroke only works as long as the actual table is in > focus. When you start editing the editing field (JTextField or whatever) is in > focus. So how can I get the table back in focus after editing AND reloading? I may have gone partway there - as I said before after reloading I programmatically set the correct selected cell (the next one along). Now when I double-click to edit it and then press TAB the focus seems to be gone again, but if I navigate to another program's window and then come back, the focus is correctly on the cell! If I single-click to select then start typing then press TAB it exhibits the behaviour I mentioned earlier, namely the focus goes to the buttons first before coming to the correct cell in the table. Thanks for your reply! --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web