Results 1 to 6 of 6
  1. #1
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default JButton to detect if cell in a table is selected

    Well, I need to make some sort of conditional check.
    There's a table and a delete button...so far I'd made it works so that when the table is selected the listselectionlistener will pick the data and then delete button will did the delete action after popping up delete confirmation.
    However as the button works on with its own listener it'll pop up delete even when there's no cell selected. so I need to make a conditional check to check whether a cell is selected or not and only perform the action if a cell is selected.

    I'd appreciate if anyone can help with this cause I seem stuck in this.


    Thanks in advance,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default

    table.getSelectedRow();

  3. #3
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default

    I was thinking that it's more of something that returns true/false...boolean, getSelectedRow doesn't return that, I don't know how to use it.

    Can you explain more on this ?


    Thanks,
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    What does getSelectedRow return if no row is selected?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default

    Have you read the API for the method? What value does it return if a row is selected? What value if no row is selected?

    If you don't kow how to write a boolean condition to test for that, you have no business mucking around with GUIs. Go back to basics.
    The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)

    db

  6. #6
    Levian is offline Senior Member
    Join Date
    Jun 2011
    Posts
    109
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    What does getSelectedRow return if no row is selected?
    I got it, thanks to the three of you.
    Last edited by Levian; 08-09-2011 at 08:21 AM.
    First is to make something usable, next is to aim for perfection which means a never ending improvements.

Similar Threads

  1. If on cell of table
    By Tovam in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 05-18-2010, 09:34 AM
  2. Replies: 6
    Last Post: 01-30-2010, 03:55 PM
  3. JButton selected
    By sky in forum AWT / Swing
    Replies: 6
    Last Post: 12-05-2009, 10:36 PM
  4. How to print selected items in a SWT table
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:30 PM
  5. How to remove selected items in a SWT table
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •