Call method after closing JFrame

Hi everyone,
I'm opening a JFrame in another JFrame.
Here is the code and beneath is the question.
import javax.swing.*;
import javax.swing.text.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class ContactsInterface extends JFrame implements ActionListener
     JList contactList;
     private DefaultListModel listModel;
     JPanel buttonPanel;
     JPanel detailsPanel;
     JButton addButton, updateButton, deleteButton, refreshButton;
     JLabel companyLabel;
     JTextField companyField;
     public ContactsInterface()
          super("ContactList");
          listModel = new DefaultListModel();
          contactList = new JList(listModel);
          buttonPanel = new JPanel();
          detailsPanel = new JPanel();
          addButton = new JButton("Add Record");
          addButton.addActionListener(this);
          updateButton = new JButton("Update Record");
          updateButton.addActionListener(this);
          deleteButton = new JButton("Delete Record");
          deleteButton.addActionListener(this);
          refreshButton = new JButton("Refresh");
          refreshButton.addActionListener(this);
          companyLabel = new JLabel(" Company:");
          companyField = new JTextField(10);
          companyField.setEditable(false);
          buttonPanel.setLayout(new FlowLayout());
          detailsPanel.setLayout(new GridLayout(6,2,10,10));
          buttonPanel.add(addButton);
          buttonPanel.add(updateButton);
          buttonPanel.add(deleteButton);
          buttonPanel.add(refreshButton);
          detailsPanel.add(companyLabel);
          detailsPanel.add(companyField);
          setLayout(new BorderLayout());
          JScrollPane contactJScroll = new JScrollPane();
          contactJScroll.setPreferredSize(new Dimension(100,80));
          contactJScroll.getViewport().setView(contactList);
          add(contactJScroll, BorderLayout.WEST);
          add(buttonPanel, BorderLayout.SOUTH);
          add(detailsPanel, BorderLayout.CENTER);
     public void actionPerformed(ActionEvent e)
          String args = e.getActionCommand();
          if(args.equals("Add Record"))
               openAddRecord();
     public static void main(String args[])   //main method of the ContactsInterface
          ContactsInterface CInterface = new ContactsInterface();
          CInterface.setJMenuBar(CInterface.createMenuBar());
          CInterface.setDefaultCloseOperation(EXIT_ON_CLOSE);
          CInterface.setSize(500,300);
          CInterface.setVisible(true);
          CInterface.setResizable(false);
     public void openAddRecord() // The method being called when clicking Add record which in turn opens another JFrame on top of the ContactsInterface  JFrame
          record = new AddRecord();
          record.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
          record.setVisible(true);
          record.setResizable(false);
          record.setSize(400,300);
     public void refreshList(String company)  //The method that needs to be called when disposing of the openAddRecord JFrame
          listModel.addElement(company);
          int index;
          index = contactList.getLastVisibleIndex();
          index++;
          contactList.setSelectedIndex(index);
          contactList.ensureIndexIsVisible(index);
     }The "openAddRecord Frame" opens fine, in the "openAddRecord JFrame" I add a company name.
How can I when I click on the "Save" button in the "openAddRecord JFrame" and then dispose(); of the "openAddRecord JFrame" let it call a method in the "ContactsInterface JFrame" which was the parent of "openAddRecord JFrame" / were the "openAddRecord JFrame" was opened in, to refresh the JList by calling the "refreshList" method.

Don't use multiple JFrames.
A typical application will only ever have a single JFrame. If you need a second window you would use a JDialog. If you want to stop execution until the dialog is closed then you would use a "modal" JDialog.

Similar Messages

  • Automatic Refresh of calling screen after closing Webdynpro Appl

    Hi All,
    We are on SRM 5.0 and we are launching a custom webdynpro application from the Sourcing Cockpit. We added a custom button on the sourcing cockpit and that button would launch the custom webdynpro application as shown below in the PAI event.
    DATA : lv_url TYPE string,
                l_obj type SMENSAPNEW-REPORT,
                l_rep type SMENSAPNEW-REPORTTYPE,
                l_url type SMEN_BUFFI-URL.
        CALL METHOD cl_wd_utilities=>construct_wd_url
          EXPORTING
            application_name = 'Z_SC_UPD'
          IMPORTING
            out_absolute_url = lv_url.
    l_obj = 'URL'.
    l_rep = 'OT'.
    l_url = lv_url.
    CALL FUNCTION 'MENU_START_OBJECT_VIA_INDX'
    EXPORTING
       OBJECT_NAME         = l_obj
       REPORTTYPE          = l_rep
       URL                 = l_url.
    The webdynpro Z_SC_UPD will update the custom fields in the shopping cart. Upon closing of this webdynpro application, we need to refresh the screen of Sourcing cockpit to reflect the changes that Webdynpro just made. Is it possible. Please advise?
    Thanks
    Abapinator.

    Hi
    In this case you would probably require to restructure your application. The webdynpro application thats launched in the new window. Need to call a method in the event handler , that finally calls the  exit plug. You can  from this  method  call your associated ASSISTANCE CLASS method.
    ASSISTANCE class should expose method to refresh you original Application, this may be a simple matter of reexecuting the transaction associated with you MAIN Application
    This in effect you call a method before exitiing that would end up reseting/ Refreshing your main app.
    Greetings
    Prashant

  • Calling method to add JFrame components

    I'm trying to build a GUI. I have a JFrame and want to add components to it from their individual classes to keep everything seperate.
    Can someone give me some guidance with the call?
    Frame.add(method from other class)
    I'm not sure how to do this. I've tried several different options and attempts, but I can't get the syntax right. I can do it from within the JFrame class, but can't figure out the external call. All the examples and tuts I find show calls within the same class, but not from other classes. Right now that's my weak point with this.
    Any guidance...
    Thanks in advance

    public class MyComponent{
        public JButton createLabel(String caption){
             return new JButton(caption);
        public JPanel createPanel(){
            JPanel p = new JPanel();
            p.add(new JScrollPane(new JTextArea()));
            return p;
    public class Demo{
        public Demo(){
            MyCompoent c = new MyComponet();
            JFrame frame = new JFrame();
            // note: if you're using 1.4.2 or older...you have to do
            //  frame.getContentPane().add(component, position);
            // JFrame by default uses a BorderLayout, to change layout..use setLayout() method
            frame.add(c.createPanel(), "Center");
            frame.add(c.createButton("Exit"), "South");
            frame.pack();
            frame.setVisible(true);
    }

  • After closing serversocket, process remains

    Hi everyone,
    I'm trying to learn to write a client/server program. I begin by creating a serversocket and waiting for data. When I close the program, the serversocket still remains even when I create handlers that try to close the socket after the GUI has been closed.
    The server is as follows:
    try
                   ServerSocket myServerSocket = new ServerSocket(6666);
                   myServerSocket.setReuseAddress(true);
                   writeToDebugger("Server successfully created.  Listening on port 6666\n");
                   //     open a socket for listening for multiple requests
                   while(listening)
                             clientSocket = myServerSocket.accept();
                             //clientSocket.setReuseAddress(true);
                             writeToDebugger("Client " + clientSocket.getInetAddress().toString() + " accepted.");
                             //store clientSocket information
                             out = new PrintWriter(
                                    clientSocket.getOutputStream(), true);
                             in = new BufferedReader(
                                      new InputStreamReader(
                                          clientSocket.getInputStream()));
                             while ((inputLine = in.readLine()) != null && inputLine != "")
                                  writeToDebugger(inputLine);
                             //breaker = inputLine.indexOf(',');
                             //store the incoming request's information --- username of requestor is first param, requested username is second param
                             //database.put(inputLine.substring(0, breaker), clientSocket.getInetAddress());
                             //return the IP address of the username lookup
                             //out.print(database.get(inputLine.substring(breaker+1)));     
              }Here is my closing handler:
    public void windowClosed(WindowEvent arg0) {
              listening=false;
              try
                   System.out.println("CLOSING FOR REAL");
                   if(clientSocket!=null)
                        clientSocket.close();
                        clientSocket.shutdownInput();
                        clientSocket.shutdownOutput();
                   if(myServerSocket!=null)
                        myServerSocket.close();
                   if(out!=null)
                        out.flush();
                        out.close();
                   if(in!=null)
                        in.close();
                   System.out.println("DONE CLOSING");
              catch(Exception e)
                   System.out.println(e.getMessage());
         }If someone could please tell me why I have to go into the task manager to close the process after I have already closed the GUI, I'd really appreciate it.
    Thanks in advance,
    Julian

    And you're doing all these closes in the wrong order, and redundantly.
    Just close 'out' and the ServerSocket, doesn't matter in what order here.
    All the other closes and shutdowns are redundant. Calling shutdownXXX after closing the socket does nothing (and calling them just before closing the socket would add nothing to what close() already does). Closing the client socket before closing the output stream built around the socket output stream denies the output stream the chance to flush.

  • How to call a private method in a JFrame

    I have a Frame which has some properties like its size, bgcolor plus other parameters, as instance variables. There is a button on the Frame with the caption : "set properties". When one clicks on that button, a new frame should appear via which a user can change the values of the parameters of the main Frame (i.e size, bgcolor,..etc). The user would input the new values in the textfields or radio buttons that are on the new frame, and then click a submit button, which has to exist on the same NFrame. How can I do that so that when the submit button is pressed, the parameters values are updated and so is the display view ?
    I made it this way : I created 2 classes, the main frame and the new Frame. I made the new Frame an instance variable of the main Frame. When the user clicks the " set properties" button on the main Frame, the new Frame is shown. The user enters new values for some of the parameters and clicks submit. The parameters in the new Frame are updated. UP TO HERE EVERYTHING WENT JUST FINE. Now, there is a private method in the main frame that changes the color, size, ...etc of the main frame according to the values stored in the instance variables color, size,...etc. THE QUESTION IS: How can the new Frame display the changes after the values have been updated ? That is, how can it call the "private" method in the main class?? Should the new class be a child class of the main class to be able to access it's private methods ??

    import java.awt.*;
    import java.awt.event.*;
    import java.util.Random;
    import javax.swing.*;
    public class CallingHome
        SkinMod skinMod;
        JPanel panel;
        public CallingHome()
            // send reference so SkinMod can call methods in this class
            skinMod = new SkinMod(this);
            JButton change = new JButton("change properties");
            change.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    skinMod.showDialog();
            JPanel north = new JPanel();
            north.add(change);
            panel = new JPanel();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(north, "North");
            f.getContentPane().add(panel);
            f.setSize(300,100);
            f.setLocation(200,200);
            f.setVisible(true);
        public void setBackground(Color color)
            panel.setBackground(color);
            panel.repaint();
        public static void main(String[] args)
            new CallingHome();
    class SkinMod
        CallingHome callHome;
        Random seed;
        JDialog dialog;
        public SkinMod(CallingHome ch)
            callHome = ch;
            seed = new Random();
            createDialog();
        public void showDialog()
            if(!dialog.isShowing())
                dialog.setVisible(true);
        private void createDialog()
            JButton change = new JButton("change background");
            change.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    callHome.setBackground(getColor());
                    dialog.dispose();
            JPanel p = new JPanel();
            p.add(change);
            dialog = new JDialog();
            dialog.getContentPane().add(p);
            dialog.setSize(200,100);
            dialog.setLocation(525,200);
        private Color getColor()
            return new Color(seed.nextInt(0xffffff));
    }

  • Calling a method after 10 seconds

    Hello,
    I need to call a method after 10 seconds. That is to make sure that if one particular field is updated, say 3 times in a window of 10 seconds, I should just be able to take the last value and process it, in my ajax app. I am so far using the Timer class, but the problem is, it ticks off a thread for every single request to be processed after 10 seconds and processes all the 3 requests, where as I should just be running that method once for the last request. Could you please help me with this ?
    Cant do this at the client level, for the page may be closed within those 10 seconds of the event and the setTimeout wont work then.
    This is what I made so far.:
    final Map<String, Object> mp = new HashMap<String, Object>();
    if(form.getEmpId() != null )
                mp.put(form.getEmpId().toString(), form);
                new java.util.Timer().schedule(new java.util.TimerTask()
                   public void run()
                      EmpForm form1 = (EmpForm)mp.get(empId.toString());
                      String empId = form1.getempId().toString();
                      String value1Changed = form1.getValue1Changed().toString();
                      String value2Changed = form1.getValue2Changed().toString();
                      myService.changeData(empId, value1Changed, value2Changed),
                }, 10000);
             }

    Thanks for replying
    tjacobs01 wrote:
    My recommendation is that you share an AtomicReference between your timer and the listener that is receiving the updates. This way, the listener can just update the value, and the timer uses the latest one when it wakes upOk, out of my limited understanding, I looked up AtmoicReference and found it a class. I think I cant use that since I am maintaining a list of empIds against the object that holds their data in a hashmap, expecting the map to override the empId on the second request. So, I made a final map and thought Id just push the timer scheduler method in another method, but the problem is, for me to ask that thread (which I expect to run after 10 seconds of my calling) to run, I need to call it somewhere, and as soon as I get a request I am calling the method which runs/ticks off the thread.
    I was thinking that since I am passing and using a final map (that I declared as a class level variable), I will be able to put update the map object and whenever the thread runs, will fetch the latest value (of the empId) in the map. But I guess I am doing it wrong. :(

  • How to call a javascript method after table load on JSFF Fragment load?

    Hello,
    The usecase is to invoke a javascript method after table is done loading (fetching data) when user lands to a JSFF fragment. With JSPX pages I can achieve that by using PagePhaseListener. I have tried with RegionController as follows, and the problem i face is that I cannot prevent multiple calls to the Javascript call when user presses a tab or button in a screen, or changes drop-down value with autosubmit on.
    import javax.faces.context.FacesContext;
    import oracle.adf.model.RegionBinding;
    import oracle.adf.model.RegionContext;
    import oracle.adf.model.RegionController;
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    public class MyListener implements RegionController{
    public MyListener() {
    super();
    @Override
    public boolean refreshRegion(RegionContext regionContext) {
    int refreshFlag = regionContext.getRefreshFlag();
    System.out.println("Render flag is: "+refreshFlag);
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    initializeMethod();
    regionContext.getRegionBinding().refresh(refreshFlag);
    return false;
    public boolean validateRegion(RegionContext regionContext) {
    regionContext.getRegionBinding().validate();
    return false;
    public boolean isRegionViewable(RegionContext regionContext) {
    return regionContext.getRegionBinding().isViewable();
    public void initializeMethod() {
    FacesContext f = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(f, ExtendedRenderKitService.class);
    service.addScript(f, "myJSFunction();");
    @Override
    public String getName() {
    return null;
    I need the javascript to be called only once after the table is done loading when user lands to a fragment (jsff).
    Any ideas appreciated?
    JDeveloper version is 11.1.1.5.0
    Thank you.
    Valon
    Edited by: Valon on Apr 11, 2013 3:10 PM

    One of the requirements is to compare every row with the next row and highlight the changes. There are other requirements as well where JavaScript solution is used.
    The question remains the same. Is it doable or not without changing the solution from JavaScript solution to server-side solution ? Can we call a JavaScript only once when the user lands to a jsff fragment ?
    Hope that is clear.
    Thanks.
    Valon

  • Calling a backing bean method after load of fragment in adf

    I needed to call a backing bean method after page load of fragment in adf.
    I used the method suggested in:
    https://community.oracle.com/message/11044570
    only difference is im giving the if clause as:
    if (refreshFlag == RegionBinding.RENDER_MODEL ) {
    instead of
    if (refreshFlag == RegionBinding.PREPARE_MODEL)
    It was working fine, but page was not getting refreshed so used the code as mentioned in example:
    public void refresh() {
              FacesContext facesContext = FacesContext.getCurrentInstance();
              String refreshpage = facesContext.getViewRoot().getViewId();
              ViewHandler  viewHandler =facesContext.getApplication().getViewHandler();
              UIViewRoot viewroot =  viewHandler.createView( facesContext, refreshpage);
              viewroot.setViewId(refreshpage);
              facesContext.setViewRoot(viewroot);
    Now issue is once page is loaded and backing bean method is called, the refresh code refreshes the page and upon page load, refresh method is called again in recursive fashion.
    please advise what to do in such scenario?
    I tried to do selective refresh using some variable(also with static) but it does not help as page wont be refresh at all or page will keep refreshing recursively.

    Use clientListener on the page load event
    <af:document id=”d1″>
        <af:serverListener type=”onloadEvent”
                           method=”#{<managedbean name>.<method name>}”/>
        <af:clientListener method=”onLoadClient” type=”load”/>
        <af:resource type=”javascript”>
        function onLoadClient(event) {
          AdfCustomEvent.queue(event.getSource(),”onloadEvent”,{},false);
          return true;
        </af:resource>

  • Calling a method on a jFrame from a jPanel that created by the jFrame

    Hi all
    I can not for the life of me work out how to do this.
    Calling a method on a jFrame from a jPanel that created by the jFrame.
    I have used this code to set a handle for one jPanel to another.
    i.e I can create new jpanel and pass in handles from one to another but not back to the jFrame.
    // this is sudo code
      private Panel_Top topPanel;
      private Menu_Panel menuPanel;
      private DataPanel dataPanel;
    //create new
        topPanel = new Panel_Top();
        menuPanel = new Menu_Panel();
        dataPanel = new DataPanel();
    // add handles from one to another
        menuPanel.setDataPanel(dataPanel);
        topPanel.setDataPanel(dataPanel);
        topPanel.setMenu_Panel(menuPanel);
        dataPanel.setMenu_Panel(menuPanel);
    // in each class I use this to set
      public void setDataPanel(DataPanel dataPanel) {
        this.dataPanel = dataPanel;
      }But I can not seam to get a handle back to the jFrame that created it.
    Please help
    as you can see I am trying but no luck so far
    Thanks

    class Life extends JPanel{
          pulic Life( JFrame owner )
                owner.doSomething(); // pass the JFrame to the constructor and feel free to use it
    }[code[                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to call a method after a page  complete load

    Hi,
    Environment: JSF1.2.12+Spring
    I have a startpage, i will call a methode after startpage complete load. (I do not want to use javascript)
    How can i implement it.
    Edited by: zlzc2000 on Nov 6, 2009 2:53 AM

    goal: optimize load startpage(accelerate to load startpage)
    in startpage i use sql to load user's information, that in startpage is required.
    in other page i need the complete User Object (hibernate load user Object).
    i want to after dispay startpage load the user Object whith Hibernet.
    if during load startpage with hibernate to load user object, that is too slow.
    concept: 1step: with sql load user information (not full, for example: id, forename, surname,...)
    2step: results display( load startpage )
    3step: after load complete startpage, call method to load user object(it include all information of user )
    then the user object can be uesed in anywhere in the future.
    but i dont know how to impement it.
    Edited by: zlzc2000 on Nov 6, 2009 3:37 AM

  • How to Use Methods AFTER Work Item Execution (Modal Call)

    Hi,
    Need to execute a piece of code after a decision based on the result.
    Hope this can be done using Methods After WorkItem Execution
    Can anyone give some idea about how to use this.
    Regards
    Imman

    Hi Mike,
    I have a common piece of code that has to get executed irrespective of the decision made,but after the decision.
    Imman

  • Window Memory usage even after closing windows

    I've included links to a test app that does nothing but
    launch a window, play a sound, close window / repeat.
    When application launches it uses about 20mb of memory. When
    you click on the only button, it will launch a secondary window
    that will simply play a wav file. (I set the volume low but you may
    want to mute it :D)
    After launching and closing the window several times the
    memory usage goes up considerably and *never* falls back a
    significant %. (I got it to about 100MB before I decided to quit
    trying to increase the memory usage. Right now it's been running
    w/o any user interaction since opening about 10 windows and it's
    fairly stable at around 61MB (although that appears to be
    increasing w/o user interaction).
    Does anyone know of any methods I can use to ensure that the
    memory consumed by secondary windows does not just persist forever
    even after closing the window? Is there something I'm doing wrong
    here?
    Example Code:
    http://www.vf-server.com/air/memorytest.air
    (AIR)
    http://www.vf-server.com/air/memorytest.zip
    (source ZIP)
    Note: When I *minimize* the window it looks like garbage
    collection is forced and app drops back to 11MB (on restore back to
    19mb).
    Edit: note in your task manager, application appears as
    JBTest.exe

    You can call System.gc() to force the garbage collector to
    run.
    Try removing the event listeners when they aren't needed
    anymore. I think it is more difficult for the gc to cleanup objects
    when there are host objects (like Sound) refering to JavaScript
    objects and JavaScript objects refering to host objects, so you
    need to be especially careful about those. It SHOULD clean them up
    eventually, but it may take longer for it to figure out that those
    objects are no longer in use.
    You might also clear the secondaryWindow reference in the
    parent document when the window closes. That reference might retard
    garbage collection, too.

  • Cannot Open Form Created on Separate Thread After Closing

    My application communicates with a device that has several sensors.  As the sensors collect data, they send messages over the com port.  I have written a class to communicate with the device.  As the messages come in and are processed, the
    class raises events that the application responds to.
    The main window of the application handles the communication with the device and displays several statistics based on the data collected.  When the user presses a button on the device, a specific event is raised.  The main window create a separate
    thread and opens a child window.  When the child window is open, the user opens a valve to dispense the product.  As the product is dispensed, a flow meter connected to the device measures the volume of product dispensed.  The flow meter generates
    messages to indicate the volume dispensed.  I need to be able to send messages from the main window to the child window so that the child window displays the volume.  When the user is done, they close the valve dispensing the product and press the
    "End" button on the child window.  The child window then updates several variables on the main window, makes a couple of database calls to record how much product was dispensed and by whom and then closes.
    I need to run the child window using a separate thread as both windows need to be able to process commands.  If only one window has control the program doesn't work at all.  I have it figured out so that everything is working.  I can open
    the child window, dispense product, se the amount of product dispensed in the child window (the main window processes commands from the device and updates the label on the child window using a delegate), closes the window (using Me.Close()) and updates the
    main display with the updated data.  The problem is that when a user goes to dispense product a second time, I get the following error:
      A first chance exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll
      Additional information: Cannot access a disposed object.
    I thought that maybe I could hide the window (change Me.Close() to Me.Hide) and then just show it.  When I do that I get this error:
      A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
      Additional information: Cross-thread operation not valid: Control 'frmPour' accessed from a thread other than the thread it was created on.
    Both of these errors make sense to me, I just can't figure out how to make it work.
    First I have to declare the child window as a global variable as I need to access the window from a couple of the event handlers in the main form.
    Public frmMeasure As New frmPour
    When the user presses the button on the device to dispense the product, the event handler executes this code to open the child window.
    Private Sub StartPour(sAuthName As String, sAuthToken As String, iStatus As Integer) Handles Device.Pour
    Dim th As System.Threading.Thread = New Threading.Thread(AddressOf Me.OpenDispenseWindow)
    th.SetApartmentState(ApartmentState.STA)
    th.Start()
    End If
    End Sub
    Which executes this code:
    Public Sub OpenDispenseWindow()
    frmMeasure.sNameProperty = sCurrentUserName
    frmMeasure.sAuthTokenIDProperty = sUserToken
    Application.Run(frmMeasure)
    bAuthenticated = False
    bPouring = False
    dSessionVolume += GetTapConversion(sCurrentValve) * iFinalTick
    UpdateDisplayDelegate(iValveID)
    End Sub
    It doesn't matter if I use Me.Close() or Me.Hide(), both methods fail on the Application.Run(frmMeasure) line with the errors shown above. 
    For the Me.Close() method, my thinking is that the global frmMeasure object is getting disposed when I close the child window.  Is there any way that I can re-instantiate it when I go to display the window again?
    For the Me.Hide method, is there any way that I can track the thread that created it in the main window and when I go to call it a second time, detect that it is already available and just Show() it?
    Any hints, tips or suggestions are appreciated.
    Thanks.
    John
    John

    To be honest, I have only grasped < 100% of your message in detail, but...: Windows that have a parent<->child relation must be running in the same thread. In addition, after closing a modeless window, you must not use it anymore. Instead, create
    a new instance.
    What happens if you do not create a new thread but instead open the child in the same thread (which is obligatory)? You wrote it doesn't work, but I don't know why?
    "First I have to declare the child window as a global variable".
    How do you define "global"? Normally this is a variable in a Module declared with the scope Public or Friend. But I guess you mean a field of the Form (a variable at class level in the Form).
    "I need to be able to send messages from the main window to the child window so that the child window displays the volume."
    Why does the main window has to send the messages? Can't the child window handle the device's messages itself?
    "I need to run the child window using a separate thread as both windows need to be able to process commands."
    Process commands from the device, or commands from the user operating the Forms?
    Armin

  • Clicking mouse after closing JDialog sends event to last component (1.1.8)

    There seems to be a bug in Java 1.1.8 that I'm looking for a workaround.
    I have a JButton on a JFrame that brings up a modal JDialog when you click it. After closing the dialog, if you click on the JFrame without moving the mouse, it will click the button on the frame that was last clicked, even if the mouse is not over the button.
    Steps to reproduce:
    1. Use the mouse to click on the button on the frame to bring up the dialog.
    2. Close the dialog with the mouse or keyboard and don't move the mouse at all. (Note that the mouse should be over the JFrame at this point, but not over the frame's button.)
    3. Click the mouse again.
    Result:
    This causes the button on the frame to be clicked.
    It seems as if the frame thinks that the mouse pointer is located where it was when the dialog came up.
    Does anyone know how to prevent this from happening or a workaround?

    We are using 1.1.8 because our product has to run on Mac OS 8.x - 9.x (and this is the latest JRE supported by these platforms).
    When I say don't move the mouse, what I mean is when closing the dialog, if you don't move the mouse, it doesn't matter where the mouse pointer is, as long as it's over the frame. When you click it, the last button to get clicked will be clicked again. It's as if the frame thinks that the mouse hasn't moved since the dialog came up. This isn't a focus problem because if I set the focus on another control after opening the dialog (by calling requestFocus()), this problem still happens. I can also tab to another control after closing the dialog, but when clicking the mouse it still clicks the last button that was clicked. It's as if the frame needs to reset where the mouse position is when it becomes activated.

  • Application crash on showing alert message after closing document in CS5

    My application crashes when I show alert message after  standard close using IDocFileHandler's close method i.e
    Close( doc, uiFlags, allowCancel, cmdMode );
    Before calling this method there is no crash on showing alert messages.
    i.e just one line before Close() method is called I am able to show alert message. And just one line after close method call , after showing alert message when I  click on OK button of alert message  my application crashes.
    I tried to use errorcode but returned value was fine i.e no error.(Checked GlobalErrorCode and GlobalErrorString before and after close).
    I also tried CanClose method to check but it worked fine.
    I also used IDocumentCommand methods but application crashed without showing  alert message.

    I used PMSetGlobalErrorCode(kCancel) after closing document and it worked.

Maybe you are looking for

  • PS CS4 can't see script in folder

    I have a Slideshow Pro script installed that I use in Photoshop to batch export Photoshop files for use in Flas with Slideshow Pro. The file is in c:\program files (x86)\adobe\adobe photoshop cs4\presets\scripts, and I have that location set in prefe

  • U0093Critical program error occurred .u0093Client out of memory error u0093 - Query

    I have a problem with Query in BI 7.0 Query works perfectly in BW3.5 environment.  BI 7.0 Vista and Excel 2007 environment – I have date range in the query – If I provide date range 4 months interval it is working fine. If I provide 5, 6,7, months in

  • Verify permissions failed: Framework unable to communicate with the Disk Management daemon

    I'm experiencing problems with the Disk Management daemon on my MBPro Retina running Mountain Lion 10.8.2. I discovered it first when I tried to enable file vault and received the "Framework unable to communicate with the Disk Management daemon" erro

  • I Don't Have a ~/Library Folder!!!

    Just upgraded to Lion 10.7.1, trying to find my Safari prefs file, which should be at ~/Library/Preferences, but I can't locate my ~/Library folder... it's not there! I thought the Mac would have problems without it, but everything, all my apps seem

  • Problem with program logic

    hi, me havin a very funny prob w one of my mtd. here's a mtd from my bean class. public boolean checkForEvent (String searchdate) { boolean hasEvent = true; try { // This is the sql statement to modify. sql = "select * from event where eventstart <=