各位大哥大姐和所有的前辈们:
在JTextArea对象中加载文本时,怎么没有滚动条?JTextArea类没有设置滚动条方法吗?我在API文档中查不到
请各位大哥大姐指点一下!
各位大哥大姐和所有的前辈们:
在JTextArea对象中加载文本时,怎么没有滚动条?JTextArea类没有设置滚动条方法吗?我在API文档中查不到
请各位大哥大姐指点一下!
JScrollPane
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class MyJTextArea {
private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="158,19"
private JPanel jContentPane = null;
private JScrollPane jScrollPane = null;
private JTextArea jTextArea = null; // @jve:decl-index=0:visual-constraint="-518,107"
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setSize(new Dimension(440, 167));
jFrame.setContentPane(getJContentPane());
}
return jFrame;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJScrollPane(), BorderLayout.EAST);
}
return jContentPane;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane(getJTextArea());
}
return jScrollPane;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea(10,40);
}
return jTextArea;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new MyJTextArea().getJFrame().setVisible(true);
}
}
谢谢所有热心的朋友们!