2 回答
TA贡献1842条经验 获得超21个赞
希望这可以帮助
GridBagLayout lay = new GridBagLayout();
// three columns with same weights
lay.columnWeights = new double[] {1,1,1};
panel = new JPanel(lay);
add(panel);
GridBagConstraints c = new GridBagConstraints();
label1 = new JLabel("This is the MaryLand State Song. After exiting, press enter");
c.gridx = 0; c.gridy = 0;
// make label span all next to last columns (cells)
c.gridwidth = GridBagConstraints.REMAINDER;
panel.add(label1,c);
c.gridwidth = GridBagConstraints.BOTH;
c.fill = GridBagConstraints.HORIZONTAL;
play = new JButton("Play");
c.gridx = 0; c.gridy = 1;
panel.add(play,c);
pause = new JButton("Pause");
c.gridx = 1; c.gridy = 1;
panel.add(pause,c);
stop = new JButton("Stop");
c.gridx = 2; c.gridy = 1;
panel.add(stop,c);
添加回答
举报