0

So i just made a thing where a static function outputs to System.out.println() and a textfield in the JFrame is going to display all of that. But it only shows 13 lines and then everything else is 'below it'. Is there a way to offset the lines without having to delete the first ones?

In case its needed: this is what i use

public static void Log(Object o){
    System.out.println(o.toString());
    targetField.setText(out.toString());
}

//different class (main) happens before any output from the Log() function: 
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final PrintStream ps = new PrintStream(out);
    System.setOut(ps);

    JTextPane console = new JTextPane();
    Debug.init(console, out);
    console.setBounds(0, 0, 400, 200);
    frame.add(console);

etc...

Toreole
  • 33
  • 1
  • 10
  • 1
    You're setting a text component's bounds, **never** do that as that constrains its size artificially and prevents it from scrolling appropriately. If this were my app, I'd use the much easier to use JTextArea, I'd set its columns and rows, not its bounds, and put it into a JScrollPane. Don't use a JTextPane unless you absolutely need to use it. – Hovercraft Full Of Eels Aug 08 '17 at 20:51
  • @HovercraftFullOfEels will try thanks – Toreole Aug 08 '17 at 20:54

0 Answers0