我是java编程的初学者,我有一个问题要问你。 我正在使用netbeans 8.0.2,我有这个错误:
------线程中的异常" main" java.lang.RuntimeException:无法编译的源代码 - 找不到符号符号:class Spacer location:class demineur.views.ParameterDialog at demineur.views.ParameterDialog.initComponents(ParameterDialog.java:59) 在demineur.views.ParameterDialog。(ParameterDialog.java:12)at demineur.controllers.Controlleur。(Controlleur.java:32)at demineur.Demineur.main(Demineur.java:19)Java结果:1
我该怎么办?
package demineur.views;
import java.awt.*;
import com.intellij.uiDesigner.core.*;
import javax.swing.*;
public class ParameterDialog extends JPanel {
private JFrame frame;
public ParameterDialog() {
initComponents();
ButtonGroup group = new ButtonGroup();
group.add(easy);
group.add(medium);
group.add(hard);
}
public void display(JPanel panel) {
frame = new JFrame("Options");
frame.setContentPane(panel);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public int getLevel(){
int level = 1;
if(medium.isSelected()){
level = 2;
}
else if(hard.isSelected()){
level = 3;
}
return level;
}
public JButton getStartGame() {
return startGame;
}
public void hide() {
frame.setVisible(false);
}
private void createUIComponents() {
easy = new JRadioButton("<html><span style=\"font-size:12px;color:green;\">D�butant</span> (10x10 cases avec 10 mines)</html>", true);
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
// Generated using JFormDesigner Evaluation license - unknown
createUIComponents();
hard = new JRadioButton();
medium = new JRadioButton();
Spacer hSpacer1 = new Spacer();
JLabel label1 = new JLabel();
JPanel panel1 = new JPanel();
startGame = new JButton();
Spacer hSpacer2 = new Spacer();
//======== this ========
// JFormDesigner evaluation mark
setBorder(new javax.swing.border.CompoundBorder(
new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
"JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});
setLayout(new GridLayoutManager(6, 1, new Insets(10, 10, 10, 10), -1, -1));
//---- hard ----
hard.setText("<html><span style=\"font-size:12px;color:red;\">Expert</span> (20x24 cases avec 100 mines)</html>");
add(hard, new GridConstraints(3, 0, 1, 1,
GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED,
null, null, null));
//---- medium ----
medium.setText("<html><span style=\"font-size:12px;color:orange;\">Interm\u00e9diaire</span> (16x16 cases avec 40 mines)</html>");
add(medium, new GridConstraints(2, 0, 1, 1,
GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED,
null, null, null));
//---- easy ----
easy.setText("<html><span style=\"font-size:12px;color:green;\">D\u00e9butant</span> (10x10 cases avec 10 mines)</html>");
add(easy, new GridConstraints(1, 0, 1, 1,
GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED,
null, null, null));
add(hSpacer1, new GridConstraints(5, 0, 1, 1,
GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK,
null, null, null));
//---- label1 ----
label1.setEnabled(true);
label1.setText("<html><span style=\"font-size:12px;color:maroon\">Veuillez choisir votre niveau de difficult\u00e9 : </span></html>");
add(label1, new GridConstraints(0, 0, 1, 1,
GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
GridConstraints.SIZEPOLICY_FIXED,
GridConstraints.SIZEPOLICY_FIXED,
null, new Dimension(500, 61), null));
//======== panel1 ========
{
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
//---- startGame ----
startGame.setText("<html><span color:maroon;>Lancer le jeu !</span></html>");
panel1.add(startGame, new GridConstraints(0, 1, 1, 1,
GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_FIXED,
null, null, null));
panel1.add(hSpacer2, new GridConstraints(0, 0, 1, 1,
GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK,
null, null, null));
}
add(panel1, new GridConstraints(4, 0, 1, 1,
GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
null, null, null));
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
// Generated using JFormDesigner Evaluation license - unknown
private JRadioButton hard;
private JRadioButton medium;
private JRadioButton easy;
private JButton startGame;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
答案 0 :(得分:0)
日志清楚地说,找不到符号Spacer。我想你没有导入必要的东西。