I know this is something very simple, but as a complete Java newbie I’m missing it and someone pointing it out would be infinitely helpful. I’ve stared at the screen and moved things around and still nothing.
Screenshot:
https://i.stack.imgur.com/ufCd9.png
This is all that comes up when this is run.
fullGUI.java:
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
public class fullGUI extends JFrame
{
JFrame frame = new JFrame(); //creates frame
public fullGUI() // constructor
{
//setLayout(new BorderLayout());
//add(new shipGrid(), BorderLayout.NORTH);
//add(new shipGrid(), BorderLayout.NORTH);
add(new JRadioButton("Horizontal"), BorderLayout.WEST);
add(new JRadioButton("Vertical"), BorderLayout.WEST);
add(new JTextArea("Instructions to player will go here"), BorderLayout.CENTER);
frame.setSize(400,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Battleship!");
frame.pack(); //sets appropriate size for frame
frame.setVisible(true);
}
}
…called by…
test.java
public class test
{
public static void main(String[] args)
{
new fullGUI();
}
}
FullGUIalready extendsJFrame, so no need to create anotherJFrameinside itgetContentPane.add()to add toJFrameSwingUtilities.invokeLaterSo overall something like this