View Single Post
  #1 (permalink)  
Old 10-18-2007, 08:33 AM
adlb1300 adlb1300 is offline
Member
 
Join Date: Jul 2007
Posts: 46
adlb1300 is on a distinguished road
Help creating a changing grid
I'm a student who is new to Java. I have a project that requires that I prompt the user for a number ranging from 1 to 5. The number they provide is than to be used to create a grid within a frame of that size. For example if you input 3 a frame with a 3x3 grid inside it will be created. I have been able to create the code for the initial prompt but I'm having trouble getting the input to create the grid. Any tips or help would be greatly appreciated.

Here is the code that I have so far:

Code:
import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JTable; public class CreateGrid { public static void main(String[] args) { String input = JOptionPane.showInputDialog( "Enter number of rows and columns you want grid to contain\n" + "(For example entering 2 will create a 2x2 grid)\n"); int gridSquares = Integer.parseInt( input ); if( gridSquares >= 1 && gridSquares <= 5){ } } }
Thanks

Bill
Reply With Quote
Sponsored Links