I saw a few questions like this question, but I couldn\'t get this solved. I cannot get a JScrollPane visible on JTextArea. Can anyone please point
When you use JTextArea component with JSrcollPane component you should set size and position to the last component and not to the first one, and when you add the created elements to the JFrame you should only add JScrollPane component because it is considered as container to the JTextArea component, try this code:
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Main extends JFrame
{
JTextArea tarea;
JScrollPane pan;
public Main()
{
tarea = new JTextArea();
pan = new JScrollPane(tarea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
pan.setBounds(100, 100, 200, 200);
add(pan);
setLayout(null);
setSize(600, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] aegs)
{
Main f = new Main();
}
}