JApplet won't switch image??

Hi everyone...
My JApplet was supposed to display a new image when the sign up button is pressed..
But it doesn't.. Here take a look at my source code!
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.*;
public class JFrameApplet extends JApplet implements Runnable
private Thread th;
private Image icon;
Image background;
  public void init()
background = getImage(getCodeBase(), "background.gif");
    Container content = getContentPane();
    content.setLayout(new FlowLayout());
    JButton signUp = (new JButton("Sign Up"));
JButton logIn = (new JButton("Login"));
signUp.addActionListener(new ActionListener()
  public void actionPerformed(ActionEvent e)
   getIcon();
content.add(signUp);
content.add(logIn);
  private void getIcon()
  MediaTracker tracker = new MediaTracker(this);
  icon = getImage(getCodeBase(), "icon.png");
  tracker.addImage(icon, 1);
try
  tracker.waitForAll();
catch(Exception exception)
  System.out.println("Error displaying new image.");
  private void getImages()
  public void start()
th = new Thread(this);
th.start();
  public void destroy()
th.stop();
  public void run()
  public void stop()
th.stop();
  public void update(Graphics g)
  public void paint(Graphics g)
g.drawImage(background, 0, 0, this);
}

Wow thanks, the following code helped my out :)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.*;
public class JFrameApplet extends JApplet implements Runnable
private Thread th;
Image background, icon;
  public void init()
background = getImage(getCodeBase(), "background.gif");
    Container content = getContentPane();
    content.setLayout(new FlowLayout());
    JButton signUp = (new JButton("Sign Up"));
JButton logIn = (new JButton("Login"));
signUp.addActionListener(new ActionListener()
  public void actionPerformed(ActionEvent evt)
   icon = getImage(getCodeBase(), "icon.gif");
content.add(signUp);
content.add(logIn);
private void getImages()
public void start()
    th = new Thread(this);
th.start();
public void destroy()
    th.stop();
public void run()
public void stop()
    th.stop();
public void update(Graphics g)
public void paint(Graphics g)
    g.drawImage(background, 0, 0, this);
g.drawImage(icon, 0, 0, this);
}Here you are, 5 duke stars!

Similar Messages

  • Photoshop CS5.1 Won't Load Images On Screen at retina MacBook pro.

    Photoshop CS5.1 Won't Load Images On Screen at retina MacBook pro. Any help? Thanks!

    I'm surprised that Apple would attempt such a "hack" design...  Switching graphics adapters mid-stream is no small task, and I can't imagine that they could ever make it work seamlessly.
    Keep in mind that the nature of the complex GPU beast is that graphics hardware doesn't all work the same (or right) and application software has to make decisions about what to do and what not to do, and even when to invoke certain workarounds - or it would never be possible to run on multiple platforms. 
    Yes, that seems wrong, but it's necessary and it makes developing cutting-edge graphics applications in the real world much more expensive.
    The decisions aren't re-made by an application all the time - that would slow things down terribly.  Instead, often the run-time environment is characterized at application startup and the features remembered for later use.  Modern applications actually even create programs (e.g., shaders or OpenCL programs) to run on specific GPU hardware, and they have to be compiled - something usually done by the application at startup.
    Now imagine that someone changes the capabilities of the graphics hardware completely after the application has started - even from one vendor's implementation to another (Intel to nVidia).
    Like I said, I'm surprised a reasonable system designer could ever think that swapping GPUs at run-time could be made to work.  At least Apple allows you to turn it off!
    Does Apple offer any "geek-level" configuration options that can force the use of a particular GPU for a given application?  It seems that this could be an automated workaround that would allow a given application to see only one GPU, which is what Photoshop appears to need here.
    -Noel

  • I've been texting my friend with iMessage with wifi on and all of a sudden it changed to text message and won't let me send messages. My wifi is still on and working but it won't switch back to iMessage. Please help

    I've been texting my friend with iMessage with wifi on and all of a sudden it changed to text message and won't let me send messages. My wifi is still on and working but it won't switch back to iMessage. Please help

    What I recommend you try doing first is to turn iMessage off then back on.  If that doesn't work, make sure that your Apple ID and password are correct.  If everything seems correct and you still can't send out messages using iMessage instead of text message, I think you should either try calling AppleCare at 1-800-MY-IPHONE (1-800-694-7466) and/or scheduling an appointment at the Genius Bar at an Apple Store (that is, if there's one close to you).
    Hope this helps!

  • My classic video ipod won't switch back to regular video mode after using it on an elliptical. The port still allows me to charge and works on the elliptical and treadmill but it will no longer change modes to allow me to watch my shows on the ipod screen

    My classic video ipod won't switch back to regular video mode after using it on an elliptical. The port still allows me to charge and works on the elliptical and treadmill but it will no longer change modes to allow me to watch my shows on the ipod screen

    From the iPod's Main Menu choose Videos -> Settings and make sure TV Out is set to Off.
    Otherwise, try a hard reset as well.  To do this, press and hold both the Select (Center) and Menu buttons together long enough for the Apple logo to appear.
    B-rock

  • My safari won't switch off - what can i do?

    i opened a page which should have allowed me to download a mock TOCFL exam (that's the standardized chinese exam in taiwan), but instead i just got a page of gibberish and since then skype won't let me close it, also while closing tabs there's no longer an x to click, instead i have to right click and then close it that way. anyone know what's going on here? also since safari won't switch off, i have no way of trying to deinstall and then reinstall it...any suggestions?

    Select  ▹ Force Quit... from the menu bar, then select Safari and press return. Do the same with Skype.
    Run Software Update and install all available updates.
    Reinstalling system components is rarely the solution to any problem, and certainly not to this one.

  • Photos won't import images from my Canon camera.  When connected, program sees the images, tells me it will import the new ones, then freezes once import starts, not allowing any other operation to happen.  MacbookPro 15" 2012, OSX Yosemite 10.10.3.

    Photos won't import images from my Canon camera.  When connected, program sees the images, tells me it will import the new ones, then freezes once import starts, not allowing any other operation to happen.  MacbookPro 15" 2012, OSX Yosemite 10.10.3.  Any suggestions?

    Solution discovered.  Faulty connector cable.  Tried a different one and it worked.

  • My iMac20 powers off by itself and won't switch back on

    I'm sorry this is a bit of a saga but I'm at the end of my tether with so will be really grateful if anyone has any experience of this issue and can give me some help?
    The problem started in May when, after an hour or so of use, my iMac 20 suddenly started to turn itself off and wouldn't turn back on again until the following day. This happened around half a dozen times so I took the machine to the local Apple store and was told that it was probably the thermal trip and if I removed the power cord and left it disconnected for a while, it would power up again more quickly. That evening when it cut out, I followed the advice I was given and removed the power cord from the back of the machine but it made no difference and the machine would not restart until the following morning. Back to the Apple store I went and this time they took the machine in to the workshop; a day or two later I was told that they had cleaned out the fans and tweaked some software and had run it successfully on the bench for several hours with no problem. After paying £49, I collected the machine, took it home, ran it for an hour or so and off it went again and as before, refused to turn on. Back again to the Apple store; "Had I reloaded the operating system?" Well no, because I hadn't been told that I needed to. And anyway why would I... surely the thermal cut-out was a hardware issue? The response was that the problem was definitely software-based and nothing to do with overheating or a faulty power supply unit (which was/is my favourite candidate for villain of the piece). So off home I went, backed up my stuff and ran Disc One successfully and started running Disc Two. After about 20 minutes into Disc Two the machine did its usual trick and powered off, and I went looking for a bottle of wine.
    Back to the Apple store. The guy controlling the 'guest list' for the Genius Bar said that if I wanted to return the machine to the workshop that day it would be considered a new incident and there would be a further charge for any repair work. However, if I made a fresh appointment (for a couple of days later) then the work would be done as part of the previous 'repair'. Somebody at Apple really needs to look at the way the stores deal with dissatisfied customers.
    So, Saturday the 11th of July arrives and I head back to the Genius Bar for my free appointment. I explained to a very helpful guy that this is my fifth visit and I would like to get to the bottom of the problem. He referred to the tech person who dealt with the original workshop repair and she came out to explain that the issue is caused by 'something' lurking in my Library folder and that if I wipe my hard drive and re-install the OS from scratch but without the Library folder, the problem should be solved.
    I spent Sunday wiping the hard drive, running the OS discs and then reinstating my iTunes, photos etc and waiting for the machine to turn itself off - but it didn't! I left my external hard drive returning all my files and documents overnight and when I woke up on Monday, everything was still up and running... bliss!
    Then, this afternoon, after downing loading a music file in flac format, I found that it wouldn't go into iTunes without the help of Fluke software. I downloaded the Fluke stuff and then as I dragged the flac file into iTunes - boof! The machine went off and won't switch back on again.
    So finally... has anyone seen any similar behaviour with their iMac and was it caused by software or hardware? And if it is software that's causing the problem, why can't I switch the machine on again immediately?
    ,

    Amsys plc, the company Apple uses for off-site repairs returned my iMac20 today and the accompanying advice note states that the fault was resolved by replacing the power supply unit. I am really grateful to Apple for finally getting to the bottom of the problem, particularly as the repair was done free of charge, although I had already paid £49 for a useless workshop investigation at the Kingston store. The service given by Amsys was exemplary... the collection and return of the machine was carried out at the times promised and whenever I contacted the company by phone, each person I spoke to seemed to have knowledge of the repair without having to refer to the case notes (and none of the 'press 1 for service, 2 for sales...' rubbish).
    So once again BDAqua, many thanks for suggesting I call Apple... it's just a shame that the staff of the Kingston store refused to accept what was obvious to me.

  • I've broke my phone, it won't switch on, is there any way to recover the data from it?

    My phone has split up the side after I dropped it down some concrete stairs and now it won't switch on, so I need to know if there is anyway to recover the data from it, such as phone numbers, photo's etc. Anyone had this problem?
    I've tried plugging it in to the computer but it doesn't do anything, and tried plugging it in to the wall to see if that will switch it on, but nothing.
    Any help gratefully received! Steve

    If it will not turn on - you have zero chance of getting anything off the phone.

  • My iphone won't switch on. I've tried holding the power and home button more than 30 seconds up to a few minutes but it didn't switch on and went straight to recovery mode. It died of a low battery and i already fully charged it i checked with my itunes.

    i really need help here. I have only used my iphone for a month. my iphone won't switch on. it died of a low battery and i've already fully charged it and usually before it even fully charged, it will turn back on right but in my case nothing happened. i've tried holding the power and home button for 30 seconds and up to 2-3 minutes but no logo appear. it went straight to recovery mode. there's nothing wrong with my cable, i checked with itunes and  this happened once a week ago but it did switch back on after i tried a few times but now it just won't switch on. i also have problems with my screen as there's some noises to the screen (i hope you get me) and when i turned the camera on, it was as if the whole screen is shaking. i'm currently studying in the middle east and there's no apple store here so i cannot use my warranty. i will only be back home in summer. please help me what should i do to at least switch my iphone on first.

    I did a little bit of experimenting. I have an iPad original versions myself. I took it out of the box knowing that I haven used it in months and I expected the battery to be dead and sure enough the battery was as dead as I imagined it would be. For the first 30 minutes I experienced exactly what you are experiencing, but then the iPad suddenly powered up on its own (like it does when plugged into the charger) and I am using it now to type this response to you.
    My point is that I am starting tothink that your battery has suddenly died on you for some reason or you have a hardware problem now. I would still try leaving the iPad charge for a while longer - maybe even overnight - and then try again in the morning. Unplug the iPad and try resetting with the home and sleep buttons. Try plugging the iPad in again. Unplug it, try restarting again. Let it charge for a while again.
    After trying something like that, if it still will not start up, then I think it's time for a trip to an Apple Store and see what the Apple Techs think.

  • I'm new to this! My old mac 0sx 10.2.8 won't switch on. Not sure where to start to fix it? I am totally useless when it comes to computing, can anyone help me please!!

    Hi, I am new to this support site so forgive me if I am doing it wrong but I have a problem that I am at a loss as what to do. My (very) old mac 10.2.8 won't switch on..I really only use it for music , there is a vast amount of music stored in it and am heartbroken that it won't even switch on. I have no idea where to start on trying to fix it. Can somebody please help me on where to start on fixing it

    You might want to try resetting its power management unit; see the following tech notes:
    http://support.apple.com/kb/HT1895
    http://support.apple.com/kb/HT1379
    The reason I'm suggesting this is that some startup settings are stored and preserved by a tiny battery that lasts about 5 years, inside the computer. When that battery dies, the computer may forget things like what time it is and which disk to start up from. If your Mac is around 5 years old or more, that little battery might be on its way out.
    If you can't revive the Mac, don't panic. You can remove its internal hard drive and put it inside a USB/FireWire enclosure so that it can be hooked up to another Mac, and then you can use or copy all of the files and music off of it (assuming the startup problem has nothing to do with the hard drive).

  • My at@t service won't switch to my new phone

    I just upgraded to the new iphone 4s and all the apps info and everything synced but my at@t service won't switch to the new phone? 

    So why are you posting in an Apple technical support forum?  Call AT&T!

  • My iPhone 4S won't switch to landscape mode

    my iPhone 4S won't switch to landscape mode. anyone else have this issue??

    LexusB wrote:
    Alas, this did not help me. I don't have an Orientation Button or any Icon that would help in this endeavor. At the bottom of my Iphone 4s, there are 3 icons: Phone, Mail and Safari. That's it. I can't get those icons to move.
    What is it you're trying to do?  If you're looking for orientation lock in iOS 7, swipe up from the bottom of your phone to access control center.  Orientation lock is the top right icon.

  • Ultrabay battery won't switch to main battery and results in sudden shutdown.

    Hi,
    I just changed my windows 7 32 bit to 64 but version. The power manager version is 3.66 and driver version 1.64, bios version is    LENOVO 7UET93WW (3.23 , 12/15/2011). The ultrabay battery drains to zero and won't switch to main battery, which leads to a sudden shutdown without any warning. In windows 7 32 bit version, I don't have such problem. It's annoying. My computer is T400 7147 CTO. 
    Thanks!
    chicagot400

    Hi I have the exact same problem. I have a T400 2764 CTO. Changes I have recently made (past 2 weeks): I upgraded to Windows 7 64, added a PC Card media reader, added an express card USB 3.0, a Samsung 256 GB SSD and the Ultra Bay Battery. Everything was working great... both batteries recognized, ran Lenovo Update... Have everything...
    Well the battery meter recognizes both batteries (a 4-cell and a 3-cell), combines their life, but it drains the 3-cell first to ZERO... and isn't bright enough to figure out how to switch before abruptly dropping power to the system.
    Hopefully like the ATI switchable graphics that had bugs for ages this battery issue eventually gets fixed. Let me know if you figure out any solution. AND LENOVO, if you are reading, try and set it up so that the 2 battery usage maximizes the life of both batteries with whatever controller you put together.
    Thanks.
     - Tom

  • IPhone 5s won't switch to landscape mode

    I have the iPhone 5s (32GB) and the software currently being used is up to date (IOS 7.1.1).
    My problem is that my phone won't switch to landscape mode. When I take pictures, it won't turn over, and all other apps, even when I play games like Temple Run, it won't allow the character to move side to side.
    I have checked to see if my phone's orientation lock is on, which it is not. I have done a hard reset which did not fix it. I also did a restore where I restored it completely and set it up as a new phone, and restored it and set it up with a backup. Nothing has helped it!!
    I don't know what to do, and would much rather figure it out than go to the Apple Store and get it looked at. If you have any knowledge or anything that can potentially help resolve this issue, i'd be very much appreciated!!
    Thanks

    try to put it on DFU Mode And Restore Again
    if you don't know how to put it
    How to enter DFU mode:
    Plug your device into your computer
    Turn off the device by holding the Sleep/Wake or Power button and swiping it off
    Hold the power button for 3 seconds
    Begin holding the Home button without releasing the Sleep/Power button for 10 seconds
    Release the power button and continue holding the home button until you get a popup from iTunes that your device is recognized as being in recovery mode.
             i hope this help you

  • N85 won't switch to silent using # key

    Hi all,
    Am hoping you can help me - new to Nokias so I'm not sure if this is a common thing...
    I've just got a new N85 and it won't switch between general/silent profiles when I hold the '#' key.
    It just....does nothing!  Only way to switch between modes is through the usual power button route.
    Any ideas?  Is my phone faulty or is there something I need to switch off/on to activate this short cut key?
    Cheers in advance!
    Rich

    Sometimes operator branding removes this feature. Also, devices manufactured for the Asian market often tie automatic line switching (for SIM cards with 2 lines) to the # key.
    If you got your phone from a reputable dealer or online from the Nokia store then you should have a EURO variant of the firmware and this should work as expected. If you got it off eBay or somewhere like that then the chances are that you may have an Asian version that someone has reflashed with European language support without telling you, or that you may even have a counterfeit device. If you got it with a SIM from a UK operator then there's not a lot you can do.
    Sometimes, though, this kind of thing can be some kind of software error. There are a few things you can try here...
    1) Try a restore factory default settings. Just enter *#7780# from standby and supply your security code when prompted. It'll be the default 12345 unless you've changed it. This won't erase any data of yours, you'll just have to redo your theme, ringtone etc. settings afterwards.
    2) If the restore factory default settings thing doesn't work then try a soft reset. This will erase your phone's memory (but not your memory card) so do a backup beforehand. If you have media files that are DRM protected, then use OVI Suite (instead of PC Suite) since that's the only thing that'll back up media activation keys (if you don't back those up then your media will be unusable afterwards). Then enter *#7370# from standby and enter your security code when prompted. The phone's memory will be reformatted. If you do have an imported model that has been reflashed with European languages, this step will make the phone revert to its original language set.
    If those don't work then you can always take the phone in to your nearest Nokia Care Point for assessment, but do bear in mind if you got your phone from an operator that what you're describing can be the result of operator branding.
    Was this post helpful? If so, please click on the white "Kudos!" star below. Thank you!

Maybe you are looking for

  • Transfer Open Items

    Hello Experts, I understand that there is no standard functionality from SAP to transfer open line items of an account in one Co Cd to another Co Cd - But can you think of anyways we can do that ? All answers/opinions/views would be duly rewarded wit

  • Intercompany sales without the EDI piece?

    Hi all, I am looking into setting up and intercompany sales process for my client.  It is a straightforward process whereby product will be sold out of one company code (A), and delivered out of a plant that is in another company code (B).  I have al

  • Can we call java jar from ODI?

    Hi All, Can we call java jar from ODI? if yes please suggest how? Regards, Satish

  • ORA-01034 help please

    Recently recieved a copy of the developer kit for linux which included Oracle 8i enterprise. I followed the instructions found in the install guide (even printed it for reference) When the install was finished I followed the instructions in the admin

  • PALM DESKTOP SOFTWARE DOES NOT INSTALL

    I had installed palm desktop software for mac on my computer & it was working fine.I downloaded the software update & tried to install it but it is not installing & it gives a error message.I tried telling about this problem to palm support & they to