Προς το περιεχόμενο

get the selected row!!


efefef

Προτεινόμενες αναρτήσεις

Δημοσ.

Γεια σας, εχω κανει ενα jtable με ενα button και θελω οταν παταω το button να παρω την γραμμη που εχω επιλέξει!Μπορει να βοηθησει καποιοσ?

εδω είναι ο κωδικας για το κουμπι

 

> 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]);
                           }
                       }
                   }
               });

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...