How do i make the old frame dissapear when i click a button for a new frame

I have a program were you have 2 buttons in a frame. When you click on a choice a new frame pops up with another choice. I wanted to know how can i make the old frame dissapear after the user makes the choice and the new frame has come up?
Thank you,
Dan

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame extends JFrame implements ActionListener
     private JButton Three;
     private JButton Four;
     private JButton One;
     private JButton Two;
     static int num = 0;
public Frame()
     JPanel p1 = new JPanel();
getContentPane().add(p1);
     if(num == 0)
     p1.add(One = new JButton("Admin"));
     One.addActionListener     (this );
     p1.add(Two = new JButton("Buy"));
     Two.addActionListener     (this );
if(num == 1)
     this.dispose();
     p1.add(Three = new JButton("Password"));
     Three.addActionListener (this);
if(num == 2)
     p1.add(Four = new JButton("Product-ID"));
     Four.addActionListener(this);
public void actionPerformed(ActionEvent e)
     if (e.getSource() == One)
          num = 1;
          Frame g = new Frame();
          g.pack();
          g.setVisible(true);
if (e.getSource() == Two )
               num = 2;
               Frame h = new Frame();
          h.pack();
          h.setVisible(true);
     if(e.getSource() == Three )
          System.out.println("Password");
     if(e.getSource() == Four)
               System.out.println("Product-ID");
public static void main(String[] args)
     Frame frame = new Frame();
frame.pack();
frame.setVisible(true);

Similar Messages

  • I migrated info from a hard drive to a new mac under time machine. It says I have shared files, but I don't see the old info on the new machine. Where do I look for it ? How do I make the old backup the base for my new macbook ?

    I migrated info from a hard drive to a new mac under time machine. It says I have shared files, but I don't see the old info on the new machine. Where do I look for it ? How do I make the old backup the basis for my new macbook ?
    The old OS was Mac X 10.5.8.   I think the new one is  10.7.2     Lion.

    Have a read here How do I set up a new Mac from an old one, its backups, or a PC?
    Stefan

  • TS2755 Is there a fix to deleting already deleted address book contact, from messages search? i.e. when you type in say letter c in messages search, all contact with a c, past already deleted and current all appear?  How do you make the old deleted ones a

    Is there a fix to deleting already deleted address book contact, from messages search? i.e. when you type in say letter c in messages search, all contact with a c, past already deleted and current all appear?  How do you make the old deleted ones appear?

    only way is to restore the phone as new.  OR wait until IOS 7 comes out in the fall.

  • How do I make the plugin run automatically when a photo is imported?

    I am trying to write a new plugin where the metadata will be automatically added to the photo when I import the photo in the Lightroom.
    How do I make the plugin run automatically when a photo is imported?
    Thanks for  your help!
    Regards,
    Prosenjit

    psaha84 wrote:
    What I want is, when I import a photo in Lightroom the plugin will run and assign the metadata.
    As John said, there is no mechanism to receive notification of import. The likely recourse is continuous polling (unless you get very creative..).
    You can try optimizing. e.g.: every second (or less), see if the count has changed, if it's gone up, something's been imported, if not then probably not (check anyway once in a while..).
    psaha84 wrote:
    How do I save the custom metadata with the image file?
    Lightroom 5 has the limitation, plugin  cannot link the custom metadata fields to XMP file or save them with image file.
    So, is there any alternative way to save the custom metadata?
    Yeah: Lightroom won't save custom metadata in xmp, nor read it if it's there, so you are pretty much on your own - you can save in a file, but if you save as non-standard sidecar Lr won't attend to it like it will jpg or xmp sidecar. For that reason it's often better to save in a separate dedicated location. You can save in image file itself, e.g. using exiftool if raw file, but that would make me nervous, and of course you'd have to have the logic to read it somewhere too..
    Good luck,
    Rob

  • HT204380 How can I make the screen full screen when I am calling?

    How can I make the screen full screen when I am calling on Facetime on a Macbook Pro Laptop?

    Ok but if the iPhone 5s and 5 can go full screen the why can't the iPad Air as it too is new the problem shouldn't be hard to solve as I have looked the apple site and it show it just fine in full screen so I'm sure you understand when I say there is most definitely away of doing it so can Apple just sort it out I'm always telling my m8 how good Apple devices are and I've been let down on this so come on fix it PLEASE

  • On a 5s how do you make the light turn off when phone rings or when you receive text, at work I would like to shut that off. Also seems like vibrate doesn't always work?

    On a 5s how do you make the light turn off when phone rings or when you receive text, at work I would like to shut that off. Also seems like vibrate doesn't always work? I had a 4s and didn't have these issues

    Thank you, I did find that. Still my phone does not always vibrate when ringer is off for texts and calls, only sometimes?

  • How can I make the voice very loud when navigating with my google gps app?

    How can I make the navigation voice on my google gps app VERY loud?

    I did a search for the Citibank virtual credit card and other similar words and could find nothing.

  • How can I make my page have animations when I click on the link?

    I am doing a class report and I need to come up with something to teach my class in one of our software programs. I am in the middle of Dreamweaver and Access so of course I chose Dreamweaver. I would like to know for my own page as well as to teach my class on how to make my page animated when I click the links.
    In power point you can set animations to your slides. I would like to know how to do almost that same thing but on a website.

    CSS Transitions, Transforms and Animations can do all kinds of fun stuff in modern browsers (everything but IE8 and lower, IE9 can do "some" of it)...
    Transitions
    http://www.w3schools.com/cssref/css3_pr_transition.asp
    Animations and Keyframes
    http://www.w3schools.com/cssref/css3_pr_animation.asp
    http://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp
    Transforms
    http://www.w3schools.com/cssref/css3_pr_transform.asp
    http://www.w3schools.com/css/css3_2dtransforms.asp
    http://www.w3schools.com/css/css3_3dtransforms.asp
    DWCC has a transitions tool, I've never used it, but it's available under Window > CSS Transitions

  • I lost the tool bar in my email, how do I get it back, and how do you get the link to open when you click on the little chain link symble

    I work on a Dell with Windows XP and Firefox 5, and when I send out an email and try to type a link in the body of the email the link does not open up for the addressee, and I highlight the link and then bold it, and the go to the little chain link symbol and clink on it and no matter how I fill out the boxes it will still not open when they get the email. What do I have to do to get it to work, please help, my email is [email protected] , and the link that I unusually send out is '''[[www.PaidonBillsNow.com |www.PaidonBillsNow.com]]''' now this was different than what is normally comes up, but how do I get this to work, thanks my email is [email protected]

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode

  • How can I access the iTunes store?  When I click on iTunes, my library appears but when I try to connect to the store I get a window saying Error -3221 has occured and cannot connect to the store.

    Can anyone please help!  I haven't been able to connect to the iTunes store to purchase music for some time now.  When I click on the iTunes icon my music library appears, but when I try to connect to the store (top RH side of window) I get a new window saying cannot connect to the store an erroe -3221 has occured.

    Baseal wrote:
    When I use her Earthlink email address to download apps or whatnot, it says I can't access teh itunes store. 
    When you say "her email address" do you mean that you set up a separate Apple ID for her using her email address as her Apple ID? If so, was it ever verified by Apple? Did she get the email verification?
    You might look here for some help.
    http://www.apple.com/support/appleid/

  • How can I customize the webpage that appears when I click add a new tab? I would like it to be google please.

    When I click the + tab option, the page goes to results by bing. I'm not a fan of this. Can you help me fix that?

    Type '''about:config''' in URL
    * filter - '''browser.newtab.url''' > Change the value to ''Google.com"

  • How can I execute the hyperlink action method when I click on the hyperlink

    Hi,
    I have created a hyperlink (hpPopupXML).
    1. I set the Target property to New Window.
    2. I set the URL to displayXML.jsp
    I ran the application and I click on the hyperLink to execute the hpPopupXML_action() method and it does not.
    Is there a way to force execution the hpPopupXML_action() when I click on my hyperLink (hpPopupXML);
    Please let me know.
    Thanks.

    The following excerpt is from http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/about_components.html#action
    Simple Page Navigation
    If you want the user to click a component to move to a specific page, and you do not want the browser to submit any user input, you can use the Hyperlink, Image Hyperlink, Tab, or Tree Node component and type the path to the destination page in the component's url property, such as /faces/Page1.jsp.
    Dynamic Page Navigation
    The Page Navigation editor enables you to specify navigation rules that map user actions and decision logic outcome to destination pages. You specify the mapping by dragging a named connector from the link or action component to the destination page. You must also create an action handler for the component that returns the outcome, which is a String value equal to the connector's name. You can use the component's action property to create the action handler.
    When a page visitor clicks the component, the browser submits the input, if any, and the action handler returns an outcome. The server looks up the outcome in the navigation rule mapping to determine what page to respond with. If there is no navigation rule for that outcome, the server redisplays the current page. You can write the action handler to return different outcomes based on business logic.
    NOTE: When you set both the url and the action property, the action handler takes precedence.
    IT LOOKS LIKE IN YOUR CASE THE URL PROPERTY IS TAKING PRECEDENCE OVER THE ACTION PROPERTY. IS THAT TRUE?

  • Old topic: Refresh when user click back button

    Yes yes, i know, this is old topic, which already discussed thoroughly in the forum,
    But, pls read my question....
    i try this:
    res.setHeader("Cache-Control", "no-cache");
    res.setHeader("Pragma", "no-cache");
    res.setDateHeader("max-age",0);
    res.setDateHeader("Expires",0);
    res.addHeader("Cache-Control", "no-store");
    However, when i forward to a page, then click back button to the previous page, which have the code above, however, the page is still the old one, the page was not reloaded from server
    Any suggestion? 1:57 am, my local time.......

    I just use:
    response.setHeader("Pragma","no-cache");
    response.setHeader("Cache-Control","no-store");
    response.setDateHeader("Expires",0);I have tried this, still the same...what can i do? Any more workable solution?

  • How can I make the comments field appear when the operator is debugging a test?

    When a test is being written the comments field is being utilized for information relating to what the test is doing and how to solve certain problems that arise. It is basically a quick place for the technician to look at when they are attempting to debug a board. However it appears when you view the sequence files these are off to the right side of the screen but when running the debug engine and the technician sets a break point then these comments are no longer visible to the user off to the right of the screen. Is there any way to have it include the comment in the data displayed when tracing through a test step by step. The technician can double click on each step but it would be alot mor
    e user friendly and timly if these could be displayed just to the right of the execution flow column.

    Hello John,
    I assume you are talking about the sequence editor. Unfortunately, there is currently no way to view the comments associated with a step inside of the execution display window (i.e during run-time). If you are using the operator interface, then you may extract the comment associated with a step and post a custom UI message that contains this information. The operator interface can then be modified to respond to this UIMessage and update its display accordingly.
    To post a UIMessage with this data, you must first obtain a PropertyObject reference to the step you are trying to extract the comment from. Then use the "Comment" property of the PropertyObject class to obtain the comment value.
    Unfortunately, the Sequence Editor discards all custo
    m UIMessages, and you will have no way of viewing the comment using the above method.
    Hope this helps.

  • How do I make the links to "one of my pages" open up in a new window?

    Whenever one selects "one of my pages" in the link pane, the option to "open link in new window" disappears?! Why? Can this limitation be got around?

    You select it as an external page and enter the URL.
    If you are publishing to .Mac the URL will be something like this ...
    http://web.mac.com/YourName/YourWebsiteName/ThePageName.html

Maybe you are looking for