Jtextarea 如何添加滚动条
publicclassTestextendsJFrame{privateJTextAreaarea=newJTextArea();privateTest(){this.s...
public class Test extends JFrame{
private JTextArea area = new JTextArea();
private Test(){ this.setLayout(null); area.setSize(420,170); area.setLocation(10,80); area.setMargin(new Insets(10,10,10,10)); Font font = new Font("宋体",0,15); area.setFont(font); this.add(area); this.setSize(465,300); this.setLocation(650,100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public static void main(String[] args){ new Test().setVisible(true); }
}
运行后如下图:
怎么样添加滚动条 展开
private JTextArea area = new JTextArea();
private Test(){ this.setLayout(null); area.setSize(420,170); area.setLocation(10,80); area.setMargin(new Insets(10,10,10,10)); Font font = new Font("宋体",0,15); area.setFont(font); this.add(area); this.setSize(465,300); this.setLocation(650,100); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public static void main(String[] args){ new Test().setVisible(true); }
}
运行后如下图:
怎么样添加滚动条 展开
展开全部
JTextArea添加滚动条代码:
package com.test;
import java.awt.*;
import javax.swing.*;
public class Test extends JFrame {
JMenuBar jb;
JTextArea ja;
JScrollPane jsp;
public void setImage() {
jb = new
JMenuBar();
this.setJMenuBar(jb);
ja = new
JTextArea();
jsp = new JScrollPane(ja);
this.setSize(600, 400);
this.setLayout(new
BorderLayout());
this.add(jsp);
this.setVisible(true);
}
public static void main(String[] args) {
Test a =
new
Test();
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
a.setImage();
}
}
运行效果图:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询