将控制台添加到面板

时间:2016-06-01 12:02:23

标签: java swing

我正在尝试添加一个简单的控制台作为面板,但我不能让它工作(看一下代码的结尾):

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);
???

我该怎么办?我对GUI组件没有多少经验。 谢谢。

0 个答案:

没有答案