View Single Post
  #5 (permalink)  
Old 10-19-2007, 12:38 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
In CreateGridRx xInc and yInc are the size of each grid cell. So each one would become 100. After you get the user input you can figure the size of the grid: number of cols/rows times 100 plus twice the pad for both width and height. You can call setPreferredSize on the panel and call pack on the JFrame or make sure that the size of the frame is big enough to allow for proper display if you want to use setSize. Or you could put the child panel in a JScrollPane - setting the panels prefSize will allow the scrollPane to properly set its scrollBars.
Code:
CreateGridRx test = new CreateGridRx(gridSquares); test.setPreferredSize(new Dimension(calculatedWidth, calculatedHeight)); JFrame f = new JFrame(); f.pack(); // instead of setSize
Reply With Quote