So when I don’t add the text area to the scrollpane the update method works, however if I do all I get is a blank screen. The other problem is if I add any of this to a JPanl mainArea one below it becomes super doper tiny.
Any Help is appreciated thank-you.
public class Gui {
JFrame frame;
JPanel mainArea;
JPanel choiceArea;
JScrollPane scrollBar;
JPanel charArea;//for later use
JPanel mapArea;
JTextArea textArea;
public Gui(){
frame = new JFrame("Escape");
frame.setSize(700, 700);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainArea = new JPanel();
mainArea.setMaximumSize(new Dimension(680, 400));
mainArea.setSize(680, 400);
//mainArea.setPreferredSize(new Dimension(680, 400));
choiceArea = new JPanel();
choiceArea.setSize(700, 150);
textArea = new JTextArea(35, 25);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
//textArea.setSize(680, 400);
//textArea.setRows(35);
scrollBar = new JScrollPane();
scrollBar.setVerticalScrollBarPolicy(scrollBar.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollBar.setHorizontalScrollBarPolicy(scrollBar.HORIZONTAL_SCROLLBAR_NEVER);
scrollBar.add(textArea);
choiceArea.setLayout(new FlowLayout());
//mainArea.add(scrollBar);
frame.getContentPane().add(BorderLayout.CENTER, textArea);
frame.getContentPane().add(BorderLayout.SOUTH, choiceArea);
frame.validate();
frame.setVisible(true);
}
public void addTextToTextArea(String s){
textArea.append("\n" + s);
textArea.repaint();
textArea.revalidate();
frame.repaint();
frame.revalidate();
}