org.drools.examples.sudoku.swing.SudokuGridView Maven / Gradle / Ivy
The newest version!
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.drools.examples.sudoku.swing;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GridLayout;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class SudokuGridView
extends JComponent
implements SudokuGridListener, ComponentListener
{
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
private SudokuGridModel model;
private GridLayout gridLayout;
private JTextField textFields[][];
public SudokuGridView()
{
gridLayout = new GridLayout(SudokuGridModel.NUM_ROWS, SudokuGridModel.NUM_COLS);
setLayout(gridLayout);
textFields = new JTextField[SudokuGridModel.NUM_ROWS][SudokuGridModel.NUM_COLS];
for (int row=0; row height)
{
while (fontMetrics.getAscent() > height)
{
font = new Font(font.getName(), font.getStyle(), font.getSize()-2);
fontMetrics = textField.getGraphics().getFontMetrics(font);
}
}
else
{
//
}
for (int row=0; row
© 2015 - 2025 Weber Informatics LLC | Privacy Policy