Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I have 2 cursors in different components simultaneously??  RSS feed

 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on an app that is modelled after excel. It contains a table, and at the top of the table is a JTextfield. I would like the JTextfield to EXACTLY resemble the cellEditor, including having the identical cursor and selection. I've set them to refer to the same document, but my attempts to keep the selections synchronized have failed. And I have a feeling getting two cursors isn't going to be possible at all.
Ideas???
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to suggest the Excel only has one input focus. You could create two components that know about each other. When one receives focus, the other mirrors the user's input. If you want it to look like a cursor in the component that's mirroring the input, you can do some custom painting. What are your thoughts on that?
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. I've had a look around, it doesn't look easy. The visibility of the cursor is checked in a private method, so it's a hassle.... I'm still trying to get the selection to line up.
e
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To Eric Moon ...
This is off this topic I'm afraid. From a different thread you said "Our biggest problem has been inferior scrolling performance in JTable. "
Can you point me to where I can find more information about the peculiarities of scrolling in JTable please, because it's hindering some development I'm doing.
Thanks,
Kate
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I am suggesting is that, even though the user can see what appear to be two cursors, only one of them really needs to be a cursor. The other can be a functionless image that looks like a cursor. This should work because only one of these two cursors is actually taking input. The second one is simply showing the input from the first. So checking the visibility of the cursor shouldn't enter into it.
Let's say, for example, that if the user double-clicks in a cell that their cursor moves to the formula editor. It appears to the user that their cursor is also still in the cell they double clicked. In fact, the real cursor is in the formula editor where they are doing input. The data they are inputting is being displayed in the cell along with an image that looks like a cursor, but doesn't really have any functionality behind it. In this way, the user thinks that they have two cursors, but since they can only use once cursor at a time, the second one can be an illusion.
Is this what you are looking for, or have I misunderstood your requirement?
 
eric moon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that's exactly right. So what do I do to display it? Nothing has worked so far. I tried overriding the cursor's visibility, and that didn't work.... And I'm not sure how the cursor interacts with the selection, but I haven't got that working either. Nobody here seems to consider it an issue (excel doesn't do it!) so I've back-burnered it....
 
Vishakha Ahuja
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'd done a similar application in VB. Because I found it difficult to mirror the input of textbox in the table cell, I changed it this way :
When user clicks on cell, I placed a textbox right on top of the cell with exact dimensions. Now the focus is on textbox taking the input and when user moves to another cell, the contents of textbox go in the previous cell and blank textbox moves on to currently focused cell.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!