我一直试图解决这个问题但没有成功.如何JPanel p尊重定义GridLayout?我得到的是第一行包含3个面板,但不是4,因为我告诉Java要执行.
什么是必要的伏都教(或我的无知的知识),使它工作?
package temp2;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Temp2 {
public static void main(String[] args) {
JFrame f = new JFrame();
JPanel p = new JPanel();
// GridLayout flow = new GridLayout(1, 5); --> With this I get a row with 5 jpanels
GridLayout flow = new GridLayout(2, 4); // --> Why it doenst work? I want 4
// jpanels in the first row and
// subsequent …Run Code Online (Sandbox Code Playgroud)