我正在将Java Swing边框添加到现有代码中。我参考了网上的资料,并将得到的代码放入我的代码中,但在运行时出现错误,并且在我的Intellij中高亮显示时出现:无法解析符号“p”。我错在哪里了?
private class AnotherBorderTest extends JFrame {
public AnotherBorderTest() {
setTitle("Border Test");
setSize(450, 450);
JPanel content = (JPanel) getContentPane();
content.setLayout(new GridLayout(6, 2, 3, 3));
p = new JPanel();
p.setBorder(new MatteBorder(new ImageIcon("BALL.GIF")));
p.add(new JLabel("MatteBorder"));
content.add(p);
setVisible(true);
}
public void main(String args[]) {
new AnotherBorderTest();
}
}