Reputation: 1
import java.awt.Container; //Container or *
import javax.swing.*; //JFrame, JLabel, *, or etc...
public class NumerologyEC extends JFrame
{
private static final int Width = 400;
private static final int Height = 300;
private JLabel word1;
public NumerologyEC()
{
setTitle ("Numerology Extra Credit");
word1 = new JLabel ("Enter a word: ", SwingConstants.RIGHT);
Container pane = getContentPane();
pane.setLayout (new GridLayout (1, 2));
pane.add(word1);
setSize(Width, Height);
setVisible (true);
setDefaultCloseOperation (EXIT_ON_CLOSE);
}
public static void main (String[] args)
{
NumerologyEC rectObject = new NumerologyEC();
}
}
I keep getting an error on "new GridLayout." im following the book for my class and it doesnt explain if i need to import something or declare it to make it work. any tips would be appreciated.
Upvotes: 0
Views: 651
Reputation: 10969
You do need to also import GridLayout
. Add this import
import java.awt.GridLayout;
Or you could change your import to the following to import everything in the package
import java.awt.*;
Or explicitly write
new java.awt.GridLayout (1, 2)
Upvotes: 1