I'm having problems getting my program to compile. Here is what I'm supposed to be doing
Instructions: Create the following GUI. You do not have to provide any functionality.
The first column has 2 check boxes. The second column has 2 input
text fields. The third column has 3 buttons. You may want to create
separate panels for each column and use GridLayout objects for the layout
managers of the panels.
|-------------------------------------------------|
| |
|Align |
| |
|-------------------------------------------------|
| |
| [ OK ] |
| [ ] Snap to Grid X: [8 ] |
| [ Cancel ] |
| [ ] Show Grid Y: [9 ] |
| [ Help ] |
| |
|-------------------------------------------------|
Here is my code for GridLayout.java
<javacode>
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GridLayout extends JFrame
{
private JButton buttons[];
private
String names[] =
{ "Snap to Grid", "X:", "OK", "Show Grid", "Y", "Cancel", "Help"};
private Container container;
private GridLayout grid1;
//set up GUI
public GridLayout()
{
super( "GridLayout" );
//Set up layout
grid1 = new GridLayout( 3, 3 );
//get content pane and set its layout
container = getContentPane();
container.setLayout( grid1 );
//create and add buttons
buttons = new JButton[ names.length ];
for ( int count = 0; count < names.length; count++ )<br /> {<br /> buttons[ count ] = new JButton( names[ count ] );<br /> container.add( buttons[ count ] );<br /> }<br /> // set size<br /> setSize(400,150);<br /> setVisible( true );<br /> }<br /> //execute application<br /> public static void main( String args[] )<br /> {<br /> GridLayout application = new GridLayout();<br /> application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );<br /> }<br /> }<br /> </javacode><br /> <errors><br /> GridLayout.java:24: cannot resolve symbol<br /> symbol : constructor GridLayout (int,int)<br /> location: class GridLayout<br /> grid1 = new GridLayout( 3, 3 );<br /> ^<br /> GridLayout.java:28: setLayout(java.awt.LayoutManager) in java.awt.Container cann<br /> ot be applied to (GridLayout)<br /> container.setLayout( grid1 );<br /> ^<br /> 2 errors<br /> C:\myjava\assignment1\problem2>
</errors>
If someone could help me with what I'm doing wrong I would appreciate it
alot.
------------------
Thanks, Dianne