Results 1 to 8 of 8
  1. #1
    sinha is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default passing an object from one JDialog to Jframe

    Hi ,
    am a newbie to Swing .
    I have an appliction consisting multiple components , I created a JFrame where I have a load button .
    When i hit the load button , it opens a jdialog , where I have to fill in some crieteria for filtering a data out of db .
    I have to send that filtered object to the JFrame again for loading it into the table which is present in 1st JFrame .

    I am able to reteive that obj in jframe , but unable to paint the JFAME with new data .

    Please help..

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

    Default

    Quote Originally Posted by sinha View Post
    I am able to reteive that obj in jframe , but unable to paint the JFAME with new data .
    Hard to say what you're doing wrong without code.

    You would extract data from the dialog's components just as you would for any OOP object. I'd give the class public getters.

    Is the dialog modal? If so, then you retrieve data from the dialog after it returns. If it's not modal, then you may need to use an observable model or listen for its closing.

  3. #3
    sinha is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default

    The JFrame's Load button actionlistener
    loadButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae) {
    SpecSelectorDialog selector = new SpecSelectorDialog(getFrame());
    selector.setVisible(true);
    _spec = selector.getSpecObj();
    if (_spec != null)
    setTable(_spec);
    else
    return;
    }
    });

    where setTable is a method which takes _spec object as a param and sets the table cells in JFrame .

    I am surprised to see that if I load the the spec object at the first time I hit load , it populates the table at first attempt
    but if I select another crieteria , it is unable to repaint the JFrame , I mean it does not shows any difference than the previous screen .

  4. #4
    sinha is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default

    I think that the JFame is not refresing

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    What does your setTable(_spec) method do?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    sinha is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default

    public void setTable(Spec spec)
    {
    validate();

    issuerTableModel = new IssuerTableModel(4,0);
    initIssuerTable();
    issuerTableModel.setTo(issuersTable,true);
    issuerTableModel.refresh();
    TableUtil.adjust(issuersTable);
    repaint();
    System.out.println(spec.getName());



    Iterator<String> issuer = spec.getAllKeys();

    System.out.println(issuer.toString());
    int row = 0;
    while(issuer.hasNext()) {
    System.out.println("Adding row ");

    issuerTableModel.addRow();
    String key = issuer.next();
    StringTokenizer keys = new StringTokenizer( key, ".");

    Double spread = spec.getRunningSpread(key);

    if (spread < 0)
    {
    issuerTableModel.setValueAt(row, 1, "N");
    }
    else
    {
    issuerTableModel.setValueAt(row, 1, "Y");
    }
    String token = keys.nextToken();
    System.out.println(token);
    System.out.println("--------------------------------");
    issuerTableModel.setValueAt(row, 0 ,token );
    token = keys.nextToken();
    System.out.println(token);
    issuerTableModel.setValueAt(row, 2, token);
    issuerTableModel.setValueAt(row, 3,spread );
    issuerTableModel.refresh();
    TableUtil.adjust(issuersTable);
    row ++;

    }
    nameText.setText(spec.getName());
    }

  7. #7
    sinha is offline Member
    Join Date
    Dec 2009
    Posts
    5
    Rep Power
    0

    Default

    I get all the values in the sysouts in the settable method but it is not refreshed in the JFrame

  8. #8
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    6

    Default

    setTable puts the data into a new-ly created issuerTableModel. Where does the Table view object get connected to this new model?

    It would seem that instead of creating a new issuerTableModel, setTable should be feching the model from the JTable object itself.

Similar Threads

  1. Communicate JFrame with JDialog
    By BeRniTo in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2009, 03:07 PM
  2. Passing data from one JFrame to another JFrame
    By tarami in forum New To Java
    Replies: 3
    Last Post: 08-06-2009, 06:44 PM
  3. Unable to display JDialog from JFrame
    By jv5 in forum NetBeans
    Replies: 2
    Last Post: 02-04-2009, 05:33 AM
  4. Returning data from a JFrame/JDialog?!
    By Joe2003 in forum AWT / Swing
    Replies: 6
    Last Post: 01-08-2009, 01:14 AM
  5. problems with jDialog in a JFrame
    By bbq in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 05:14 AM

Posting Permissions

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