求助关于java滚动条
各位高手们:请教如何在JTextArea上添加垂直滚动条和水平滚动条呢?
请您帮我把源代码写上,小妹在此感谢你了!谢谢!
import java.awt.Container; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class Scroll extends JFrame{ private Container container; public Scroll(){ super("滚动条"); container = getContentPane(); container.add(new JScrollPane(new JTextArea(10,50))); pack(); Dimension frameSize = getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((screenSize.width - frameSize.width)/2,(screenSize.height - frameSize.height)/2); setVisible(true); } public static void main(String[] args) { new Scroll(); } }