Why the JScrollPane is not working?

hi i'm having a problem with this JScrollPane that does not allow me to scroll when my textarea exceed the screen. I can't figure out the problem Can anyone tell me why ?

import java.awt.*;

import java.text.*;

import javax.swing.*;

import java.awt.event.*;

publicclass MovieBook1extends JFrame

{

private JPanel jPane6;

private JTextArea atext1;

private JScrollPane scroll;

publicstaticvoid main(String[] args)

{

MovieBook1 m =new MovieBook1();

m.setVisible(true);

m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public MovieBook1()

{

setSize(200,300);

setTitle("Movie Booking");

Font bigFont =new Font("TimesRoman", Font.BOLD, 24);

getContentPane().setLayout(new GridLayout(1,1));

jPane6 =new JPanel();

jPane6.setLayout(new BorderLayout());

atext1 =new JTextArea(1,1);

atext1.setText("Movie\t\tTime\t#Tkt\t$");

atext1.setCaretPosition(atext1.getText().length());

scroll =new JScrollPane(atext1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,

JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

jPane6.add(atext1,BorderLayout.CENTER);

jPane6.add(scroll,BorderLayout.EAST);

getContentPane().add(jPane6);

}

}

[2264 byte] By [MrDavidsona] at [2007-11-26 12:40:36]
# 1

looks like the main problem was adding the textArea twice (scrollpane and panel)

try these changes

import java.awt.*;

import java.text.*;

import javax.swing.*;

import java.awt.event.*;

class MovieBook1 extends JFrame

{

private JPanel jPane6;

private JTextArea atext1;

private JScrollPane scroll;

public static void main(String[] args)

{

MovieBook1 m = new MovieBook1();

m.setVisible(true);

m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public MovieBook1()

{

//setSize(200,300);//<-

setTitle("Movie Booking");

Font bigFont = new Font("TimesRoman", Font.BOLD, 24);

getContentPane().setLayout(new GridLayout(1,1));

jPane6 = new JPanel();

//jPane6.setLayout(new BorderLayout());

//atext1 = new JTextArea(1,1);

atext1 = new JTextArea(10,40);

atext1.setText("Movie\t\tTime\t#Tkt\t$");

atext1.setCaretPosition(atext1.getText().length());

scroll = new JScrollPane(atext1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,

JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

//jPane6.add(atext1,BorderLayout.CENTER);

jPane6.add(scroll);//,BorderLayout.EAST);

getContentPane().add(jPane6);

pack();//<-added

}

}

Michael_Dunna at 2007-7-7 16:12:23 > top of Java-index,Desktop,Core GUI APIs...
# 2
Wow cool man. the jscroll worked. Thanks.
MrDavidsona at 2007-7-7 16:12:23 > top of Java-index,Desktop,Core GUI APIs...