How can I change cursor while it does something?
hi, all
following code dosen't change current cursor.
I want to change cursor to wait_cursor while it opens file,
but, it doesn't change cursor at all.
What's problem?
class aClass extends JFrame{
btOpen.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int returnVal = jfcFileDialog.showOpenDialog(SourceEditor.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
openedFile = jfcFileDialog.getSelectedFile();
setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//read openedFile and return text
String fileContent=readSourceFile();
setCursor( Cursor.getPredefinedCursorCursor.DEFAULT_CURSOR));
thank you.
I finally figured it out. You have to set the cursor on the JFrame's GlassPane. The solution was alluded to in the Evaluation section of a couple of bug reports:
http://developer.java.sun.com/developer/bugParade/bugs/4357573.html
http://developer.java.sun.com/developer/bugParade/bugs/4320939.html
There is also some discussion about this in various Forum threads. (Search for topics using "+getGlassPane +setCursor".)
My corrected code follows. With this method, you don't even need to start up a secondary thread to get the cursor to change. I do, however, because I have other UI elements that I want to be updated (such as a sort indicator on my column headings.) I also reduce the priority of the sort thread a bit so my UI gets priority.
Note that I removed the code that tries to remember the original cursor, since, with all the asynchronous execution going on, the wait cursor could actually be the frame's current cursor when this gets executed. If you're not doing a sub-thread as I am, you don't have to worry about this. Also, I have extended JFrame to JFrameBase to handle threading issues and consolidate redundant code (among other things not pictured here). The JFrameBase class definition follows the example code.
Component lTopLevelComponent = JTableSortable.this.getTopLevelAncestor();
final JFrameBase lFrame;
if ( lTopLevelComponent instanceof JFrameBase )
lFrame = (JFrameBase)lTopLevelComponent;
lFrame.setFrameCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
else
lFrame = null;
Thread lSortThread = new Thread( "JTableSortable" ) {
public void run()
((SortableTableModel)lModel).sortByColumn( lSortCol, lAscending );
if ( lFrame != null )
lFrame.setFrameCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
lSortThread.setPriority( Math.max( Thread.MIN_PRIORITY, Thread.currentThread().getPriority() - 1 ) );
lSortThread.start();
public class JFrameBase extends JFrame {
public void setFrameCursor( final Cursor aCursor )
SwingUtilities.invokeLater( new Runnable() {
public void run()
getGlassPane().setCursor( aCursor );
getGlassPane().setVisible( true );
Similar Messages
-
How can I change country while I still have remaining credit (only $0.12)? I won't allow me to do this.
Click here and request assistance.
(67661) -
I forgot my password along with the answers to my security questions. So I try sending an E-Mail to myself but the E-Mail I am sending it to isn't even mine, nor the one I have registered. How can I change the E-Mail or something?
Security questions:
https://discussions.apple.com/thread/4533485?tstart=0 -
I bought a new 5c and transferred from an old update from my iPhone 4. The only issue I have is the name of my new phone. How can I change it from Amyiphone4 to something else?
settings - general - about - name - make the changes
-
How can I change cursor format in xy graph (LabVIEW 6.1)
I created a XY Graph where the format on the X-axis can be either the number of the data record or the Date/Time at which it was collected (selectable by the user).
Now I can set the format of the X-scale (0 or 7 respectively) but the cursor format will not change, i.e. it will show a large decimal number and no Date/Time if X-scale is switched to Date/Time format via 7.
Any ideas how to achieve it?
I also tried using 2 cursors but apparently both have to have the same format, i.e. one cannot be decimal while the other is Date/Time.
Thanks in advance,
JuergenAh, you have to go in that way. I was looking for something under the Cursors property for the control. Though, I can see why it's not there. Thise are all parameters that you can individually set for each cursor.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
How can i change country while having balance in my account?!
Hey All,
my account is under united states . now i want to change it under my country to add credit card but its not allowing me cause i have balance $0.43 ! and i cant use it to buy any thing so what to do ? i need to change the payment methodIf you are now in a different country then you can try contacting iTunes support and ask if they can remove the balance for you : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page
-
Can You Listen FOR while AS does something else too?
Play and control the playing of a QT movie while also listening with Speech recognitionServer to some word from the user.
i heard AS cant multithread.......An AppleScript doesn't multithread, but there can be multiple scripts running. In any given script it also depends on any results or user interface items used, since targeted applications will be doing their things separately.
-
How can we change delivery document while doing shipment
Hi all,
How can we change delivery document in background while changing shipment document.My requirement is to change the netweight in delivery while doing shipment.Actually it gets blocked when we open the shipment.
Thank You,
Regards,Hi,
if you have done the PGI(Post Goods Issue), you can't change the delivery.
If you want to change the devlivery Qty, you should create the delivery with Partial Split (= X) and you can deliver the splitted qty with a new delivery.
Regards,
Baburaj -
I purchased my iPad in Korea, and while almost everything is in English, my App Store is in Hangul, how can I change it to be in English?
My iTunes was setup in the states, and is setup with a US credit card. I did use my iPad in Korea, but I've been back in the states for almost 4months now, and my App Store is still in Hangul. I've tried changing the language in the international setting in the settings, but I'm not having any luck.
-
I signed up for my apple account while living in Canada, and now I lives in the US. I am looking for a specific app that apparently is only available through the US app store. How can I change my account to the US Apple Store?
As long as you have a form of payment (credit or debit card) with a USA source, and with a billing address in the USA, then you just need to change your payment information on your account to that, change your country in the store settings, and you will then be able to shop in the USA store.
Your AppleID will work in any country's store, as long as your payment source and billing addres are also specific to that country (and you are in that country as well, as there may be IP filters in place to stop use outside of the country). -
When I open a new website, the page does not open, instead it places a tab in the bottom task bar? How can I change the settings so as when I open a new website the page is automatically displayed on my desktop. Thank You!
Tools > Options > Tabs - is the last preference there check-marked??
-
How can i change the font while im coding?
How can i change the font while im coding? I am not talking about the final product and inserting fonts in my documet i am talking about when i am in the progress of coding I want to change the font so it is way more pleaseing to the eye when I am staring at it while coding? please do help and thanks!
Editing the source is a bit of a pain because you'll have to redo it after every update. It's better to write yourself a mini-extension that adds a new stylesheet -- that is also very simple to do. Just follow these instructions: https://github.com/adobe/brackets/wiki/Customize-Your-Code-Font.
- Peter -
Dear All,
we have two apple computers (iMac) in our office. Why does my colleague see my e-mail drafts? How can I change that?Dear All,
we have two apple computers (iMac) in our office. Why does my colleague see my e-mail drafts? How can I change that? -
When I edit my DokuWiki a lot of text is displayed in the textarea. Until Firefox 4 the cursor was always at the beginning of the textarea, which made it easy to scroll down to the part I needed to edit. Now the cursor is always at the end. This is a serious usability nightmare for me. How can I change it that the cursor is at the beginning of the textarea text?
Hello cor-el,
thanks for your answer but unfortunately, this isn't it. I can toggle bidirectional text and the whole text is changed so that it aligns on the right side. But the problem I have is that the text is still aligns on the left side, editing is left-to-right, it's just the cursor that's at the end of the text.
Best regards & thank you
Daniel -
Now that Apple no longer supports AppleWorks, how can I change a lot of AppleWorks files to Pages, without doing them one at at time?
Maybe these?
https://discussions.apple.com/thread/3162022?start=0&tstart=0
http://macscripter.net/viewtopic.php?id=19987
But why if you're running 10.6 do you need to do this? AW works fine in 10.6 with Rosetta.
(BTW, you're in the older iMac PPC forum.)
Maybe you are looking for
-
Cannot install 10.4.3 on my brand new mini
Help! I have a brand-new mac mini OSX 10.4, which is not connected to the internet. It tells me that the HD has 37.1GB, 25.2GB free. I downloaded the 10.4.3 update onto my 256MB "datakey" (USB flash drive) and tried to install it onto my new mini. Wh
-
My ipad is stuck in the united kingdom itunes store and i am getting a message to go back to the u.s. itunes store but do not know how to do it. Any ideas?
-
As far as I understood now.....you have to drag your albums from your Itunes library to your Ipod on your left side (Ipod icon in Itunes). This way you can play it on the Ipod later on. However....Itunes is messing everything up completely. Gives an
-
IMAGE SOURCE PROBS IN GEOCITIES
www.geocities.com/geedsuk on my tshirts page none of my images load up. when i try to upload the image, the image folder comes up but the images that i stored in there for the tshirts page aren't visible..... what's happening? it is crucial i sort th
-
Workshop generated WSDL.
In short when I load a WSDL that Workshop generates into XMLSpy , SoapScope , and Cape Clear Studio 4 the file shows up as invalid. So when I tried to generate a WSDL with Cape Clear Studio 4 using the same input and out put parameters for the previo