0

I am trying to add a simple console as a panel, but I don't get it working (have a look at the end of the code):

super.setSize(600,4*46);    
super.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
pane = super.getContentPane();
GridLayout flo = new GridLayout(4,1,20,2);
pane.setLayout(flo);
pane.setBackground(grey);

// 1: STOP button
JPanel row_cmd = new JPanel();
FlowLayout flo_row_cmd =  new FlowLayout(FlowLayout.CENTER,10,1);
row_cmd.setLayout(flo_row_cmd);
row_cmd.setBackground(grey_pale);
STOP.addActionListener(this);
STOP.setBackground(red);
STOP.setForeground(yellow);
STOP.setFocusable(false);
ft= STOP.getFont();
ft=new Font(ft.getFontName(),Font.BOLD,14); 
STOP.setFont(ft);
row_cmd.add(STOP);
pane.add(row_cmd);

// 2: communication

// 3: progression

// 4: console
Console console = System.console();
//FlowLayout flo_row_con =  new FlowLayout(FlowLayout.LEFT,10,10);
//row_con.setLayout(flo_row_con);
//row_con.setBackground(grey_pale);

frame.getContentPane().add(console);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//pane.add(row_con);
//pane.validate();
setVisible(true);
???

How could I do? I don't have much experience with GUI components. Thank you.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
Hans
  • 361
  • 1
  • 3
  • 9
  • See duplicate question/answer, and if that doesn't answer your question, search for the hundreds of other similar questions on this site. Having said that, the best solution is not to try to shoehorn a linear console program into an event-driven GUI. This is a great opportunity for you to re-write your program from the ground up with an eye to refactoring it, toward getting it more OOP-compliant, to making it actually event-driven as GUI programs should be, to also thinking about M-V-C structure. – Hovercraft Full Of Eels Jun 01 '16 at 12:27
  • It does, but I don't get it working: JTextArea txtConsole = new JTextArea(); pane.add(txtConsole); PrintStream con=new PrintStream(new TextAreaOutputStream (txtConsole)); System.setOut(con); System.setErr(con); A white text area features, but no text appears – Hans Jun 01 '16 at 15:17

0 Answers0