How can i get ProgressMonitor to display while task is going on.

hi can anybody tell me what i'm doing wrong.. I don't understand threads that well. I'm writing ftp client that uploads user files to our ftp.server. My problem is ProgressMonitor hangs until ftp transfer is done before displaying message of the job status... I try to give it it's own thread. but it seems like the process for ftp upload takes higher priority so ProgressMonitor does not get attention til all ftp process is done...
import java.io.*;
import java.util.List;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import sun.net.ftp.*;
import sun.net.*;
* An application that displays a ProgressMonitor
* when the 'Upload' button is pressed. A complex
* 'operation' to upload files and update the monitor
* @author
public class ProgressTestApp extends JApplet {
private JPanel actionPanel;
private String names[] = { "browse..","Upload" };
private JButton choices[];
private JLabel label;
private JTextField FolderpathText;
private JPanel reportPanel;
private String newline = "\n";
private JTextArea taskOutput;
private File pwFile;
private ProgressMonitor monitor;
private String fullpath;
private List mylist;
Thread thread = new Thread();
JFrame frame = new JFrame( "Progress-Monitor" );
private int mini=0;
public int maxi=100;
public int boo=0;
private Runnable runnable;
/** a lable for the lient info text **/
private JLabel getclientLabel()
     if ( label == null )
     label = new JLabel("Directory to upload: ") ;
     return label;
/** a text to show client info */
private JTextField getFolderpathText()
if ( FolderpathText == null)
     FolderpathText = new JTextField (100);
     FolderpathText.setText( " " );
     return FolderpathText;
/** a text to show client info */
private JTextArea gettaskOutput()
if ( taskOutput == null)
     taskOutput = new JTextArea(5, 20);
taskOutput.setMargin(new Insets(5,5,5,5));
taskOutput.setEditable(false);
     return taskOutput;
private JPanel getreportPanel()
if (reportPanel == null)
     reportPanel = new JPanel(new BorderLayout());
     reportPanel.add(getclientLabel(),BorderLayout.WEST);
     reportPanel.add(getFolderpathText(),BorderLayout.CENTER);
return reportPanel;
* Application entry point.
* Create the splash window, and display it.
* @param args Command line parameter. Not used.
public void init() {
// Create a frame with a single button in it.
// When the button is pressed, a thread is spawned
// to run out sample operation.
//JFrame frame = new JFrame( "ProgressMonitor Test" );
//create array of buttons
choices = new JButton[names.length];
//set up panel for buttons
actionPanel = new JPanel();
actionPanel.setLayout( new GridLayout(1,choices.length));
//set up buttons and register their listeners
for ( int count = 0; count < choices.length; count++ )
choices[count]=new JButton(names[count]);
     actionPanel.add(choices[count]);
Container container = getContentPane();
container.setBackground(Color.gray);
container.add( getreportPanel(), BorderLayout.NORTH);
container.add( actionPanel, BorderLayout.CENTER);
// Create a ProgressMonitor. This will be started
// when the Upload button is pressed.
int min = mini;
int max = maxi;
String[] message = new String[2];
message[0] = "Performing Operation.";
message[1] = "This may take some time...";
final ProgressMonitor monitor = new ProgressMonitor( frame,
     message,
     " of ",
     min,
     max );
// This is our sample operation.
final Runnable runnable = new Runnable() {
public void run() {
if( boo == 1 )
maxi=file_utility(pwFile);
int sleepTime = 1000;
for( int i = 1; i < maxi; i++ ) {
try {
monitor.setNote( i + " of " + maxi );
monitor.setProgress( i );                              monitor.setMinimum( i );                              monitor.setMaximum( maxi );
if( monitor.isCanceled() ) {
monitor.setProgress( maxi );
break;
Thread.sleep( sleepTime );
catch( InterruptedException dontcare ) {
monitor.close();
choices[0].addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent event ) {
// Run the operation in its own thread.
pwFile=findfile();
     FolderpathText.setText(pwFile.getAbsolutePath());
     boo=1;
choices[1].addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent event ) {
// Run the operation in its own thread.
          Thread thread = new Thread( runnable );
          thread.start();
          ftp_utility(pwFile);
} // main
/*** Folder locater to find local file to upload ***/
File findfile()
     JFileChooser myFC = new JFileChooser();
     myFC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     int returnVal = myFC.showOpenDialog(new JFrame());
     if(returnVal == JFileChooser.APPROVE_OPTION)
     //JOptionPane.showMessageDialog( null, myFC.getSelectedFile());
     File file = myFC.getSelectedFile();
     //String fullpath=c.getSelectedFile().getName();
     return file;
/***Fi_l_e_s to upload ***/
public int file_utility (File uploadFile)
     int files=0;
     FtpClient fcMyFtp = new FtpClient();
     try
     int ch;
     fcMyFtp.openServer("ftp.abc.com");
     fcMyFtp.login("Anonymous","[email protected]");
     fcMyFtp.binary();
     fcMyFtp.cd("incoming40");
     if( uploadFile.isDirectory())
     if( mylist == null )
          mylist= Arrays.asList(uploadFile.list());
     catch (Exception exception)
     JOptionPane.showMessageDialog(null,exception);
     return mylist.size();
/***FT_P _ ***/
public void ftp_utility (File uploadFile)
FtpClient fcMyFtp = new FtpClient();
     try
     int ch;
     fcMyFtp.openServer("ftp.abc.com");
     fcMyFtp.login("Anonymous","[email protected]");
     fcMyFtp.binary();
     fcMyFtp.cd("incoming40");
     if( uploadFile.isDirectory())
     if( mylist == null )
     mylist= Arrays.asList(uploadFile.list());
     for(int count=0; count < mylist.size(); count++)
     fullpath=uploadFile.getAbsolutePath()+"\\"+mylist.get(count);
     File file = new File(fullpath);
     if( file.isDirectory())
     //file.mkdir();
     //ftp_utility(file);
     else
     TelnetOutputStream out = fcMyFtp.put(file.getName());
     FileInputStream in = new FileInputStream(file);
     int c = 0;
     while ((c = in.read()) != -1 )
          out.write(c);
     in.close();
     out.close();
     fcMyFtp.closeServer();
     //JOptionPane.showMessageDialog( null, "Upload completed...");
     catch (Exception exception)
     JOptionPane.showMessageDialog(null,exception);
} // ProgressTest

First of all, please use the code tags when posting code, especially that much code. http://forum.java.sun.com/faq.jsp#messageformat
The problem is that you need to switch the threads, so you should spawn the ftp process in a new thread, and let the monitor run in the main thread (actually the UI thread). I don't think that's really documented anywhere. I had the same problem the first time.

Similar Messages

  • How can I get iTunes to display the tracks from a CD in their original (album) order?

    To be absolutely honest, I don't really understand what this box is for, so I shall just use it to repeat and expand on my question. (I have already sent a "Feedback" comment on the same topic).
    How can I get iTunes to display the tracks from a CD in their original (album) order?
    It seems to me that there is something very basic wrong with the way iTunes handles CD Tracks.
    Professionally produced CD tracks are seldom if ever in a randomised order. Why then does iTunes seem unable to display the tracks in the order they appear on the original CD source - whether from a personally owned CD or from a download from the iTunes Store?
    Some music demands a specific, non-alphabetic sequence in order to make sense. Why does it seem that iTunes only offers Alphabetic, or reverse alphabetic order - both of which make a nonsense of the original, often intended order of tracks?
    Why not replace the so-called "cover-art" in the bottom left hand corner if the iTunes window - which, while it may look attractive to some, gives the barest of information concerning the original disc, with a list of the original CD tracks in their original order, so that the user can easily reestablish the order in which they should be played.
    As I would expect legibility might be a problem with doing this, why could not the original contents, (in their original order), at least, be displayed when the "cover art" is double clicked-on - the result of which at present gives me an enlarged version of the "Cover Art". While on the subject of the contents of the source disc, what about all the album notes which someone takes trouble to write in order to increase the appreciation of the music on the CD and the listener's general background knowledge of the artists involved. Such notes, it seems to me, have considerable intrinsic value in their own account. I would, I think, normally be prepared to buy such "Sleeve notes" - so long as a "taster" was supplied (as it is for the music) - for something like the cost of a single 'Tune" on iTunes.
    These two aspects let Apple iTunes down enormously, in my opinion. I think that by chopping even quite protracted sequences of music up into bits does no one any favours - except perhaps Apple's already quite substantial bank balance. People have to be aware that two and a half, to three and a half minutes is a very short time to develop a piece of worthwhile music, and that there are many, many composers, not all of whom are alive today who have written music that huge masses of mankind value for the enrichment of their lives and the human condition in general.
    Please make the viewing of iTunes tracks in their correct order by default possible. By all means have the alphabetical variations available as offering a different approach to the music, but not the sole approach to it - PLEASE.
    Frustratedly yours
    Alan Whitaker
    PS I work at my old 24" iMac Intel Core 2 machine which runs OS "Tiger" - because it is more beautiful to look at, the screen is more pleasant to work on, and because, in some ways it is more capable (it will run FreeHand MX without needing a "patch"), than my more recent 21.5" which runs "Snow Leopard". (I don't find it that much slower, either).

    Dear Mike
    Thanks for the support. I am utterly amazed that after all the hype about how good iTunes is that it cannot play a downloaded CD in the correct order, and that what that order should be is not available directly from within one's own iTunes installation. (I know that one can go back to the iTunes Store to check what the order should be, but having downloaded the tracks surely iTunes is clever enough to retrieve this important information.
    My iTunes to differ from yours in that I have also noticed that it seems unable to download copies of my "talking books" in the correct order either. But in my case it downloads them - from a CD - in order, but with the first track downloaded first - so that it appears at the bottom of the column of tracks so that it would get played last! (At least this is, while being inexplicable, a relatively "logical" bit of blundering and because of this is relatively easy to put right!).
    I like many genres of music, some of which are not really programmed except perhaps by the artist performing them. I know that Frank Sinatra was very careful to programme his album songs to obtain a particular effect and in relation to the keys of the music. iTunes presumes to know better.
    Film scores may be totally randomly put together, in some cases, but in others the order is vital to one's appreciation of the music as a whole and how it relates to the plot of the film.
    In symphonic music most works are divided into sections and are conceived by the composer that way. Some individual sections may gain a life of their own if played separately, but they are never complete in the sense that the composer envisaged them without being placed in their proper context.
    Opera and probably most choral music too, is similar except that the words may well become meaningless if the order is changed at the whim of a piece of ill-written computer code, while ballet music has to be heard totally within its sequential context or it becomes meaningless.
    Finally, I would venture that iTunes, by jumbling up the order of the tracks as recorded on a CD, does an immense disservice, not only to the music on a particular CD, but to music in general, by expressing everything in terms of "Songs" - which it seems to interpret as stand-alone items of between 2 and 4 minutes whatever the genre. Even the way the iTunes publicity speaks of how many "songs" it can store instead of how many minutes or hours of recorded sound. This has to be another brick in the wall of "dumming-down" of people's expectations, and the shortening of their attention spans.
    I don't know about anyone else, but I feel betrayed by Apple over this. Perhaps the look, feel and general presentation of an item are not the most desirable features of a consumer product. Maybe it should be judged more on it fitness for the purpose for which it was sold. There is one other possibility - that Apple are trying to redefine "Music" - and that everything that lasts longer than about 3.5 minutes or is in the form of what could for want of a better term be called symphonic in the broadest sense is something else - not "Music" within Apple's new definition, at all!
    Well that's off my chest! now I can get down to creating some sort of order in my iTunes Libraries, knowing that I have to reconsult all the sources in order to confirm the source playing order.
    Anyway thanks again. At least I know that it is not just me
    alanfromthatcham

  • How can I get my desktop display to go to 1440*900?thanks[solved]

    I am using KDE 4,My problem is I can't set my graphics display to 1440*900
    In my searching
    I've found this on the Ubuntu forum, which seems to be my issue. It doesn't matter what I set up in xorg.conf file, it ignores it.
    It references a file called "kcmrandrrc", which doesn't seem to exist on my system. I am not sure where KDE is getting the 320x200, 320x240, 400x300,...,640x480, 800x600 and 1024x768 graphics modes. It's not from xorg.conf.
    I found this file...
    "krandrrc"
    Which contains the following...
    [Screen_0]
    OutputsUnified=false
    UnifiedRect=0,0,0,0
    UnifiedRotation=1
    [Screen_0_Output_CRT1]
    Active=true
    Rect=0,0,1154,768
    RefreshRate=0
    Rotation=1
    How can I get my desktop display to go to 1440*900
    thanks
    Last edited by icywalk (2010-01-27 10:18:30)

    What I was looking for was something along these lines:
    Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    DefaultDepth 24
    Option "NvAGP" "3"
    Option "Overlay" "False"
    Option "ConnectToAcpid" "False"
    SubSection "Display"
    Depth 1
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 4
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 8
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 15
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 16
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 24
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    SubSection "Display"
    Depth 32
    Modes "1280x1024" "1024x768" "800x600" "640x480"
    EndSubSection
    EndSection
    Then you put in the 1400x900 that you wanted in the Modes line.
    If you are to use Xorg -configure successfully, you will need to do it from a console screen.  If you are using like kdm or gdm,  I would suggest that you log out, then go to a console screen (<ctrl><alt><f1>) and then log in to an account.  You will need to su, and then issue the following command to shut down x: telinit 3  that command should shut down X and your login manager.
    After that you can run Xorg -configure and do whatever else you need with it.
    Then, to get back to what you had before, the command telinit 5 should restore you back to your gdm or kdm or whatever.  (Normally <Ctrl><Alt><F7> will get you back to your login manager, if it doesn't try F6 or F8 until you find it.)
    HTH

  • I was at a friends and on Itunes on his computer.. with my apple ID i bought some songs. How can i get those songs onto my computer without going back over to my friends house?

    I was at a friends and on Itunes on his computer.. with my apple ID i bought some songs. How can i get those songs onto my computer without going back over to my friends house? They said i have to have his computer and mine in order to get it onto my computer... well... and on my itunes ID is says i bought them in a recent purchase.

    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • I have 2 iPhone 4s currently.  On one of them the cameria icon shows in the botom left corner of the screen in the lessaging app but not on the other device.   How can I get it to display on the one that it does not show up?  I have tried everything I can

    I currently have 2 Iphone 4 s.  Both are unlocked vervion from Apple.  In the messaging app  the camera icon shows but it does not show on the other.  How can I get it to chow on both devices?  Thanks in advance for your help.
    Chet    [email protected]

    So after looking a bit closer i have noticed that when i have the phone plugged into the computer it shows the songs but when i dont have it plugged in and i go so the song icon on the bottom of the music menu screen it says i have no songs!

  • New Mac Air and HP monitor.  The monitor only displays the background.  How Can I get both to display the same thing?

    I have a new Mac Air and want to use my HP Monitor HPLP2475w to save $$.  I attached it to the Mac Air but all I get is the background of my laptop.  How do I get this to match or use in the dual mode.
    Thanks,

    Hi Jackie,
    Welcome to the Support Communities!  How did you attach the Macbook Air to your HP Monitor?  What cable did you use?  The article below will explain how to setup the display.  Video Mirroring is the option that will allow you to see your computer's display on your HP.
    OS X Yosemite: Connect a display
    http://support.apple.com/kb/PH19035?viewlocale=en_US
    You can easily view the contents of your Mac on a display, like an Apple Thunderbolt Display, or on your TV.
    Connect an Apple Thunderbolt Display: 
    Plug the display’s cable directly into the Thunderbolt port  on your Mac. 
    Connect an Apple LED Cinema Display: 
    Plug the display’s cable directly into the Thunderbolt port  on your Mac. 
    Connect a TV or display with an HDMI connector: 
    Plug the cable directly into the HDMI port on your Mac. For more information about using a TV, see Use your TV as a display. 
    Connect a display with a VGA connector: 
    Use a Mini DisplayPort to VGA Adapter to connect the display to the Thunderbolt port  on your Mac. 
    Connect a display with a Mini DisplayPort: 
    Plug the display’s cable directly into the Mini Display port  on your Mac. 
    After you connect your Mac, the contents of your screen automatically appear on the display or TV. 
    If your display uses a video port that’s not available on your Mac, you may be able to use an adapter to connect your display. For example, If your Mac doesn’t include an HDMI port, you can use a Mini DisplayPort to HDMI video adapter with the Thunderbolt port on your Mac.
    OS X Yosemite: Connect multiple displays to your Mac
    http://support.apple.com/kb/PH19039
    Set up the displays for video mirroring
    Video mirroring shows the entire desktop on each connected display.
    Choose Apple menu > System Preferences, click Displays, then click Display.
    Set both displays to the same resolution.
    Click Arrangement, then select Mirror Displays.
    Enjoy your new Mac!
    - Judy

  • How can I get the username displayed in BW Web-Report?

    Hello all,
    I try to get the username displayed in BW-Report such as 'welcome <username>'.
    Maybe you can give me a suggestion how to do it.
    I appretiate your answer.
    Regards
    Vivian

    you can use the following javascript within the webtemplate to get the user id
    <script language=javascript>
    var user_name ='<object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="TEXTELEMENTS_USER"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_TEXT_ELEMENTS"/>
             <param name="DATA_PROVIDER" value="DP"/>
             <param name="GENERATE_CAPTION" value=""/>
             <param name="ELEMENT_TYPE_1" value="COMMON"/>
             <param name="ELEMENT_NAME_1" value="SYUSER"/>
             <param name="ONLY_VALUES" value="X"/>
             ITEM:            TEXTELEMENTS_USER
    </object>';
    </script>
    Regards
    Raja

  • How can I get my serial number while I'm rebooting?

    I'm trying to reboot my MacBook Pro because it had many problems and things i didn't need but when I try to install OS X Mavericks with my apple id (which is the final step into rebooting your mac) it says "OS X Mavericks has not been purchased" when it has been purchased because I used it on my Mac before I decided to reboot.
    Besides that I'm trying to chat with the apple support group to fix the problem becuase I can't finish rebooting but i need my serial number but I can't get it while rebooting. The only option I have when clicking the apple icon is
    Startup Disk
    Restart
    Shut down
    Can anyone explain how I can my seial number?

    When you are booted into the Recovery HD (This is where you see the option to Install OS X, Run Disk Utility, etc)
    If you look on top, you will see a Utilities menu. Click on that and select Terminal.
    In the Terminal, type in the following code and then hit enter.
    system_profiler SPHardwareDataType

  • How can I get HyperTrend to display the numeric value output of a CHOOSE statement?

    I have non-linear values I need to display on a HyperTrend graph.  I'm currently converting the input raw signal to a Units (Engineering) value and then looking up the actual value (from a calibration chart) using a CHOOSE statement in order to display the actual value on a panel, but I need to display the values output by the CHOOSE statement on a HyperTrend graph, along with other similar values.
    How can I do this?

    I have non-linear values I need to display on a HyperTrend graph.  I'm currently converting the input raw signal to a Units (Engineering) value and then looking up the actual value (from a calibration chart) using a CHOOSE statement in order to display the actual value on a panel, but I need to display the values output by the CHOOSE statement on a HyperTrend graph, along with other similar values.
    How can I do this?

  • When I press the down arrow on the right side of my location bar and history is displayed, how can I get it to display history from most recently accessed site on down?

    When I click the down arrow on the right side of the location bar (without having typed a full or partial URL in, I am just clicking the down arrow) a history dropdown is displayed which shows 12 website URLs that I have visited, but there does not appear to be any rhyme or reason as to what is being displayed. How can I cause this dropdown to display sites visited from the most recently accessed on down? And how can I cause more than 12 URLs to be listed in this dropdown? Why I can't I scroll down through my entire history in chronological order from most recently accessed site?

    Upgrade your browser to Firefox 8 and check
    * getfirefox.com

  • How can I get a new phone while under a contract?

    I got my iPhone 5c in December 2013 and had to get the screen replaced about 4 months ago. It was not fixed by apple. 2 months ago it dropped again and only the top of the phone smashed, though there were no problems and the camera could still be used as well as the screen could still be seen clearly. I am in a 12 month contract and pay $90 a month for my plan. I need to get a new phone, mine won't even let me touch the screen and when it does unlock, I'm lucky to have a minute to try to do what I need before it glitches and begins pressing its own buttons and opening its own apps. I also can't answer phone calls. This is a major problem for me as I really do need my phone. I need to get a new one, how can I do this? Please help!

    Talk with your carrier or get an Out of Warranty replacement for a fee by making an appointment with Apple genius bar.
    Note; Replacement will be the same model, colour and capacity.

  • How can I get Firefox to display details about a JavaScript error when one occurs?

    When in Internet Explorer I can set it up to display JavaScript errors as follows. Select Tools then Internet Options… then the Advanced tab. Under Browsing, find '''Display a notification about every script error '''and be sure its box is checked.
    I cannot find out how to do this in Firefox. I would like for it to display details about JavaScript errors when they occur instead of doing nothing.

    *Web Developer: https://addons.mozilla.org/firefox/addon/60

  • How can I get class's members while editing?

    Hi, all.
    I am creating Java editor.
    In Forte, JCreater, MS's visual studio..
    most editor shows all members of the class you are editing.
    When you declare one method it shows the method name on the member's tree right away. How can I do this.
    Thank you for your considering..

    Or for before they are compiled:
    http://developer.java.sun.com/developer/technicalArticles/Parser/SeriesPt1/

  • How can I get iPhoto to display ONLY file numbers of pictures and not document titles when displayed as thumbnails?

    I am a pro photographer and I've never used iPhoto. I use a combination of Adobe's Bridge, Lightroom & Photoshop programmes.  I've sent a disk of images to a client and they cannot see the file numbers of the images.  Their version of iPhoto only displays the document title that I have embedded in the metadata when importing the images into Bridge.
    When I ran a test and imported the same images into my version of iPhoto(7.1.5, since you ask) some of the thumbnails displayed the file number while others displayed the document title.  Why does this happen?  Can I make it stop?  How do I make iPhoto display just the file number in thumbnail mode and not the document title?
    When I view the images in Bridge, all I see is the file number but I can't convince the client to use the programme even though they have it.  Any help/guidance will be very gratefuly received.
    Many thanks,
    Adam.

    In every version prior to iPhoto 11:
    Select one of the affected photos in the iPhoto Window and right click on it. From the resulting menu select 'Show File...
    In iPhoto 11:
    Select one of the affected photos in the iPhoto Window and go File -> Reveal in Finder -> Original...
    Regards
    TD

  • How can I get iphoto to display my library?

    Here's the situation. My iphoto library is on an external drive and was running on an old version of iPhoto. Moved to a new imac and Mavericks and the new version of iPhoto. I have opened iPhoto and addressed it to my library on the external drive through the 'switch library' menu but it only comes up with the iPhoto start screen and no photos found. I have checked with the 'switch library' dialog and it is definitely the chosen library, I have tried opening with Alt key and re-choosing it but still the same. The library on the external HD now has the iPhoto icon instead of the old folder and has been aggregated into one package rather than the visible file structure of old but I have looked in 'view package contents' and everything is there ready to go. Have tried iPhoto library manager but it says the library is fine and does not need rebuilding for the new iPhoto.
    iPhoto is definitely addressed to this external library. The library is definitely intact and modified by iPhoto. Why can it not display my photos?
    Thanks for any help you can give.

    TRy to
    BAckup your iPhoto library and launch iPhoto while holding downthe option and command keys. Use the first aid window to repair permissions and if necessary rebuild your database
    LN

Maybe you are looking for