Solved

repainting issue

Posted on 2002-05-06
9
213 Views
Last Modified: 2010-03-31
I have an applet that pops out a dialogbox. now how can i repaint tha applet when this dialog box is removed. I have so far passed a reference of the applet to the dialogbox and tried to repaint (via {applet}.repaint() ) and then use the update(g) method to paintComponents(g) but it is not working...

even tried repaint(tm) but failed.

Help much appreciated
0
Comment
Question by:aKa
  • 5
  • 4
9 Comments
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
applet is supposed to repaint itself - unless you block the event thread. do you perform any long task immediatelly after closing the dialog box (in the same thread) ?
0
 

Author Comment

by:aKa
Comment Utility
yes...there is a long task after i close the dialog box...should i start the long task in a separate thread perhaps??

0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
> should i start the long task in a separate thread perhaps??

absolutely

0
 

Author Comment

by:aKa
Comment Utility
well that's something that is very difficult for me to implement. This is the program flow:

methodXX()
{
    [#1 perform some tasks, declare method variables]
   
   if(error==true)
   {
        popUpDialogbox()
   }
      [#2 continue task, involves setting and accessing method variables declared above]
}

so now if i include portion #2 in a thread, i can't possibly set any of the values in #1 right? since the run() method of the Runnable class is void, i can't return any value to the method either. Only way is to use static variables??

thanks a bomb for any advice!!
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
Comment Utility
you can always do something like this


methodXX()
{
   [#1 perform some tasks, declare method variables]
 
  if(error==true)
  {
       popUpDialogbox()
  }

  TaskHandler handler = new TaskHandler();
  handler.val1 = ...;
  handler.val2 = ...;
  handler.start();
}


class TaskHandler extnds Thread
{
  public int val1;
  public String val2;
 
  public void run()
  {  
     // task 2
  }
   
}
0
 

Author Comment

by:aKa
Comment Utility
right...!

blimey...you got my points!!

0
 

Author Comment

by:aKa
Comment Utility
but how about passing values from the thread back to the method?
0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
> but how about passing values from the thread back to the method?

just pass the result handler to the Task Thread

class TaskHandler extnds Thread
{
 public ResultHandler resultHandler;
 public int val1;
 public String val2;

 public void run()
 {
    // task 2
    resultHandler.taskCompleted(result);
 }
}
0
 

Author Comment

by:aKa
Comment Utility
actually...i took an easier route....got the Sun Java Plugin and guess what...no more repainting problems!!!

cheers
thx for the help anyways
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now