Click here to Skip to main content
15,742,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created one JPanel to add JTextArea in that how to add Both Scrollbar to JTextArea...using manually not using any IDE's

1 solution

Check whether the below code is what you need or let me know if your requirement is different.

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

public class TextAreaExample extends JFrame {

	private static final long serialVersionUID = -116021326175824941L;
	private JScrollPane jScrollPane1;
	private JTextArea textArea;

	public TextAreaExample() {
		this.setPreferredSize(new Dimension(360,200	));
		textArea = new JTextArea(8,30);
		jScrollPane1 = new JScrollPane(textArea);
		JPanel panel = new JPanel();
		panel.setSize(200, 200);

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				UIManager.put("swing.boldMetal", Boolean.FALSE);
				new TextAreaExample().setVisible(true);

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900