- Java code
JPanel searchConditionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); //searchConditionPanel.setPreferredSize(new Dimension(700, 65)); //searchConditionPanel.setBackground(BACKGROUND_COLOR); JPanel jp = new JPanel(new GridLayout(1, 6, 15, 5)); jp.setPreferredSize(new Dimension(580, 25)); jp.setBackground(BACKGROUND_COLOR); JLabel label = new JLabel("1"); jp.add(label); label.setText("2"); jp.add(label); label.setText("3"); jp.add(label); label.setText("4"); jp.add(label); label.setText("5"); jp.add(label); label.setText("6"); jp.add(label); searchConditionPanel.add(jp);
坐等大神解答
------解决方案--------------------
不是大婶,菜鸟见解:
JLabel label1 = new JLabel("1");
jp.add(label);
label2 = new JLabel("2");
jp.add(label2);
label3 = new JLabel("3");
jp.add(label3);
label4 = new JLabel(4");
jp.add(label4);
label5 = new JLabel("5");
jp.add(label5);
label6 = new JLabel("6");
jp.add(label6);
------解决方案--------------------