• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

searching a row using text fields

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out JComponent # requestFocusInWindow, JTable#getCellRect and JComponent#scrollRectToVisible
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check the method which I mentioned, that lets you play around with the focus?
 
jhon max
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry sir
 
Grow a forest with seedballs and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic