CODE
import javax.swing.*;
import java.io.*;
import java.util.Scanner;
import java.awt.*;
public class Help extends JFrame
{
private static final int HEIGHT = 39;
private static final int WIDTH = 20;
public Help()
{
JPanel p = new JPanel();
JTextArea area = new JTextArea(WIDTH,HEIGHT);
JScrollPane sp = new JScrollPane(area);
sp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
sp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
Scanner scan;
PrintWriter output = null;
String s = "";
try
{
scan = new Scanner( new FileInputStream( "Help.txt"));
scan.useDelimiter("finito");
s = scan.next();
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog( null, "The Help File not found!!");
s = "The text is not available!!!";
}
area.setText( s);
p.add(sp);
getContentPane().add( p);
pack();
setVisible( true);
}
}
import java.io.*;
import java.util.Scanner;
import java.awt.*;
public class Help extends JFrame
{
private static final int HEIGHT = 39;
private static final int WIDTH = 20;
public Help()
{
JPanel p = new JPanel();
JTextArea area = new JTextArea(WIDTH,HEIGHT);
JScrollPane sp = new JScrollPane(area);
sp.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
sp.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
Scanner scan;
PrintWriter output = null;
String s = "";
try
{
scan = new Scanner( new FileInputStream( "Help.txt"));
scan.useDelimiter("finito");
s = scan.next();
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog( null, "The Help File not found!!");
s = "The text is not available!!!";
}
area.setText( s);
p.add(sp);
getContentPane().add( p);
pack();
setVisible( true);
}
}
When I executed this frame using a main method the scroll bar created at the end of the text area like this:


But I used BlueJ to execute this class and I did not create a main method. I just create a new Help object and the scroll bar was created from the top.
WHY!!!
How can this error be fixed.Please help me...










