free web page hit counter
Sunday Feb 12, 2006

Lengthy process in Netbeans - Sample plugin

In my previous blog Preventing user interaction during lengthy operation in netbeans, I gave a tip on how to use Window.glassPane to prevent the user interaction during lengthy process. Geertjan has requested if I could provide a plug-in, as a context for my tip. So I wrote this small plugin as a sample. You can download the NBM from here. This plugin adds a menu item called "A simple lengthy process" to the Tools menu. This menu item fires a process to calculate some prime numbers. The process takes about 15-20 secs to finish. During that time the user is prevented from interacting with the IDE.

When I was creating the module, I noticed that user could still interact with the UI even after I made the glasspane visible. So I had to do a small trick by adding the following line of code for the glasspane to grab the mouse focus.

mainWin.getGlassPane().addMouseListener( new MouseAdapter() {});

Also I've added the progress indicator at the status bar as shown in the picture below. Adding the progress bar is very easy. All you need to do is to use the Progress API. The code snippet I used is very simple

ProgressHandle handle = ProgressHandleFactory.createHandle("Prime number calculator");
handle.start(100);
int progressValue = <calculated value>;
...
handle.progress(progressValue );


Comments:

Very cool. Could you send me (or make available somehow) the source code of this plugin?

Posted by Geertjan on March 31, 2006 at 08:02 AM PST #

Hi Winston, I've noticed you've done quite some work for the Creator team, This si a little off topic, but in this post you have used the addMouseListener. I am trying to run some complex procedures from a mouseEntered/MouseOver a Static Text, it doesn't like the addMouseListner command, is there a workaround? Cheers, sorry if it's a little off topic, but havn't seen an awnser for this with creator2

Posted by 3P on May 15, 2006 at 09:38 PM PDT #

Hi 3P, this is for a swing application. You can not use mouse listeners in the StaticText (JSF tag). Instead you should use onMouse and onBlur javascript to do similar actions in the StaticText

Posted by 192.18.43.249 on June 16, 2006 at 07:06 AM PDT #

ProgressHandle handle = ProgressHandleFactory.createHandle("User"); handle.start(); for(int i=0;i<10000;i++){ if(i%100==0) handle.progress(i/100); } handle.finish();

Posted by Mayank Patel on October 18, 2006 at 04:32 AM PDT #

i have writen the following code but it is not working please give me the solution, ProgressHandle handle = ProgressHandleFactory.createHandle("User"); handle.start(); for(int i=0;i<10000;i++){ if(i%100==0) handle.progress(i/100); } handle.finish();

Posted by Mayank Patel on October 18, 2006 at 04:34 AM PDT #

http://www.batteryfast.co.uk/samsung/q25.htm samsung q25 battery,
http://www.batteryfast.co.uk/samsung/np-x1.htm samsung np-x1 battery,
http://www.batteryfast.co.uk/sony/pcga-bp1n.htm sony pcga-bp1n battery,

Posted by laptop batteries on October 24, 2008 at 12:00 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed