2 threads in one applet should use paint()

hello,
i'm new to java and my english is bad - so sorry for this.
i read faqs and documentations, but still i don't know.
i've got applet with two threads in it. each thread should independently paint some stuff.
my idea: i need a intelligent paint method, which recognizes the sender.
is it possible to overwrite the paint method?
public void paint(Graphics g, String sender)
all my tries failed. i don't know how to handle the repaint() method.
presumable this idea is not the right way.
so, how can two threads in one applets share the paint() method?
thanks for any help
beste gruesse
jochen

If you employ AWT you should paint in the paint method, overriding it, just like YATArchivist example.
If you employ AWT You must'n override the paint method never or you won't be able to paint properly. you must override the paintComponent() method, the first line in this method must be a call to the parent's method: super.paintComponent() and then put the code for painting. You must call super's methos because it deals with some stuff, like buffering. and (I think but not sure) flickering.
Ehen you want you Swing component to be reapinted never call directly paintComponent method, you should call repaint().
I prefer drawinf in Swing, it deals automatically with the flickering trouble, which you must do by hand in AWT.
About how painting from the threads employ YATArchivist idea: draw in a buffer in each thread, this buffer must be employed by the paincomponent() mehtod, assuming you choose Swing, and after the dawing cll repaint().
Abraham.

Similar Messages

  • RFC and Webservice which one i should use and why?

    Hi,
      I have to write a extractor program in BI which would be fetching a huge data from CRM.
      I have two options to achieve this targer.
               1-> Create a RFC which will give me all the data
               2-> Create a Webservice in CRM and use it in BI
    Please advice me , which way i should go and advantage of that way.
    Regards
    PG

    Hi,
    If amount of data is huge then it is recomnded to use RFC because of its speed and reliability. Webservice not yet proven good for extracting and handling very large chunk of data.
    Regards,
    Gourav Khare

  • Need to paint objects from one applet into another

    Maybe this question is more at home here; I have an applet test program which uses the timer class to make a car drive across the screen. The test works fine with the rectangle I used, but now I need to use the car created in this class:
       import java.applet.Applet;
       import java.awt.Graphics;
       import java.awt.Graphics2D;
       import java.awt.Rectangle;
       import java.awt.geom.Ellipse2D; 
       import java.awt.geom.Line2D;
       import java.awt.geom.Point2D;
         public class Car extends Applet
              public void paint(Graphics g)
                   Graphics2D g2 =(Graphics2D)g;
                   Rectangle body =new Rectangle(100, 110, 60, 10);
                   Ellipse2D.Double frontTire =new Ellipse2D.Double(110, 120, 10, 10);
                   Ellipse2D.Double rearTire =new Ellipse2D.Double(140, 120, 10, 10);
                   Point2D.Double r1 =new Point2D.Double(110, 110);
                   //the bottom of the front windshield
                   Point2D.Double r2 =new Point2D.Double(120, 100);
                   //the front of the roof
                   Point2D.Double r3 =new Point2D.Double(140, 100);
                   //the rear of the roof
                   Point2D.Double r4 =new Point2D.Double(150, 110);
                   //the bottom of the rear windshield
                   Line2D.Double frontWindshield =new Line2D.Double(r1, r2);
                   Line2D.Double roofTop =new Line2D.Double(r2, r3);
                   Line2D.Double rearWindshield =new Line2D.Double(r3, r4);
                   g2.draw(body);
                   g2.draw(frontTire);
                   g2.draw(rearTire);
                   g2.draw(frontWindshield);
                   g2.draw(roofTop);
                   g2.draw(rearWindshield);
         }The only thing I could think of was making an object of type Car in the test program and then doing something like this:
    Car c =new Car();
    g2.draw(c.paint(g));
    But it says in the test program void type not allowed here. Any tips as to what I'm doing wrong? My guess is that its a problem in the Car class and not the test program, but I didn't think I was supposed to alter Car. (Plus I tried already and couldn't get it to work.)

    what? I don't see what you are trying to do..
    You are trying to make an instance of a class which has no constructor?
    You are trying to move a Panel (an Applet is a subclass of Panel) in another Panel (in Test class?)
    Keep in mind that the Panel automatically has flow layout. In flow layout the components are sized to minimum size, and if the component is another Panel, the minimum size is 0 if there are no components in it.
    Do you need both applets open at once?
    Why not just copy this paint code into your test class?
    Also note that you CAN copy the Graphics from one component onto another, but the Graphics object cannot be null, or you will get a NullPointerException... which is what will happen if you try to copy it in the init() of your test class.
    Why not just make your car a Component (or a Panel even) and give it a constructor? (And make sure to set minimum size to something other than zero?)
    I think you have more than one problem..
    Jen

  • I have an external drive - WD My Passport FOR MAC. I want to format it to work on both mac and windows. Which format do you think I should use? Will either one cause damage to the files on the hard drive?

    I have an external hard drive - WD My Passport FOR MAC. I want to format it to work on both mac and windows. I also want to be able to connect it to my TV and watch movies.
    I read up and I think I am supposed to use exFAT or FAT32? I also saw MS-DOS. Which format should I should use? Will any of them cause damage to the files on the hard drive?
    My little memory stick uses MS-DOS and it works on both mac and windows.
    Please can you just tell me a little about each and suggest which one to use.
    I know how to change it once you tell me so don't waste your time writing about changing it.

    Will any of them cause damage to the files on the hard drive?
    WARNING: FORMATTING A DRIVE ERASES IT COMPLETELY !!
    If you need to carry large files (e.g., larger than about 4GB) back and forth, you may need ExFAT. Otherwise MS-DOS works for smaller files.
    The Mac can Read, but not write Windows New Technology File System (NTFS) without an add-on program such as Paragon NTFS.

  • I want to set deadlock priority of a stored proc to low so that when ever any one call it from entity or command object it should use same priority

    Hi,
       I want to set deadlock priority of a stored proc to low so that when ever any one calls it from entity or command object it should use same priority.
    some body sugested to put 
    set deadlockprioirty low 
    go
    exec yourSP()
    but in this case i have to change my bussiness layer.
    is there any other way from database which do the task?
    yours sincerley.

    You can modify your stored procedures and add the code line
    set deadlock_priority low
    at the very beginning of the SP.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Elements 10, windows 8, 64 bit, epson artisan 835 printer: prints are really dark even after using enhancements like adjusting lighting. Prints are darker than photoshop edit screen. Prints are acceptable using paint, windows photo viewer, or gallery.

    Elements 10, Windows 8, 64 bit, Epson Artisan 835 printer: Prints are really dark even after applying enhancements, like adjusting lighting. Prints are darker than Photoshop Edit Screen. Prints are acceptable using Paint, Windows Photoviewer, or Photo Gallery.

    In general theory, one now has the Edit button for their posts, until someone/anyone Replies to it. I've had Edit available for weeks, as opposed to the old forum's ~ 30 mins.
    That, however, is in theory. I've posted, and immediately seen something that needed editing, only to find NO Replies, yet the Edit button is no longer available, only seconds later. Still, in that same thread, I'd have the Edit button from older posts, to which there had also been no Replies even after several days/weeks. Found one that had to be over a month old, and Edit was still there.
    Do not know the why/how of this behavior. At first, I thought that maybe there WAS a Reply, that "ate" my Edit button, but had not Refreshed on my screen. Refresh still showed no Replies, just no Edit either. In those cases, I just Reply and mention the [Edit].
    Also, it seems that the buttons get very scrambled at times, and Refresh does not always clear that up. I end up clicking where I "think" the right button should be and hope for the best. Seems that when the buttons do bunch up they can appear at random around the page, often three atop one another, and maybe one way the heck out in left-field.
    While I'm on a role, it would be nice to be able to switch between Flattened and Threaded Views on the fly. Each has a use, and having to go to Options and then come back down to the thread is a very slow process. Jive is probably incapable of this, but I can dream.
    Hunt

  • New in Java: java applet program using multithreading

    I am trying to write a program, which should move the words "Java Platform2" from left to right every time we 'refresh'.
    Can you please advise what is wrong in the logic??
    import java.applet.*;
    import java.awt.*;
    import java.lang.*;
    public class Ch61appth extends Applet implements Runnable
    int i=30;
    int x=10;
    int y=30;
    Thread t,cur;
         public void start()
              t=new Thread(this);
              t.start();
         public void paint(Graphics g)
              g.setColor(Color.blue);
              g.drawString("Java Platform2",x+i,y);
         public void run()
                   if ((x+i)<400)
                        {     i=i+20;
                        else
                        {     i=20;
              //cur=new Thread.currentThread();
              repaint();

    thanks for reply
    i tried using for loop. Earlier also i had tried using while loop with condition t==Thread.currentThread()
    The problem i am facing is the string just does not move and even after clicking refresh, it appears at same locations.
    CAN U ADVISE>
    bye
    kumar

  • Communication between thread in the same process using file interface.

    Hi,
    I am developing  driver and i need to communicate between two thread.
    >can anyone guide me on implementing communication between two thread in the same process using File Interface. First thread will be driver and second will be application.I need to send IOCTL like commands using File interface ie is WriteFile(),ReadFile()
    from Host process to driver through file-interface(which run's in driver context).Host process should not be blocked for the duration of the driver to process the command.
    >File-interface will run in driver context and it will be responsible to receive command from application and pass it to the driver.
    what are the complexity introduced?
    >Can anyone also give me the link/reference to get more information on this topic?
    >How to replace IOCTL command's for instance baud _rate change command with a file interface for example with IRP.

    Here  is the detailed query:
    Hardware Abstraction Layer will interact with Driver(Both will be running in complete different process) .there is a IOCTL for command and  File interface for read and write.
    My requirement is:
    Both should run in the same process so HAL will run as one thread and driver as another thread in the same process .I don't want HAL to wait for completion of request and also i don't want driver to be blocked .
    We are planning to use a File Interface for communication between Hardware abstraction layer and Driver
    HAL will send the command or read/write operation to a file interface and driver will get the command or read/write request from the File interface
    There is a flexibility to change Hardware Abstraction layer and also the Driver
    Is it possible to use IOCTL between two thread under same process? if not what other options do we have.
    Can we use File interface to  send command (like IOCTL) between two thread?

  • What kind of database driver should use for database adapter  in BPEL?

    what kind of database driver (XA or non-XA) should use for database adapter in BPEL? I have only one database adapter and no JMS.
    Thanks
    Jo
    Edited by: 799095 on Sep 30, 2010 8:35 AM

    Hi
    It depends on wheter you need XA transaction or not.
    See http://www.theserverside.com/discussions/thread.tss?thread_id=21385 third reply.
    If you only have one database and no synchronous dependency to the caller, non-XA should be OK.
    -Johan

  • Lost Page on when you should use MVC vs when you should use web forms

    I read a page last week.  I think it was on MSDN.  It was talking about the relative merits of MVC and web forms.  However, unlike the page http://msdn.microsoft.com/en-us/library/dd381412.aspx,
    which merely states the advantages and disadvantages of each format, this page went on to state something like:
    You should use MVC:
    when building web apps that do this
    when you web app needs that
    when you are doing the other
    You should use web forms:
    when building these other kinds of web app
    when your web app does this other thing
    when your web app does this.
    Does anyone know the page to which I am referring?
    (Oh and since when did it become impossible to paste anything into a question or reply block in MSDN forums.  This makes it very difficult to paste in page links.)
    Also I am not seeing an appropiate forum in my forums dropdown list.  So if a moderator wants to move it to the right forum I would appreciate it.
    Edward R. Joell MCSD MCDBA

    @Darnie Graceline Selvamary Thangalazar
    The first link is not what I was looking for as it tells the difference between MVC and Web Forms but not which is better for what.
    The second link does get more into which is better in certain situations but doesn't really analyze each type of project and specify that this is good for web forms and this is good for MVC.  However, it does provide some ways to analyze if your
    "situation" would be best served by using web forms and which would be best served by using MVC. 
    It specified that if reaction time is an issue then MVC is the answer.  This is good because with our excruciatingly slow network we need apps that take inherantly as little time as possible to load.
    I took another look at the link provided by gaurav.  Turns out that link has a link to an article by Dino Espisito which actually has the statement that I referred to above i.e. if your app has a lot of busines data.  After two years, that
    is as much as I remember of that page.  So in fact indirectly gaurav found the page I was looking for.
    Too bad I did not re-read this link when I started the current project, though.  One thing each of them says is that if your team (in this case me) has not had much experience in handling html elements directly then MVC is not a good fix for them. 
    For the last 6 months theis has been a major learning process in using JQuery, AJAX, and MVC to accomplish tasks which I've could have done using server controls and web forms with my eyes closed.  Too bad they don't make MVC so that you can use server
    controls with it.
    However since this thread is so old and unlike "Whose Line is it Anyway?" the points
    do matter. I am going to award the answer to gaurav.  Thanks everyone for providing some very interesting links on MVC.
    Edward R. Joell MCSD MCDBA

  • When to use Paint over Photoshop?

    Im newer to Photoshop so its easier for me to throw my images into Paint to resize and crop them.
    I was curious if other community members ever use Microsoft Paint for tasks and if so what?
    Also, should I be doing this or would it benefit me to use Photoshop for resizing and croping images?  I plan on using Photoshop but I rarely have it open since I mostly use the development programs within CS5 and it takes magnitudes longer to open Photoshop than Paint.  But even with Fireworks running and the image attended for Fireworks I still through my image into paint because it seems faster.  Am I dumb? Should I give up the paint? Some hot keys for this task probably would be better ahhhh... any insight?
    Thanks,

    I do not think that I have used MS Paint, since about Windows 2.0. I did not even realize that it was still around.
    I just use PS for everything, with the exception of JPEG's, with bum header info, that PS will not open. Then, I just use either ThumbsPlus, or IrfanView, to Open, then Save with proper header info.
    I do not have any data on the Scaling (Resizing) algorithms in Paint, but would think that those in PS would be better. They do offer you a good range of choices, but maybe Paint has similar? Same when Cropping. What part of those operations do you find easier in Paint?
    Though I use PS a lot, and have for a very long time, image editing software is but a tool in a process. Using the right tool, or the one that the artist is most comfortable with, is the trick. I use Painter (now Corel) for a lot of treatments, but almost always finish up in PS. Over the decades, PS has become closer to Painter, than in days past. Still, there are treatments that I want to apply in Painter, and part of those choices will be my personnal comfort level. I might have something very similar in my newer PS, but if I know every step by heart in Painter, my comfort level rises.
    Use what you like for different operations, but I would do a visual check with an operation, like Scale/Resize. Do the same exact operation in each program, using the same base Image, and the same exact settings. Compare the results of the two programs critically.
    Good luck,
    Hunt

  • I cannot open pdf files from one supplier when using Adobe Reader but I can using another Viewer

    I cannot open pdf files from one supplier when using Adobe Reader but I can open it if using Google PDF viewer or another viewer. The Adobe reader gives the error "There was an error opening this document. The file is damaged and could not be repaired" when I try to open the file. The version of Adobe Reader is 10.1.7, however I have tried other versions and they all fail the same way.  I have tested on a number of different PC's in different networks and all fail using Adobe Reader but work using alternate viewer. Also the PC's will open a PDF from any other source.

    Newer Reader versions are more strict than older versions (and other PDF viewers).  If certain minimum requirements are not met, Reader will tell you that the PDF is damaged.  This can happen when a document was created with software that does not adhere to PDF standards, or when the file was damaged during a download or email transmission.
    You should contact the creator of these PDFs.

  • How does one continue to use Mail on the early MacBook Pro, Model 1,1, that is not upgradable to Lion?  I have been running iCloud on my iPhone (OS5) and iMac (Lion) along with the MacBook Pro (OS Version 10.6.8)

    How does one continue to use Mail on the early MacBook Pro, Model 1,1, that is not upgradable to Lion?  I have been running iCloud on my iPhone (OS5) and iMac (Lion) along with the MacBook Pro (OS Version 10.6.8) since November until now.  Mail will no longer download on the MacBook Pro and keeps asking for my password.

    Mail should still be usable with your machine - but you'll need to update the settings to conform to the requirements of your system. Check with your ISP (like ATT, etc.) for the settings that will work with your Mail. Once you've updated this, you should be able to email like before.
    For example, my ISP required that I go to Mail Preferences/Accounts and make sure the details conform to your email settings.
    I have no idea of what your ISP is or what the settings might be, but this is likely the source of the problem.

  • HT204053 I need to use an existing ID (email address) on a new iPhone. It tells me "choose another ID - that one is in use," with the option to "use existing ID," however, it is an endless loop, referring me only to change my password on the existing ID.

    I need to use an existing ID (email address) on a new iPhone. It tells me "choose another ID - that one is in use," with the option to "use existing ID," however, it is an endless loop, referring me only to change my password on the existing ID.
    How do I enable my new device with an existing ID - I do not need to change the password for the millionth time!
    None of the FAQs (or the Community choices below) address new devices, they are all about APPS and iCloud stuff.

    If it is an existing iCloud ID, you should be able to just go to Settings>iCloud and sign in with it.

  • I just bought a new MacBook Pro.  I managed to transfer everything to the new laptop.  BUT I'm having some real problems--e.g., wg from my older one to the new one.  Both use the same latest version of Snow Leopard.  My new laptop has the newer track pad.

    I just bought a new MacBook Pro.  I managed to transfer everything from my older MacBook Pro to the new one.  Both use Snow Leopard, the latest update.
    My new one has the newest trackpad, the old one, no.
    I'm have big problems using Text Edit on the new laptop--the curser does not go where I want it to go for editing, I cannot get the text to be a clear or as large
    as with the older Laptop.  Similarly, I cannot find a way to enlarge the menu bar.  But the text edit is my biggest problem right now.  I have reviewed all the preferences, particularly those in Universal Access, to no avail.
    I finally gave up, used dropbox to send the text edit document to my old laptop, and continued with ease.  But this is not the way it should work.  I bought the
    new laptop because the old one is showing signs of age.....
    Is there something wrong with Text Edit while using the new trackpad? 

    Thanks, Sig.
    The old computer is a 2.6 Ghz Intel Core 2 Duo
    The new one is a 2.3 GHz intel core i7
    In going over this, thanks to "tallking it out" with you, I did discover the Text Edit problem.  Because I've still been unable to get the new computer text size (fonts or whatever) to match the old computer, I did not notice that the curser is now different--the line midway down the curser has to be placed on the line I am working upon, otherwise the edits go elsewhere on the page.  Now, with a bit of difficulty, I am able to get Text Edit to work correctly.
    If you have any ideas as to why my menu bar and Text Edit type are still so slow, I'd love to have them. 
    (I went through the process you suggested earlier, re my Trackpad preferences, and found no improvement.)

Maybe you are looking for