This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes searching a row using text fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "searching a row using text fields" Watch "searching a row using text fields" New topic
Author

searching a row using text fields

jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45

I have some problem with searching a value(focusing on the selected searched row).

when I run the program the table doesnt have the selection focus (if that is the right term to say). I have to click first in any of the cells in the table, so the selection will be on focus.
(is there any way to make a default selection focus in a JTable?)


when the program searches for the equivalent "name" input in the text field, it highlights it but the "scroll" doesnt scroll down to view the part where that value resides
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Check out JComponent # requestFocusInWindow, JTable#getCellRect and JComponent#scrollRectToVisible


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45


heres a program for the auto scroll.
I tried to get some idea on this program but I only know how to scroll automatically at the "bottom", what I need now, is to specify the view of the scroll according to the searched value.. I tried to search and play with Viewports, but Im still stuck with this problem, I'm not also sure If the viewport can help me with this... please I need more help...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

In pseudo code
1) User types something
2) Figure out which cell has a match
3) Scroll to the required cell.
jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45
In pseudo code
1) User types something
2) Figure out which cell has a match
3) Scroll to the required cell.


tnx for the psedocode sir,

,, this one was reffering to the cell I never thought of that thank you for that,

I solved that part.. But the problem now is the highlight of the specific cell, those codes that I posted was just for illustrating the problem, but in my original code
I have a rendered table with Image background, when I clicked(selected) a cell I dont see a highlight but the foreground color of the text in the cell changes(Im fine with that),

what I want now is the selection focus,

For example I have already searched the value, the program will automatically highlight that cell , how can I accomplish this one?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Did you check the method which I mentioned, that lets you play around with the focus?
jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45
no sir...

to make the highlight(the selection focus) i have to click first the table so there will be a selection focus in any of the cell, so If i search the matching value it will highlight it,,

but i have to click first the table... is there any way to make a default selection focus ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Maneesh Godbole wrote:Did you check the method which I mentioned, that lets you play around with the focus?

jhon max wrote:no sir...


Thank you for wasting my time. Have a nice day.
jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45
no sir...
I didnt mean to say that I didnt check it, actually it helped me a lot..Im just getting too confused on the resources that Im getting from google.. sorry for using such an informative words, but english is not my native language , im sorry,

what I mean with "no sir" ,- I didnt know what should I do In the method that you gave me to make a selection focus,

again, Im so sorry, I didnt intend to waste your effort, sorry for using such a word...
jhon max
Ranch Hand

Joined: Jan 06, 2010
Posts: 45
sorry sir
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: searching a row using text fields
 
Similar Threads
Deleting The Whole Table problem(Index Out Of Bounds)
JTable
JTable in JFrame
how to delete a row header
JTable