java 图形界面的gridlayout问题,我的要求是三个按钮排在同一行,这段代码有什么错啊。一个按钮一行了
importjava.awt.*;importjavax.swing.*;publicclassmusic5{publicstaticvoidmain(Stringarg...
import java.awt.*;
import javax.swing.*;
public class music5
{
public static void main(String args[])
{
JFrame frame=new JFrame();
JMenuBar bar=new JMenuBar();
frame.setJMenuBar(bar);
GridLayout yout=new GridLayout(12,3);
Container con1=frame.getContentPane();
con1.setLayout(yout);
frame.setSize(300,500);
frame.setLocation(new Point(100,300));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("music");
bar.add(new JMenu("菜单"));
con1.add(new JButton("按钮1"));
con1.add(new JButton("按钮2"));
con1.add(new JButton("按钮3"));
frame.setVisible(true);
}
} 展开
import javax.swing.*;
public class music5
{
public static void main(String args[])
{
JFrame frame=new JFrame();
JMenuBar bar=new JMenuBar();
frame.setJMenuBar(bar);
GridLayout yout=new GridLayout(12,3);
Container con1=frame.getContentPane();
con1.setLayout(yout);
frame.setSize(300,500);
frame.setLocation(new Point(100,300));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("music");
bar.add(new JMenu("菜单"));
con1.add(new JButton("按钮1"));
con1.add(new JButton("按钮2"));
con1.add(new JButton("按钮3"));
frame.setVisible(true);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询