Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2006

Tip: Looking for answers? Try searching our database.

jLabel.setText doesn't?

Thread view: 
DevNull - 08 Nov 2006 08:00 GMT
Hello everyone,
I have a Swing program that functions as a wrapper around a command
line program.
As the command line program runs it outputs various status messages.
I'ld like to pump these messages into the GUI specifically a jLabel but
theres a problem.
Try as I might I can't seem to get jLabel.setText(line); to output the
messages even though there is a call to System.out.println(line) that
IS working.

Here is my function, it's a little mangled due to me trying lots of
things to get this to work.  But I think it makes it's point clear
enough...

   private int execMe(String[] args){
            try
           {
               Runtime rt = Runtime.getRuntime();
               Process proc = rt.exec(args);
               InputStream is = proc.getInputStream();
               try{
                       InputStreamReader isr = new
InputStreamReader(is);
                       BufferedReader br = new BufferedReader(isr);
                       String line=null;
                       while ( (line = br.readLine()) != null){
                           System.out.println(line);
                           jLabel3.setText(line);
                           int val = jProgressBar1.getValue();
                           if(val < 100){
                               jProgressBar1.setValue(val++);
                           }else{
                               jProgressBar1.setValue(0);
                           }
                           repaint();
                       }
                       jProgressBar1.setValue(100);
                   }catch (IOException ioe){
                       ioe.printStackTrace();
                   }
               // any error???
               //int exitVal = proc.waitFor();
               int exitVal = 0;
               System.out.println("ExitValue: " + exitVal);
               return(exitVal);
           }catch (Throwable t){
               t.printStackTrace();
           }
           return(1);
   }

Please note the jProgressBar is not working either :(

Any ideas on what else I can do?
Thanx in advance!
Ian Wilson - 08 Nov 2006 09:46 GMT
> Hello everyone,
> I have a Swing program that functions as a wrapper around a command
> line program.

<snip multiposting>

You also posted this in another Java newsgroup and got an answer there.
Since you multiposted (rather than crossposting), people here may be
unaware of that and waste time answering a question that has already
been answered.

> Any ideas on what else I can do?

You could read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
DevNull - 08 Nov 2006 10:01 GMT
Yeah I understand that, I only became aware of the other group after
having posted here.
Then it was a matter of waiting for this post to show up so I could
inform that the solution was found, and was related to threading
issues.
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=437592

Regards,

> > Hello everyone,
> > I have a Swing program that functions as a wrapper around a command
[quoted text clipped - 10 lines]
>
> You could read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.