import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
import java.util.*;
import java.awt.event.*;
import java.net.URL;
import java.awt.Graphics;
import java.io.*;
import javax.imageio.*;
//商店类
public class w18{
JFrame j=new JFrame();
Container c=j.getContentPane();
public w18(){
JButton a[]=new JButton[24];
JPanel j1=new JPanel();
JPanel j2=new JPanel();
j2.setLayout(new GridLayout(12,8,5,5));
for(int i=0;i<24;i++){
//j2.add(a[i]);
}
JScrollPane s=new JScrollPane(j2);
//Icon dj2=new ImageIcon("dj2.png");
//dj[0].setIcon(dj2);
JButton w1=new JButton(" 装 备 ");
JButton w2=new JButton(" 药 剂 ");
JButton w3=new JButton(" 材 料 ");
JButton w4=new JButton(" 道 具 ");
//创建滚动面板,给文本域添加滚动条
j1.setBounds(0,0,300,50);
s.setBounds(0,50,275,350);
j1.add(w1);
j1.add(w2);
j1.add(w3);
j1.add(w4);
s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);//左右
s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);//上下
j.add(s);
j.add(j1);
//列 行
j.setLocationRelativeTo(null);//窗体居中
j.setSize(300,475);
j.setDefaultCloseOperation(2);//窗体关闭方式
j.setResizable(false);//用户禁止拉伸窗体
j.setLayout(null);
w1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
w2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
w3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
w4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
}
public static void main(String[]args){
new w18();
}//主方法
}
for循环这里,编译没问题,运行报错,求指点