Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to change cursor position in Swing?

 
rosh skanth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic