JPanel that close the parent JFrame

Hello.
I'm puzzled... how can I close a JFrame from the JPanel it contains?
I mean:
I have a Form that extends JFrame. In this form there's a JPanel, which has a BorderLayout. In the South part of the BorderLayout there's a JPanel (BoxLayout) that contains a JButton.
I'd like this JButton to get disposed of the Form.
How should I?
Is there a better way to manage with this?
(putting the button somewhere else...)
Thank you

Sorry, I forgot to mention that my sub-panel is in another class, another file.
So I don't know how to call the parent frame.
I tried with some .getParent(), but I get
JPanel
JLayerPane
JRootPane
and no JFrame.
I could just put everything into 1 single class (or inner classes at least), but if there's a chance to keep them in different files, I would be glad to learn about it :)
Thank you.

Similar Messages

  • Getting the Parent JFrame or JDialog

    I am trying to get the parent JFrame or JDialog so I can change the cursor. Right now I am doing it in a stupid way by doing this:
    private void changeCursorQuestion(){
              JFrame frame=(JFrame) getParent().getParent().getParent().getParent().getParent().getParent().getParent();
              Cursor cursor=new Cursor(Cursor.HAND_CURSOR);
              frame.setCursor(cursor);
         }//end changeCursorQuestionBut is there an easier and of course better way of getting the frame or jdialog that a panel is in?

    I am trying to get the parent JFrame or JDialog so I can change the cursor. You can change the cursor of the JPanel ( in fact any Container) so why use that getParent() thing....
    Also, if you want to have quick refrence to JFrame object from JPanel, extend JPanel to make a new class and have a refrence to that JFrame/JDialog in that class, that way you can access it quickly.
    Thanks!

  • Create a Button that Closes the Presentation

    All, I want a button on the last slide of my presentation that, when clicked, will close the browser window in which the presentation is playing. Will this involve Javascript? I tried some, but I probably screwed it up because it won't work. Some step-by-step guidance would be much appreciated, should someone have a few moments to guide me. Trying to make something more obvious than the X button on the playbar. Thanks so much!

    Hi there
    As explained in the Frequently Encountered Issues topic, closing the window is "iffy" and depends on different factors.
    The simplest approach is to avoid JavaScript altogether. Just configure the project to close when it completes. Then if you want a button that closes the project, configure it to jump to the last slide. Time that last slide super short. The net result will be that the user clicks the button, it jumps to the last slide for a split second, then if the project is capable of closing, it closes!
    Cheers... Rick
    Helpful and Handy Links
    Begin learning Captivate 5 moments from now! $29.95
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcererStone Blog
    Captivate eBooks

  • How to close the parent process.

    Hello World
    I am trying to open the external process like word using Runtime.exec(). The code below works perfectly fine. But I want to close the parent process. And only word file should remain on. How to do this? Experts please comment.
    Regards,
    Sachin Dare.
    import java.io.*;
    class Test {
    public static void main(String[] args) {
    try {
    String cmd[] = new String[3];
    cmd[0]= "cmd.exe";
    cmd[1]= "/C";
    cmd[2]= "C:\\Sachin\\EvicDocs\\sst58.doc";
    Process process = Runtime.getRuntime().exec(cmd);
    if(process != null) {
    StreamHandler errorGobbler = new StreamHandler(process.getErrorStream(), "ERROR");
    StreamHandler outputGobbler = new StreamHandler(process.getInputStream(), "OUTPUT");
    errorGobbler.start();
    outputGobbler.start();
    int exitVal = process.waitFor();
    System.out.println(" Exit Value is : " + exitVal);
    if(exitVal != 0) {
    throw new Exception();
    } else {
    System.out.println("Process is destroying......");
    process.destroy();
    catch(Exception e) {
    e.printStackTrace();
    class StreamHandler extends Thread {
    InputStream is;
    String type;
    StreamHandler(InputStream is, String type) {
    this.is = is;
    this.type = type;
    public void run() {
    try {
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line=null;
    while ( (line = br.readLine()) != null) {
    System.out.println(type + ">" + line);
    br.close();
    isr.close();
    } catch (Exception e) {
    e.printStackTrace();
    }

    If you mean by "parent process " the java one starting e.g. Word, then say System.exit() after having launched the child process. Hopefully Word will not take care of stdin, stdout or err so this arrangement will be okay.

  • How can I list all folders that contain files with a specific file extension? I want a list that shows the parent folders of all files with a .nef extension.

    not the total path to the folder containing the files but rather just a parent folder one level up of the files.
    So file.nef that's in folder 1 that's in folder 2 that's in folder 3... I just want to list folder 1, not 2 or 3 (unless they contain files themselves in their level)

    find $HOME -iname '*.nef' 2>/dev/null | awk -F '/'   'seen[$(NF-1)]++ == 0 { print $(NF-1) }'
    This will print just one occurrence of directory
    The 'find' command files ALL *.nef files under your home directory (aka Folder)
    The 2>/dev/null throws away any error messages from things like "permissions denied" on a protected file or directory
    The 'awk' command extracts the parent directory and keeps track of whether it has displayed that directory before
    -F '/' tells awk to split fields using the / character
    NF is an awk variable that contains the number of fields in the current record
    NF-1 specifies the parent directory field, as in the last field is the file name and minus one if the parent directory
    $(NF-1) extracts the parent directory
    seen[] is a context addressable array variable (I choose the name 'seen'). That means I can use text strings as lookup keys.  The array is dynamic, so the first time I reference an element, if it doesn't exist, it is created with a nul value.
    seen[$(NF-1)] accesses the array element associated with the parent directory.
    seen[$(NF-1)]++ The ++ increments the element stored in the array associated with the parent directory key AFTER the value has been fetched for processing.  That is to say the original value is preserved (short term) and the value in the array is incremented by 1 for the next time it is accessed.
    the == 0 compares the fetched value (which occurred before it was incremented) against 0.  The first time a unique parent directory is used to access the array, a new element will be created and its value will be returned as 0 for the seen[$(NF-1)] == 0 comparison.
    On the first usage of a unique parent directory the comparison will be TRUE, so the { print $(NF-1) } action will be performed.
    After the first use of a unique parent directory name, the seen[$(NF-1)] access will return a value greater than 0, so the comparison will be FALSE and thus the { print $(NF-1)] } action will NOT be performed.
    Thus we get just one unique parent directory name no matter how many *.nef files are found.  Of course you get only one unique name, even if there are several same named sub-directories but in different paths
    You could put this into an Automator workflow using the "Run Shell Script" actions.

  • How do I find the parent JFrame of a JMenuItem?

    When an ActionEvent occurs from a JMenuItem selection, how can
    I get a reference to the JFrame the JMenuItem is on?
    Thanks

    Good afternoon...
    it's a pretty good / standard idea to make your event-thread a subclass of the JFrame. i.e.:
    public class MySwingApp extends JFrame implements ActionListener {
        public MySwingApp() [
            super("My App Title");
            // ...build your GUI...
            // ...register this as your action listener for the menu items...
        /* this is in the class that is the JFrame of the application */
        public void actionPerformed(ActionEvent ae) {
            System.out.println(ae.getCommand());
    }hope that helps
    Schultz

  • Firefox doesn't open and even when i want uninstall it the window comes that close the firefox if it open but it doesn't open actually

    my mozilla firefox doesn't work when i want to open it , window comes that is user account something say do you want to allow and if i want to uninstall the firefox it doesn't uninstall.

    Make sure that you do not use [[Clear Recent History]] to clear the 'Browsing History' (Navigatiegeschiedenis) when you close Firefox.
    * [[Firefox does not ask to save tabs and windows on exit]]

  • HT201304 Kindle Amazon app store has an app called childs place. It's a parental control app that allows the parent to put only apps into it for childrens access & requires a password to get out of. Anyone know if there is a similar app in the Apple app s

    Kindle App Store has an app names Child's Place. It lets you add only the apps you want your child to access and requires a passcode to exit it. That way your child cannot access any other content except what you have allowed in this particular app. Does anyone know if Apple App store has anything comparable? I know you can set up restrictions in settings but this is different.
    Thanks

    Sorry but no, that is not possible in iOS. Other than what is offered in the Restrictions, there is no way to lock apps in general unless the app itself has a password feature. You can in iOS 6 lock the iPad into a single app, but that's your only option.
    It's a tradeoff; apps can't affect each other except in very restrictive ways in iOS which makes such features from third parties impossible, but it also renders getting malware infecting your iOS device extremely unlikely, something not the case with Android-based devices.
    Regards.

  • Vi or any function that closes the VI abruptly

    Hi,
           Is there any vi or function that stops running the main vi abruptly upon true.(inside the main vi there may be a subvi that has a while loop meaning it runs indefinitely)
                           only the main vi should be closed not the LabVIEW insatance.I'm using LabVIEW 2009
    Message Edited by Robin Hood on 03-11-2010 06:50 AM
    Regards
    RobinHood

    There are several options for this, depending on the overall architcture of your software. Most often, such a request makes sense in a producer/consumer environment.
    So the task is to inform the producer and the consumer to shutdown. Even there you have different options:
    a) The producer inits the shutdown. This is very easy since it follows the idea of produce/consumer.
    b) If the consumer should init the shutdown, you have to include a "messaging mechanism" for the consumer in order to shutdown the producer. Custom user events come quite handy here....
    c) You have some kind of watchdog for this feature. The watchdogs takes care about shutting down other parts of the application using user events or notifications. This can be used in producer/consumer as well as in other design patterns.
    Sure, the shutdown is not really "immediate", but if there are certain security requirements involved (e.g. robotics emergency shutdown), you must not have a software shutdown working within non-deterministic systems! If you have such an environment, the only acceptable "softwaresolution" would work on FPGAs.......
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Mac Book Air shuts down completely if I close the cover and leave for hours.  Message: you shut down your computer because of a problem.  Any thoughts what is happening?

    Mac Book Air shuts down completely if I close the cover and leave email running.  Is n't it supposed to just sleep and awaken whe the cover is reopened?  Instead, I have to boot it.  Any idea what the problem is?  I am unaware of any problem, just close the cover for safety.

    Well I don't know anyone that closes the cove and leaves it for Hours... But try going to System Prefrences > Energy Saving > Uncheck Put Hard Disk to Sleep.

  • Can I insert the name poperty of the RequestedByUser related object of the parent Change Request workitem in a review activity email notification template?

    I am working on a SCSM change control workflow driven by email. 
    A lot of my work is based on the information found in this post:
    http://blogs.technet.com/b/servicemanager/archive/2012/04/03/using-data-properties-from-the-parent-work-items-in-activity-email-templates.aspx#pi158453=4
    This is an excellent post to which my Internet searches continually return. The workflow is about 90% complete. 
    My question is can I insert the properties of a related object of the parent workitem in a workflow email notification? 
    For example, I want to include the name property of the RequestedByUser related object of the parent workitem object in a review activity notification.

    Thank you for your reply.  I have confirmed my template is using a projection that includes the parent workitem and requested by user.  Where I am having trouble is the notification template syntax used to call the properties of the related
    object of the parent workitem.  The picker in the GUI won't show that related object, so I have no example to follow.  I hope this reply makes sense!

  • How to get the parent Frame of a component ?

    Hi,
    I'm wondering how to get the parent JFrame (or JDialog) of a component.
    Thanks for tips

    I'm using this code:
    public Component getFrame(Component comp)
        Component frame = comp;
        while ((frame != null) && !(frame instanceof Frame))
            frame = frame.getParent();
        if (frame == null)
            frame = comp;  // no parent found
        return frame;
    }

  • How to create a button that close a window/popup.

    Hi, I must create in a view a button that close the window/popup that include the view, the button must be like the OK button of the popup or the X button at the top-right side . It's possible?

    Hi Avalor.
    You can create a custom pop up window. Just create a view that contains all
    elements that you want to display. Add the button that closes the view. Create a
    new window that only contains this new view. Use the mentioned method to create
    a new window as pop up. You just have to pass the name of the window you have
    created. Store the reference to the new window in the component controller
    (mr_window).
    From the new window->view you have access to the component controller.
    In the action handler of the button you can use something like this:
    wd_comop_controler->mr_window->close( ).
    Cheers,
    Sascha

  • I need an AS2 button that closes out a pop-up window...

    So, I’ve constructed a portfolio site with ActionScript 2.0, but I would like the pop-up window that displays the portfolio image to have its own ‘X’ button that closes the swf movie from the browser.  I’m assuming that the code begins something like this:
    on(release){
    //actionscript 2.0 code that closes the browser window.
    Any suggestions on how this will work across platforms and browsers?
    Best,
    R.

    Hi kglad,
    My main flash as2 file has a stage size of 1200 width x720 height.  I’ve looked online through various methods on creating pop-up browsers that will display a portfolio image when a button on the main.swf is clicked.  Having no luck in finding what I needed (most tutorials just give getURL examples where the image is displayed in a separate tab), it finally dawned on me to create an overlaying movie, of the same size as the document size, on the top layer of the primary flash stage.  Setting the movie symbol as ‘invisible’ keeps the movie symbol inactive and invisible until called by an action.  The button on the main.swf that calls the movie has the following as2 script attached to it:
    on(release){
                   loadMovie("images/aauComp.swf", _root.movie2);
    However, the aauComp.swf file is where the exit button is located.  I need to implement an on(release){} method onto the exit button in aauComp.swf  that will close the movie out in the main.swf file.  Here’s the double wammy, though: the exit button on the called movie file, aauComp.swf, does not recognize any gotoAndStop(); or on(release){} functions relating to itself when it is loaded. For instance, since I could not find any functions that would close the movie out and return me to the main.swf interface, I wrote the following command on the ‘exit’ button in aauComp.swf:
    on(release){
                   _root.gotoAndStop("blank_frame");
    Where “blank_frame” is within a scene of aauComp.swf that is completely empty – which should, in theory, allow for interaction with the main.swf below the loaded movie since there is nothing on that layer of the loaded aauComp.swf movie.  Make sense?  The ‘exit’ button works fine when aauComp.swf is tested and published by itself, but when it is called into the main.swf with the loadMovie(); function, the 'exit' button will not work and, so, it will not forward to the “blank_frame”.
    Any suggestions?  Let me know if you need anything clarified.
    Thanks.

  • Links that close previous file

    I have a PDF file that acts as a table of contents, and contains links to other PDF files. When a link is clicked on in the table of contents, the appropriate PDF file opens. However, the table of contents PDF remains open and I want it to close after a link to another PDF is clicked on. Does anyone know how to accomplish this -- to click a link in one PDF that closes the first PDF and opens the linked PDF?

    Hi,
    Here is something to try.
    Using the Link tool, access a link's properties.
    In the Actions tab, select the Open a file action.
    Select Open a file then click the "Add" button.
    Select the target PDF file.
    The 'Specify Open Preference' dialog opens.
    There are three choices:
    --| Window set by user preference
    --| New window
    --| Existing window
    Pick 'Existing window' then click OK - OK.
    Save the file & select the Hand tool.
    Now click on the link.
    The target PDF opens in the active window.
    The source PDF is closed.
    To confirm - while viewing the target PDF, select Window from menu bar.
    Observe, at bottom of drop-down, that only one (target) PDF is "open".
    Be well...

Maybe you are looking for

  • MM Open Purchase Order by Cost Center

    Does anyone knows of a report that can give me Open Purchase orders Orders by Cost Centers? Thanks for your help

  • REG:ERROR IN BIP

    Hi All, i want to schedule the report using delivery channel FTP For that i created report first it is working fine In admin tab i installed scheduler schema for enable scheduler and in delivery add server for FTP, I entered FTP host name as localhos

  • Photos Do Not Display in Browser

    I have posted photos to an iweb page and published to .Mac. When I select "Visit published page" from the drop down menu I am redirected to the URL and everything displays correctly. However, when I try to bring up the URL directly on any other compu

  • SSRS reports integration with sharepoint 2010

    Hi Friends, Any one can u pls tell me what are the  prerequisites for integrating SSRS Reports with Sharepoint. This is the first time im going to integrate SSRS reports with Sharepoint. Any one pls help me on this. Thanks in advance. Regards, LuckyA

  • Mapping in update rules

    Hi experts, could anyone please advice on how to map in update rules for the following requirement. I have a generic extractor, with Order date,Billing date and Delivery Date fields. to map { Order date,Billing date, Delivery Date} - three different