grid fixed

git-svn-id: svn://anubis/gvsu@86 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-03-28 22:36:51 +00:00
parent e9ded6a43c
commit f2418fd7b6

View File

@ -16,8 +16,8 @@ public class KnightsTour extends JFrame
private JTextField m_startXField;
private JTextField m_startYField;
private JButton m_startButton;
private JPanel m_mainPanel;
private JPanel m_boardPanel;
private JPanel m_boardContainerPanel;
private JLabel m_statusLabel;
public KnightsTour()
@ -30,13 +30,8 @@ public class KnightsTour extends JFrame
Container c = getContentPane();
m_boardContainerPanel = new JPanel();
m_boardContainerPanel.setBorder(
BorderFactory.createEmptyBorder(5, 0, 0, 0));
createBoardPanel(5, 5);
/* set up the main window contents */
c.add(new JPanel(new BorderLayout()) {{
c.add(m_mainPanel = new JPanel(new BorderLayout()) {{
setBorder(BorderFactory.createEmptyBorder(9, 9, 9, 9));
add(new JPanel() {{
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
@ -82,17 +77,19 @@ public class KnightsTour extends JFrame
new Dimension(Short.MAX_VALUE, 0),
new Dimension(10000, 10000)));
}}, BorderLayout.NORTH);
add(m_boardContainerPanel);
}});
createBoardPanel(5, 5);
setVisible(true);
}
private void createBoardPanel(int width, int height)
{
if (m_boardPanel != null)
m_boardContainerPanel.remove(m_boardPanel);
m_mainPanel.remove(m_boardPanel);
m_boardPanel = new JPanel(new GridLayout(width, height));
m_boardPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
for (int x = 0; x < width; x++)
{
for (int y = 0; y < width; y++)
@ -104,8 +101,8 @@ public class KnightsTour extends JFrame
m_boardPanel.add(l);
}
}
m_boardContainerPanel.add(m_boardPanel);
m_boardContainerPanel.validate();
m_mainPanel.add(m_boardPanel);
m_mainPanel.validate();
}
private class ActionEventHandler implements ActionListener