Setting up a gui and the actionlisteners..?

hi... i am new to java...so this might be a stupid question ...this is w i did until now:
import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.border.*;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.*;
public class menuepanel extends JPanel
public menuepanel()
Border rille = BorderFactory.createEtchedBorder();
setBorder(rille);
public menuepanel(String text)
ImageIcon symbol = new ImageIcon("Smiley.jpg");
setLayout(new GridLayout(24,0));
JButton regel = new JButton("Regeln");
regel.setBackground(Color.darkGray);
regel.setForeground(Color.white);
regel.setMnemonic('r');
add(regel);
JButton histo = new JButton("History");
histo.setBackground(Color.darkGray);
histo.setForeground(Color.white);
histo.setMnemonic('h');
add(histo);
JButton hisco = new JButton("Highscore");
hisco.setBackground(Color.darkGray);
hisco.setForeground(Color.white);
hisco.setMnemonic('s');
add(hisco);
JButton mstart = new JButton("M�hle Starten");
mstart.setBackground(Color.darkGray);
mstart.setForeground(Color.white);
mstart.setMnemonic('m');
add(mstart);
JButton exc = new JButton("Spiel abbrechen");
exc.setBackground(Color.darkGray);
exc.setForeground(Color.white);
exc.setMnemonic('a');
add(exc);
JButton test = new JButton("test");
test.setBackground(Color.darkGray);
test.setForeground(Color.white);
test.setMnemonic('t');
add(test);
JButton exit = new JButton("Fenster schlie�en");
exit.setBackground(Color.darkGray);
exit.setForeground(Color.white);
exit.setMnemonic('f');
exit.setActionCommand("exit");
add(exit);
my question is:
what do i have to do now to get an action if i hit a button?
could some1 give me a short example, like how the code should look if i want the gui-window to be close when hitting the exit-button?
please help
pfff

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
class menuepanel extends JPanel implements ActionListener
  String[] buttonText = {"Regeln","History","Highscore","M�hle Starten",
                         "Spiel abbrechen","test","Fenster schlie�en"};
  char[] mnemonic = {'r','h','s','m','a','t','f'};
  JButton[] btn = new JButton[buttonText.length];
  public menuepanel()
    Border rille = BorderFactory.createEtchedBorder();
    setBorder(rille);
    setLayout(new GridLayout(7,1));
    for(int x = 0; x < btn.length; x++)
      btn[x] = new JButton(buttonText[x]);
      btn[x].setBackground(Color.darkGray);
      btn[x].setForeground(Color.white);
      btn[x].setMnemonic(mnemonic[x]);
      btn[x].addActionListener(this);
      add(btn[x]);
  public void actionPerformed(ActionEvent ae)
    if(ae.getActionCommand().equals(buttonText[buttonText.length-1])) System.exit(0);
class MainApplication extends JFrame
  public MainApplication()
    setLocation(400,300);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    getContentPane().add(new menuepanel());
    pack();
  public static void main(String[] args){new MainApplication().setVisible(true);}
}

Similar Messages

  • If you have an itunes acct that was not set up to share and the lap top it was on is no longer working, is there a way to open up the old itunes acct to get music and photos?  This was before icloud was available, can you reset your password?

    If you have an itunes acct that was not set up to share and the lap top it was on is no longer working, is there a way to open up the old itunes acct to get music and photos off of it?  This was before Icloud was available.  Can you reset your itunes password somehow?

    iTunes and the iTunes Store won't have anything to do with your photos. Those would be stored only on your laptop unless you made a backup of some sort. If you didn't, and the hard drive in your laptop has failed, then your photos are gone unless you wish to pay a disk recovery service a lot of money to try and get them back.
    As to your music, if you purchased it from the iTunes Store you can probably re-download it. Go to the iTunes Store, log into your account, and click the Purchases link under the Quick Links. From there you should be able to re-download some or all of your purchased content. Note that not all content has been licensed for re-downloading in all countries at this time. You can see what content you can download here:
    http://support.apple.com/kb/HT5085
    You can also re-download content using an iOS device.
    For full instructions, see:
    http://support.apple.com/kb/ht2519
    Regards.

  • I have everything set for Arabic fonts and the keyboard as well. When I type in WORD or EXCEL I just get individual Arabic letters, but they never connect, they should be for example like this   الس    but they always appear like that ا ل س

    I have everything set for Arabic fonts and the keyboard as well. When I type in WORD or EXCEL I just get individual Arabic letters, but they never connect, they should be for example like this   الس    but they always appear like that ا ل س

    MS Word for Mac has never supported Arabic.  You have to use other apps.  Mellel is best, but Pages 5, TextEdit, Nisus Writer, or Open/LibreOffice should work OK.
    Sometimes you can make Word for Mac do connected Arabic if you are editing a document created with Windows Word.

  • I have an iMac with 10.9.1 and an iPhone 5 also updated to the newest system and I cannot get a sync set up between Ical and the iPhone or Outlook 2011 mac calendar with the iphone

    I have an iMac with 10.9.1 and an iPhone 5 also updated to the newest system and I cannot get a sync set up between Ical and the iPhone or Outlook 2011 mac calendar with the iphone. I would perfer using outlook but will settle for the Imac calendar

    It depends on what iMac you have. If it is an old PPC (G4 orG5) iMac then no further upgrades are possible. If it an Intel iMac:
    Start by checking if you can run Snow Leopard:
    Requirements for OS X 10.6 'Snow Leopard'
    http://support.apple.com/kb/SP575
    (NB: PowerPC applications can still be run in Snow Leopard using Rosetta, but they will not work in later versions of OS X.)
    The OS 10.6 Snow Leopard install DVD is available for $19.99 from the Apple Store:
    http://store.apple.com/us/product/MC573/mac-os-x-106-snow-leopard
    and in the UK:
    http://store.apple.com/uk/product/MC573/mac-os-x-106-snow-leopard
    When you have installed it, run Software Update to download and install the latest updates for Snow Leopard to bring it up to 10.6.8, or download the combo update from here:
    http://support.apple.com/kb/DL1399
    Check via Software Update whether any further updates are required, particularly to iTunes.
    You should now see the App Store icon in iTunes, and you now need to set up your account:
    http://support.apple.com/kb/HT4479
    You can now upgrade to Mavericks OS 10.9 for free IF you have one of the following Macs, with not less than 2GB of RAM, and at least 8GB of available space on your hard drive:
    iMac (Mid-2007 or later)
    MacBook (13-inch Aluminum, Late 2008), (13-inch, Early 2009 or later)
    MacBook Pro (13-inch, Mid-2009 or later), (15-inch, Mid/Late 2007 or later), (17-inch, Late 2007 or later)
    MacBook Air (Late 2008 or later)
    Mac Mini (Early 2009 or later)
    Mac Pro (Early 2008 or later)
    Xserve (Early 2009)
    iCloud system requirements:
    http://support.apple.com/kb/ht4759
    If you cannot run Mavericks you can purchase the code to use to download Lion from the App Store (Lion requires an Intel-based Mac with a Core 2 Duo, i3, i5, i7 or Xeon processor and 2GB of RAM, running the latest version of Snow Leopard):
    http://store.apple.com/us/product/D6106Z/A/os-x-lion
    or Mountain Lion:
    http://store.apple.com/us/product/D6377Z/A/os-x-mountain-lion

  • Cannot send attachment beyond 1.5 MB, the MaxFileSize parameter is already set to 6 MB and the exchange server's limit is 10 MB

    Hi Experts,
    I cannot send attachment beyond 1.5 MB, the MaxFileSize parameter is already set to 6 MB and the exchange server's limit is
    10 MB.
    What could be the issue?
    aa

    But I am able to send the same  attachment from my web browser
    aa
    I am not expert in Exchange but web browser may not be using SMTP protocol? Check with your SMTP/Exchange Admin about "4.3.1 Message size exceeds fixed maximum message size"
    4.3.1 is response from the server.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • I have a number of apps on my Ipad2 that no longer have sound. I have checked setting on my ipad and the settings on the apps that have a settings and the sound and volume are ok. Do I have a virus in some apps?

    I have a number of apps on my ipad2 tha no longer have sound.  I have checked the ipad settings and the apps that have settings and all sound and volume are ok.  Do I have a virus?  Pandora sound is ok. It seems mostly to be games...angry birds, tap tap, and educational games for little ones. Any suggestions?

    There aren't any viruses for iOS devices. Have you got notifications muted ? Only notifications (including games) get muted, so the iPod and Videos apps, and headphones, still get sound.
    Depending on what you've got Settings > General > Use Side Switch To set to (mute or rotation lock), then you can mute notifications by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085

  • I have 3 airport express units, an Ipod and a PC.  I used the PC to set up an airTunes and the AirUtility can see all three of the airexpresses.  The Ipod displays all of the airexpresses and I can pick any one to stream music to. PC won't - any ideas?

    I have 3 airport express units, an Ipod and a Windows 7 PC.  I used the PC to set up an iTunes/airTunes and the AirUtility can see all three of the expresses.  The Ipod displays all of the expresses and I can pick any one to stream music to. The PC won't - any ideas? AirUtility tells me the 7.5.2 version of the firmware is the latest for the expresses and ITunes is also reporting that there are no upgrades available.  I get an error code -15000 when I try to connect from the PC to one of the expresses.

    How do I configure the AX to connect to the hub's wireless network? It will only scan one base station Airport Express at a time in the Airport Utility. I think what I am trying to do is use the hub as a router to the two AX's. Is there a specific way to set this up?
    To set up the AX to join a wireless network as a "Wireless Client," using the AirPort Utility, either connect to the AX's wireless network or temporarily connect your computer directly (using an Ethernet cable) to the Ethernet port of the AX, and then, try these settings:
    Launch the AirPort Utility.
    Select the AX.
    If not already connected to the AX's wireless network, go ahead and switch to it when prompted.
    AirPort Utility > Select the AX > Manual Setup > AirPort > Wireless
    Wireless Mode: Join a wireless network
    Network Name: <type in the network name/SSID of the wireless network that you want to join or select it from the pop-up menu>
    Wireless Security: None OR, if you are using security on your wireless network:
    Wireless Security: <Select the appropriate level of security for the existing wireless network: WPA/WPA2 Personal | WPA2 Personal>
    Password: <enter your wireless network security password>
    Verify Password: <re-enter the same security password>
    Click Update to write the new settings to the AX.

  • Trying to set up family share and the invitation does not show the accept decline option so we can't accept the invitation.  Anyone know how to fix?

    invitation to family share does not have the accept or decline option to choose

    Several things here so let me attempt to clarify.
    For iCloud the reason the contacts where removed from he other device is because you updated your contacts, in this case deleted them, and then iCloud updated the other device to match. By deleting the iCloud account on the device it will stop the device from using that iCloud account and therefore nothing will change on the other device. By using a seperate Apple ID you can still use the features of iCloud, Find My iPhone comes to mind, without your content (contacts, message etc.) merging with the other device
    For iTunes, you cannot use two Apple IDs for one account however if you use the same account iTunes on your computer will keep the content on each device seperate very nicely. You can also configure the settings for iTunes and the App store on each device to keep the content from automatically downloading to the other device. What I meant by share apps and music is this. What happens if you find a game, lets say Minecraft, that you really like and it cost, as Mincraft cost, $6.99USD. You buy it and play for a while and then you realize that your husband really likes the game as well. If you both use the same Apple ID for iTunes he can download the $7.00ish game to his device at no additional charge. If you use seperate Apple IDs for iTunes well... it look like he will also be paying for the game to have it on his account. Same goes for Music and Movies
    I hope that clears things up. Let me know if you have anymore question.

  • I'm trying to recover the network password for my Time Capsule so that I can connect another device (a PC) to it.  I have my Macbook pro set to connect automatically and the password is hidden.  How can I find out what it is.

    My issue is that I'm trying to connect a PC to my wireless network run off of a Time capsule/airport router.  My macbook pro connects fine but the network password is hidden and set to autoconnect.  I thought I wrote the password down but when I try to connect the PC laptop and type in the timecapsule network PW is doesn't work.  Trying to verify if the passwird I wrote down is correct but there doesn't seem to be a way to recover this.
    Does anyone out there in the community know how to do this? (or do I just have to do a reset on the time capsule

    Reset the TC.

  • HT2518 How do you reset the password on a migrated user account? Mac wants the old password putting in before we can set a new password and the old password won't work.  How do we get around this?

    Used Migraton Assist to transfer data from old Dell PC onto new Macbook Pro.  Data has come across but cannota access the User Account from the Dell.  It is displayed on the desktop of the Mac but is requesting and new password.  Before we can reset the password we have to put in the old password.  We have put in the old password but it doesn't work and therefore we can't reset the password and get into the User Account. 
    How do we get around this problem so that we can access the User Account.
    Although the data has transferred we cannot see our contacts transferred from Outlook into Mail.  We are wondering if they are contained within our User Account, but can't find out until we can access the it?
    Help wold be much appreciated.
    Pensos

    Hello:
    Hopefully this will help you:
    http://support.apple.com/kb/PH4117
    Barry

  • The load process runs in the SAP GUI and the GUI will timeout if someone do

    Hi
    Our main issue: for loading DRW/BKT/Characteristics/Doc Files, I have already tested processing the Idocs in Background mode. All the Idocs failed because the background process on the SAP application server cannot access the doc files. (it has to use saphttp.exe on the client)
    help me  to solve thi sproblem
    regards,
    jagadish

    https://jdic.dev.java.net/
    The JDesktop Integration Components (JDIC) project aims to make Java� technology-based applications ("Java applications") first-class citizens of current desktop platforms without sacrificing platform independence.
    This demo application demonstrates functionality in the JDIC APIs org.jdesktop.jdic.tray package.
    It creates a tray icon on the desktop (in the System Tray Area for Windows platforms, or in the Notification Area for Unix platforms), with a caption (text), an animated icon, and an associated Swing menu containing icons. It also has a tooltip displayed when the mouse hovers over the tray icon.

  • Why can't I post? I set up an account and the page has my info on it.

    My photos are not showing up in IPhoto 9.6. I am using Yosemite. Someone said to run Library Installer 1.1, but it is not in my Utilities application. I got one of my events to show up and 9 photos by individually highlighting them, but I don't want to do that with 5,000 photos. My IPhoto is listed as 9.6.

    The updater 1.1 is only needed if your library was create with iPhoto 7 (08) or earlier and it's the first time you're trying to open the library with iPhoto 9.6.
    What you need to do is do the following:
    1 - launch iPhoto with the Command+Option keys held down to open the First Aid window. Be sure to follow the circled recommendation in the screenshot.
    2 - run Option #4, Rebuild Database.

  • I upgraded to snow leopard, since then safari does open in the dock but does not load as set in my preferences and the title page remains blank even though I have set-up a home page. I completely re-initialised safari, but no change.

    I upgraded to snow leopard, since then safari does open in the dock (white dot) but does not startup as set in system preferences. Also, if I open safari, the title page remains blank even though I have set a home page under safari's preferences. I re-initialised safari, but no change.

    Having put my home-page under "new windows open with home-page" solves the "blank title page problem".
    One problem left: "safari" does not startup automatically as set in system preferences, whereas "mail", also set for startup DOES startup

  • HT5661 I restored my phone now its asking for the original apple id that was used to set up phone. myself and the previous owner want to nknow is there a was to get it or can apple delete it.

    Can not find original apple id to restore my iphone 4s help.

    If you know the apple id login it's possible for you to be able to reset the password to this apple id by going to:
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/
    This will give you the opportunity to reset your password that is once again if you know the name of the apple id.
    There will be significant identify verification required.
    Good luck.

  • In Safari, my iMac sometimes zooms way too much and will not zoom back.  I have a wireless mouse set to zoom in and out on double tap, but the excessive zooms happen with no taps.

    In Safari, my iMac sometimes zooms way too much and will not zoom back.  I have a wireless mouse set to zoom in and out on double tap, but the excessive zooms happen with no taps.  A page zooms in so less than 1/4 of the page is visible and nothing I do will zoom back out, command minus doesn't do it, double tap on mouse does not zoom out, and the window will not scroll to show any of the rest of the page.  reloading the page does not help.  Loading a different page gives me a normal view again.

    If it were a tweaked setting, it should happen less randomly.  And there should be no settings that could override the zoom setting in unversal Access and the Mouse zoom preferences. 
    In addition, this only happens in Safari 6, and seems to happen more fredquently on some websites and not on others.  That suggests some sort of conflict in the site code with Safari and Apple wireless mouse code.  It does not happen in Mail, Word, Excel, Photoshop, Illustrator, or other software as far as I can tell.

Maybe you are looking for

  • Can I merge purchases from my US iTunes account and UK iTunes account?

    While living in the US i made purchases from the iTunes store but have moved to the UK. I've been forced to make purchases from the UK iTunes store. Now I have a new 5S and would like the music purchased in the US on my phone but can't figure out how

  • Word2007 to PDF conversion FONT issue!

    I converted My 181 Page Word Document to PDF through the PDFmaker(acrobat 9 pro)embeded into word2007. Everything Went smooth almost a 1:1 replica. The one issue I am having is that I noticed the PDFmaker did not convert my Font properly, as I will e

  • Why Mail displays the name and address instead of address book name?

    File under the category of unanswered miscellaneous quirks by a new Mail user (the old posts were archived/locked).... I have found that by eliminating any spaces in FIRST name field, the Address Book name appears w/ blue losenge (w/o the e-mail addr

  • TS3297 itunes store wont load..

    my itunes store wont load!! dont know what to do just done that keychain thing and eveything was fine!

  • File System Question

    Hello, I do a lot of nature photography, and I personally like arranging my photo's myself. I don't like the way Aperture and iPhoto organize in events, and I am wondering if there is a way to use aperture as an editor and not a library. If that is n