answersLogoWhite

0


Best Answer

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();

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

AnswerBot

6mo ago

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.

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

Related questions

What is orphan thread meaning in CPU scheduling?

When a particular thread has many dependent thread, and that particular thread is terminated, then all the threads that depends on that terminated thread will no longer belong to something and they will certainly mislead to their each functions. This is what it call orphan thread.


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 do you call a series of emails?

Usually a series of emails on the same topic is called a thread.


Which simple machines are made of other simple machines?

screws have something called a thread, and this thread wraps around the screw. You can call the thread a kind of ramp, because this thread prevents the screw from falling off.


What do you call the thing where you put the thread on a sewing machiean?

A bobbin.


What is the Kannada word for 'thread'?

In Kannada, we would call Daara.


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


How start method call the run method?

I think you're referring to the Thread class, and how calling Thread.start() simply appears to call the Thread.run() method. What happens is that the start() method tells the Java Virtual Machine to actually create and run a new thread. If you manually call the run() method, then your Thread object will execute its code, but it will run like a normal method - that is to say it will not spawn a new thread in the JVM.


What do you call a person that sells small articles such as laces and thread?

A person who sells small articles such as laces and thread is often referred to as a haberdasher.


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.


How do you read a screw thread call out?

This sounds like an easy question, but the answer depends on which type of thread call-out you are trying to read. There are multiple types of screw threads and each has its own call-out; but many are similar in syntax. The most common screw thread style in the USA is the UN-series. These screw threads are specified in ANSI/ASME B.1. An example of a UN-series thread call-out is: 1/4"-20 UNC-2A Decoded it is: Nominal Major Diameter (1/4")-Threads-per-inch (20) Type of thread (UN) Sub-thread-series (C)-Class-of-fit (2A) An example of the M-series thread call-out is: M16x1.5-6g Decoded it is: Type of thread (M) Nominal major diameter (16) Thread pitch (1.5) class-of-fit (6g) For more detailed information here is a link to a nice PDF book which gives very clear basic information on screw threads: http://www.ring-plug-thread-gages.com/ti_starret.pdf. I do hope that you found this information helpful.