Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2008, 11:21 PM
Member
 
Join Date: Jan 2008
Posts: 4
ludragon is on a distinguished road
GUI cursor change problem
I have a gui that changes the cursor to the hourglass as a certain task is being performed:
Code:
container.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
I thought the code to change it back to the default arrow would be rather simple:
Code:
container.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
but its just plain not changing back to the arrow! I have tried all the Cursor.CONSTANTS, but its stuck on the hourglass and wont change from that. I have debugged and the above code definately gets called. What do I have to do to change the cursor back?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-09-2008, 12:51 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 769
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
ludgragon, try this:
Code:
container.setCursor(Cursor.getDefaultCursor());
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on July 27, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-09-2008, 11:03 PM
Member
 
Join Date: Jan 2008
Posts: 4
ludragon is on a distinguished road
No good, thanks for clarification on the right method to use though. I think my problem is how I coded threading into my program. I am new to threads and don't think I implemented it properly.

I have 2 classes, one GUI class, and one class that is instantiated on a thread to do the actual work, and multiple threads of this same class can be created and working at the same time. The cursor should only change back when all the threads are finished. The only way I could figure out how to prevent using static everywhere, and yet still call on the GUI class from any thread created by the GUI class (to call container.setCursor()), was to create a GUI class instance, and pass the same instance as a variable to the constructor of every created thread.

Code:
private void convertActionPerformed(java.awt.event.ActionEvent evt) { fileNameSelect = leftTextField.getText(); destNameSelect = rightTextField.getText(); frf = new FileReaderFrame(); if (threadcount > 1) { return; } else { PatternRunner pr = new PatternRunner(frf,createAddressTwoFlag,isheader, singlequotequalifier); pr.start(); } threadcount++; frf.container.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); }
This is the method that a thread is supposed to call when finished in the GUI class.

Code:
public synchronized void threadDone() { threadcount--; if(threadcount == 0) frf.container.setCursor(Cursor.getDefaultCursor()); }
Problem is, frf is the reference I pass into the threads, and its also what I use to change the cursor. Changing the cursor with the frf reference instead of the Main() created instance, the cursor doesnt change to the busy cursor as when I just called it in the Main() created instance. A new GUI reference doesn't seem to work, as I can't change all of the GUI variables that netbeans creates to use the reference I created instead of the first instance thats created by Main()

How do I call on the container variable in the Main() instantiated GUI class from my thread classes and not make everything static, and also not having a reference that only some of the objects can use? I hope i worded my question correctly. I am still a newb about static and how to prevent it, especially in threading. It's also possible I am misunderstanding something else entirely. Please correct me if needed. Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change JDK? mew Eclipse 2 12-01-2007 10:43 PM
Using a cursor notnumber6 New To Java 3 11-26-2007 11:56 PM
Is it possible to change the '\n' into ' ' ... johnny7white New To Java 1 11-15-2007 03:32 PM
How to Hide cursor priya Java Announcements 0 11-14-2007 09:27 AM
How to change the resolution ? samson Java 2D 1 07-17-2007 12:15 PM


All times are GMT +3. The time now is 01:05 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org