aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes how to change cursor position in Swing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to change cursor position in Swing?" Watch "how to change cursor position in Swing?" New topic
Author

how to change cursor position in Swing?

rosh skanth
Greenhorn

Joined: Jan 11, 2001
Posts: 3
Hi:
Here is my question.
From my login form, when I hit the OK button, I want to change the default cursor to wait cursor before I pop up the next form. To do that, in my OK() method I have written the first line of code as follows....
public void ok() {

//change the cursor constants
setCursor(new Cursor(Cursor.WAIT_CURSOR));
........other code continues
}
but my cusrsor is not changing when I hit OK button, before I get the next form.
Can any one please answer this with sample code??
thanks
Alagan
Glen Tanner
Ranch Hand

Joined: Apr 16, 1999
Posts: 147

I'm not sure what kind of container you're using, but I found this to work for Windows and Frames (and their children):
[your dialog].this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
[This message has been edited by Glen Tanner (edited January 11, 2001).]
rosh skanth
Greenhorn

Joined: Jan 11, 2001
Posts: 3
Thanks for your reply.
I tried to that. No success.
My login Form class extends JInternalFrame

JInternalFrame
|
XXXInternalFrame
|
XXXForm
|
MyLoginForm.
thanks
Alagan
Glen Tanner
Ranch Hand

Joined: Apr 16, 1999
Posts: 147

Here is a code snippet from my "MyInternalFrame" constructor. (MyInternalFrame extends JInternalFrame)
button.addActionListener
(
new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
MyInternalFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
}
);
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Your problem might be because you are trying to set the cursor on an item that is not visible. From your hierarchy in your problem explanation it seems that you LoginForm will take up the entire width and height of the InternalFrame. Therefore covering the InternalFrame (and maybe the others in between also). It might work if you set the cursor for your 'front' component: LoginForm.
Manfred.
Glen Tanner
Ranch Hand

Joined: Apr 16, 1999
Posts: 147

Umm...that was MY code snippet, not Alagan's.
So, we don't know what Alagan's code looks like until he posts it.
(Size is set earlier, this code actually works for me believe it or not)
[This message has been edited by Glen Tanner (edited January 11, 2001).]
rosh skanth
Greenhorn

Joined: Jan 11, 2001
Posts: 3
Hi:
In the case of JInternalFrame, we have to add the setCursor code to the Top level Component (JInternalFrame). I modifies the code as follows:
getTopLevelAncestor().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
It is working fine now.
Thanks
Alagan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to change cursor position in Swing?
 
Similar Threads
session lost when including another file from another server
Wait Cursor
Need help with wait cursor and setEnable( false )
Reloading the page data
:confused: How to call sql cursors in java ??? Urgent Plz. help...