System.out console in GUI

hi i'm constructing a GUI for one of my programs using the swing librarys however i cant figure out how to display the system.out's. I really have no idea how to do it or i would post how im trying to or usual if anyone knows a better way to print strings (an undetermined number of strings this is) to a GUI please let me know

Hi,
Why are you using System.out combined with Swing? Just print text to some text component instead (e.g. JTextArea, see the javadoc for that class for more info)
Kaj

Similar Messages

  • System.out.println in gui--- question

    Hello People.
    First of all, I'm new to the forums, so if it doesn't belong here, plese tell me where to post questions like this.
    The Problem:
    I have a GUI and another class,which contains the Program.
    Here's the code of my class:
    int Battle(String CharName) {
              System.out.println(CharName + " Is fighting agains a monster");
              while (CharHP > 0 && MonsterHP != 0) {
                   MonsterHP = MonsterHP - CharDmg;
                   System.out.println("The monster has " + MonsterHP + "Hitpoints left ");
                   CharHP = CharHP - MonsterDamage;
                   System.out.println(CharName + " has " + CharHP + " Hitpoints left");
              if (MonsterHP == 0) {
                   System.out.println(CharName + "Has lost the fight!");
                   CharEXP = CharEXP + 20;
                   System.out.println("You have gained " + CharEXP + " Exp");
              if (CharHP == 0) {
                   System.out.println("You have lost the fight!");
              return CharHP;
         }So what would be the code to print all the "System.out.println's" here into the gui test area?

    camickr wrote:
    Check out the [Message Console|http://www.camick.com/java/blog.html?name=message-console].
    Just out of curiosity, how do you come up with ideas for all the awesome stuff on your blog?

  • System.out console output CP1252/CP850

    I've been trying to write something to receive XML as 'messages' through a socket connection and, in order to see better what's being parsed, I've been writing the elements and data to System.out so I can see the values in the console window (this is Windows XP).
    The problem I get is that when the client passes German characters such as '�' (o-umlaut), they don't get displayed correctly on the console window - the character that actually gets displayed is '�' (division sign?) - even though the correct value DOES (as far as I can tell) find its way into my Java String object.
    I've investigated this a bit and I find that if I 'force' the output to use encoding 'Cp850' (OEM - Multilingual Latin I) then it works correctly (I do this by creating an OutputStreamWriter object with that encoding and based on System.out and then I create a BufferedWriter based on that OutputStreamWriter).
    If, however, I explicitly use Cp1252 (ANSI - Latin I) then I get the original problem. I don't understand this because as far as I can tell, Cp1252 included the '�' character as code 246, which is the one I'm passing to it.
    It also may (or may not) be significant that my file.encoding property is set to 'Cp1252' but when I override this using the java -D command option, I get the correct result.
    So, in essense, my question is: why does Cp850 work but Cp1252 not work?
    Thanks in advance for any help
    Regards
    John

    I could do, but that's not really a problem - I've already got the 'work around' I need using Cp850. I just want to understand WHY it does what it does, because it seems to me that Cp1252 should work as well.

  • System.out.println not showing up in the console

    Hi,
    I've some System.out.println statements in a static block in a Stateless
    Session Bean. I could not see these outputs in the Weblogic console. I'm
    using Weblogic 5.1 Any one faced this problem before? any help is
    appreciated.
    Thanks & Regards,
    Nithi.

    Take a look in the weblogic log files they might be redirecting std out.
    "Ryan LeCompte" <[email protected]> wrote:
    >
    Hello Nithi,
    I'm all out of ideas, unfortunately! However, check out the following
    links for
    some possible insight into the problem:
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=60&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3d3df18e%40newsgroups.bea.com&rnum=69
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=70&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3977417b%40newsgroups.bea.com&rnum=71
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=200&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3bc20346%241%40newsgroups.bea.com&rnum=209
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi Ryan,
    Thanks for your reply and sorry for the long silence. I was on vocation.
    Thre problem still remains.I'm very sure that the EJB
    is deployed by WebLogic as I'm able to call some methods.
    and I'm also calling EJB methods from Servlet. But my
    System.out.println statments work fine in the Servlet and
    not inside EJB (or anyother classes used by EJB).
    Any one has faced similar problems? BTW am using WebLogic 5.1
    Thanks in advance,
    Regards,
    Nithi.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    Hello Nithi,
    I find it strange that your System.out.println statements are beingexecuted from
    within your servlets, but not in your stateless session bean. Are
    you
    positive
    that your EJB is being located and deployed by WebLogic? The statementsin
    your
    static { } block should be executed as soon as the WebLogic class
    loader
    finds
    the class and loads it into the JVM. I would suggest examining theconsole
    and
    try to determine if your EJB is in fact being deployed. Are you invokingmethods
    on the EJB inside of your servlets? Are you using any logging frameworkfrom within
    the EJBs which would redirect output to a file?
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi Ryan,
    Thanks for your reply. The setting in the weblogic.properties is
    as
    follows.
    weblogic.system.enableConsole=true
    So, that tells me that I should see all the System.out.printlns right?
    (Pleasecorrect me if I'm wrong). I can see all the System.out.println
    from
    my
    servletand not from the Session Bean (even if the System.out.println
    is
    outside
    static block).
    Please let me know your thoughts.
    Thanks & Regards,
    Nithi.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    Hello Nithi,
    Are you sure that you don't have WebLogic configured to redirect
    all
    messages
    to a file instead of the console? Are you able to see yourSystem.out.println
    statements when placed within other methods of your stateless sessionbean? Please
    be a bit more specific.
    Thank you,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi,
    I've some System.out.println statements in a static block in a
    Stateless
    Session Bean. I could not see these outputs in the Weblogic console.
    I'm
    using Weblogic 5.1 Any one faced this problem before? any helpis
    appreciated.
    Thanks & Regards,
    Nithi.

  • What does System.out.println("Hello world!");  when System.console()=null?

    Hello,
    the code below:
    if(System.console()!=null)
                outStream=System.out;
            else
                outStream=new PrintStream(new FileOutputStream(new File("BasicCardReaderManagerLog.log")));
            outStream.println(System.currentTimeMillis());
            outStream.println(System.out.toString());produce the following output, in the BasicCardReaderManagerLog.log file:
    1249991451796
    java.io.PrintStream@190d11
    So it looks like System.out is valid and usable, however, since the application as no console, where I can see the output ???
    Precision: I get this situation in the main function of a console application which I launch using Process.Start. Is there any way to get a console by this mean ?
    Best regards,
    Sebastien

    Based on [http://forums.sun.com/thread.jspa?messageID=10790600#10790600|http://forums.sun.com/thread.jspa?messageID=10790600#10790600]
    import java.util.*;
    public class Java {
         public static void main(String[] arg) throws Exception {
              String[] cmd = { "cmd.exe", "/C", "start", "java.exe" };
              List<String> l = new ArrayList<String>(Arrays.asList(cmd));
              l.addAll(Arrays.asList(arg));
              cmd = l.toArray(cmd);
              Process p = Runtime.getRuntime().exec(cmd);
    }

  • GUI - Displaying system.out

    Hello
    I am creating a database application in Java. When an user enters an invalid query several of my class-methods call the System.out.println method. I was wondering if there was an easy way of redirecting all these print statements to a JTextArea in my JFrame(GUI)-to act like a small debug window :s
    Any suggestions would be greatly appreciated

    I answered something like this before
    try here: http://forum.java.sun.com/thread.jsp?forum=31&thread=403289&message=1762839#1762839
    Basically what you have to do is:public class JTextAreaWriter extends Writer
      protected JTextArea writeTo;
      public JTextAreaWriter(JTextArea writeTo)
        if (writeTo == null) throw new NullPointerException();
        this.writeTo = writeTo;
      public void close() {}
      public void flush() {}
      public void write(char[] cbuf)
        writeTo.append(new String(cbuf));
      public void write(char[] cbuf, int off, int len)
        writeTo.append(new String(cbuf, off, len));
      public void write(int c)
        writeTo.append((char)c + "");
      public void write(String str)
        writeTo.append(str);
      public void write(String str, int ofs, int len)
        writeTo.append(str.substring(ofs, ofs + len));
    System.setOut(new PrintWriter(new JTextAreaWriter(myJTextArea)));You can also use System.setErr in the same way, with a different JTextArea
    HTH
    =====
    Phlip

  • Where do Java Embedding "System.out.println()" go? Where is Java Console?

    Assume I embed a "Java Embedding" object in a BPEL process
    and write the following Java code into it:
    System.out.println("Hello BPEL");
    where does this text go when executed? If I remember it well there must be somewhere an AppServer console.
    But where is it exactly ?
    Peter

    Hi Peter,
    The out stream is generally redirect into files in applications servers.
    OC4J : $ORACLE_HOME/opmn/logs/<your_group>~<your_home_name>~<your_group>~1.log
    WebSphere : $LOG_ROOT/SystemOut.log
    JBoss : $SERVER_LOG_ROOT/server.log
    Hope this helps.
    Regards,
    Raphaël
    http://bpelsoa.blogspot.com

  • Java - Eclipse debug applet with System.out.print in jboss console

    I use System.out.print to debug my java programs using Eclipse. I'm new
    with applets, and when nothing showed up in the applet window, I tried
    using print statements. I was expecting to see them in the jboss console like
    always, but there was nothing there. I tried looking this problem up
    online and found nothing. Does anyone know how I can use print
    statements to debug my applet? (Japplet to be specific).

    System.out.println works for me. The output statment are visible in the Console Window within Eclipse.

  • How to print to console with out using system.out.print

    Hi All
    Is it possible to print the text to console with our using System.out.println(). i done as follows but i does not worked
    import java.io.*;
    import java.util.*;
    public class myclass
         public static void main(String[] args)
              BufferedWriter br = null;
              try {
                   br = new BufferedWriter(new OutputStreamWriter(System.out));
                   br.write("Myclass123",0,10);
              } catch (Exception io) {
                   io.printStackTrace();
    so it will be appretaible if any body helps me in solving this question

    i am using sysstem.out to specify that out put
    generated should be pumped to console inted of file.
    i mean system.out will lead to the console. thats why
    i used that. as Either I have no idea what you are talking about, or you have no idea what I am talking about when I refer to writing to File "con".
    suystem.in means keyboard.Actually, it means "the system's standard input stream, wherever it may come from".

  • Using same line in Console/Screen System.out.println()

    Ok next small prob, and then thats it lol,
    Let's say if I want to print something out to the screen...
    And after that print something again on the same line...
    So, sorta like refreshing the line.
    I can't figure it out because System.out.prinln() jumps to the next line.
    Thnkx in advance
    Robert

    public class Switch
        public static void main(String args[])
            try {
                for(;;){
                    System.out.print("Hello   ");
                    System.out.flush();
                    Thread.sleep(2000L);
                    System.out.print("\u0008\u0008\u0008\u0008\u0008\u0008\u0008\u0008");
                    System.out.print("Good Bye");
                    System.out.flush();
                    Thread.sleep(2000L);
                    System.out.print("\u0008\u0008\u0008\u0008\u0008\u0008\u0008\u0008");
            catch(Exception ex) {
                ex.printStackTrace();
    }

  • Need to hide System.out.println output in console

    class Hide{
    public void test(){
    System.out.println("hai");
    public static void main(String[] args){
    Hide obj=new Hide();
    obj.test();
    Output is : hai
    But I don't want to display hai. How i can hide this
    kindly help me on this........

    class Hide {
         public void test() {
              System.out.println("hai");
         public static void main(String[] args) {
              System.out.println("before");
              java.io.PrintStream old_out = System.out;
              try {
                   java.io.PrintStream pw = new java.io.PrintStream("test.txt");
                   System.setOut(pw);
              } catch (java.io.IOException e) {
                   e.printStackTrace();
              Hide obj=new Hide();
              obj.test();
              System.setOut(old_out);
              System.out.println("after");
    }

  • System.out  View Console via Unix box/ Command Line

    I am dumping messages to System.out. When I package it and run it as a service, I can drop this to an out file. When I just run the jar file from the windows command line or from a Unix box it runs silently. Is there a way to have the System.out dropped to a file in this scenario or better yet shown on screen?
    Once I run the jar file how do I kill it without killing the process?
    Thanks

    Fanbladeus02 wrote:
    "Killing a jar file..." I don't want to kill the Jar file itself, but I do want to stop it from running after I launch it.Then you mean you want to kill the process which is using the jar file.
    >
    Example from my unix prompt I do something like this:
    java -jar -classpath </home/user/jarprog/> /home/user/jarprog/JARPROG.jar jarprog.Main.java
    I don't see any output, it just drops to the next open prompt. This means the program has finished. It could have started another one which does the real work, but you have no control over it.
    I assume java is still running my jar file somewhere. (My first thought was) That is very unlikely unless the writers of the code have gone to great lengths to hide another running process from you. (But reading further this appears to be the case)
    How do I stop it? Find the process with "ps" and send it a kill signal.
    Once I start the program how do I interact with it to stop it?ctrl-C, but you cannot kill it after the prompt has returned because its not running any more. (it started another process and then bailed)
    Similiarly in Windows, I run it from the command line it drops to the next "c:\". I look in task manager and see java running. It appears your program starts another java process in the background.
    I look in the database that it is updating and the records are flying in. If I end the process, the records stop flying in (DUH). Again how do I interact with it to gracefully end the process?It appears that whoever wrote the program has gone to some lengths to prevent you from doing that. I would ask them.

  • System.out will not flush before input

    Hello everyone,
    I am using Netbeans 5.5, JDK6, and J2EE. I am new to the environment so I wrote a test application that would prompt a user to enter a string and then echo it. I have:
    String str = "";
    BufferedReader br = new BufferedReader(new nputStreamReader(System.in));
    System.out.print("Enter a string: ");
    System.out.flush();
    try
    str = br.readLine();
    catch(IOException ex)
    System.out.print(ex.toString());
    System.out.print(str);
    What is really bizarre is that System.out will NOT flush no matter what. My application will always ask for input before it even prompts the user for the string. This is what the output looks like when running:
    init:
    deps-jar:
    compile:
    run:
    hello
    Enter an string: hello
    BUILD SUCCESSFUL (total time: 5 seconds)
    Notice how I had to enter the string first? The only way that I have seen that it flushes is if I used println() instead of print. But what if I don't want the prompt to have an end line in it. This just seems like weird behavior. Also, I have tried using a Scanner for input and the results are the same. Not really sure what to do. Any help would be most appreciated. Thanks.

    are you running this inside netbeans as well? the "console" view in netbeans (and eclipse, and probably other IDEs) is not a real console, it's a GUI component that the IDE writes to. it's behaviour isn't guaranteed to act like a real console. I've seen this sort of thing on eclipse before, but never used netbeans. but it still stands that an IDE's console view isn't an actual console/terminal window. that may well be the root of the problem

  • Redirect, System.out  ?

    Hi.
    I want to redirect System.out to a Swing Component like JTextArea, etc.
    try with printstream, Reader, etc. but i dont know how.!.
    I want to see, messages (The standard out) in a Swing Component.
    plis some help..
    tnks.

    I was using the Redirect method you made edna for my software and it works wonderfully when using strings, unfortunately I ran in to a strange problem which is fitting since my current objective is very strange.
    I am writing a piece of software that has an embedded jython interpreter in it. When I execute my jython scripts all the output went to the console and I had no direct way of saying append to this particular text area since I wasn't able to pass my Java GUI class in to the script.
    Thus redirecting my output with your method came in quite handy. This is where the problem comes in. I tried the println function in my regular java classes and all the primitive types worked fine, but within in the script only String worked. Here is the code for the println function
    PrintStream stdout = new PrintStream(System.out) {
       public void println(String x) {
          outputTextArea.append(x + "\n");
       public void println(int x) {
          outputTextArea.append(x + "\n");
       public void println(boolean x) {
          outputTextArea.append(x + "\n");
       public void println(Object x) {
          outputTextArea.append(x.toString() + '\n');
    };Here is the sample Jython code:
    import JythonScripter
    System.out.println(4) #fails to print correctly
    System.out.println("HelloWorld") #works
    System.out.println(10) #fails
    System.out.println("Goodbye Cruel World") #works
    If you have any advice on why strings would work but not other types I would greatly appreciate it.

  • Sustitution of System.out.println in Graphical mode

    Dear Sirs:
    I am changing my applications to graphical mode. I would like to know what is the command that substitutes System.out.println in graphical mode. Thanks in advance

    I am not sure exactly what you mean when you say you are changing your apps to graphical mode,
    I assume you will be using Swing?
    If you will be using a gui in the place of a command prompt program, you may need to completely redesign your app (I'm not sure I can help you with that).
    In a Java applet, and application, you can still use System.out.println. It will print to the console while your app runs. I use it pretty often for simple debugging (Although I use JBuilder and the option for the execution Log, if you are in windows and expect the size of the errors to be large an don't have something like this, you may want to run the output into a file using the IO package).
    Hope this helps you,
    Dan Hughes
    Dear Sirs:
    I am changing my applications to graphical mode. I
    would like to know what is the command that
    substitutes System.out.println in graphical mode.
    Thanks in advance

Maybe you are looking for

  • Using Multiple iPhoto Libraries

    Hi, I just got a new macbook pro. I have photo libraries on two other machines that I transferred over. I would rather not spend money to merge the libraries but every time I switch from one library to the other it duplicates the pictures in the "all

  • Converting Files to Adobe PDF

    Hi Guys, I am running Windows XP SP 3 on all 120 computers in my workplace. We use Adobe Acrobat 8.0 / 9.0 on most of our computers. We have the print to pdf functionality and use it quite extensively. I have been having this problem since day one an

  • Anyone successfully installed SOA [Advanced] & Service Registry 10.1.3.1 ?

    Hi all, has anyone found a reproducable process for a clean install of: - Oracle Database 10g Express - SOA Suite 10.1.3.1, advanced install (as required by Service Registry) - OracleAS Service Registry 10.1.3.1, standalone all on a single Win XP mac

  • How to insert into a nvarchar2 column

    Dear all, I am using a UTF8 database and I like to create a table with nvarchar2 datatype. However, when I insert data into the table, no matter what character, error prompts. ERROR at line 1: ORA-12704: character set mismatch Any parameters I need t

  • How come I can't shuffle a specific genre anymore?

    Yeah I remember in the lastest iOS 6 version the option to shuffle a specific genre of music was always available now you guys took it off, how come??? Sometimes I want to hear just electronica and other times maybe hip hop. Please fix this problem a