How do you change system.out.println colour?

Hi, I am developing some basic rmi client/server applications, I have an 2D array on a central server being read/written by remote clients. all the development is using system.out. statements at the moment (hopefully being replaced by GUI later) my question is when a client remote calls a read operation, and reads an array location, eg x3, y4 I want to print the location contents in a different colour to indicate the read, at the moment the displayArray() simply has nested for loops to cycle through the array and System.out.println statements to get it to the screen. I wonder is there a simple way to change the colour of system.out type statements? thanks for any help

I could be wrong, but I don't think that is possible. The System.out and other streams are just streams of characters, and doesn't contain any data about the characters. You could possibly get it to work if you knew which terminal the stream was going to and if the terminal had escape commands that could set colors. BBS browsers have that functionality, but I think that would be a hard path to follow.
If you are printing out a lot of data and need some color to aid it's readability, try printing directly to your graphic context:
Graphics g = getGraphics();
g.setColor(Color.white);
g.drawString("Hello",100,100);

Similar Messages

  • How does one intercept System.out.println stream.

    If you want some functionality wherein when you call System.out.println - the stream gets written to System.out AND additionally does something else (e.g. send mail).
    AND
    You do not want to write a new class/method to do so and replace all System.out.println in your source base with this new class/method;
    Then how would you be able to achieve this. Thanks in advance.

    Here is the basic code, you may need to tune performance. I havent compiler or tested it, but it should give you a good idea.
    public class OutputStreamCollection extends OutputStream{
    private OutputStream[] outs = new OutputStream[0];
    public synchronized void addOutputStream(OutputStream argOut) {
    OutputStream[] old = outs;
    outs = new OuputStream[old.length + 1];
    System.arraycopy(old,0,outs,0, old.length);
    outs[outs.length - 1] = argOut;
    public syncrhonized void write(int data) {
    for(int i = 0; i < outs.length; i++) {
    outs.write();
    public synchronized void write(byte[] data, int offset, int length) {
    for(int i = 0; i < outs.length; i++) {
    outs[i].write(data, offset, length);
    nor the following code, will print and log to respective files whatever is going to stdout or stderr
    OutpputStreamCollection out = new OutputStreamCollection();
    out.addOutputStream(System.out);
    out.addOutputStream(new FileOutputStream("stdout.log"));
    System.setOut(out);
    OutpputStreamCollection err = new OutputStreamCollection();
    out.addOutputStream(System.err);
    out.addOutputStream(new FileOutputStream("stderr.log"));
    System.setOut(err);
    you can write adapter classes to process the stream in any way you need, like logging with log4J, or sending mail depending on some crieteria.
    Hope it helps.

  • How do you change the slide background colour in the keynote app?

    How do you change the slide background colour in the keynote app?

    You can't (not in Keynote for iOS). The background color is a function of the template selected when you create the file initially and cannot be altered. the only workaround I know of is to add a graphic file to the slide and position it behind all other content, but this would need to be repeated on any slide you wish to "recolor".

  • Changing System.out.println()

    Imagine having hundreds of java classes. In these classes there are many System.out.println(data) in different places. When printing in the console screen I cannot know which java class is printing. Of course I could open every java-file and in every System.out.println() write as:
    System.out.println("This is TheNameOfJavaClass" + myData)
    or
    System.out.println(this.getClass().getName() + " - " + myData)...but I want a nice approach like extending or implenting some how in classes and the java classes add java-class-name when using System.out.println(myData) it becomes className + myData
    Do you have any suggestion? Is there clever approach to this?
    Edited by: Maria1990 on Aug 12, 2010 12:32 PM

    You may have missed the first reply, so here just an example:
    import java.io.PrintStream;
    public class PrefixPrintln {
        private static class Prefixer extends PrintStream {
         public Prefixer(PrintStream ps) {
             super(ps);
         @Override
         public void println(String txt) {
             super.println(findCaller() + ": " + txt);
         // I'm not sure if other print methods will invoke println(String),
         // so you may have to overwrite other print methods as well.
         private String findCaller() {
             StackTraceElement[] elms = Thread.currentThread().getStackTrace();
             for (StackTraceElement elm : elms) {
              String name = elm.getClassName();
              if (!name.equals(this.getClass().getName())
                   && !name.equals(Thread.class.getName())) {
                  return name;
             return null;
        public static void main(String[] args) {
         System.setOut(new Prefixer(System.out));
         new PrefixPrintln().useSystemOut();
        private void useSystemOut() {
         System.out.println("Some message");
    }

  • How to :Logging or System.out.println????

    Hi,
    Iam not able to see any System.out.println output in SAP? where exactly can i see it? any configuration required to enable logging? if so how?? please help

    Hi Sujesh,
    see https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars/using logging and tracing on the sap web as java.pdf pages 12-17 and pages 22-24.
    Also see http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm for portal specific logging issues.
    Hope it helps
    Detlev

  • How do you overwrite System.out.print()

    I am sure there is a way to over write the last entry to System.out.print ?
    I think it is by using an escape sequence (eg \t or \n), but cant work out which letter to use.
    can any one help?
    Simon

    It's \r:
    class Overwrite {
         public static void main(String[] args) {
              System.out.print("Old Text");
              System.out.print("\rNew");
    }

  • How do you change the drill hole colour in ultiboard to no colour

    Hi,
    I need to know how to change the colour of the drill holes to no colour, at present the holes are coloured yellow.

    Hi Linac,
    By Default the drill holes are part of the "board outline" layer.  To change the color of this layer just go into the layers tab of the design toolbox and click the yellow box next to "board outline".   This will bring up a color palette and you can select one of these colors.  I am not entirely sure what you mean by no color but hopefully one of the options in the palette will be satisfactory.
    I hope this helped and thanks for posting your question on the forum,
    Regards,
    Tom
    Applications Engineer
    National Instruments UK & Ireland

  • Turn off System.out.println

    The nohup.out file is getting too big, how to turn off System.out.println without change any coding?
              

    java weblogic.Server > server.out 2>&1
              cheers
              mbg
              "Jen " <[email protected]> wrote in message
              news:[email protected]..
              >
              > How can I capture the System.out on windows?Thanks
              >
              > "Deyan D. Bektchiev" <[email protected]> wrote:
              > >just put the output to /dev/null on Unix/Linux or "nul" on Windows...
              > >
              > >Of course then the output is lost forever and you'll only have the
              > >Weblogic log files to look at any potential problems.
              > >
              > >--dejan
              > >
              > >java guy wrote:
              > >
              > >>The nohup.out file is getting too big, how to turn off
              System.out.println
              > >without change any coding?
              > >>
              > >>
              > >
              >
              

  • System.out.println capture to buffer

    Hi All,
    My application runs other application in back. How can I capture system.out.println() written by another application & display via dialog box.
    Like :execl() or execv() function in C runtime library. Where every printf() message printed to passed buffer.
    Thank you,
    Avin Patel

    If i understand your question correctly, you should execute command for you help.html file. The system will run default browser.
    such as:
    void runBrowser(String file)
    {String cmd = null;   
         Process p;   
              try  {       
                   String os = System.getProperty("os.name");            
                   if (os != null && os.startsWith("Windows")) {           
                        if (os.startsWith("Windows 9") || os.startsWith("Windows Me")) 
                        // Windows 9x/Me               
                             cmd = "start " + file;
    else
                        // Windows NT/2000/XP               
                             cmd = "cmd /c start " + file;
    p = Runtime.getRuntime().exec(cmd);            
    catch(IOException x)
    // couldn't exec browser
    System.err.println("Could not invoke browser, command=" + cmd);
    }

  • How do you change the ugly brown(leather look) at the top of iCal page?

    How do you change the ugly brown colour (leather look) at the top of iCal?

    TT99,
    Try:
    1. MacNix: Change Mac OS X 10.7 Lion iCal and Address Book Skins from Leather to Aluminium - Easy Method
    2. How to remove the faux leather in iCal for OS X Lion | Simple and Usable

  • Is it possible not to use System.out.println?

    Hi guyz,
    Can anyone tell me if there is a way not to use System.out.println but produce the output on the command prompt? I need to add two numbers which are accepted through the args(command prompt). I have to add them and show them on command prompt without using System.out.println. Can ANYONE HELP?

    Hi guyz,
    Can anyone tell me if there is a way not
    s a way not to use System.out.println but produce the
    output on the command prompt? I need to add two
    numbers which are accepted through the args(command
    prompt). I have to add them and show them on command
    prompt without using System.out.println. Can ANYONE
    HELP?Why can't you use System.out.println? What's the reason?
    Kaj

  • Can't run java apps with System.out.println on any builder.

    Hello,
    I'm currently using Vista RC2, which is the immediate problem.
    Classes with System.out.println won't launch the console window. As I'm a student and practicing on these steps, I do have quite a problem on my hands. I click on run, build succesfull, nothing happens.
    I have tried Netbeans and Jcreator, and gave up on trying different builds, as I reckon I'll have to find some other way to counter this; any way to get println messages working in vista?

    It is run as a desktop app, and other runs with commands such as JOptionPane do function, only the println windows don't appear at all. So I think JRE is installed and working.
    I did notice there was one command for input where I'd be able to enter it at the bottom of Netbeans.
    Like just now I clicked build and run for the following code
    import java.util.*;
    public class FirstProgram
        public static void main(String[] args)
            System.out.println("Hello out there.");
            System.out.println("I will add two numbers for you.");
            System.out.println("Enter two whole numbers on a line:");
            int n1, n2;
            Scanner keyboard = new Scanner(System.in);
            n1=keyboard.nextInt();
            n2=keyboard.nextInt();
            System.out.println("The sum of those two numbers is");
            System.out.println(n1+n2)
    }Resulting in a brief flash of "input" in the output window (which is below the coding window) and it dissapears. But this also occurs when I don't include system scanner code.
    Using commands in cmd
    java -jar "C:\Users\Alegis\Netb\MyApp\dist\MyApp.jar"
    Does not yield desired results either. Nothing happens.

  • How does System.out.println(). Work inside src.zip file !

    Hello guyz,
    I was just wondering how System.out.println() worked so i opened up the src.zip file and checked the source code. But could not understand it. As written i remember
    "out is an object encapsulated in the System class."
    Thats ok. But i could not understand the code.
        public final static PrintStream out = nullPrintStream();
        private static PrintStream nullPrintStream() throws NullPointerException {
         if (currentTimeMillis() > 0) {
             return null;
         throw new NullPointerException();
        }Also when i ran the DJ Decompiler it decompiled it to this:
    public class One
         public static void main(String args[])
              System.out.println("hello world");
    import java.io.PrintStream;
    public class One
        public One()
        public static void main(String args[])
            System.out.println("hello world");
    }Also, why does it need to import PrintStream ?

    Peter__Lawrey wrote:
    I was just wondering how System.out.println() worked so i opened up the src.zip file and checked the source code.This value is a place holder. This value is changed as soon as enough of the JVM is initialised for printing to work.
    Also, why does it need to import PrintStream ? It doesn't, but it is used in the code so DJ is including it just in case.Sorry,
    But i don't understand at all.

  • How can I show a System.out.println(""); into a JSP?

    Is a simple doubt that would help me a lot to reach other thing that I wished reach with a JSP.
    Thank you!!!

    Hi!!!
    Thank you to answer me......my question�is because�my problem is a little more complicated��let me tell you�.
    My problem is that I wish to do some queries to a table of a Municipalities DB, I have read about that....and according with the exemples....my JSP...should be running and executing very well....but I haven�t had success with that...:(
    My JSP file is:
    <!doctype html public "-//w3c//dtd html 3.2//en">
    <html>
    <!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
    <head>
    <title>Query of Municipalities</title>
    </head>
    <body bgcolor=#FFFFFF>
    <font face="Helvetica">
    <h1>
    <font color=#DB1260>
    Municipalities List
    </font>
    </h1>
    <%@ page import="
    weblogic.db.jdbc.*,
    weblogic.html.*,
    java.sql.*
    " %>
    <p>
    <%
    Connection conn = null;
    try {
    Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
    catch (Exception e) {
    e.printStackTrace();
    Statement stmt = conn.createStatement();
    stmt.execute("select * from cat_municipio");
    ResultSet rs = stmt.getResultSet();
    while (rs.next()) {
    System.out.println(rs.getInt("cve_municipio") + " - " + rs.getInt("cve_sepomex") + " - " + rs.getString("desc_municipio"));
    stmt.close();
    conn.close();
    %>
    <p>Please call Mary with any updates ASAP!
    <p>
    <font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    </font>
    </font>
    </body>
    </html>
    My result obtained is the following:
    Municipalities List
    Please call Mary with any updates ASAP!
    Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    I don�t obtain nothing.....is like DB table were without information......but in reality the DB table has information.....and I can obtain it with the following JSP:
    <!doctype html public "-//w3c//dtd html 3.2//en">
    <html>
    <!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
    <head>
    <title>Query of Municipalities</title>
    </head>
    <body bgcolor=#FFFFFF>
    <font face="Helvetica">
    <h1>
    <font color=#DB1260>
    Municipalities List
    </font>
    </h1>
    <%@ page import="
    weblogic.db.jdbc.*,
    weblogic.html.*,
    java.sql.*
    " %>
    <p>
    <%
    Connection conn = null;
    try {
    Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
    // Fetch all records from the database in a TableDataSet
    DataSet dSet = new TableDataSet(conn, "cat_municipio").fetchRecords();
    TableElement tE = new TableElement(dSet);
    tE.setBorder(1);
    out.print(tE);
    } catch (SQLException sqle) {
    out.print("Sorry, the database is not available.");
    out.print("Exception: " + sqle);
    } catch (Exception e) {
    out.print("Exception occured: " + e);
    } finally {
    if(conn != null)
    try {
    conn.close();
    } catch(SQLException sqle) {}
    %>
    <p>Please call Mary with any updates ASAP!
    <p>
    <font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    </font>
    </font>
    </body>
    </html>
    and with this JSP I obtain all the following information:
    Municipalities List
    CVE_MUNICIPIO CVE_SEPOMEX DESC_MUNICIPIO
    1 1 ACAJETE
    2 2 ACATENO
    3 3 ACATLAN
    4 4 ACATZINGO
    5 5 ACTEOPAN
    Now...I need that the first JSP work very well, because...with that way...I can do queries and obtain the needed results for showing them in the Browser......
    So, I already find out�.that�any string that I send to the browser with System.out.println(); isn�t showed�.so it is the reason of my question�..how I can see my results of a query using a loop (like a for, while) resolving it....I think my problem would be resolved.
    So...I hope you understand me, and you could help me please...thanks.....
    Mary
    P.D. I also attempted with the following JSP...but the result is the same....I don�t obtain none result...
    <!doctype html public "-//w3c//dtd html 3.2//en">
    <html>
    <!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
    <head>
    <title>Query of Municipalities</title>
    </head>
    <body bgcolor=#FFFFFF>
    <font face="Helvetica">
    <h1>
    <font color=#DB1260>
    Municipalities List
    </font>
    </h1>
    <%@ page import="
    weblogic.db.jdbc.*,
    weblogic.html.*,
    java.sql.*
    " %>
    <p>
    <%
    Connection conn = null;
    try {
    Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
    catch (Exception e) {
    e.printStackTrace();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select CVE_MUNICIPIO, CVE_SEPOMEX, DESC_MUNICIPIO from cat_municipio");
    while (rs.next()) {
    System.out.println(rs.getInt(1) + " - " + rs.getInt(2) + " - " + rs.getString(3));
    rs.close();
    stmt.close();
    conn.close();
    %>
    <p>Please call Mary with any updates ASAP!
    <p>
    <font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
    </font>
    </font>
    </body>
    </html>

  • How can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1

    how can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1

    Hi Nitin,
    Look out the below link, Hope this helps you.
    http://knowledgebase.iplanet.com/ikb/kb/articles/4235.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4699.html
    Regards,
    Dakshin.
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support.

Maybe you are looking for