Hi Giorgio, There is another solution.
You can have a per frame cursor. A custom long action cursor can be set on that frame. Then for any long action/synchronous server round trip initiated from that frame that custom cursor will be shown. Please see the snippet at the end of this mail. It demos two frames that set different cursors for long actions. In ULC, there is a concept of InputBlocker which blocks input and installs wait cursor on all root panes when a synchronous server round trip is initiated from the client. In the workaround, we install a special root pane with special glass pane that intercepts setting of wait cursor and replaces wait cursor with custom cursor. Let me know if this solution is acceptable to you. Thanks and regards, Janak >-----Original Message----- >From: Zanetti, Giorgio [mailto:[EMAIL PROTECTED] >Sent: Wednesday, August 02, 2006 6:42 PM >To: Janak Mulani >Subject: RE: [ULC-developer] FW: How to change client cursor > > >Thanks for your quick response, > We have looked to the snippet code you have sent me... the >problem is, we want to have the "custom hourglass" behaviour >*every time* the client is waiting for a server's response. For >example, every time the user selects a menu item that triggers an >action on the server, every time a server-side validation is >invoked, etc... and not only for specific operations attached to a button. >To give you a better idea, a client-side roundtrip listener would >be a perfect solution for us. >This is why we tried to work on the event queue. If we were able >to add our own logic to ULC FilteringEventQueue, we could achieve >what we need: we could simply change the cursor as soon as an >interaction event is received (mouse click, etc.). > >Let us know, >Giorgio > --------------------------- import com.ulcjava.base.application.AbstractAction; import com.ulcjava.base.application.AbstractApplication; import com.ulcjava.base.application.IAction; import com.ulcjava.base.application.ULCBoxPane; import com.ulcjava.base.application.ULCButton; import com.ulcjava.base.application.ULCFrame; import com.ulcjava.base.application.ULCMenu; import com.ulcjava.base.application.ULCMenuBar; import com.ulcjava.base.application.ULCMenuItem; import com.ulcjava.base.application.event.ActionEvent; import com.ulcjava.base.application.util.Cursor; import com.ulcjava.base.client.UIFrame; import com.ulcjava.base.development.DevelopmentRunner; import com.ulcjava.base.shared.internal.Anything; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JRootPane; import java.awt.Component; public class HorGlassCursorSnippet2 extends AbstractApplication { public void start() { LongAction longAction = new LongAction(); ULCMenuBar menuBar = new ULCMenuBar(); ULCMenu menu = new ULCMenu("Menu"); ULCMenuItem item = new ULCMenuItem(longAction); menu.add(item); menuBar.add(menu); ULCButton button = new ULCButton("Long Action"); button.setAction(longAction); ULCBoxPane centerPane = new ULCBoxPane(true); centerPane.add(ULCBoxPane.BOX_EXPAND_EXPAND, button); ULCSpecialFrame frame = new ULCSpecialFrame("HourGlassCursorSnippet"); frame.setLongActionCursor(Cursor.HAND_CURSOR); frame.setMenuBar(menuBar); frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); frame.setContentPane(centerPane); frame.setSize(200, 200); frame.setVisible(true); ULCSpecialFrame f2 = new ULCSpecialFrame("Frame2"); f2.setLongActionCursor(Cursor.CROSSHAIR_CURSOR); f2.setSize(200, 200); f2.setLocation(300, 300); final ULCButton button2 = new ULCButton("Long Action2"); button2.addActionListener(longAction); f2.add(button2); f2.setVisible(true); } public static void main(String[] args) { DevelopmentRunner.setApplicationClass(HorGlassCursorSnippet2.class); DevelopmentRunner.main(args); } public class LongAction extends AbstractAction { public LongAction() { putValue(IAction.NAME, "Long Action"); } public void actionPerformed(ActionEvent e) { try { System.out.println("Long Action Started"); Thread.sleep(5000); System.out.println("Long Action Ended"); } catch (InterruptedException ex) { } } } public static class ULCSpecialFrame extends ULCFrame { private int longActionCursor = Cursor.WAIT_CURSOR; public ULCSpecialFrame(String string) { super(string); } protected String typeString() { return UISpecialFrame.class.getName(); } public void setLongActionCursor(int cursor) { longActionCursor = setStateUI("longActionCursor", longActionCursor, cursor); } public int getLongActionCursor() { return longActionCursor; } protected void uploadStateUI() { super.uploadStateUI(); setStateUI("longActionCursor", longActionCursor); } } public static class UISpecialFrame extends UIFrame { private int longActionCursor; protected Object createBasicObject(Anything args) { return new SpecialFrame(); } public void setLongActionCursor(int cursor) { longActionCursor = cursor; } protected void postInitializeState() { super.postInitializeState(); ((SpecialGlassPane)(getBasicFrame().getRootPane().getGlassPane() )).setLongActionCursor(longActionCursor); } public class SpecialFrame extends BasicFrame { protected JRootPane createRootPane() { return new MyRootPane(); } } public class MyRootPane extends JRootPane { protected Component createGlassPane() { JComponent c = new SpecialGlassPane(); c.setName(this.getName() + ".glassPane"); c.setVisible(false); ((JPanel)c).setOpaque(false); return c; } } public class SpecialGlassPane extends JPanel { private int longActionCursor; public void setLongActionCursor(int cursor) { longActionCursor = cursor; } public void setCursor(java.awt.Cursor cursor) { if (cursor.getType() == java.awt.Cursor.WAIT_CURSOR) { cursor = java.awt.Cursor.getPredefinedCursor(longActionCursor); } super.setCursor(cursor); } } } } _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
