Applet Button acting weirdly...

Hello
I'm quite new at Java, and new to this forum, so don't be too hard;)
I've got a problem with a awt.button in an Applet. When i click on the button it seems to send two events, and thus executing twice the code. I would like it to execute only once the code.
I've tried changing the MouseListener from MouseClicked to MouseReleased, but doesn't seem to change anything. I've also tried to put a button.setEnabled(false) in the code executed, but still doesn't change anything.
This is weird to me, because i've also got an application version of the program and it doesn't have that problem.
Could you please help me...
Pierre
public class ScanAPPlet extends Applet {
  JButton jButStart = new JButton();
jButStart.addMouseListener(new ScanAPPlet_jButStart_mouseAdapter(this));
  void jButStart_mouseReleased(MouseEvent e) {
    String param = (String) jCCommand.getSelectedItem();
    Prog programme = new Prog(this, param);
    thread = new Thread(programme);
    thread.start();
class ScanAPPlet_jButStop_mouseAdapter extends java.awt.event.MouseAdapter {
  ScanAPPlet adaptee;
  ScanAPPlet_jButStop_mouseAdapter(ScanAPPlet adaptee) {
    this.adaptee = adaptee;
  public void mouseClicked(MouseEvent e) {
    adaptee.jButStop_mouseClicked(e);
}

Ok thanks for everything, i think i've found the problem!
For reference, it's a problem of Jbuilder, it changed the constructor of the Applet like this:
public ScanAPPlet() {
    try {
      Init();
    catch (Exception e) {
      e.printStackTrace();
  }and then launches the applet with :
public static void main(String[] args) {
   ScanAPPlet applet = new ScanAPPlet();
   applet.isStandalone = true;
   Frame frame;
   frame = new Frame();
   frame.setTitle("Cadre de l'applet");
   frame.add(applet, BorderLayout.CENTER);
   applet.init();
   applet.start();
   frame.setSize(600,300);
   Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
   frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
   frame.setVisible(true);
}So in the end, there's the init() has been called twice. Probably making the problem. I deleted the changed constructor and it seems to be working.
But Thanks of lot for your help!!
Pierre

Similar Messages

  • Lumia 720: Power and camera button act weird

    Hi,
    My Nokia Lumia 720 is acting weird.
    The camera button doesn't work and so does the power button.
    However if I press the volume down and the power button simultaneously the button does work.
    Does anyone know how to fix this?
    I've already brought the phone back to the default settings.
    I'm running the latest developer preview if that matters.
    -- Mathijs
    Solved!
    Go to Solution.

    That's great to hear, Mathijs. If you need further assistance in the future, don't hesitate to post again here in the forum and let our community help you. 
    Cheers! 

  • Mic button acting weird.

    It seems sometime when I turn my phone on and insert my apple headphones, it wont pause or change songs using the mic button. If I unplug it and plug it back in, it starts working again. Im pretty sure this only happens when I first turn on the phone, but I could be mistaken. I think it happened a few times already. Anyone have this problem?

    My friend and I are having the exact same problem. We took both of our phones to the store and was told to restore it, reboot it, try different headphones and all those things still did not resolve the problem. I helped the "mac genius" discover that it may be a glitch in the software because he tried it on his iPhone and his co-worker's phone and the same thing happened. Sometimes you plug it in and the mic clicker works and sometimes it doesn't. I would challenge others to try this out and see if the same occurs on their phone. The mic may work initially when you plug in the headphones, but if you take them out and plug them back in, they may not work. Let me know..

  • Power button acting weird...

    So, I don't know if its just me but in the past week or so (don't recall if this was happening before most recent updates), I've noticed that my power button doesn't do ANYthing while the computer's up and running. Didnt it used to prompt up for if I want to shut it down, sleep, etc? It still works to boot up the computer and to wake it from sleep and such, but when the compy's up, it doesn't work.
    Thoughts, anyone?

    A quick press of the power button on my MBP (on 10.5.6), while it's awake, still gives the Restart/Sleep/Shut Down dialog box.
    Perhaps try a PRAM and/or SMC reset:
    http://support.apple.com/kb/HT1379
    http://support.apple.com/kb/HT1411

  • Ipt 1g home button acting weird (1 presss equals 2)

    ok i have the ancient ipod touch 1g, and the home button has seemed to die on it, when you half press it in it works, and the button is really weak, so half way is easy pressed in by mistake, and when you press it with normal strength and push in all the way like normal, it comes up with the music menu, i know it isnt software b'cos the ipod casnt detect half presses and i have already just restored. i am willing to do anything to it now, i will probably open it up, but am not sure if there is some other easy fix, has anyone else had this problem? so again its when you press it, it regesters it as twice, sometimes 3 as the menu comes up then dissapears half a second later

    If you attempt to repair on your own, do considerable research prior to doing it.
    cnn.cn gives you a good place to start.
    Another location similar to cnn.cn is: HorizonWirelessOnline.com
    truesupplier.com
    do CONSIDERABLE research prior to repairing your own equipment.

  • OS 4.0: HOME button acting weird and inconsistently since updating

    The new double click for multitasking is not working properly for me - sometimes I get the new multitasking bar; but most of the time I don't. Sometimes I'll get it with just one click, other times after clicking THREE times?!! Its so annoying. I'm on a 3G 32gb Touch and I updated with no problems at all; but everytime I double click the Home button I just get the search feature coming up instead - prior to updating I had the Home button set to get me there via a double click, but I've attempted to change that setting and I've noticed that the option to customise the Home button click function has been removed?!! Basically, multitasking is a lottery as far as my Home button is concerned, I have to keep trying different Home click combos to get it to appear and I'm regretting updating at all.
    Please help!

    Well that was a waste of time.

  • Nano "Enter" button acting weird and restarting

    Hey -
    So I've had my nano (4GB) for about 7 months now and its been great, but recently it's been restarting a lot randomly, that is, the screen goes black and the apple logo is shown before bringing me back to the main menu.
    Yesterday after it restarted once, the enter button appeared to stop working, but I realized that it works on every function BUT entering the music menu. So for instance when it starts up I can go to Shuffle Songs, or play a game of solitaire, but if I go to click on the MUSIC menu, which would bring up the Artists, Songs, Albums, then the whole nano just restarts. It keeps doing it over and over and over. I have no idea what's wrong with it.
    Any help would be GREATLY appreciated.
    Thanks.

    Sounds to me like you are having the same problem I had. I trouble shooted (trouble shot?) it and figured out that installing podcasts from the iTMS was causing the problem. This took me several instals, updates, etc. When I finally figured it out, I restored my nano with the latest update (at the time), kept the "drive" free of iTMS podcasts, and it has worked like a charm ever since.
    PB G4 12" 1.5 Ghz; Tangerine iBook 300 Mhz; PB G3 400 Mhz; iMac G4 flat panel, 15" 800 Mhz   Mac OS X (10.4.5)   Black nano, 4 Gb; 3G iPod; Shuffle 1 Gb

  • On/Off Button on Shuffle (1Gb) Acting Weird

    My Second Generation iPod Shuffle started to act weird after about 3 months of flawless usage.
    When pulled from the charger, Shuffle will play music as expected as long as I don't touch the On/Off Button. (Regardless of the state of the button)
    If I toggle the button, the Shuffle will appear dead until I replace it on the charger again. (Nothing works in On or Off Position)
    At first, I thought it was a battery issue but was suprised to find that it played with the switch in the off position right off the charger.
    I did recently update my iTunes and also updated to the latest iPod software. (Problem may or may not have happened post-upgrade)
    I have tried the everything listed on the Apple Website except the Reset Utility. (Will try that tonight)
    Just wondering if anyone else is experiencing this issue and also if anyone has any ideas as to the resolution. (Other than Sending it into Apple for Repair)

    I think your contact for your switch may be dirty or damaged
    Your best bet is to see if you can try to cleen under the button or take it to the store to have them replace the contacts on the power button pad
    And no reset will not help with it , your probally dealing with an electric problem.

  • My MacBook was acting weird so I restarted it and when I login a white screen flashes and goes back to the login page. Help?

    My MacBook was acting weird like sometimes I would log on and I wouldn't be able to type my password for a couple seconds,but it usually logged in after that. Then I left my computer open after installing the recent update after that all my applications were not responding. So I shut it down, when I turned it back on about an hour later it went to this loading screen and then to the login like usual. After I tried logging in a white screen flashed and it went back to the login/ password screen like nothing happened. Any ideas on what happened and what I can do to fix it?

    Reinstall OS X;
    Reinstalling Lion/Mountain Lion Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall Lion/Mountain Lion: Select Reinstall Lion/Mountain Lion and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.

  • I have an IPhone 4, and I wanted to reset it, but couldn't do it via computer because the "find my IPhone" was turned on. So I went to ICloud Find My IPhone and just erased my phone from there. The was acting weird but I finally got to a black scre

    I have an IPhone 4, and I wanted to reset it, but couldn't do it via computer because the "find my IPhone" was turned on. So I went to ICloud > Find My IPhone and just erased my phone from there. The was acting weird but I finally got to a black screen with the spinning circle. And it won't advance. I can't just hold the sleep button and home button down because my sleep button is broken! Any help? I have reset my phone before.

    Hello cwypyski,
    The link below provides information on and can also assist with setting up service for your iPhone to have your Sleep/Wake button repaired.
    Service Answer Center - iPhone
    http://support.apple.com/kb/index?page=servicefaq&product=iphone
    All my best,
    Allen

  • Does low disk space make my Macbook Pro act weird?

    Hi! I have an early 2011 15" MBP with a 750gb hard disk space. Just the other day, while I was using photoshop with my laptop, the screen went off so I had to reset it. My laptop acted weird after: doing a screen split (the right part goes to the left and vice versa), one time it had weird pixels that were scattered all over, recently, a blue striped screen. All of this froze my laptop by the way. And all of this happened after a few minutes of usage. And I noticed if I use photoshop, it would only take a little amount of time before it would act weird again compared to when I don't. All the times caused me to reset my laptop by holding the power button.
    Yesterday, it wouldn't boot past the gray screen after resetting about five times. But after it turned off by itself, I tried turning it on again and it booted normally. And I could use it normally again, but with extra care (using it beside an electric fan, checking the temperature with iStat pro).
    I tried the extended Apple Hardware Test but it told me no trouble was found.
    Another thing was, everytime my laptop froze and did the weird screen thingy, my laptop was hot.
    I tried to use it again yesterday to just surf the web, and after some minutes it was still functioning. But I remember one time I was only surfing the web, it did the split screen and froze after almost an hour or so.
    Also, my laptop heats up quickly compared before. And can stand being hot for a long time until now.
    I haven't used any heavy applications besides photoshop to test my laptop's weird behavior by the way.
    So I guess it's because of the laptop's heat. Because I can only use it for a very short time when using photoshop but I can use my laptop for a longer time when only surfing the web.
    I also noticed that if I was forced to reset my laptop and turn it on again, it would boot longer than normal. But if I was able to shut it down properly and turn it on again, it would boot normally.
    And, just a while ago, I remembered my laptop's disk space was only 14gb from 750gb (downloaded a lot of series since I bought my laptop). So maybe what's causing the heat was the low disk space. Just a guess.  So is it possible that my laptop is behaving weird because of the low disk space?

    The problem is back. But this time, it only happened when I used photoshop or played a 1080p video. I was using my laptop for almost 3 hours when i decided to use photoshop. It froze as soon as it started and made my screen display weird pixels. I restarted and tried to open photoshop again and this time, it froze. I did it the third time and after using PS for a minute, it did the split screen. After restarting yet again, I tried to play a 1080p video to just test my laptop. It froze as soon as VLC started. But when i only surf the web (which is the only thing I did before using PS), everything goes well. So I guess it really is the GPU and not the logic board or some other parts. I've decided to just have my laptop checked.

  • My iphone 3gs is acting weird, every time i get a call or if i try and call some one my iphone gets random black lines down it) so what can I do to fix it?

    My iphone 3gs is acting weird, every time i get a call or if i try and call some one my iphone gets random black lines down it) so what can I do to fix it?

    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
    - Restore to factory settings/new iOS device.
    - Make an appointment at the Genius Bar of an Apple store.
    Apple Retail Store - Genius Bar

  • MacBook Pro acting weird at startup

    Hi,
    First of all thank you for reading this, it's quite a long story. And sorry for any grammatical mistakes, I'm Dutch.
    Summary
    My MBP suddenly has been acting really weird: kernel_task eating 150-200% of the CPU which caused a super slow MBP, power button not working well, and MBP shutdown after ten minutes without touching it and with the battery on 90%. I did a clean install of OS X Lion, some PRAM and SMC resets and removed the MacBookPro7_1.plist file from the system library. The kernel_task high CPU problem is now fixed. But the power button is still not working: most of the time my MBP shuts down three seconds after I push the power button in a first attempt. In the second attempt I hold it for like five seconds and this works. Sometimes it works fine on the first attempt. Restarting the MBP from the desktop works fine. I'm also worried about the random shutdown. What could probably cause the problem with the power button and the MBP shutting down when I don't touch it, and is there a way to fix this myself? I'm not really into tech, so please keep your answer simple.
    My MacBook Pro "13 (mid 2010) with OS X Lion has always been a charm since I bought it. I've never had any problems with my MBP until now. Two weeks ago I was going on a holiday and had to check a few things on my MBP in a hurry right before I was leaving. I'm afraid I forgot to turn off my MBP before I went on my holiday, but I can't remember this exactly. When I came back after a week, my MBP started acting weird at startup and then became really slow. The kernel_task was eating my CPU with 200% and I've tried many things to fix the MBP myself but it still isn't working well. I hope you can help me with this.
    This is what happened:
    1. When I push the power button to start my MBP, the first time it shuts down three seconds after I push the button. After the first attempt I hold the power button for five seconds, and my MBP turns on the right way. After all the fixes I've done this is still an issue.
    2. When I finally got my MBP started the first time after my holiday, it was really really really slow. I later found out that the cause was the kernel_task eating my CPU. It was using 150-200% with no applications running.
    3. The MBP was acting normally (not slow) in safe mode, but in safe mode I couldn't open some sites in Google Chrome, like Facebook and Google Maps. So this didn't work either (and was not the solution to my problem).
    4. I did some things with PRAM and SMC reset but this didn't work.
    5. A clean install was already on my mind for weeks, so I decided that this was the right moment. After I did a manual backup (not with Time Machine) I restarted my MBP holding some buttons to startup the OS X Utilities screen. I first erased my Macintosh HD and then I wanted to install Mavericks because that was the only option from the menu. It took me five hours and at the end it came up with a 'can't download Mavericks, try again' screen. The MBP wasn't starting up anymore because OS X Lion was already erased.
    6. So I became annoyed and decided to use my original Snow Leopard dvd which came with my MBP. Installing Snow Leopard took me two days!!!!!!!
    7. When I finally got Snow Leopard installed, it still was really really slow and the kernel_task was messing up my CPU again.
    8. After some hours of searching on the internet, I read the following thing: fixing the kernel_task problem was easy by removing a file from the system library (http://www.rdoxenham.com/?p=259). Of course I've researched this solution because I'm not a fan of changing things in the system. But I decided to give this a try and it worked! Like a charm!
    9. I still was on Snow Leopard and decided to upgrade to Lion again, because I did know for sure that my MBP could handle Lion and I wasn't sure with Mavericks. So I first downloaded Lion from the App Store and then opened the installation program. This took me one day again, probably because the file from the system library was put back with the installation of Lion...
    10. When I finally got Lion running, the kernel_task was using a high CPU% again so I removed the file from the system library again and restarted my MBP. This worked.
    11. I'm working on Lion for a day now and I've installed some applications (Adobe CS5 Master Collection, Office for Mac, updated my 17.000 mails in Mac Mail, and installed some browsers). It's working fine and the kernel_task is at 1-10%. The issue with the power button is still there but sometimes it works fine at the first attempt. Yesterday my MBP suddenly shut down when I didn't touch it for like ten minutes. The battery was still on 90%. Maybe this was caused by the fact that my MBP was running for four days non stop because of the OS X installations, and it was a hot day yesterday.
    So this is what I've done so far in this order:
    1. First of all I did a manual backup on my external HDD. Not with Time Machine.
    2. I tried to restart my MBP multiple times. Restarting from the desktop worked well, but shutting it down and than turning it on with the power button didn't work well.
    3. I did PRAM and SMC resets multiple times.
    4. I decided to do a clean install and erased my Macintosh HD from the OS X Utilities screen at startup.
    5. Then I wanted to upgrade from Lion to Mavericks but Mavericks couldn't be downloaded.
    6. I've installed Snow Leopard from the original dvd, this took me two days.
    7. I've followed the instructions from http://www.rdoxenham.com/?p=259 (remove the file MacBookPro7_1.plist from the system library) and this worked for my MBP.
    8. Because my MBP was working fine again, I decided to upgrade to Lion. This took me one day.
    9. My MBP was really slow again: Lion put the MacBookPro7_1.plist back in the system library so I removed it again. This worked.
    10. The problem with the power button still holds so I did a SMC reset again. Didn't work. My MBP also shut down yesterday when I didn't touch it for like ten minutes. I hope this was caused by the fact that the MBP was running for four days non stop, and it was a hot day so maybe it was overheated.
    So everything is working fine again, but the power button still isn't. Most of the time my MBP shuts down three seconds after I push the power button. In the second attempt I hold it for like five seconds and this works. Restarting the MBP from the desktop works fine, and the kernel_task is now using 1-10%. I'm also worried about my MBP suddenly shutting down. Is there a way to fix this myself?
    Thank you!
    Regards,
    TokkieTor

    TokkieTor,
    This is the full error message I got from the test:
    4SNS/1/40000000: IP0R-9:166
    I read that those letters (IP0R) stand for different errors in the hardware, in my case it's something with the Power Bus according to this website: http://www.cnet.com/news/how-to-invoke-and-interpret-the-apple-hardware-tests/.
    Again, I'm really not into tech so what is a Power Bus and should I be worried?
    what you have is a problem with a sensor which monitors power bus current. The power bus is the main pathway along which electricity travels in your MacBook Pro. If the sensor isn’t individually repairable, then you could have reason to worry — if they tell you that a logic board replacement would be needed, then that could cost hundreds of euros. (One would hope that replacing a sensor would not require a logic board replacement, but only hardware experts can say for sure.)
    I think that posts here are only editable for ten or fifteen minutes after replying.

  • Lion acts weird

    For some days now my OS X Lion 10.7.2 acts weird...
    - at startup when I log in always the same programs open, even if I had them closed before shutting down or if I unchecked the "open programs at startup" thingy in the shut down dialog (for example iTunes and iCal open without me wanting them to)
    - iTunes opens always in the same genius-tab, even though I had another folder / song selected before closing the program
    - Finder preferences that I changed reappear the way they were before changing them after a renewed login
    - A plugin I tried installing and / or registering numerous time in Adobe Lightroom gets kicked out if I close and reopen LR (I tried reinstalling an older version of LR and reinstalling the newest version, but that didn't help anything)
    - I cannot delete files from my own folder without me having to login as Admin (though I do have read and write rights in the information tab) - though it is working with for example a test file I download to the downloads folder, but not with stuff already in there)
    - I spent a long time with an apple support hotline guy yesterday who didn't know what it could be (we tried cmd+r at startup and reattribute rights with no effect) and told me to reinstall Lion -> that didn't help either
    It seems my imac is suffering from dementia... any help or ideas would be appreciated.
    Would it help to press some other button combination at startup in order to reset some kind of ram (sorry I don't know which ram is for what)?
    edit: also Preview is not working any more...
    edit2: the Preview error also mentions something about permissions (I could also post the rest of the error message if that helps):
    Saving after update for container (~/Library/Containers/com.apple.Preview/Data) failed: NSCocoaErrorDomain:513 You don’t have permission to save the file “Container.plist” in the folder “com.apple.Preview”.

    Boot from your recovery partition by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the recovery desktop appears, select Utilities > Terminal from the menu bar.
    In the Terminal window, enter “resetpassword” (without the quotes) and press return. A “Reset Password” window opens.
    Select your boot volume if not already selected.
    Select your username from the menu labeled “Select the user account” if not already selected.
    Under “Reset Home Directory Permissions and ACLs”, click the “Reset” button.
    Select Apple menu > Restart from the menu bar.

  • Standard keyboard is acting weird!

    Just recently my keyboards been acting weird. Most annoying of the problems is when I am pressing delete and it gets to the end of the word and then inserts another word instead of deleting! At first I thought I was knocking letters around the delete button and the predictive text was inserting them but I've been very precise pressing the delete button and still it inserts words. Anyone else had this?

    Thanks everyone! I'll follow the chrome clear guidance above and fingers crossed it will sort it I try googling it before asking but nothing came up so apologies if it's a repeat post

Maybe you are looking for