在我的棋盘中提示用户输入行和列?(Java编程)

在我的棋盘中提示用户输入行和列?(Java编程),java,swing,Java,Swing,我试图通过一个对话框(J选项什么的?)提示用户输入我的棋盘的行和列 //显示由红色和黑色矩形组成的8 x 8网格 import javax.swing.*; // For JFrame and JPanel import java.awt.*; // For Color, Container, and GridLayout public class checkerboard{ public static void main(String[] args){ JF

我试图通过一个对话框(J选项什么的?)提示用户输入我的棋盘的行和列

//显示由红色和黑色矩形组成的8 x 8网格

import javax.swing.*;  // For JFrame and JPanel
import java.awt.*;    // For Color, Container, and GridLayout

public class checkerboard{

    public static void main(String[] args){
        JFrame theGUI = new JFrame();
        theGUI.setTitle("Checkerboard");
        theGUI.setSize(300,300);
        theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container pane = theGUI.getContentPane();
        pane.setLayout(new GridLayout(8,8));
        Color color1 = Color.black;
        Color color2 = Color.red;
        for (int i = 1; i<= 64; i++){
            JPanel panel = new JPanel();
            // Alternate colors on a row
            if (i % 2 == 0)
                panel.setBackground(color1);
            else
                panel.setBackground(color2);
            pane.add(panel);
            // At the end of a row, start next row on the other color
            if (i % 8 == 0){
                Color temp = color1;
                color1 = color2;
                color2 = temp;
            }
        }
        theGUI.setVisible(true);
    }
}
import javax.swing.*//对于JFrame和JPanel
导入java.awt.*;//用于颜色、容器和网格布局
公共类棋盘{
公共静态void main(字符串[]args){
JFrame theGUI=newjframe();
theGUI.setTitle(“棋盘”);
设置大小(300300);
setDefaultCloseOperation(JFrame.EXIT\u ON\u CLOSE);
容器窗格=GUI.getContentPane();
窗格.setLayout(新网格布局(8,8));
Color color1=Color.black;
Color color2=Color.red;
对于(inti=1;i你试过了吗

columns = Integer.parseInt(JOptionPane.showInputDialog("Enter number of columns"));

您的确切问题是什么?我需要帮助,通过一个对话框提示用户输入我的行和列。您已经尝试了哪些内容?您尝试使用
JOptionPane
的代码在哪里?您发布的代码中没有任何与用户输入相关的代码,因此我们不知道您尝试了什么,甚至不知道您想要什么。