//滚动条 ScrollPane scrollPane = new ScrollPane(); //再把文本域textArea添加到滚动条上 scrollPane.add(textArea); //最后把滚动条添加到frame上 frame.add(scrollPane);