我正在尝试显示一个 JOptionPane 输入对话框,然后显示视图,但我不确定为什么它没有出现,视图弹出但没有输入对话框,我尝试注释掉视图部分并且没有任何反应
这是我的控制器 JOptionPane 输入对话框所在的位置
package model;
import java.util.*;
import javax.swing.*;
public class Controller {
private View myView;
private NQueensModel myModel;
private static int int1, possibilities;
private static String intString;
public static void main(String[] args)
{
intString = JOptionPane.showInputDialog(null, "How many rows/cols?");
int1 = Integer.parseInt(intString);
}
public Controller()
{
myView = new View(this);
}
public void solve()
{
myView.doViewGrid();
myModel = new NQueensModel(int1);
myModel.solvePuzzle();
possibilities = myModel.getPossibilities();
myView.addButtons();
myView.setPossibilitiesLabel(possibilities);
myView.revalidate();
myView.repaint();
}
public boolean[][] getMyBoard()
{
return myModel.getBoard();
}
}
这是第一次调用控制器的主类
package model;
public class queensBasics
{
public static void main(String[] args)
{
Controller myController = new Controller();
}
}