0

For some reason when the Jframe opens it is not visible until I resize the frame. any idea why this might be? This is only my second time using swing so it's probably a stupid error on my part. Thanks!

package test.console;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class InputConsole{


    public static void startConsole(){
        JFrame frame = new JFrame("test");
        JPanel textOut = new JPanel();
        JTextArea jTextArea = new JTextArea();  
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        double screenwidth = screenSize.getWidth();
        double screenheight = screenSize.getHeight();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
        frame.setVisible(true);
        frame.setLayout(new GridLayout(3, 1));
        frame.add(textOut);
        jTextArea.setSize(400,400);    
        jTextArea.setLineWrap(true);
        jTextArea.setEditable(true);
        jTextArea.setVisible(true);
        textOut.add(jTextArea);
        JScrollPane scroll = new JScrollPane (jTextArea);
        scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        frame.add(scroll);
        jTextArea.setBackground(Color.BLUE);
        jTextArea.append( "Hello World." );
        jTextArea.append("\ntest");




    }


}
CNorlander
  • 375
  • 3
  • 13

0 Answers0