• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

anchor cell return -1 for row and column

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
when i get focus on the anchor cell of my JTable , it returns -1 value for both row and column, and when i move it forward to the next cell in this row ,only then it selects the this row, i wanted to select this row when the anchor cell has the focus.need some help here
thanks
harcharan
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi harcharan,
What do you mean by the term anchor cell?
Michael Morris
 
harcharan kanwal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that is the first cell in JTable at position 0,0,where i get the focus with my tab key ,and at this point on , i like to select this row, but this does not happen untill i move the focus to the next cell at 0,1(row,column),i could not find in api anything like selectrow(int row),i found
isRowSelected();
setRowSelectedAllowed(true);
and i am also working with
getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column)
I am trying to select the first row ,when the focus is at cell number 0,0.Am i missing anything,or any advice will be valuable.
thanks

thanks
harcharan
[ September 26, 2002: Message edited by: harcharan kanwal ]
[ September 26, 2002: Message edited by: harcharan kanwal ]
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi harcharan,
Give us some more details on what you want to do here. Is your JTable editable, are you using a ListSelectionListener, etc.? Without a little more info we can't try any sample code.
You may try something like this:

Michael Morris
[ September 26, 2002: Message edited by: Michael Morris ]
 
harcharan kanwal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Michael,
i want to select a row and pop up a book dialog with this flight info using key board operation,ofcourse evreything works fine with the mouse click,my table cells are not editable,and i am not using
ListSelectionListener.is that something i have to work ,
thanks for taking me through
harcharan
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi harcharan,
Are you using the TAB key to acquire the focus? For an uneditable JTable the behavior seems to be that upon gaining the focus, nothing is selected. On the next TAB, a selection occurs. You could try something like this in your JTable (assuming you are extending JTable):

Let me say that I have no idea as to whether this is going to work or not, but it's worth a shot.
Hope this helps,
Michael Morris
 
harcharan kanwal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
he michael,
i got this problem solved with this
table.setRowSelectionInterval(row, row),i can think ahead from here.
thanks for your help
 
harcharan kanwal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Michael,
is it ok to tell the user to use the tab key to move the focus around on components in a container
or do we have to write mnemonics .
thanks for help
harcharan
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Harcharan,


is it ok to tell the user to use the tab key to move the focus around on components in a container


That's fine. No need to use mnemonincs. It's always better to use the default behavior if you can. CTRL+TAB is actually what is required when using a JTable, because when the JTable gets the focus, TABs move from cell to cell in the table.
Michael Morris
 
harcharan kanwal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Michael,
yes ctrl+tab is helpful to get the focus out from jtable to container one before the where jtable is displayed.
thanks for help
harcharan
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic