Display the console during execution

edited November 2014 in Using Processing

Once I exported a program (in my case for win x32/64, if it matters), can I/how do I make the console visible while running it? What I mean with console, to be clear, is that pointed by the giant red arrow.

image

Tagged:

Answers

  • Answer ✓

    It is not possible, AFAIK.
    After export, you get a Windows GUI application, these applications doesn't output data to a console.
    One mean I used is to use a kind of logger, appending text to a file.

    http://bazaar.launchpad.net/~philho/+junk/Processing/view/head:/_SmallPrograms/Email/Logger.java

  • Hm yeah, could expect this, thx for the code...any chance I can still create sorta textboxs or similar on the GUI and get my strings there? Would be easier for users yknow.

  • Answer ✓

    Certainly. Just display it in the window using text().

    String fakeConsole = "";
    void Println(String in){
      println(in);
      fakeConsole = fakeConsole + "\n" + in;
    }
    
    void setup(){ size(400,400); }
    void draw(){
      background(0);
      pushMatrix();
      // Your drawing here.
      popMatrix();
      fill(255);
      text(fakeConsole, 20, 20, width-40, height-40);
    }
    
    int mouseCounter = 0;
    void mousePressed(){
      mouseCounter++;
      Println( "You have pressed the mouse " + mouseCounter + " time(s)." );
    }
    
  • Awesome, thank you.

  • One thing only: the piece of that code I need is basically the void setup {...} + void draw{...} assuming that I don't need outputs based on mousepressed like in your example? I mean, the rest of the code displays on the console which is of no use for what I want, right?

  • edited November 2014

    You can use ACM Java Task Force library ("acm.jar") in order to get a graphics console: B-)
    http://www-cs-faculty.stanford.edu/~eroberts/jtf/


    "library.properties":

    name = acm category=Framework sentence=ACM Java Task Force authorList=[JTF](http://www-cs-faculty.stanford.edu/~eroberts/jtf/) url=http://www-cs-faculty.stanford.edu/~eroberts/jtf/acm.jar version=2 prettyVersion = 1.99.1 (2008-Sep-20)


    import acm.program.ConsoleProgram;
    import javax.swing.JButton;
    import java.awt.event.ActionEvent;
    
    void setup() {
      new ACMButton().start(args);
      //Thread.currentThread().suspend();
    }
    
    void draw() {
      background(0);
      text("Frames: " + frameCount, width>>3, height>>1);
    }
    
    class ACMButton extends ConsoleProgram {
      static final String BTN_LABEL  = "Hi";
      static final String FONT_NAME  = "DejaVu Sans";
      static final String FONT_STYLE = "BOLD";
      static final short  FONT_SIZE  = 24;
    
      void init() {
        setFont(FONT_NAME + "-" + FONT_STYLE + "-" + FONT_SIZE);
        add(new JButton(BTN_LABEL), SOUTH);
        addActionListeners();
    
        println(getTitle());
        println(acm.util.Platform.getJTFVersion());
        println();
      }
    
      void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        if (BTN_LABEL.equals(cmd))  println("Hello there!");
      }
    }
    

Sign In or Register to comment.