package com.jeditorPanel.test;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
public class JEditePanelTest1 extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* @param args
*/
private JFrame jf = new JFrame();
private JPanel panel = new JPanel(new BorderLayout());
private JScrollPane jsp = new JScrollPane(panel);
private JTextPane jedit = new JTextPane() ;
public void test()
{
jedit.setText("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
panel.add(jedit);
jedit.setBounds(500, 500, 500, 500);
jedit.setBackground(Color.red);
jf.add(jsp);
jf.setBounds(500, 500, 500, 500);
jf.setVisible(true);
}
public static void main(String[] args)
{
JEditePanelTest1 t1 = new JEditePanelTest1();
t1.test();
}
}
------解决方案--------------------
Swing - Disabling word wrap for JTextPane
这是一个禁用换行的帖子。可以参考一下写一个换行的。