Making Buttons Work...?

I am working on this project with some friends, and am fairly new at Java, so need some help with this. This is my GUI so far...
import javax.swing.*;
import javax.swing.text.*;
import java.text.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
public class CustomerView
     public static void addComponentsToPane(Container pane)
          pane.setLayout(new GridBagLayout());
          GridBagConstraints c = new GridBagConstraints();
          c.fill = GridBagConstraints.HORIZONTAL;
          JLabel tCarModel = new JLabel("Car Model");
          // inserts (top, left, bottom, right)
          c.insets = new Insets(10,40,10,7);
          c.gridx = 0;
          c.gridy = 0;
          pane.add(tCarModel, c);
          // temporary string of Audi Models to go into combobox
          String[] carModels = {"A2", "A3", "A4"};
          JComboBox iCarModel = new JComboBox(carModels);
          c.insets = new Insets(10,10,10,60);
          c.gridx = 1;
          c.gridy = 0;
          pane.add(iCarModel, c);
          JLabel tFirstDayOfRental = new JLabel("First Day of Rental");
          c.insets = new Insets(10,10,10,7);
          c.gridx = 2;
          c.gridy = 0;
          pane.add(tFirstDayOfRental, c);
          JFormattedTextField iFirstDayOfRental = new JFormattedTextField(new SimpleDateFormat("dd/MM/yy"));
          iFirstDayOfRental.setValue(new Date());
          c.insets = new Insets(10,10,10,40);
          c.gridx = 3;
          c.gridy = 0;
          pane.add(iFirstDayOfRental, c);
          JLabel tCarType = new JLabel("Car Type");
          c.insets = new Insets(20,40,10,7);
          c.gridx = 0;
          c.gridy = 1;
          pane.add(tCarType, c);
          // temporary string of Car Types to go into combobox
          String[] carTypes = {"Audi"};
          JComboBox iCarType = new JComboBox(carTypes);
          c.insets = new Insets(20,10,10,60);
          c.gridx = 1;
          c.gridy = 1;
          pane.add(iCarType, c);
          JLabel tNumberOfDays = new JLabel("Number of Days");
          c.insets = new Insets(20,10,10,7);
          c.gridx = 2;
          c.gridy = 1;
          pane.add(tNumberOfDays, c);
          JTextField iNumberOfDays = new JTextField(4);
          c.insets = new Insets(20,10,10,40);
          c.gridx = 3;
          c.gridy = 1;
          pane.add(iNumberOfDays, c);
          JLabel tLicence = new JLabel("Licence");
          c.insets = new Insets(20,40,10,7);
          c.gridx = 0;
          c.gridy = 2;
          pane.add(tLicence, c);
          String[] licence = {"International", "UK Licence"};
          JList iLicence = new JList(licence);
          c.insets = new Insets(20,10,10,60);
          c.gridx = 1;
          c.gridy = 2;
          pane.add(iLicence, c);
          JLabel tTimeOfBooking = new JLabel("Time of Booking");
          c.insets = new Insets(20,10,10,7);
          c.gridx = 2;
          c.gridy = 2;
          pane.add(tTimeOfBooking, c);
          JFormattedTextField iTimeOfBooking = new JFormattedTextField(new SimpleDateFormat("dd/MM/yy:HH:mm"));
          iTimeOfBooking.setValue(new Date());
          c.insets = new Insets(20,10,10,40);
          c.gridx = 3;
          c.gridy = 2;
          pane.add(iTimeOfBooking, c);
          JButton iOK = new JButton("OK");
          c.insets = new Insets(30,10,20,10);
          c.gridwidth = 2;
          c.gridx = 0;
          c.gridy = 3;
          pane.add(iOK, c);
          JButton iCancel = new JButton("Cancel");
          c.insets = new Insets(30,10,20,10);
          c.gridwidth = 2;
          c.gridx = 2;
          c.gridy = 3;
          pane.add(iCancel, c);
     private static void createAndShowGUI()
          // create and set up the window
          JFrame tJFrame = new JFrame("Car Rental Information Systems");
          tJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          // set up the content pane
          addComponentsToPane(tJFrame.getContentPane());
          // display the window
        tJFrame.pack();
        tJFrame.setVisible(true);
     public static void main(String[] Args)
          // schedule a job for the event-dispatching thread
        // creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable()
            public void run()
                createAndShowGUI();
}I am trying to make the Cancel button close the frame... don't have a clue how to do it though. Any suggestions please?

That was just in response to Michael_Dunn's comment... Again, why waste time with an unnecessary comment that doesn't add anything to solving the problem.
Michael suggested that you need an ActionListener and System.exit();
So your comment should have been "Thanks for the help", at least if you expect to get help in the future!

Similar Messages

  • Help with making buttons work within mc/shape tween

    hi,
    i've created a movie clip for a navigation link named
    "Products". when you mouse over the "Products" mc, the movie clip
    has a sub-navbar that tweens horizontally out of the movie clip.
    when the subnav is done coming out and stops, i have buttons that
    appear that i would like the user to be able to click on.
    everything works out fine until i roll over the button the rollover
    state doesn't work. i have a feeling it is because the button is
    nested, but not sure.
    i set up a simple example here:
    http://kurtcom.com/examples/jeannettes_damn_navbar.html
    let me know if you want me to email you the file as well,
    thanks!

    A single Path would just be an out line of your three shapes.  As you knew to create  the above using vectors requires three shape layers.  Shapes can only be filled  with a single color or pattern.  They also can be stroked and have layer styles added. Additional strokes may be need to highlight the green area like you show above..
    With CS6 you can merge shape layers into a single shape layer your result would be a single color shape however the merged paths would be the outlining path you seem to want. you can save the path in the path palette when the merged shape is the active layer.
    adding an empty layer and stroking the merged path,
    Message was edited by: JJMack

  • Making buttons work when creating forms

    I am creating a form in Acrobat X Pro, Mac OS 10.6.8. I have setup several buttons for things such as printing, submitting a form, etc. I have set the trigger to Mouse Enter, but when I'm testing it, all you have to do is get the mouse NEAR the button, and it triggers it. How do I fix this?

    The instructions I was following said to use Mouse Enter. I initially tried Mouse Down (instructions from another site), but when that didn't work, I changed it to Mouse Enter, but that didn't solve the problem.

  • Navigation Buttons Work on and Off?

    Anyone with any suggestions would be greatly appreciated as I am out of ideas.  I am new to Flash CS4 so I may be doing something stupid.  I created my assests on Photoshop CS4 and imported them into flash as flash layers.  I followed a training video by Paul Trani about creating a first website.  I have several pages in my site, home, about, contact, photos etc.  I created navigation buttons for the homepage and they work great.  However on my other pages I created different buttons as they are in a different place and have some additional buttons that the homepage does not have (except the contact page has common buttons to the homepage).  I put the homepage and second page (contact) actions on frame 1.  I then created a new keyframe at frame 20 where the rest of the pages uses common buttons.  I then changed the language in the action script so as not to conflict with the frame 1 action script.  I had trouble making the second group of buttons work so I created a new actions layer (actions2) and they work, except...
    Well my homepage buttons work, all of them.  I can even go to my contact page (which share the same buttons with the homepage) and then go back to the home page.  I can also go from the homepage to the other pages and those buttons work...UNTIL I go back to the home page or to the contacts page (the pages that share buttons) then those buttons NO LONGER WORK???  It seems like once I committ myself to one group of pages (I consider myself having two groups of pages based on the sharing of buttons by each group) it disables the other group.
    Any ideas or direction I may look at?  
    Thanks, Mark

    Hello and thank you for the response.  If I may bother you for a bit more detail...for the later, would I put all the code in actions/frame 1?  Then are the layers where the buttons artwork and the buttons themselves expanded out to the full length, then I make portions invisible?  Also am having trouble where to find the invisibilty command...I remember seeing it somewhere but can't find it.
    Again, any addional help would be great.  I feel like I am almost there.
    Mark

  • Importing a button worked in PhotoShop

    How can i import a button that i created in Photoshop to DSP
    cause in DSP u can only make a rectangle or square or u have to use the shapes that DSP have
    what if i wanna draw a button and i want it to work as a button in DSP
    any ideas ?

    that means that theres limitation of making buttons
    Yes, in general, sort of The button area that you draw in DVD SP is limited BUT the image itself can be any shape that is highlight. So the button itself can be be any shape. For instance you can use circles (made a quick file) Of coursse there is a limit on how close the shape can get to one another (buttons should not overlap) and at some point some more shapes (think of maybe peices of a jigsaw puzzle being highlighted) may be hard to implement, but with a little work and planning (see overlays below as one option) you can fake it.
    http://www.geocities.com/mypix013/Circles.zip has a project and photoshop files There is also a folder called screen shots to help see what I am talking about. Open up DVD SP and press the F3 Key to get the same layout
    whats the difference if its layered or overlay both of them u have to draw
    In the project above I made 4 menus (not they do not link actually, just to show layout) You can take a look at them to see how it is done. (If you need more details let me know.) Quick description below
    The first is called Layered Menu with 2 buttons
    There are 6 layers of circles
    Red 1 (top circle)
    Red Copy (lower circle)
    Blue 1 (top circle)
    Blue Copy (lower circle)
    Green Copy (top circle)
    Green 2 (lower circle)
    In the general Tab of the inspector you will what layer are always set to be visible (non in this case) (See screenshot Layer1)
    Now if you select a button and click on the layers tab in the inspector you will see how the layers are set Red 1 is normal for button 1 (non selected, non active) for button 1, Blue 1 is selected for button 1 and Green 1 is activated for button 1 (you can simulate the menu.) (See screenshot Layer2) Same for button 2, but using the Red Copy etc.
    Layered shapes is a variation of the same with shapes that cross over (note the buttons themselves are over to the right) Using layered menus does not require the buttons to be over an area
    NOTE: Layered menus are not as reliable as non layered menus and may not behave the same on all players
    The more reliable method is basic overlays (picts are most relaible for me)
    Non Layered 1 Has background of Circles.pict and overlay layer of Black_Over.pct Select the menu (not a button) and inspector click on the colors tab. You will see grayscale is selected. Then three more selections, normal, selected, activated. There colors were set to Red, Blue, Green for ech state (See Screenshot Layer3)
    Non_layered 2 is the same thing but uses Black_Gray overlay (a black circle with gray inner circle) and you can see how you can map the gray area using the sliders in the inspector for the colors
    Hope this helps

  • How to stop my movie by using stop(); but keep my buttons working

    Hi,
    Im making a website using flash,
    And on my movie it says Welcome to Blah Blah Blah,
    And then a button appears, To make sure my button works,
    The writing turns to bold and goes bigger,
    When the button appears it works and goes bigger,
    Until it reaches the point in the timeline where it has stop();
    It stops my movie from looping or restarting which is what i want,
    But it stops my buttons from working aswell, How to keep my button working but movie stops,
    If you want me to explain more just ask

    Nevermind i have fixed this,
    But are still needing urgent help on one thing,
    http://forums.adobe.com/thread/456310?tstart=0

  • Menu button works on pc but not on tablet and mobile

    Hi! I've made a desktop site and I've published it. Everything works on a pc browser but into tablet and mobile, there is a button on a menu that doesn't work..the link to the rest of the site doesn't start. Maybe because that link goes to a part of the site that is too heavy (the structure under that button goes to 30 different pages)?

    This is the url:
    http://www.babylove2000.com/
    If you try to visit the site by tablet or mobile, you cannot enter in the section 'MARCHI' trough the correspective button. The other buttons work correctly.
    Thanks,
    Marianna

  • Making button and a html site in visual studio community version

    Hi,
    I like to Making button and a html site  in visual studio community version but i dont know how to put the right code in my c# form to perform a action to my new html site i made with visual studio.
    So ik have a button and i added a html site with the "add" options to my form.I want the button to open onclick that site so i can make a html about some info of the button image (tool to use with metal)
    Any one? Sorry i am very new at this and also from the netherlands but i want to  coding in c# great to to learn..
    Many thanks!
    Arend

    Hi Arend,
    Thank you for posting in MSDN forum.
    Since this forum is to discuss: Visual Studio WPF/SL Designer, Visual Studio Guidance
    Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor. Based on your issue, I think that the issue is more related to the programming. So I’m afraid that it is not the correct forum for this issue.
    To help you find the correct forum for this issue, could you please tell
    me which kind of app you want to create? Is it winform app or others?
    If you want to code for a winform app using c# language, I suggest you
    can consult your question on specific
    WinForm forum so that they can share you something for you to start.
    Thanks for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • I updated to new 3.6.6 version now my browser does not work at all just gives me an untitled tab. neither bookmarks or google button work .

    Updated to new version 3.6.6 now browswer doesn't work. Just gives me a untitled tab. Bookmarks nor google button work either.
    == This happened ==
    Every time Firefox opened
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; StarBand Version 4.0.0.2; SearchToolbar 1.1; .NET CLR 2.0.50727; StarBand Version 4.0.0.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; StarBand Version 4.0.0.2)

    On my previous post I said:
    "When upgraded to FF 3.6.6, due to Norton 360 v.4, everything froze.
    My solution was to downgrade to FF 3.6.4, because with that version i had no problems, and now again everything works fine.
    Not the best solution but it is better than downgrading to FF 3.5.x as I saw many users did."
    Now I want to add that, after running FF 3.6.4 for 3 days, i got again the security warning to upgrade to FF 3.6.6, so I did.
    Now am running FF 3.6.6, and even with Norton, everything works fine, no bugging, freezing, refreshing, blank pages...
    I can't figure out why the problem still persist for other users. Now maybe it is not due to Norton any more?

  • How do I make a submit button work on a mobile oriented page?

    How do I make a submit button work on a mobile oriented page?  I have the .html file and the .data file (and one other kind), but it just spins and spins and spins when I try to send the form in (for an absence).  I'd like it to work on all devices.  Help?

    HTML forms don't do anything.  You need a form processing script to gather and process form data.  Which server-side scripts does your web hosting plan support -- php, asp, asp.net, perl?  This will determine which scripts you can use with your form.
    Nancy O.

  • Why doesn't the "back" button work all the time in Safari?

    Why doesn't the "back" button work all the time in Safari?

    thanks for the reply. You prompted me to check and I realised it wasn't installed on my test laptop and opening in Microsoft Reader. I've installed it now and it works.
    My next challenge is to prevent the mailto: command opening Microsoft Mail instead of Outlook, but I guess every user will have a different default.
    Thank you

  • How can I get ThinkVantage button working again? (after a full HD rebuild)

    WindowsXP Pro, ThinkPad T60   (2007-F4G / UT0F4UK)
    Hi
    How do I get my Thinkvantage button working again?
    Background:
    I had a virus attack and as a precaution I zero-ed my ENTIRE hard disk (using KillDisk). I have managed to re-install most things, including I now have an icon on the taskbar called "Launch Lenovo ThinkVantage Toolbox". However I would prefer it to be fired up by my pressing the (blue) ThinkVantage button at the top of my keyboard.
    I have refused point blank to pay the (outrageous) price of GBP 40.00 for Lenovo to send me a CD with Windows etc on it, but have managed (eventually) to rebuild the entire disk driver by driver until the ThinkVantage Toolbox thing (version 6.0.5449.31) could take over and bring my drivers up to date when I Update my system.
    (It's just that they may have gone in incorrectly??)
    Is there something I should have done during installation.
    Ship

    Hi Ship,
    1. Install these for thinkvantage button:- 
    http://www-307.ibm.com/pc/support/site.wss/MIGR-62850.html
    http://www-307.ibm.com/pc/support/site.wss/MIGR-68000.html
    Hope it helps.
    Maliha (I don't work for lenovo)
    ThinkPads:- T400[Win 7], T60[Win 7], IBM 240[Win XP]
    IdeaPad: U350
    Apple:- Macbook Air [Snow Leopard]
    Did someone help you today? Compliment them with a Kudos!
    Was your question answered today? Mark it as an Accepted Solution! 
      Lenovo Deutsche Community     Lenovo Comunidad en Español 
    Visit my YouTube Channel

  • How to make buttons work in Interactive Adobe Forms

    Hi Experts,
    I am new to interactive form. Though i have worked in normal/non-Interactive form, i do not know how to make buttons work in interactive adobe forms using ABAP  (I don't know JAVA). Can any one help me out and walk me through to how to code in ABAP to make buttons work.
    Kind Regards,
    Sharat.

    Please refer to my earlier post ... You will get an idea
    Please refer to the below thread for detail solution
    Sample Interactive form example ?....urgent...
    Cheers
    Satya

  • When I try to use the Submit Form button on the Interactive PDF I created (IN Design CS6) I get this message. "There is no value in form field 'Program.' Please put in it before proceeding. What can I do to fix this and make the Submit button work?

    When I try to use the Submit Form button on the Interactive PDF I created (In Design CS6), I get this message:
    There is no value in form field "Program." Please put in it before proceeding.
    How can I fix this and make the Submit Form button work?

    Are you running modified software on your phone?  This error seems to be common if the firmware has been modified and you're trying to restore the phone again. 

  • Whenever I open the editor in Photoshop Elements 12 it does not work. When I try to click open in the application it does not do anything. None of the buttons work. When I open a photo using file at the top it opens but I cannot edit it or use any of the

    Whenever I open the editor in Photoshop Elements 12 it does not work. When I try to click open in the application it does not do anything. None of the buttons work. When I open a photo using file at the top it opens but I cannot edit it or use any of the features on the left side.

    Hi Nealeh
    Thanks i think I got it working of a fashion.
    Except the replace colour, does not seem to end up with the colour I picked using the picker tool. Its as though it hads not replaced the colour but blended in the desired colour with the old incorrect colour!
    Buy trial and error picking not the right colour but close - which when mixed with the existing colour is close.
    Sorry I can't post the pictures as the Lingerie Mfg, has me under non disclosure.
    The scenario is:-  say a blonded mainly tanned model a high cut [at the hips] corsette style basque, with an ultra low bra line.
    Our dear model, has just come back from St Barts with a fabulous Tan, and equally striking bold Tan lines!.
    So we have great tanned legs, then the 'porcelain white band' where her swimsuit was.
    Likewise we have a tanned face, and arms, shoulders etc and a great tan on the top of the cleavage, then it stops, white band to the top of the ultralow cut bra line of the basque.
    She must have lived in like the most conservative bikini on the planet [50's style], for 2 weeks!
    Had she had a normal skimpy bikini on, no problem!
    If i don't solve it, she will get fired!
    Not a lack of interest in your post, but I was out, and tried to log in to this site; which I could do, on my iPad Air / 5 [whatever its the new one]. And tried to 'sign in' - but it just hung at the
    "Join Adobe Community" adobe sign in splash screen! with he little whell spinning around continuously!!!
    I have Safari on this iPad. Guess that is all it runs.
    So technology is not my friend today!

Maybe you are looking for

  • Macbook Pro 2013 HDMI Monitor Goes Black for a few seconds

    So I purchased a brand new Macbook Pro 2013 (specs below) and for the entire time I have been using it with a BenQ RL2455 via HDMI with no problems at all. Recently though I have started to experience problems between the computer and the monitor. Th

  • Error -1

    I run the latest version of FCP X and am on OS X Mavericks. I have never had a problem exporting my video to Master File or anything else but ever since I upgraded to Mavericks I am always getting an error-1 when exporting the file. I've posted about

  • Best way to recreate all live assets in SAP and scrap current assets

    We have a situation where we have to recreate all  (15000) our assets as new assets. We will have to create new assets, provide new acquisition value and new useful life and start depreciating them from scratch. Also we will have to dispose all the c

  • Scripting Status?

    I'm a pretty good javascript programmer and thought I'd give scripting a try on Bridge, but I found that the developer tool crashes frequently (mac pro, cs4), and bridge itself tends to crash the more I use scripts.  Some of the well-documented featu

  • How to create multiple channels in DAQmx

    Hello , I created an application based from this example program, MultiFunctionSyncAIAO_DigStart (from VCNet). I added another input and output channels, which later on I plan to add trigger features between the two signals ( could be both inputs, bo