Java常用组件与布局

public class Example9_4
{
public static void main(String args[ ]) {
new ShowLayout( );
}
}

import java.awt.;
import javax.swing.
;
public class ShowLayout extends JFrame {
PanelGridLayout pannelGrid;
PanelNullLayout panelNull;
JTabbedPane p;
ShowLayout() {
pannelGrid=new PanelGridLayout();
panelNull=new PanelNullLayout();
p = new JTabbedPane();
p.add(“网格布局的面板”,pannelGrid);
p.add(“空布局的面板”,panelNull);
add(p,BorderLayout.CENTER);
add(new JButton(“窗体是BorderLayout布局”),BorderLayout.NORTH);
add(new JButton(“南”),BorderLayout.SOUTH);
add(new JButton(“西”),BorderLayout.WEST);
add(new JButton(“东”),BorderLayout.EAST);
setBounds(10,10,570,390);
setVisible(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
validate();
}
}

import java.awt.;
import javax.swing.
;
import java.awt.GridLayout;
import java.awt.Label;
public class PanelGridLayout extends JPanel {
PanelGridLayout( ) {
GridLayout grid=new GridLayout(12,12);
setLayout(grid);
Lable [ ][ ] label=new Label [12][12];
for(int i=0;i<12;i++) {
for(int j=0;j<12;j++) {
label [i][j]=new Label();
if((i+j)%2==0)
label[i][j].setBackgroud(Color.black);
else
label[i][j].setBackgroud(Color.white);
add(label[i][j]);
}
}
}
}

错误截图如下:

各位大佬们,这段代码出现了三个错误,可是我一直都找不出来,跟例题的代码是一样的,检查了很多遍,一直运行不成功。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值