KyodaiUI.java:15: 非法字符: \12288
JPanel actionPanel = new JPanel();
^
KyodaiUI.java:19: 非法字符: \12288
JPanel contentPanel = new JPanel();
^
KyodaiUI.java:27: 非法字符: \12288
public static void main(String[] args) throws HeadlessException{
^
KyodaiUI.java:27: 非法字符: \12288
public static void main(String[] args) throws HeadlessException{
^
KyodaiUI.java:31: 需要 <标识符>
}
^
5 错误
JPanel actionPanel = new JPanel();
^
KyodaiUI.java:19: 非法字符: \12288
JPanel contentPanel = new JPanel();
^
KyodaiUI.java:27: 非法字符: \12288
public static void main(String[] args) throws HeadlessException{
^
KyodaiUI.java:27: 非法字符: \12288
public static void main(String[] args) throws HeadlessException{
^
KyodaiUI.java:31: 需要 <标识符>
}
^
5 错误
import java.awt.*;
import javax.swing.*;public class KyodaiUI extends JFrame{
public KyodaiUI(){
this.setSize(780,500); //将窗体的大小设定为780*500
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false); //窗体不能改变大小
this.setTitle("连连看"); //设置标题
JPanel toolBar = new JPanel();
toolBar.setBackground(Color.white);
toolBar.setPreferredSize(new Dimension(780,48)); JPanel actionPanel = new JPanel();
actionPanel.setBackground(Color.yellow);//设置背景色
actionPanel.setPreferredSize(new Dimension(160,380)); //设置大小 JPanel contentPanel = new JPanel();
contentPanel.setBackground(Color.blue);
contentPanel.setPreferredSize(new Dimension(620,380));
this.getContentPane().add(toolBar,BorderLayout.NORTH);
this.getContentPane().add(actionPanel,BorderLayout.EAST);
this.getContentPane().add(contentPanel,BorderLayout.CENTER);
} public static void main(String[] args) throws HeadlessException{
KyodaiUI kyodaiUI = new KyodaiUI();
kyodaiUI.show();
}
}
import javax.swing.*;public class KyodaiUI extends JFrame{
public KyodaiUI(){
this.setSize(780,500); //将窗体的大小设定为780*500
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false); //窗体不能改变大小
this.setTitle("连连看"); //设置标题
JPanel toolBar = new JPanel();
toolBar.setBackground(Color.white);
toolBar.setPreferredSize(new Dimension(780,48));
JPanel actionPanel = new JPanel();
actionPanel.setBackground(Color.yellow);//设置背景色
actionPanel.setPreferredSize(new Dimension(160,380)); //设置大小
JPanel contentPanel = new JPanel();
contentPanel.setBackground(Color.blue);
contentPanel.setPreferredSize(new Dimension(620,380));
this.getContentPane().add(toolBar,BorderLayout.NORTH);
this.getContentPane().add(actionPanel,BorderLayout.EAST);
this.getContentPane().add(contentPanel,BorderLayout.CENTER);
}
public static void main(String[] args) throws HeadlessException{
KyodaiUI kyodaiUI = new KyodaiUI();
kyodaiUI.show();
}
}你出错的那些行的前边的空白处,有看不见的字符
你写的代码没有问题,我的是把那些字符去掉了,你试试!