Results 1 to 2 of 2
  1. #1
    AARON22 is offline Member
    Join Date
    May 2011
    Posts
    7
    Rep Power
    0

    Default get the select row from a jtable

    Hello i have done a jtable with a button and i want to get the selected row after i click my button! here is the button code..


    Java Code:
     button.addActionListener(new ActionListener() {
    
                public void actionPerformed(ActionEvent e) {
                    button.addActionListener(new ActionListener() {
    
                        public void actionPerformed(ActionEvent e) {
                            if (table.getColumnSelectionAllowed()
                                && !table.getRowSelectionAllowed()) {
                                // Column selection is enabled
                                // Get the indices of the selected columns
                                int[] vColIndices = table.getSelectedColumns();
                            } else if (!table.getColumnSelectionAllowed()
                                && table.getRowSelectionAllowed()) {
                                // Row selection is enabled
                                // Get the indices of the selected rows
                                rowIndices = table.getSelectedRows();
                            }
                            if (rowIndices.length > 0) {
                                for (int i = 0; i <= rowIndices.length; i++) {
                                    System.out.println(rowIndices[i]);
                                }
                            }
                        }
                    });

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Crosspost: get-the-selected-row

    It is considered inconsiderate to cross-post the same question in multiple forum without notifying all forums involved. No, we're not related to stackoverflow, and to understand why this is an issue, I ask that you read this link: BeForthrightWhenCrossPostingToOtherSites

    Thanks in advance for reading the link and for responding in an understanding and mature way.

    edit: and posters here would see that the question has already been answered!
    Last edited by Fubarable; 05-21-2011 at 06:44 PM.

Similar Threads

  1. Select a row in Jtable
    By pink123 in forum AWT / Swing
    Replies: 5
    Last Post: 03-21-2011, 04:04 PM
  2. Auto select JCombo box Adding to JTable
    By kasiram.p@gmail.com in forum AWT / Swing
    Replies: 0
    Last Post: 01-03-2011, 07:08 AM
  3. Problems with Shift select in Jtable
    By kovski88 in forum Advanced Java
    Replies: 0
    Last Post: 01-28-2010, 05:04 PM
  4. result select sql in jtable
    By herfnai in forum JDBC
    Replies: 0
    Last Post: 08-17-2008, 01:20 PM
  5. result select sql in jtable
    By herfnai in forum JDBC
    Replies: 0
    Last Post: 08-17-2008, 01:20 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
  •