How to deal with the mouse events when the thread is running

Hi everybody,
I have a problem with my program.
Now I want to present a picture for some time in the Canvas,then automatically clear the screen, but when the user press the mousebutton or keybutton, I want to stop the thread and clear the screen.
How can I receive the mouse event when the thread is running?
Thanks,

I use my code in a GUI applet.
I try to use the code tag, it's the first time.
               Image im=sd.getStimulus(obj);
               if(pos==null){
                    g.drawImage(im, (w-im.getWidth(null))/2,(h-im.getHeight(null))/2,null);
               }else{
                    g.drawImage(im, pos.x,pos.y,pos.w,pos.h,null);
               try{
                    sleep(showtime);
//                    Thread.sleep(showtime);
               }catch(InterruptedException e){}
               if(pos==null){
                    g.clearRect((w-im.getWidth(null))/2,(h-im.getHeight(null))/2,im.getWidth(null),im.getHeight(null));
               }else{
                    g.clearRect(pos.x,pos.y, pos.w, pos.h);
               }

Similar Messages

  • How to deal with  time zone while upgrading the database?

    Hi,
    How to deal with time zone while upgrading the database?
    Thanks
    Edited by: user12135020 on Jul 4, 2011 3:06 AM

    Hello,
    I answered to a Wrong post.
    Best regards,
    Jean-Valentin
    Edited by: Lubiez Jean-Valentin on Jul 4, 2011 12:15 PM

  • How to catch the mouse event from the JTable cell of  the DefaultCellEditor

    Hi, my problem is:
    I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
    So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
    Any idea will be highly appreciated!
    Thanks in advance!

    Hi, bbritta,
    Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
    Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
    Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3
    extends JFrame {
    // JTextField jtf = new JTextField();
    Object[] as = {"aa","bb","cc","dd"};
    JComboBox box = new JComboBox(as);
    public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {
    "One", "Two", "Three"};
    String[][] data = {
    "R1-C1", "R1-C2", "R1-C3"}
    "R2-C1", "R2-C2", "R2-C3"}
    JTable jt = new JTable(data, head);
    box.addMouseListener(new MouseAdapter() {
    // jtf.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JComboBox mouseclick....");
    jt.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JTable mouseclick....");
    // jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
    jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    public static void main(String[] args) {
    new Test3().setVisible(true);
    }

  • How can I make only the shape active for the mouse events, not the whole box around it?

    I want to create mouse over events for different parts of an image (say of a hard disk drive), so when the user places their mouse over the spindle, say, it will change colour.
    At the moment I have it working however the event is triggered when ever the mouse is in the bounding box of the spindle image. How can I get it to only be triggered when it is above the non transparent part of the image (or symbol)?

    Thanks joris182, but that wont work when there are other objects within the bounding box of the transparent symbol. For example, if I want the sclera to highlight, if I use an invisible shape over it, it will be active even if someone has their mouse over the vitreous body.

  • How to deal with tiny text size on the display, especially in email?

    I got a Macbook a week ago. I have been using a Windows laptop for about 5 years. Before that I had a couple of Mac desktops.
    All in all I am very happy with the Macbook. I haven't had any of the problems which have come up in these forums, unexpected shutdown, bad DVD drives, etc. One thing I love about mine which I had not seen mentioned before I got it is that the Macbook (or mine anyway) is absolutely whisper quiet. I cannot hear the hard drive doing anything. My Dell laptop sounds like a construction site in comparison.
    The main issue that is vexing me has to do with the high-res, small-size display. The combination of those two factors means that the text size onscreen is often so small that even with reading glasses I have serious eyestrain.
    Back on my Dell this was a lot easier to deal with. In Internet Explorer and Outlook Express, there are very simple settings in the menus to make text sizes better. And this is really important -- those text sizes are remembered after you close and restart the program.
    So far as I can tell, that is not true (in general) on the Mac. I find this shocking, since Apple makes such a big deal about the simplicity and usability of the Mac.
    Specifically, in Safari I went into preferences and reset the fonts. A little more complicated than in Internet Explorer but it basically works alright.
    With Apple Mail, though, it is really troublesome. There is no remember-able setting to increase the text size for viewing (that I can find). And the on-screen size of 12 point text in an incoming email in Apple Mail is just absurdly small. It makes me wonder if Apple is taking bribes from the American Opthalmology Association. This is going to ruin my eyesite pronto.
    Of course I can hit Command-+ several times when viewing each email to increase the text size to a readable size. But what a pain.
    Is there a way to make those settings rememberable?
    Otherwise I like Apple Mail. But I really prefer not to have to hit 6 keystrokes when looking at each email just to get it to a reasonable size.
    I looked at the help files for Mozilla Thunderbird. They seem to indicate that program works the same way.
    How about Eudora? Any others? Any suggestions much appreciated.
    thanks
    Paul D.
    Macbook   Mac OS X (10.4.7)   1st gen. iPod Mini 4Gb

    Hi Jeff, thanks for your careful attention and your comment.
    But I have to point out you've missed what I'm talking about.
    In OE, in the View menu (right on the menu bar, not under Tools>Options) there is a setting called "Text Size" which allows you to set the text size for viewing and composing (independent of sending). That makes it very easy to make the text easier to read on small screens. It does not "change the appearance of the formatted text so that it no longer corresponds to the intent of the sender". It merely makes the text bigger or smaller, like a magnifying glass.
    Via email I had some back and forth today with another poster here discussing this. You might be interested to see the email he sent me in which he included both Helvetica 12 and Helvetica 14. I took a screenshot of the email he sent me (from Apple Mail). When I read this email in Apple Mail with the "Message Font" set to Arial 18 (which is the size I need it set at for readability), Helvetica 14 is displayed at a smaller size than Helvetica 12.
    screenshot here: http://www.pbase.com/paulduke/image/64910338/original
    That's weird.
    Here's a test I did, and this is what really matters to me.
    I sent two emails from Windows/Outlook Express. For one I set the default composing font to Arial 12. For the other I set the default composing font to Arial 18.
    When I downloaded and read these emails in Apple Mail, sure enough, the Arial 18 font appears much bigger than the font in the Arial 12 mail.
    Then I did the reverse. I set the "Message Font" in Apple Mail prefs to Arial 12. Sent an email.
    Then I changed the "Message Font" to Arial 18 in prefs and sent another email.
    Then I downloaded both these emails into Outlook Express.
    On OE, font size is displayed exactly the same in both emails.
    So that's good -- I know that Apple Mail, whatever the setting in "Message Font", is sending some sort of "standard" font size. (By the way, I have Apple Mail set to send Rich Text Format mail). My correspondent tells me that Apple Mail doesn't send "true" HTML mail, and Outlook Express does, so perhaps that explains this.
    Okay, no big deal. But if I were a graphic designer and I wanted to know for sure that my carefully crafted email styles were getting through, I might be going bonkers because of this.
    But I'm not a graphic designer, and for the moment my concerns are assuaged.
    And I accept the wisdom of your advice to "go native". I'm trying, I'm trying...
    PD
    Macbook   Mac OS X (10.4.7)   1st gen. iPod Mini 4Gb

  • How to deal with Short dump that restarts the index server?

    Hi ,
    I have been experiencing this problem whenever any exception occurs in my SQL SCRIPT procedure. For instance when there is a situation when I try to insert a value of 50 characters in length to a column with max size of 40 it throws a short dump and restarts the index server. I tried to insert the exception handling code as well but still the problem persists. Is there a way to solve this issue?

    Hi Sudarshan
    crashes are rather generic reactions of the system to virtually any kind of problem that may occur.
    Memory shortage is one of the more common issues in current SAP HANA setups and SAP HANA development is heavily working on handling memory shortage situations more gracefully.
    Massive over allocation of memory, for example by very large intermediate result sets or join result sets typically can be addressed by correcting the query or model that leads to the issue.
    Anyhow, the initial post was not about a memory shortage but about a crash that seemed to have occurred with wrong data type handling.
    These are two very different kinds of problems, so I am not really sure how your comment relates here.
    - Lars

  • How to deal with unknown costs & load on the material

    Hi,
    I have asked similar question a many times but so far not have got any satisfying suggestion to this.Here I am putting it again.
    This is a Intercompany scenario.
    ICT PO is raised and subsequently Delivery/picking-pgi done.
    Then Billing is done and goods are sent to the receiving location of another company code.
    This transfer of goods involve some 2-3 types of delivery costs which are not known till the goods are received by the receiving location .
    Many a times what happens is that goods are dispatched to the receiving location by clubbing the number of POs.It could be possible that user clubs some 20-30 POs and send the goods against them in one container.
    The problem which the receiving location faces is how to book these additional delivery costs on the material at the time of GR as they(users) only know these costs when they receive invoices from the local vendors for the resepective expenses.
    Even if they decide to change PO before they do GR it is not possible or becomes very difficult for the user to split the total additional delivery costs and distribute in all the 30 POs(assume he is receiving goods against all 30 POs in one container).
    Is there any best way to handle this scenario ?
    I am sure this is a typical requirement & it must be happening in most of the industries.
    Even for a single PO, how the additional cost can be distributed based on PO value.
    All these additional costs should be loaded on to material while GR.
    Please suggest
    Thanks in advance
    Regards,
    BM

    hi arjman!
       1) You do MIGO for all the purchase order in one document
    enter the PO no and execute
    *again without saving the document enter the next PO no and execute
    *continously do this for all PO's
    *now post the docu - only one material document is created.
    2) * Now you post the invoice in MIRO by entering the first PO and execute.
    Without saving go to the arrow symbol next to the place where you enter the PO no.
    There u enter all other PO no's and execute.
    Now all the PO's cleared in migo will get in the same invoice document. Still dont save the document.
    3) Now the you have to map the cost which have incurred during GR. These costs are called as UNPLANNED COSTS.
    These upc are entered collectively in the header data in the Detail field of the MIRO document.
    You can set how you can post this unplanned costs -- whether to post in Material account or in separate GL a/c. For this you do settings in IMG>MATERIAL MANAGEMENT>LOGISTIC INVOICE VERIFICATION>INCOMING INVOICE>CONFIGURE HOW UPDC IS POSTED.
    Thata it.
    reward if useful.
    yuvi.

  • How to deal with complex SOAP responses when calling web services ???

    Hi all,
    I have an issue when calling a web service that returns a complex
    SOAP response message. With simple responses (e. g. array of strings) it
    worked.
    I created the PDF as an Interactive form with Livecycle Designer 8.2.
    The Javascript looks like this:
    var cURL = "http://blabla";
    var cTestString = "too";
    SOAP.wireDump=true;
    var response = SOAP.request(
         cURL: cURL,
         oRequest: {
              "http://blabla.com/:complete" : {
              arg0: cTestString
              cAction: "http://bla.com:50000/"
    var resp = response["http://blabla.com:serviceResponse"];
    console.println("lenght:"+resp.length);
    var myns = "http://blabla.com/namespace";
    for (var nItem in resp.return)
      console.println("" + nItem + " " + resp.return[nItem] );
         for (var ConceptView in resp.return[nItem])
           console.println("  "+resp.return[nItem].length);
           console.println("  "+ConceptView+" "+resp.return[nItem][ConceptView] );
           if (ConceptView == myns + ":Response")
              for (var item2 in resp.return[nItem][ConceptView]){
                  console.println("    "+item2+" "+resp.return[nItem][ConceptView][item2] );
    I call the service and when I realized that I do not find out the type of the object returned, I used the nested for-in-loops to iterate through it. But it seems that there is just one item in the Javascript object returned, although the SOAP message clearly shows that there are more than one item.
    Can you help me?
    One key problem when analyzing this issue is that I do not know at all
    the Javascript type of response. We suspected it might be an array, but it is not
    because the method .length returns "undefined". It would already be
    helpful to know at least the type of this object and to know callable
    methods and so on ...
    Best regards
    Christoph
    P.S. As mentioned I used Livecycle Designer 8.2 and displayed and
    debugged the document using Acrobat 9.

    Christoph,
    Firstly LiveCycle Designer 8.2 is still not supported to develop forms as per my knowledge. The latest version compatible for SAP Interactive Forms is ALD 8.0.
    There is a difference between Acrobat based forms and LiveCycle forms and based on your coding it looks to me  that you are trying to create a LiveCycle based form with coding of Acrobat which is not supported in LiveCycle Desginer, which is why you may be getting the error.
    I hope that does not confuse you, so may check this [link|http://www.acrobatusers.com/articles/2006/08/designer_or_forms/index.php] for some clear information on what point I was trying to make.
    Chintan

  • Any ideas how to deal with "An error occurred when attempting to change modules."

    Trying to use Lightroom 5; get this message every time I begin. "An error occurred when attempting to change modules," and that's all the further the app will go. Very sad, but WHAT IS THE ERROR? I've uninstalled and reinstalled it four or five times -- a couple through Creative Cloud/Application Manager and a couple by direct download .dmg. I've removed preferences, etc., reinstalled Creative Cloud Desktop, repaired permissions, appealed to the Lord, wished on a dandelion. Nothing.
    Searching for the error I find no information anywhere in the last week or month, and beyond that nothing that applies to version 5.
    I'm on a 2012 Macbook Air (Intel i5), OS 10.8.4, 4GB RAM, plenty of disk space and Camera Raw 8.1 installed if that matters.
    Little help? Thanks.

    See here: http://helpx.adobe.com/lightroom/kb/error-changing-modules-lightroom.html
    See here for where to find the Preference file for your OS: http://helpx.adobe.com/lightroom/kb/preference-file-locations-lightroo m-4.html
    See here for how to go about Replacing the Preference File: http://lightroomers.com/replacing-the-lightroom-preference-file/745/

  • What is the deal with itunes12.1.1 when the computer states the latest software is 11.4

    I cannot sync new iPod nano to my iMac. Manual states to download 12.1.1 but iMac states 11.4 is most uptodate.

    Have a look here >  How to trouble-shoot iOS 7.1 battery problems

  • When I attempt to connect my new MacBook Air to my home network I receive a dialogue that says " Could not join name of network .  A connection timeout has occurred.  Any ideas on how to deal with this?

    When I attempt to connect my new MacBook Air to my home network I receive a dialogue that says " Could not join <name of network>.  A connection timeout has occurred.  Any ideas on how to deal with this?

    Please review the following Apple Support article for assistance with troubleshooting wireless connections.
    You may also find this OSXDaily article helpful as well.

  • How to deal with the barcode?

    i'm developing a file storage system in java, there're two barcode on each file(one is pdf417, the other one is code128) , but now ,there's a problem confused me :
    i use the barcode scanner to scan the file and get images of these files from the scanner , but i have no idea how to deal with these images,
    i need the barcode information on the images, and i know there're some java components can help me to read the barcode from images , for example : BarcodeReader from Barcode Library, but these components were too expensive for me , is there any other way can solve this problem?

    yes, look for a cheaper component...
    Or write your own...
    Or save up until you can afford the more expensive ones...

  • How to deal with images stored in oracle

    hi,
    can anyone help me to solve this issue please:
    in fact i am developping a swing based standalone application based on a TCP/IP client-server connection, so the point is to display on my frame for each student his information and also his personal picture
    first step : storing the personal picture into the oracle database from a specefic frame that allows to specify each NEW student's profile and his photo.
    step 2: as needed, a specefic frame allows to retrieve all the information related to a student and his photo to ( in a jlabel or other swing componenet)
    how to deal with this storing and then the retriving from the oracle DB
    any help please!

    If I understand well your problem, you need your client java application to store and retrive information from an oracle DB.
    This can be done via JDBC.
    Here's the tutorial:
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
    Look at
    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC2018
    for storing and retriving binary data (like java serialized objects (Images for example))

  • How to deal with "Error 1001. The specified service already exists" when install a service using installer package?

    Hi everybody,
    I wrote a "Class Library" project which is a service using Visual Stodio 2008 recently, then tried to use a Visual Studio 2008
    Setup Project to install it.
    Here is what I did for the "Class Library":
    1. Finish the program.cs, Service.cs
    2. Add Installer
    3. Change the serviceInstaller so that "StartType" to be Aotumatic
    4. Change the ServiceProcessInstaller2 so that "Account" to be LocalSystem
    5.
    6. Click in F5 (Start Debugging)
    Here is what I did for the Setup Project:
    1. Add the exe file built from the "Class Library" project to the Application Folder
    2. On the Custom Action Editor, add the exe file from 1 to Install and Commit
    3. Change the property of the project so that "RemovePreviousVersion" to be true
    4. Click on F6(Build Solution)
    Then I tried to run the msi file from the built of the Setup Project. Because I modified the two projects serveral times, I uninstalled the Class Library using "Control Panel->Add or Remove Programs" before I reinstall. Two things I notived:
    1. After unstall, the registry was not cleaned up about the installed program
    2. After several rounds install/uninstall, I got "Error 1001. The specified service already exists"
    My questions are:
    1. How to cleanup the registry when uninstall a program?
    2. How to deal with the "Error 1001. The specified service already exists"?
    3. Did I do anytbing wrong with the "Class Library" or the "Setup Project"?
    Thanks a lot!
    Helen

    Hi Simon, not a problem!
    I spent some more time on this and here are few more notes:
    it is called Major Upgrade, when you are installing new version of the product upon a previous one and
    MSI supports 2 strategies:
    Strategy 1. Install a new version and uninstall previous one. (Install a new version right upon previously installed version (file merging is performed based on dll version number) and the delete previously
    installed files)
    Strategy 2. Uninstall previous version and install a new one (Delete all previous files and install from scratch new files.)
    From the first look it seems that 1st strategy is weird and buggy. But, remember, MSI is great because it's transactional!!! That means that if once some of the phases (Installation, Uninstallation, Rollback, Comit) fails, your machine
    will be reverted to the previous state and it'll be still functional. 
    Let's consider both strategies:
    Consider you have installed product_v1.msi and you want to install product_v2.msi.
    Strategy 1
    1. MSI engine copies files from Product_v1 directory to TEMP directory
    2. MSI engine merges files based on the assembly version (between v1 and v2)
    3. Once merging is completed successfully it removes files in TEMP (RemoveExistingProducts  action triggers it) and you got product_v2 installed, otherwise if it fails MSI engine revert machine to V1 and copies previous files from TEMP.
    Strategy 2
    1. MSI engine tottaly removes all files from v1.
    2. MSI engine installs v2 files and if something goes wrong you cannot revert back, because RemoveExistingProducts  allready worked out and MSI doesn't have files to revert machine back
    I recommend to everybody to use Strategy 1 and leverage MSI transaction functionality. And you can set this strategies by defining sequence of RemoveExistingProducts action. See more info
    here.  So, I think it's not even a bug in VS as I said in the upper post it is default recommened behaviour.
    AND, you got "Error 1001. The specified service already exists"
    because if we follow Strategy 1 MSI engine tries to install Windows Service on top of the existing service and OF COURSE it fails MSI engine (StopServices, DeleteServices actions are executed before actual
    installation and  they look at ServiceControl table). In order to stop service first and delete them you have to fill ServiceContol table of the MSI (and then StopServices, DeleteServices actions will recognize what to they have to stop
    and delete), like this:
    *clip*clip*clip*
    ' see http://msdn.microsoft.com/en-us/library/windows/desktop/aa371634(v=vs.85).aspx for more info
    ' Update the Service Entry to stop and delete service while uninstalling
    query = "INSERT INTO ServiceControl (ServiceControl, Name, Event, Arguments, Wait, Component_) VALUES ('MAD_Service', 'Service name', '160', '', '1', '"
    + componentName + "')"
    Set view = database.OpenView(query)
    : CheckError
    view.Execute : CheckError
    ' Update the Service Entry to stop and delete service while installing
    query = "INSERT INTO ServiceControl (ServiceControl, Name, Event, Arguments, Wait, Component_) VALUES ('MAD2_Service', 'Service name', '10', '', '1', '"
    + componentName + "')"
    Set view = database.OpenView(query)
    : CheckError
    view.Execute : CheckError
    *clip*clip*clip*
    We can uninstall service first by following Strategy 2, but then we lose transactional support.
    So, Simon did I encourage you to change your code a bit?:)
    And, btw, if you don't want to change the strategy, please don't rely on SequenceID in MSI table, it can be change, you have to get the at the runtime.
    Hope it will help to everybody!
    See also more advanced explanation of how MSI works
    here.
    Truly yours, Marat

  • How can flex tell if  it's a mouseup event when the user releases the mouse button outside the flex application?

    how can flex tell if it's a mouseup event when the user
    releases the mouse button outside the flex application? Say for
    instance mousedown was done within a 500x500 embedded flex app but
    mouseup is outside or relased on the HTML background. One more
    thing, when we have something draggable, Flex doesn't execute the
    stopDrag() when the user releases the mouse button outside the
    embedded swf or fles app. Pls. help me with this. Thanks!

    I don't think the flex app can tell what happens outside the
    app. But it can detect when it leaves the app, so I have found the
    following line works fine inside initApp():
    this.stage.addEventListener(Event.MOUSE_LEAVE, yourFunction);
    and you have to:
    import flash.display.Stage;
    Doug

Maybe you are looking for

  • Files needed to be present to use HTML help and Web help

    For using RoboHelp for word generated .hlp files, we kept .hlp and .cnt files in the production environment for the users. Now, we are planning to migrate to Robohelp for HTML help and gradually to WebHelp. In that case what are the files that are re

  • HT201263 my iPod is disable and i want to unlock it without iTurns

    My iPod touch was Stolen and I got it bac but now its disable because he put the wrong code in so many times and now I cant get in it and I dont have iTurns.Please help me someone.

  • Updating iTunes to 7.5

    I know will sound like a stupid question...however, this is the first time I am updating itunes ever since I originally dowloaded itunes for my new ipod. So...since I wanted to update itunes I went to the apple site and it gave me the page where you

  • Connecting an external dvd player

    is there any way of connecting an external (tv use) dvd player to an iBook G4? I understand the latter doesn't have video input...but are there adapter cables one could buy or something? any helpful clues would be much appreciated. thanks

  • My iPod Classic (the older version) will only start up, what to do?

    My iPod Classic (older version) will only start up but as soon as it starts up it turns itself off again and it makes quite a loud clicking sound when it turns itself off, I have had it plugged in for quite a while and in the first 30 minutes of havi