Results 1 to 2 of 2
  1. #1
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Get selected row value

    Hi,

    I am trying to retrieve a value from a row in a table.
    This I have succeeded, but I now try to include this value in a JDialog which contains a new table that will display the selected data based on the value I am trying to get over.

    Heres som code before I call the dialog:
    Java Code:
    int selectedRow = ledgerTable.getSelectedRow();
    int account = Integer.parseInt(ledgerTable.getModel().getValueAt(selectedRow, 0).toString());
                    
    TransSelectForm transSelect = new TransSelectForm(frameTrans, this, account);
    transSelect.setVisible(true);
    When I debug the code, I have the value I want in account.

    Here is the code in the Dialog:
    Java Code:
    public class TransSelectForm extends javax.swing.JDialog {
               
    private LedgerForm lf;
    private int konto;
        
        
    public TransSelectForm(JFrame frame, LedgerForm parent, int account) {
            
    super(frame, true);
    lf = parent; 
            
    initComponents();
            
    this.konto = account;
    Here is account = 0.

    Any advice would be appreciated.

  2. #2
    asai is offline Senior Member
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    115
    Rep Power
    0

    Default Re: Get selected row value

    Ok, I solved it!

    I added this code:
    Parent:
    Java Code:
    Integer getAccount() {
    return account;
    And in the Dialog:
    Java Code:
    this.account = lf.getAccount();

Similar Threads

  1. Get selected row
    By asai in forum New To Java
    Replies: 1
    Last Post: 06-06-2012, 05:31 PM
  2. How to get Line Selected
    By AryanArs in forum New To Java
    Replies: 2
    Last Post: 03-01-2012, 12:50 AM
  3. how to get selected value
    By gedas in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 05-03-2011, 08:08 AM
  4. how to get the currently selected row fo a jtable?
    By kulangotski in forum AWT / Swing
    Replies: 4
    Last Post: 01-16-2011, 06:22 AM
  5. JButton selected
    By sky in forum AWT / Swing
    Replies: 6
    Last Post: 12-05-2009, 10:36 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
  •