Preventing user interaction during lengthy operation in netbeans
If your module has to do some lengthy operation, then avoid doing it in the AWT thread. This causes ugly repaint problem even though user may not be able to interact with the UI, as it appears hanging with out repainting. The best practice may be to fire another thread to do your lengthy operation, thus freeing the AWT thread so repaint could occur properly (If your operation itself needs to do any GUI operation, then invoke those opreations using SwingInvokeLater). But the problem now is, user can interact with the UI and may create other unpleasant events. Here is a tip on how avoid this.
Before starting the lengthy operation, get the glasspane of the netbeans main window and set it's visibility true. Set the cursor of the glasspane as Cursor.WAIT_CURSOR. Now start your operation in another thread. When the thread finishes, set the visibility of glasspane false and set back the cursor to normal. Put the operation between try .. catch .. finally block to make sure the glasspane is set invisible even if some unexpected exception occurs during the lengthy operation.
Here is a sample code
final JFrame mainWin = (JFrame) WindowManager.getDefault().getMainWindow();
// set status text
StatusDisplayer.getDefault().setStatusText("");
RepaintManager.currentManager(mainWin).paintDirtyRegions();
// set wait cursor to glasspane after making it visible
mainWin.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
mainWin.getGlassPane().setVisible(true);
// Start you operation here
Runnable myOperation = new Runnable() {
public void run() {
try {
// Your operation here
}catch (Exception ex) {
// Report error
}finally{
// clear status text
StatusDisplayer.getDefault().setStatusText(""); // NOI18N
// clear wait cursor
mainWin.getGlassPane().setCursor(Cursor.getDefaultCursor());
mainWin.getGlassPane().setVisible(false);
}
}
};
new Thread(myOperation ).start();
When you make the glass pane visible, it is like a sheet of glass over all the other parts of the main window. Since it is completely transparent, user can still see the parts of main windows, but can not interact with them, until it's visibility is set to false.
Posted at 11:40AM Feb 07, 2006 | Permanent link to this entry
Posted by Geertjan on February 07, 2006 at 01:12 PM PST #
http://www.batteryfast.co.uk/hp/nc8230.htm hp nc8230 battery,
http://www.batteryfast.co.uk/hp/nc8200.htm hp nc8200 battery,
http://www.batteryfast.co.uk/hp/nw8200.htm hp nw8200 battery,
Posted by laptop batteries on October 24, 2008 at 12:28 AM PDT #
If you want to know how to use laptop battery well, You can see it from http://www.adapterlist.com/hp/nc8230.htm hp nc8230 battery,it's very useful .
Posted by laptop battery on February 16, 2009 at 01:34 AM PST #
If you want to know more about laptop bettery,you can see it from http://www.batterygoshop.co.uk/hp/nc8200-battery.htm hp nc8200 battery .
Posted by laptop bettery on February 17, 2009 at 05:08 PM PST #
If you want to know something about laptop betteries,you can see it from http://www.adapterlist.com/hp/nc8230.htm hp nc8230 battery ,It,s very cool.
Posted by laptop bettery on February 25, 2009 at 10:27 PM PST #
Perfect IBM Laptop Accessories and Gadgets
IBM Laptop LCD Hinges : http://www.laptopbattery-usa.com/ibm-laptop-parts-ibm-laptop-lcd-hinges-c-8_88.html
IBM Laptop Keyboards: http://www.laptopbattery-usa.com/ibm-laptop-parts-ibm-laptop-lcd-hinges-c-8_88.html
IBM Laptop Batteries: http://www.laptopbattery-usa.com/ibm-laptop-parts-ibm-laptop-batteries-c-8_29.html
IBM Laptop CPU Fans: http://www.laptopbattery-usa.com/ibm-laptop-parts-ibm-laptop-cpu-fan-c-8_115.html
IBM DVD-CD/RW Combo Drive: http://www.laptopbattery-usa.com/dvdcdrw-combo-drive-ibmlenovo-c-121_127.html
Posted by david2008 on August 17, 2009 at 07:40 PM PDT #
Perfect Laptop Keyboard for Acer HP Dell Apple Sony and more brand
Acer Laptop Keyboards : http://www.ukeyboard.co.uk/acerlaptoppartsacerlaptopkeyboards-c-1_2.html
Dell Laptop Keyboards : http://www.ukeyboard.co.uk/delllaptoppartsdelllaptopkeyboards-c-4_17.html
HP Laptop Keyboards: http://www.ukeyboard.co.uk/hplaptoppartshplaptopkeyboards-c-5_21.html
IBM Laptop Keyboards: http://www.ukeyboard.co.uk/ibmlaptoppartsibmlaptopkeyboards-c-6_14.html
SONY Laptop Keyboards: http://www.ukeyboard.co.uk/sonylaptoppartssonylaptopkeyboards-c-8_26.html
Apple Laptop Keyboards : http://www.ukeyboard.co.uk/applelaptoppartsapplelaptopkeyboards-c-7_10.html
Posted by keyboard2009 on October 13, 2009 at 07:57 PM PDT #