JTextArea tp=new JTextArea();
new JScrollPane(tp);
new JScrollPane(tp);
解决方案 »
- 请问自学java SE 应该按什么顺序呐?
- 谁能解惑?
- 新手请教封装和继承的问题。
- 请问数字转字符串的问题 如 32 转为 '0032'
- 在java编写的绘图程序中怎样实现局部刷新
- 调查以下,各位用java开发哪方面的系统及相应的配置。
- java如何实现向linux控制台输入命令啊
- javamail 发送邮件,附件中有中文名称的文件,收邮件时中文文件名变成乱码
- 谢谢网友coolskeeter(蚊子) 给我的一个IP地址文本框类,写得不错,现贴给大家共享。
- 请问各位大虾那里有好一点的关于design pattern的网站/论坛!
- 来帮帮忙吧
- 我编的applet若想上传到个人主页空间上去,只要传.class和.html两个文件就够了吗
//good luckimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class JTextFrameClass extends JFrame {
private JPanel contentPane;
private BorderLayout borderLayout1 = new BorderLayout();
private JScrollPane jScrollPane1 = new JScrollPane();
private JTextArea jTextArea1 = new JTextArea(); //Construct the frame
public JTextFrameClass() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
contentPane.setToolTipText("");
jTextArea1.setBackground(Color.pink);
jTextArea1.setText("jTextArea1,Pleae continue type untill the vertical scroll bar becomes active!!!"+
"jTextArea1,Pleae continue type untill the vertical scroll bar becomes active!!!"+
"jTextArea1,Pleae continue type untill the vertical scroll bar becomes active!!!"+
"jTextArea1,Pleae continue type untill the vertical scroll bar becomes active!!!");
jTextArea1.setLineWrap(true);
jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
contentPane.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jTextArea1, null);
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
} public static void main (String args[])
{
JTextFrameClass test = new JTextFrameClass();
test.setSize(200,150) ;
test.show();
}
}