Results 1 to 2 of 2
  1. #1
    yetibdhrana is offline Member
    Join Date
    Jan 2012
    Rep Power

    Default jDialog and JFrame Data Troubles

    I have a couple questions about jDialog and JFrame. Firstly, I'm using Netbeans' GUI editor and I'm working on a program that has to transfer 1000's of integer and string values between multiple jDialogs and a JFrame (the main GUI). Therefore, my first problem is: how do I transfer values across forms, and is there a way to do it efficiently in bulk? Also, the jDialog's normal behavior is to set itself into focus and disable the main form. I can stop it from focusing by unchecking "focusableWindowState" but I can't get it to enable the main form again. Finally, I have one other JFrame which opens with the setVisible command upon clicking a button in the main GUI. Unfortunately, because closing one JFrame typically closes the whole application, I set the close property to hide on close. Now I can't close it programmatically (with .dispatchEvent). Finally, the data on my frames must be conserved after closing. Is there any way to preserve the data?

    Summarizing my questions:
    1) How do I transfer values across forms in bulk?
    2) How do I make jDialog to not focus on itself?
    3) How do I close a jFrame programmatically when it is set to hide on close?
    4) How do I keep the data on my frames after closing?

    Also, a little more information on numbers 1 and 4 - here is my code for how the values in one of the dialogs is created (into a jTable). Envision a 6 column, 1000+ row jTable. I will have values on it consistently changing (the modification numbers being sent from the main form).
    Java Code:
        private void btn_UpdateActionPerformed(java.awt.event.ActionEvent evt) {                                           
    //set the rows in the table tbl_Units to the number in the textfield val_Units
    int rows = Integer.parseInt(val_noUnits.getText());
    //loop through the rows and add the units
    for (int i=1; i<=rows; i++) {
        model.setValueAt(i, i-1, 0);
        private void btn_assignActionPerformed(java.awt.event.ActionEvent evt) {                                           
    //generates a random number in a given range
    Random random = new Random();
    int min = Integer.parseInt(val_min.getText());
    int max = Integer.parseInt(val_max.getText());
    int rows = Integer.parseInt(val_noUnits.getText());
    //gets the index value of the selected combobox item
    int index = val_cbx.getSelectedIndex() + 1;
    for (int i=1; i<=rows; i++) {
        int range = random.nextInt(max - min + 1) + min;
        model.setValueAt(range, i-1, index);
    As you've probably realized, my knowledge of Java is quite gimmicky. I'm confident using loops and other things I remember back in C#, but at the same time I can't even figure out the mechanics of a simple frame. It's not at all helped by Netbeans, which imposes really annoying restrictions in editing that frankly I could do without.
    Last edited by yetibdhrana; 01-24-2012 at 08:48 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: jDialog and JFrame Data Troubles

    It's not at all helped by Netbeans, which imposes really annoying restrictions in editing that frankly I could do without.
    So, do without. just go through the tutorial, all except the third topic listed: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Passing value from JFrame to JDialog
    By rpc86 in forum AWT / Swing
    Replies: 3
    Last Post: 11-11-2011, 10:13 PM
  2. How to show JDialog is a JFrame ?
    By xuanhung123 in forum AWT / Swing
    Replies: 6
    Last Post: 07-21-2010, 03:32 PM
  3. Communicate JFrame with JDialog
    By BeRniTo in forum AWT / Swing
    Replies: 2
    Last Post: 08-31-2009, 02:07 PM
  4. Returning data from a JFrame/JDialog?!
    By Joe2003 in forum AWT / Swing
    Replies: 6
    Last Post: 01-08-2009, 12:14 AM
  5. problems with jDialog in a JFrame
    By bbq in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 04:14 AM

Tags for this Thread

Posting Permissions

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