ActionListener - Button appears but doesnt press!

Hi Guys,
I'm pretty new to Java so please be patient. I am trying to create a simple GUI hello world in AWT (and AWT only, not SWING).
I have come up with the following code to display a button that when pressed outputs a message to the console.
I'm using Eclipse to "run" the program and the button is displayed but the action does not occur.
Im pretty sure i understand the concept behind ActionListeners. I just can't see where the problem is.
Thanks for your help
Ron
import java.awt.*;
import java.awt.event.*;
public class Gui{
     public static void main(String[] args){
          Button btn = new Button("Touch Me");
          Frame f = new Frame();
          btn.addActionListener(new Action());
          f.add(btn);
          f.pack();
          f.setVisible(true);
class Action implements ActionListener {
     public void actionPerformed(ActionEvent e) {
          System.out.println("It Worked!");
}

Lol, I know it seems a little odd.
I'm doing research for my University Final Year Project. The project involves creating a java gui that will work on both a PC and a mobile device amongst other things.
My project supervisor stated that swing wouldn't work on all mobile devices but there is a higher chance of awt working with most versions of java. Im not sure if he is right but im running with it.
Right, so your saying that the program works fine ? ok, so how would i compile it from the command prompt? considering im using Linux!
Im really sorry that im asking such a trivial question. Im a C++ programmer and this Java malarky has completely confuzzled me.
Thanks again
Ron

Similar Messages

  • Im trying to log into a website. When I log in, a message appears that the website has been blocked for my safety. Allow button appears but I cant click on it

    I type a website address and go to that website. I try to log into website and message appears on top screen that I am blocked out for my safety. An Allow button appears, but when I click on it, I am still not allowed to log into website. How can I be allowed to log into website?

    Thank you for responding madperson. No, the message didnt say connection was untrusted, just "blocked for my safety." Allow button quickly appeared/disappeared, I couldnt click on it. This is a webpage in which I am a member & needed to log in my user & password. I deleted my cookies & cache and went to internet options & where you can choose which websites you dont want cookies, I entered website address, clicked OK & then was able to log into website. It was frustrating, but now solved.
    Thank you for your help, madperson, appreciate it. Madison2013

  • I want to install a WiFi- USB dongle. I tried to install two. Installation seems to go well until when the 'Install' button appears but cannot be selected. It stays faded. I've tried repairing permissions but there were apparently no repairs necessary

    Can't install non-Apple software.

    hi Bern 
    Firstly welcome to Crowd Support  
    The Australian Communications Industry Forum (ACIF) Credit Management code states that Telstra must perform s credit assessment when a customer is applying to us for credit.   
    For our Credit Assessments to be passed there are many factors of information considered to determine if the Credit Assessment is satisfied. 
    There are many reasons why a Credit application may be declined, and one of the most common is due to the new Customer not having any previous history with Telstra.
    While this may be frustrating for you, in the circumstance of a Mobile Phone contract being involved, we really do need to be sure that we have the correct billing information, up to date contact details and also viability to pay bills on time. 
    There is a process where this decline decision can be disputed, and I would be more than happy to lodge this dispute for you if you could provide me with some information. 
    I will send you a PM so that we can work together offline to lodge this dispute. 
    Lindy  
     

  • ITunes won't play song, even though pause button appears

    Recently my iTunes has stopped playing songs. If I click the play button, the pause button appears but the progress bar does not move and no sound is made. The volume on my computer is fine as I can still watch videos on youtube and such. I've recently updated to the lastest iTunes and am not sure whether the songs played find after that or not. I read that it could be a probably with quicktime but I've deleted that and downloaded it again but that did not help.
    Please help me!

    I noticed today I am having the same problem. Song would not play in Ver. 9.1.0 and 9.1.1. Same song plays fine in another media player. Also seeing the same that al0022 is seeing, my play button changes to a pause button, and my progress bar does not move. I am able to navigate around iTunes until I try to play a song then I have to kill the task.
    I had a Windows update performed yesterday, and believe the windows update is the cause of the problem.
    Anyone else unable to play after Windows updates were performed?
    Collin

  • I accidentally pushed the power button of my macbookpro... it restarted but doesnt open... what appears now is a flashing FOLDER logo with a QUESTION MARK on it.. can someboby help me to fix this?

    i accidentally pushed the power button of my macbookpro... it restarted but doesnt open... what appears now is a flashing FOLDER logo with a QUESTION MARK on it.. can someboby help me to fix this?

    (Assuming you don't have a firmware boot lock set)
    First easy step...
    1. Shut down the computer if it's on (hold the power button down... until it shuts off)
    2. Press the power button
    3. Immediately press AND hold the Option key ASAP
         Hold until drive option images appear in a single row across the screen. Typically most people running 10.7 or 10.8 will see 2 drive options to boot from: the main volume they usually boot from, and a recovery volume. If your main volume pops up. Use the cursor or arrow keys to highlight/select the main volume and press enter. That should boot your main volume. Let me know what you get from this point... I'll give you more as you go along.

  • I want to turn my macbook air off. the shut down button already appeared but the mouse/cursor just hang and won't work. even after pressing the enter button to shut my mac off won't work. what will i do?

    i want to turn my macbook air off. the shut down button already appeared but the mouse/cursor just hang and won't work. even after pressing the enter button to shut my mac off won't work. what will i do?

    This is not a reply. I just want to elaborate on this problem.
    My computer freezes occasionally when it is used after being sleep for a while. The spinning ball appears and everything is totally disabled. Nothing on the keyboard works.
    The mouse moves, but does not work.
    The only solution is to turn the power off and on (losing all data in open applications.)
    I kept the System monitor running on the side to find out which program was running when the computer froze. The Monitor as well as all other applications froze, but the data showed:
    Firefox 18.4%
    Activity Monitor 0.9%
    Firefox Plugin 0.2%
    This is all the information I have. By the way, I am using iMac with OS 10.6.

  • HT201401 When I press the + and - buttons, the volume icon appears, but the slider is empty. When I receive a call, I hear it ring, and I can hear the ringtones in the sound menu. However, the message/mail notifications don't make any noise, and I can't h

    When I press the + and - buttons, the volume icon appears, but the slider is empty. When I receive a call, I hear it ring, and I can hear the ringtones in the sound menu. However, the message/mail notifications don't make any noise, and I can't hear the sound menu.
    - During a phone call, if I put the conversation on speakers ==> it works and the volume bar reappears. I can control the volume with + and - buttons. But when the conversation is over, the bar disappears again.
    - With the headphones, everything is ok!
    - I also noticed (only a few times) that when I do a silent to ringer mode, the volume slider reappears and works correctly during 2 or 3 seconds, before disappearing again.
    I don't know what is problem,because the speakers work.

    Hello jam5064,
    We've an article which provides tips that can help get your iPhone working correctly.
    iPhone: No sound or distorted sound from speaker
    http://support.apple.com/kb/TS5180
    Cheers,
    Allen

  • My ipad won't start up. it's less than 1 year old.  I've tried plugging it in and pressing the start button.  the apple logo appears but then disappears and nothing else happens.

    My IPad shut down this afternoon and now it won't start up.  It's less than 1 year old.  I tried plugging it in and pressing the on/off button.  After holding the button in for several seconds, the Apple icon appears, but then disappears. 

    First, try this:
    Plug it in to the wall using an Apple charger and Apple cable for several hours.  The idea is to fully charge it.
    Then hold the home and on/off buttons together for about 10 seconds.  Hopefully the Apple logo will appear and it will start.  Do not release the buttons until you see the Apple logo.
    If it starts, great.  If not, you say your iPad is less than a year old.  If you bought it brand new from an Apple Store or Authorized Apple vendor, it is under warranty.  Take it to an Apple Store or Authorized Apple Service Center for diagnosis and repair.

  • Why is it that whenever I download a song from Itunes that a small grey round button appears next to the song (apparently this is the download progress button), but when I press on it to resume, the song disappears. This wasn't happening before.

    Why is it that whenever I download a song from itunes that a small grey button appears next to the song (apparently this is the download progress) but whenever I hit it to resume, the song disappears. I am getting annoyed with having to copy the songs manually onto my phone. Thanks for anyones help. Cheers

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copies of the dodgy tracks and try redownloading fresh copies. For instructions, see the following document:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the items that are not playing properly. If you can't see "Report a Problem" next to the items, click the "Report a problem" button. Now click the "Report a Problem" links next to the items.

  • I am trying to listen BBC radio news from BBC App, but on pressing the button I always get the error "there was an error playing this radio feed". What is the source of this error and how can I remove it?

    I am trying to listen BBC radio news from BBC App, but on pressing the button "live radio" I always get the error "there was an error playing this radio feed". What is the source of this error and how can I remove it?

    That is probably just a generic error message and you might not ever know what is causing it. Assuming that you have been able to play live radio with the app in the past (I know nothing about the app) and assuming that all other Internet related functions (Safari, email, etc.) are working properly on your iPad, quit the app completely and reboot your iPad.
    Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    If that fails to resolve the issue, you might want to reboot your router, unplug it for about 30 seconds and then plug it in again.

  • HT201272 Why are the in-app purchases made and billed to me but doesnt appear in application?

    I recently purchased an in-app purchase, and it didnt appear in the application. The application is Soccer Superstars 2012. When i tried purchasing it again, it says "You have bought this purchase but it has not been downloaded yet. Press Ok to download it" So i pressed Ok and yet it still doesnt appear in the application. Please help me. It is still billed to me but doesnt appear in the application. There are 2 purchases that were billed but did not appear in the application. I'm being billed when i did not even get the purchase in the application.

    Also, I have purchased other apps and music on iTunes since the problem started.

  • My iPad 2 won't charge and it's completely shut down. I've tried pressing the two buttons simultaneously, but nothing works. It's driving me crazy! Any offers of suggestions would be greatly appreciated. Thanks!

    My iPad 2 won't charge and it's completely shut down. I've tried pressing the two buttons simultaneously, but nothing works. It's driving me crazy! Any offers of suggestions would be greatly appreciated. Thanks!

    1. The most efficient way to charge an iPad is with the charger that came with the iPad and having that plugged into a wall outlet. Trying to charge while connected to a laptop often doesn't work because the USB port may not provide enough power.
    2. Once an iPad battery has completely drained it may take an hour or more on the wall charger before the iPad responds. So after an hour on the charger reset the iPad. Press and hold both the Home button and the Sleep/Wake button continuously until the Apple logo appears. Then release the button and let the device restart. You will not lose data doing this. It's like a computer reboot.
    3. If the iPad still does not start up make an appt at the Apple store. It will be far better if you have an appointment rather than just walking in because those with appointments will be taken care of before you are.

  • I'm on my iPod touch 4th generation and I wanna delete apps. Well I hold it down nd the X appears but as soon as I press the X it doesn't do anything for a little bit and then shuts down and turns on again by itself, HELP ME DELETE!

    I'm on my iPod touch 4th generation and I wanna delete apps. Well I hold it down nd the X appears but as soon as I press the X it doesn't do anything for a little bit and then shuts down and turns on again by itself, HELP ME DELETE!

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar    

  • I want to delete some songs from iTunes but no delete button appears when i right click or when i try to delete it from edit. what can i do?

    I want to delete some songs from iTunes but no delete button appears when i right click or when i try to delete it from edit. what can i do?

    If the songs are downloaded into your iTunes library (i.e. they don't have the cloud icon against them) then you should be able to delete them by selecting them and pressing the delete button on your keyboard.
    If they do have the cloud icon then they are in the cloud - you can turn off the showing of all icloud music via the 'Show iTunes in the Cloud Purchases' on the Store tab in iTunes > Preferences (command-comma), or you can hide individual tracks and/or albums so that they don't show in the cloud : iTunes Store: Hiding and unhiding purchases.

  • HT1363 after pressing Menu and Select, when the Apple sign appears, I immediately press select and play/pause, but again the red X sign appears. so it does not go to Disk Mode. Has anyone had this issue? I would be grateful if you could tell me what to do

    The red X has appeared in my Ipod Classic Screen. Apple support tells me that I need to first put it manually on disk mode. to put it on disk mode I ought to press menu and select buton togeher, when the apple sign shows up, hold select button and play together.
    After pressing Menu and Select, when the Apple sign appears, I immediately press select and play/pause, but again the red X sign appears. so it does not go to Disk Mode. Has anyone had this issue? I would be grateful if you could tell me what to do.

    Thank you everyone for the replies. It defiantly helped point me in the right direction. With any luck, I will have my replacement phone sometime tomorrow.
    I was able to call the iPhone support line this morning. The Apple rep stayed on the line with me for about an hour until he was sure the new phone would ship out. For $199 plus $29 for expedited handling I was able to get the replacement ordered with overnight shipping. Since the replacement doesn’t involve ATT&T I have no reason to suspect any further delays. Kudos to the Apple rep that helped me straighten out this mess.
    It’s a shame that AT&T cares so little for their existing customers. Not only did they try to sell me the same phone for $499, they outright refused to help me. They also lied to me on numerous occasions and strung me along for close to three weeks for something that only took an hour to complete with the Apple rep.
    I filed a formal complaint against AT&T through the Better Business Burrow as well as requested a review of our cooperate contract with AT&T. Our company currently has over 3000 phones with AT&T and there contract comes up for bid the end of our fiscal year (this October). We will be giving it heavy consideration before we consider renewing their contract.
    I doubt that any of that will matter to a company that cares so little about their customers, but you never know.
    Thanks again for all your help. I would probably still be trying to get my replacement for the next few months if it wasn’t for your suggestions.
    -Niel

Maybe you are looking for