jpanel 网格布局3,3 第三个是空的其他都填满,怎么搞啊? 例: 1 2 4 5 6 7 8 9
1个回答
展开全部
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Calculater
{
public static void main(String [] args){
JPanel frame = new JPanel();
}
}
class JPanel extends JFrame{
public JPanel(){
this.setBounds(300, 300, 300, 300);
this.setLayout(new GridLayout(3, 3));
this.add(new JLabel("1"));
this.add(new JLabel("2"));
this.add(new JLabel(""));
this.add(new JLabel("4"));
this.add(new JLabel("5"));
this.add(new JLabel("6"));
this.add(new JLabel("7"));
this.add(new JLabel("8"));
this.add(new JLabel("9"));
this.show();
}
}
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Calculater
{
public static void main(String [] args){
JPanel frame = new JPanel();
}
}
class JPanel extends JFrame{
public JPanel(){
this.setBounds(300, 300, 300, 300);
this.setLayout(new GridLayout(3, 3));
this.add(new JLabel("1"));
this.add(new JLabel("2"));
this.add(new JLabel(""));
this.add(new JLabel("4"));
this.add(new JLabel("5"));
this.add(new JLabel("6"));
this.add(new JLabel("7"));
this.add(new JLabel("8"));
this.add(new JLabel("9"));
this.show();
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询