The following program displays the text area for the entire JFrame even though I have set the dimensions of the text area to be 10 x 15. Any help will be greatly appreciated.

Thank you!

import javax.swing.*;
import java.awt.*;

public class Scrollers extends JFrame {

            JTextArea area;            
            JButton button;
            public Scrollers ()
               super ("Text Area and Scroller");
               Box box = Box.createVerticalBox();
               String m  = "I am here";
               area = new JTextArea(m, 10, 15);
               button = new JButton ("Click");     
               JScrollPane pane = new JScrollPane(area,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
               add(box, BorderLayout.CENTER);
            public static void main (String args[])
                Scrollers scroll = new Scrollers();
                scroll.setSize(500, 500);

Components placed in BorderLayout.CENTER expand to fill the available space in the container.

if you set JTextArea(m, 10, 15); , then scroll.setSize(500, 500); is too contraproductive, call for scroll.pack(); before scroll.setVisible(true); rather than manually set for size on the screen

This question has already been answered. Start a new discussion instead.