Hello,
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");
//area.setLineWrap(true);
JScrollPane pane = new JScrollPane(area,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
box.add(pane);
box.add(button);
add(box, BorderLayout.CENTER);
}
public static void main (String args[])
{
Scrollers scroll = new Scrollers();
scroll.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
scroll.setSize(500, 500);
scroll.setVisible(true);
}
}