java - Update Jlist when new Jframe closing -


i've tried find kind of information problem no success, maybe stackowerflow big or i'm using wrong keywords.

anyway, problem i'm kind new java migrating sharp world. i've project in develop simple servicedesk software. i've made jframe startscreen buttons , jlist display cases. 1 of buttons on start frame create new case. button open new jframe user can enter information needed , button save: save information in list. list handled in different class below.

start jframe opens case jframe save in list in listclass close , return start jframe. when user returns start jfram , want jlist in start jframe refresh , display new saved case - dont know how do.

i guess event writing in start jframe has respond when case jframe closing dont know how.

it's kind hard explain, don't have reputation upload images.

i think might want consider creating new custom dialog box displays when select button. here's sample piece of code keep handy reference. main items here static method displays dialog, , fact dialog modal, execution "pauses" until close dialog, allowing capture dialog's saved data , return static method displays dialog. use template , modify needed. more specifically, "response" value returned method. in reality, "response" not simple boolean, ( used test logic), listclass contains information collected dialog's input controls. call getuserinput() you'll want main jframe code start ball rolling. actionperformed() method you'll grab data dialog box controls , populate class contains return info.

import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class confirmdialog extends jdialog implements actionlistener {            private boolean response = false;         private jbutton btnok = new jbutton("ok");         private jbutton btncancel = new jbutton("cancel");         private jpanel contentpane = new jpanel();          public static boolean getuserinput()         {                     return new confirmdialog().showdialog();          }          private boolean showdialog()         {                     setvisible(true);                     //next line executes after dialog disposed,                 since dialog modal.                     return response;         }          private confirmdialog()         {                          setdefaultcloseoperation(windowconstants.dispose_on_close);                     btnok.setactioncommand("ok");                     btncancel.setactioncommand("cancel");                     btnok.addactionlistener(this);                     btncancel.addactionlistener(this);                     contentpane.add(btnok);                     contentpane.add(btncancel);                     setcontentpane(contentpane);                     setmodal(true);                     pack();          }         public void actionperformed(actionevent e)         {                     if(e.getactioncommand().equals(btnok.getactioncommand()))                     {                                 response = true;                     }                     setvisible(false);                     dispose();         }          /**          * @param args          */         public static void main(string[] args) {                     // todo auto-generated method stub                     system.out.println(getuserinput());          }   } 

Comments