当我执行这段代码时,会弹出一个小窗口,它的内部约为 116x63,整个尺寸(包括边框)约为 140x100。如何将内部设置为我需要的样子?
public static void graphics() {
JFrame frame = new JFrame();
String title = "test window";
frame.setTitle(title);
frame.setSize(gridRow, gridCol); //101 x 101
frame.setResizable(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
Run Code Online (Sandbox Code Playgroud) 所以我今天花了几个小时写出逻辑,然后把它变成代码,但我完全陷入困境,我不知道该怎么做.我现在只用java编程了几个月,所以整个"逻辑"思维方式还没有完全实现.谁能帮助我思考如何在java中创建ulam螺旋的逻辑?
import java.util.Arrays;
public class GridMaker {
private static int gridRow = 5; // R = length
private static int gridCol = 5; // C = height
private static int[][] grid = new int[gridRow][gridCol];
private static int totalSteps = (gridRow * gridCol); // total blocks on the grid
private static int location = 1; // location refers to the number in the box, ie. 1, 2, 3, etc.
private static int rowLength = 1;
public static void main(String[] args) { …Run Code Online (Sandbox Code Playgroud)