answersLogoWhite

0


Best Answer

To call repaint using a thread in a Java applet, you can use the repaint method directly within the run method of a Thread or within the run method of a Runnable that is executed by a Thread. Inside the run method, you can call repaint to update the applet's graphics. For example:

public void init() {
   // ...
   Thread thread = new Thread(new Runnable() {
      public void run() {
         // Perform background tasks
         // ...
         repaint(); // Call repaint to update graphics
      }
   });
   thread.start();
}

Alternatively, you can also extend the Thread class itself and override its run method to include the repaint call.

User Avatar

AnswerBot

2mo ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

You call the repaint method the same way you'd call any other method from a thread.

final Applet appletToRepaint;

new Thread() {

public void run() {

appletToRepaint.repaint();

}

}.start();

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you call repaint using thread in java applet?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How are arguments passed to a function?

Arguments are passed to functions via the thread's function call stack. Every thread has its own call stack, which is a small region of contiguous, fixed-size memory that extends downwards into lower addresses. The stack is allocated when the thread is instantiated and deallocated when the thread terminates thus there is minimal cost in using the stack. Data is pushed and popped from the stack while a stack pointer keeps track of the top of the stack (the lowest unused address).


What happens to child thread when you delete main thread during run-time?

In Java, if the main thread somehow exits then all other threads will stop executing. This generally does not happen, as the main thread will wait for all child threads to terminate before the main thread itself finishes. Interrupting this process is hard to do short of an un-handled exception or a call to System.exit. If the child thread is also a daemon thread, then the child thread will continue to execute. If the child thread is a normal thread then, the moment System.exit is called, the child thread also terminates If you call the join() method from the child thread, then the main thread will wait until the child is over before executing the System.exit


What is the name of the method used to schedule a thread for execution?

"start" You've created a Thread object and it knows its target. Now it's time to get the whole thread thing running. It's pretty straight forward: t.start(); Prior to calling start() on a Thread instance, the thread (when we use lowercase t, we're referring to the thread of execution rather than the Thread class) is said to be in the new state as we said. The new state means you have a Thread object but you don't yet have a true thread. So what happens after you call start()? • A new thread of execution starts (with a new call stack). • The thread moves from the new state to the runnable state. • When the thread gets a chance to execute, its target run() method will run.


What is the difference between paint and repaint methods of java?

The paint method is where actual painting occurs. If you want to change the way a Component is drawn, you should override this method. The repaint method typically just tells your Component that it should call its paint method as soon as it can. This is the method you should call to force a Component to update itself. The Java API warns not to ever directly call the paint method, mostly for efficiency reasons.


What does the A signify in the thread call out of 250-20UNC-2A?

A refers to the external thread of a screw or bolt. B means internal thread, specified for nuts and inserts. For example a 2A bolt uses a 2B nut