JPanel pane = new JPanel() ;
pane.setBackground(Color.WHITE);
pane.add(area) ;
scrollPane = new JScrollPane(pane) ;
scrollPane.setBackground(Color.WHITE);
scrollPane.setForeground(Color.WHITE);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setPreferredSize(new Dimension(PANEL_WIDTH,PANEL_HEIGHT));
getContentPane().add(scrollPane);
//area is JTextArea
pane.setBackground(Color.WHITE);
pane.add(area) ;
scrollPane = new JScrollPane(pane) ;
scrollPane.setBackground(Color.WHITE);
scrollPane.setForeground(Color.WHITE);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setPreferredSize(new Dimension(PANEL_WIDTH,PANEL_HEIGHT));
getContentPane().add(scrollPane);
//area is JTextArea
JTextArea jtxtr_Message = new JTextArea();this.getContentPane().add(sp_message, BorderLayout.SOUTH);
sp_message.add(jtxtr_Message);
sp_message.add(jtxtr_Message);
后,程序运行时,连jtxtr_Message都看不到了,:(
先把JTextArea放到JScrollPane 中
再把JScrollPane 放进容器内,试试