textArea.setWrapStyleWord(true);设置了,可还是没反应啊???

解决方案 »

  1.   

    这样增加你的textarea到窗口:
    Frame f=new Frame("title");
    f.setLayout(new BorderLayout);
    JTextArea textArea=new JTextArea();
    textArea.setWrapStyleWord(true);
    JScrollPane scrollPane=new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED)
    f.getContentPane.add(scrollPane,BorderLayout.CENTER);
      

  2.   

    先拖一个Swing控件里的JScrollPane,然后再拖一个JTextArea到你的JScrollPane里,jb7会自动生成代码:
    JScrollPane jScrollPane = new JScrollPane();以后
    jScrollPane.getViewport().add(jTextArea, null);