当前位置: 代码迷 >> J2SE >> JTextPane 取消自动换行解决办法
  详细解决方案

JTextPane 取消自动换行解决办法

热度:543   发布时间:2016-04-24 01:40:44.0
JTextPane 取消自动换行
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
这是一个禁用换行的帖子。可以参考一下写一个换行的。
  相关解决方案