Opening one window from another

I've created a method which opens a window that takes an input from the user and then closes and returns the input to the main program. When I called this method from a test program it seemed to work perfectly but when I tried to call it from my main GUI via an action listener on a button it just seems to crash.
So my input window would wait until the return button was pressed, I set up a while loop which delays the program until a flag is changed by pressing the return button. As far as I can tell it is this while loop which is causing the problem. Has anyone got any idea why this method works with my test program but not through a GUI? I expect that there is also a better way of retrieving this information from my input window and that I have probably just forgotten something very simple. If anyone has got any suggestions I would be very grateful.
Thanks, Tom

Hi Tom,
the while loop is not very suitable for this situation.
The best solution, in my opinion, is to attach ActionListener to the 'submit' or 'ok' button of your child window, from the main GUI.
Let's say A is your main GUI class and B is the JDialog (better if modal) that should return the value. Proceed as following:
1. in the class B implement a method that attaches a listener l to the Ok button
public void addOkListener(ActionListener l)
  okButton.addActionListener(l);
}2. in the class A, create a ActionListener object like:
ActionListener al = new ActionListener()
  public void actionPerformed(ActionEvent)
      do whatever you like, this code is executed when the user clicks
      on the button OK in the JDialog.
      For example you may want to retrieve the value from the JDialog:
      System.out.println(b.getMyValue());
}3. in the class A, attach the listener to B:
  b.addOkListener(al);Antonio :)

Similar Messages

  • How do I open one .mxml from another?

    I suppose I would make a "link" some how, just like in an html page.  What would the URL look like?  What is the ActionScript command to open that other .mxml file?  (Which may be a form or just another page)
    Thanks in advance.

    to open another .mxml file within your project? Like a sub window within your main app? You can do it as a popup;
          var win:[MXML FILE NAME] = PopUpManager.createPopUp(this, [MXML FILE NAME], true) as [MXML FILE NAME];
          PopUpManager.centerPopUp(win);
    or, if it's a completely different app you're trying to link to;
    navigateToURL(new URLRequest('http://wherever/the/compiled/html/is.html'),'_self');
    quite unsure about what exactly you want though...

  • Opening one applet window from another

    Hi everyone,
    Can anyone provide any pointers about how I can open one JApplet from another (say, on a button click). I am new to applet development and I searched for examples on this forum and google, but could not find anything relevant.
    Thanks,
    Alan

    Hi Dear
    Just use this simple commmand.
    String url;
    url1 = "http://<Name of the HTML page>"
    try {
    getAppletContext().showDocument(new URL(url1), "_blank");
    } catch(Exception e) {e.printStackTrace();}
    This will prompt another browser. In this browser write u r applet code & load the class file.
    One thing more this will not work in the case if you are using appletviewer , it will only work when you running u r applet over the network.
    In case you wana test with appletviewer then initiate the browser from the system .... In that case you have to search the net.
    Vipin

  • Moving tabs from one window to another makes the new window vanish. I have hot corners enabled so when I move up to the right corner of my display I can see all my open windows but when I click on the tab that I moved to make it its own window it vanishes

    Moving tabs from one window to another makes the new window vanish. I have hot corners enabled so when I move up to the right corner of my display I can see all my open windows but when I click on the tab that I moved to make it its own window it vanishes

    I came up with an alternative solution.
    Instead of actually trying to move the JInternalFrame from one JDesktopPane to another, I added a single, maximized JInternalFrame to the left side. When one of the right side frames is to be docked, I merely copy its ContentPane to the single JInternalFrame on the left, set the original to be non-visible, and adjust the properties of the JSplitPane to make the "docked" frame appear.
    When the "close" button on the docked frame is pressed, I simply undo this procedure to "undock" the frame and redisplay it on the right-hand side (with its content intact from the docked frame, but in its original position).

  • How do I move tabs from one window to another window?

    With the previous version of firefox, I could drag a tab from one window to another window. (and if there was only one tab left in that window, it would automatically close that window because there were no more tabs open in it)
    With the latest version of firefox, '''How do you drag or move a tab from one window to another window'''

    Hi,
    To move to the next tab it's '''Ctrl''' + '''Tab''' or '''Ctrl''' + '''Pg Dn''' (Page Down). To go to the previous tabs (reverse order) it's '''Ctrl''' + '''Shift''' + '''Tab''' or '''Ctrl''' + '''Pg Up''' (Page Up) keys. More about this and other keyboard shortcuts [https://support.mozilla.com/en-US/kb/Keyboard%20shortcuts here.]

  • My new Photoshop Elements 12 has a RAW file plug-in, but when I try OPEN to select a photograph, there are only generic icons instead of pictures-- I can't tell one photograph from another! How can I fix this so I can tell which photograph I want to open?

    My new Photoshop Elements 12 has a RAW file plug-in, but when I try OPEN to select a photograph, there are only generic icons instead of pictures-- I can't tell one photograph from another! How can I fix this so I can tell which photograph I want to open? Thank you!

    Thanks R_Kelly:
    Adobe Photoshop Elements Version: 12.0 (12.1 (20140303.12.1.49334)) x32
    Operating System: Windows Vista 32-bit
    Version: 6.0 Service Pack 2
    System architecture: Intel CPU Family:6, Model:15, Stepping:11 with MMX, SSE Integer, SSE FP, SSE2, SSE3
    Physical processor count: 4
    Processor speed: 2400 MHz
    Built-in memory: 3069 MB
    Free memory: 1631 MB
    Memory available to Photoshop Elements: 1598 MB
    Memory used by Photoshop Elements: 69 %
    Image tile size: 128K
    Image cache levels: 8
    Video Card: ATI Radeon HD 4800 Series
    Video Mode: 1680 x 1050 x 4294967296 colors
    Video Card Caption: ATI Radeon HD 4800 Series
    Video Card Memory: 512 MB
    Application folder: C:\Program Files\Adobe\Photoshop Elements 12\
    Photoshop Elements scratch has async I/O enabled
    Required Plug-ins folder: C:\Program Files\Adobe\Photoshop Elements 12\Required\
    Primary Plug-ins folder: C:\Program Files\Adobe\Photoshop Elements 12\Plug-Ins\
    The first thing I did was UPDATE. I have all the latest updates available (according to the updater). The Camera Raw Plug-in says it is version 8.0.
    The RAW files are from a Canon T3i. It's a very common camera, I can't believe it wouldn't be supported.

  • Folder/ file icons are different sizes from one window to another!

    Hi there
    I am having an extremely annoying problem where all my folders and files (in icon view) are totally different sizes from each other from one window to another. For example, I might click on a folder that's icon is small sized (64x64), but when that folder opens up, the icons of the subfolders inside are huge (276x276) and need to instantly be resized and re-arranged. Then if i continue to open one of these subfolders, the file icons inside it are now medium sized (96x96). Each new folder that I go into on my hard drive will be differently sized and I end up spending ages resizing and re-arranging them before I can do my work. This problem never happened in Leopard and Im despairing of what to do.
    Is there a way of setting a default icon size and spacing that can then be applied to every folder and file on the hard drive? I have used the 'Use as defaults' option on the 'View options' window but this doesn't apply it to anywhere else besides the current window you are on.
    Surely, Im doing something wrong as Apple could never have overlooked such an obvious problem like this?
    Can anyone advise?
    Many thanks
    Dan

    The Finder will (theoretically) remember the view settings for each individual folder that you visit. If you have not opened a particular folder before, you should get the default view settings, but once you have changed the view then that is what you will get on subsequent visits. You can erase the previous settings by deleting the (normally invisible) .DS_Store file that is created in a folder when it is opened, but this file can contain other Finder metadata.

  • Fire Plug from one window to another

    Dear All,
    Is it possile to fire an outbound plug from one window to another?
    I am using a Popup window and on clicking a button in the popup window, I want to navigate to another view in the parent window.
    I know there are other ways to handle these kind of scenarios like using an eventhandler in the parent view and them firing a plug, but that would affect the rest of the applicatin flow.
    So I cannot avoid firing the plug from the view in the popup window.
    Can it be done?
    Thanks and regards,
    Mayuresh

    Hi Mayuresh Kanvinde ,
          I believe your popup is a modal window. If so in your action handler of the button on the popup window you can hide the popup window and then fire the navigation plug of your parent window.
       Your popup button action handler can call a method in your component controller where you can write the code to hide the existing popup window and then fire the plug in your parent window.
       make sure you store the IWDWindow object of your popup window on the context so that you have access to it to hide the popup window.
    Regards,
    Sanyev

  • How to call one .SWF from another?

    How do I call one .SWF from another. I built a very beefy
    base .SWF, and want to add music overlay, and an intro slide show
    to the exsting Flash animation, but put it in a second .FLA/.SWF
    file. How do I call one from the other?
    This will be embedded in an HTML file but I assume this is
    superfluous to my question.
    F.Z.

    I think you should open that Another SWF (FLA),
    and add some actionscript..
    For example, you could create a movie clip, and write
    actionscript in the
    first keyframe:
    loadMovie("
    http://www.somewebpage.com/movie.swf",
    this);
    "FredZimmerman" <[email protected]> wrote in
    message
    news:ftnjas$mj5$[email protected]..
    > How do I call one .SWF from another. I built a very
    beefy base .SWF, and
    > want
    > to add music overlay, and an intro slide show to the
    exsting Flash
    > animation,
    > but put it in a second .FLA/.SWF file. How do I call one
    from the other?
    >
    > This will be embedded in an HTML file but I assume this
    is superfluous to
    > my
    > question.
    >
    > F.Z.
    >

  • Frm-92101 happens when I open a form from another form and close it.

    Frm-92101 happens when I open a form from another form, check something, show a message to the user and exit the form to the previous form.
    Forms version: 10.1.2.0.2. Java: 1.6.0_23. Browser: IE6
    When I put before the "EXIT_FORM" two messages, everything is fine and the second form is closed and I repeat to the first form just as I wanted.
    In forms 9.0 it didn't happen.
    Does it have a connection with the fact I use JRE instead of JInitiator?
    Thank you.

    >
    There are numerous causes of the FRM-92101 error. I recommend you start your investigation by tracing your Forms session so you can see what your form is doing when the error occurs. Check out My Oracle Support document How to Use Forms Trace with Forms [ID 209372.1] for information on how to enable the trace. Also, take a look at My Oracle Support document Known Causes of FRM-92101 Error In Forms [ID 604633.1].
    Hope this helps,
    Craig
    >
    I have just found that there is a "Synchronize" command in one of the main attached libraries, and when I comment that command the application works well. But I don't want to comment it because it's a great library and I assume it has a part in the system.
    I have discovered that in the new Forms' help, the fact that the System.Current_Item mustn't be null so the command "Synchronize" will work, is mentioned. In the old Forms' help, that fact is not mentioned.
    So I tried to put it inside a condition that checks if the current item is not null, but the compiler doesn't recognize the "current_item". I don't know why. Because it's a library? So how can I check this? I can sent it as a parameter, but I don't want. Do you know something about it? Thank you.

  • My slide presentation (with sound) is done. How can I change one song from another?

    My slide presentation (with songs) is done. How can I change one song from another?

    Do you still have your Aperture Slideshow project? Then open the slideshow and select the one of the green audio file clips in the film strip that you want to replace. Press the "delete" key and drag another audio file from the Media Browser directly onto the slide, where the sound should start.

  • Can I Call method on one JVM from another through a dll?

    Let me explain.
    I have this java jar file that I can only have one instance of running at any given time. I'm using a shared data segment in a dll to store a bool indicating whether the program is already running or not. If it's already running, I have to not run the second instance and give focus to the current running instance.
    The jar file calls a native method "canInstantiate()" on a dll to see if there's already an app running. If there isn't, the env and obj are stored in the shared data segment of the dll and we return true. If there is already an instance of the program running, I want canInstantiate call a function on the current instance of the jar (like a callback) to tell it to request focus. It's not working. Can someone tell me if my code is right?
    The .h file
    #include "stdafx.h"
    #include <jni.h>
    #include "CardServer.h"
    #pragma data_seg("SHARED") // Begin the shared data segment.
    static volatile bool instanceExists = false;
    static JavaVM *theJavaVM = NULL;
    static JNIEnv* theJavaEnv= NULL;
    static jobject instanceObject = NULL;
    static jmethodID mid = NULL;
    static jclass cls = NULL;
    #pragma data_seg()
    #pragma comment(linker, "/section:SHARED,RWS")
    jdouble canInstantiate(JNIEnv *env, jobject obj);
    jdouble instantiate(JNIEnv *env, jobject obj);
    jdouble uninstantiate(JNIEnv *env, jobject obj);
    void grabFocus();
    </code>
    The .cpp file:
    <code>
    #include "MyFunctions.h"
    #include <string.h>
    #include <stdlib.h>
    #include "stdafx.h"
    #include <iostream.h>
    jdouble canInstantiate(JNIEnv *env, jobject obj)
    printf("In canInstantiate!!");
    if (!instanceExists)
    printf("No instance exists!!");
    return (jdouble)0.0;
    else
    printf("An instance already exists!!");
    grabFocus();
    return (jdouble)1.0;
    jdouble instantiate(JNIEnv *env, jobject obj)
    printf("**In CPP: Instantiate!!\n");
    cout << "At start, env is: " << env << endl;
    cout << "At start, obj is: " << obj << endl;
    if (instanceExists == false)
    instanceExists = true;
    theJavaEnv = env;
    instanceObject = obj;
    theJavaEnv->GetJavaVM(&theJavaVM);
    cls = (theJavaEnv)->FindClass("TheMainClassOfTheJar");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
    if (mid == 0) {
    fprintf(stderr, "Can't find grabFocusInJava\n");
    exit(1);
    printf("About to call grabFocusInJava\n");
    grabFocus();
    printf("CPP: After the grab focus command in instantiate!!\n");
    cout << "At end, env is: " << env << endl;
    cout << "At end, obj is: " << obj << endl;
    return 0.0;
    else
    printf("CPP: Finished Instantiate!!\n");
    return 1.0;
    jdouble uninstantiate(JNIEnv *env, jobject obj)
    printf("CPP: In uninstantiate!!\n");
    if (instanceExists == true)
    instanceExists = false;
    theJavaVM = NULL;
    instanceObject = NULL;
    printf("CPP: Finishing uninstantiate!!\n");
    return 0.0;
    else
    printf("CPP: Finishing uninstantiate!!\n");
    return 1.0;
    void grabFocus()
    printf("In CPP::GrabFocus!!\n");
    instanceObject = theJavaEnv->NewGlobalRef(instanceObject);
    cls = (theJavaEnv)->FindClass("CardFormatter");
    if (cls == 0) {
    fprintf(stderr, "Can't find Prog class\n");
    exit(1);
    printf("Got the cls id again!!\n");
    if (cls == 0)
    printf("IT'S INVALID!!\n");
    mid = (theJavaEnv)->GetMethodID(cls, "grabFocusInJava", "(I)I");
    if (mid == 0) {
    fprintf(stderr, "Can't find grabFocusInJava\n");
    exit(1);
    theJavaEnv->CallIntMethod(instanceObject, mid, 2);
    printf("Called grabFocusInJava\n");
    </code>
    thanks in advance

    Can I Call method on one JVM from another through a dll
    ...The rest of your question merely expands on your title.
    And the answer to that question is no.
    When you call a method you are executing a "thread of execution." A thread of execution exists only in a single process. It can not exist in another process.
    If the dll is doing some interesting things then you could call a method that sets a flag. Data can move between instances. But you would then have to have a thread in that different process monitoring that flag. And sharing data in a dll is not a normal process, so it would have to be coded appropriately.
    If all you want to do is set the current focus to the existing application, then that can be done with existing windows functionality. You don't need to do anything special in your dll. You can probably search these forums to find the exact code. If not there are countless examples in windows repositories (like MSDN) on how to do that.

  • Safari 5.1.1 opens all windows from previous session

    Since updating to Safari 5.1 (maybe 5.0 not sure) Whenever I begin a new session (open Safari from the closed state), it opens ALL the windows I had previously viewed in the previous session! Now, I can plainly see a "button" to do this trick in the History Menu (Open All Windows From Last Session), but I'm NOT clicking on that menu item. It happens exactly when I open Safari. I've looked everywhere for a preference or option to turn that "feature" off, but, Alas, I have not found anything to do so. Mind you, these are NOT windows I had open all at the same time in my previous session, just that I may have been searching for something and either had a bunch of windows open to compare items or used the little tiny red button in the upper left hand corner of the window to close that window and then sometime later, opened a new window with a different URL. Once, it opened so many windows that it ground the dual CPU's to a near halt. I had to shut it down with the power button because "Force Quit" wouldn't come up. This has really been agravating. 
    I'm desparate. Any ideas on how to fix this would be very appreciated.
    My equipment is: 24" iMac 2.8Ghz Core 2 Duo / 4GB RAM / 750GB HD purchased in 2007 OS X Lion 10.7.2.
    Thanks,
    Kevin

    Thanks, that is much more descriptive then the discussions message above.
    How To Disable Lion's 'Resume' Feature
    Wednesday July 20, 2011 7:00 pm PDT by Jordan Golson
    Resume is one of the main new features to OS X Lion, one taken directly from iOS:
    Now apps you close will reopen right where you left off, so you never have to start from scratch again. And when you install software updates, you no longer need to save your work, close your apps, and spend valuable time setting everything up again. With Resume, you can restart your Mac and return to what you were doing — with all your apps in the places where you left them.
    Now, this feature might be all well and good, but what if you want your Mac to behave like it did in Snow Leopard? Resume can be easily disabled, but the option is fairly hidden.
    Head to System Preferences and select the General tab. At the bottom of that page is a checkbox labeled "Restore windows when quitting and re-opening apps." If you uncheck that, your apps will continue to behave as they did in Snow Leopard.
    Hat tip OS X Daily.

  • Update column in one table from another

    I've got two tables:
    t1:
    con_num
    con_code
    ex
    elin
    addressee
    a few other columns
    t2:
    con_num
    con_code
    elin
    addressee
    contact
    a few other columns
    I just got about 300 rows into t2 using sqlloader, and now I need to use t2 to update t1. t1 will have 3 rows per ex||elin, but t2 can have more or less rows per elin (which is the same as ex||elin in t1). If t2 has 4 rows per one elin, then that is 4 distinct pieces of data, and I need to make sure that t1 reflects 4 rows in its ex||elin, each containing the addressee||contact from t2. So I'll need to add a row to t1, as well as update 3 rows. Is this possible with just SQL, or do I need to write PL/SQL?
    The following is the code I've been trying:
    update t1
    set t1.addressee =
    (select addressee from t2
    where t2.con_num = 'number'
    and t1.con_code = t2.con_code
    and t1.ex ||t1.elin_num = t2.elin_num)
    This code is not correct, it returns more than one row from t2. Also, I'd need to concatenate contact onto addressee with a space in the middle, not just addressee, into t1.addressee.
    Any ideas, pointers?
    Thanks!

    Forgot some info: Ora8.1.5 on win2kpro. Also, I was wanting to combine addressee||contact in the insert/update statement to differentiate one addressee from another in t1 after the data is inserted. We can have several addressees that are the same, but each one goes to a different contact for each record.
    Thanks!

  • How to kill one class from another class

    I need to dipose one class from another class.
    So that first i have to find what are all threads running in that class and then to kill them
    Assist me.

    Subbu_Srinivasan wrote:
    I am explaining you in clear way
    No you haven't been.
    >
    In my application i am handling many JInternalFrame.Simultaneously i am running working on more than one frame.
    Due to some poor performance of some thread in one JInternalFrame,the thread is keeps on running .
    i could not able to proceed further on that screen.
    So i have to kill that JInternalFrame.Yoinks.
    To be begin with your problem sounds like you are doing everything in one thread. So stop doing that. Second when you get it split up and if a task is taking too much time then interrupt it. No kill. Interrupt. This means the worker thread needs to check sometimes if it has been interrupted.

Maybe you are looking for

  • Report on results of multiple stored procs

    Post Author: RobotSlave CA Forum: Data Connectivity and SQL I'm creating a report where I have data coming from three different slightly related stored procs,  when I try to get sub totals from the result sets my data is all wacky. How to I get the t

  • ERROR: Install cannot verify the oracle 10g Database

    I just completed installation of the SES 10.1.8.2 version and am now trying to apply the 10.1.8.4 Service Pack. After the OUI screen asks for my sys password, I click on Next and receive a popup error message that reads, Install cannot verify the ora

  • Form Designing

    Hai Guys, i have a problem while designing Smart Form 1) in that i need one box like to draw half line between the box but i am not able to divide the box.  Some text Some Text      Some TextSome Text Some Text Some Text       ________________ Some T

  • Failed with exit code 5?

    Hi everybody, yesterday I renewed my dev account, at first I had no problem archiving apps to test them into my ipad, but suddenly every build gave me "build failed" with this error: CodeSign /Users/cristiano/Library/Developer/Xcode/DerivedData/Multi

  • How can I disable the new built-in PDF-viewer?

    Hi Folks, I recently got a strange problem with Nightly 15.0a1. All PDF documents are opened with the new built-in PDF viewer and it does not matter if it´s enabled or disabled - it just always opens and renders/loads the PDF file. But I want it to b