Java - Ошибка не может найти символ

1

Я не понимаю, почему я получаю сообщение "Ошибка не может найти символ" в нескольких местах. Может кто-нибудь, пожалуйста, пролить свет на эту простую проблему.

  • PriceCalculator.java:18: ошибка: не может найти символ --- частный JTextFeild priceFeild1;
  • PriceCalculator.java:19: ошибка: не может найти символ --- частный JTextFeild priceFeild2;
  • PriceCalculator.java:41: ошибка: не удается найти символ --- setDefaultCloseOpperation (JFrame.EXIT_ON_CLOSE);
  • PriceCalculator.java:44: ошибка: не удается найти символ --- buildPanel();

    import javax.swing.*;
    public class PriceCalculator extends JFrame
    {
    private JPanel panel;                               // References the panel
    
    private JLabel messageLabel1;                       // References the whole sale label
    private JLabel messageLabel2;                       // References the markup label percentage
    
    private JTextFeild priceFeild1;                 // References the whole sale price
    private JTextFeild priceFeild2;                 // Referencts the markup label percentage
    
    private JButton calcButton;                     // References the calculator button
    
    private final int WINDOW_WIDTH = 550;           // References the window width
    private final int WINDOW_HEIGHT = 550;          // Referenecs the window height
    
    /** 
    
    Constructor below
    
    */
    
    public PriceCalculator()
    {
    // Set the window title
    setTitle("Retail Price Calculator");
    
    // Set the size of the window
    setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    
    // Set the [x] exit button to close the program for the user
    setDefaultCloseOpperation(JFrame.EXIT_ON_CLOSE);
    
    // Build the panel and add it to the JFrame
    buildPanel();
    
    // Add the contents to the panels frame
    add(panel);
    
    // Display the window here
    setVisible(true);
    }
    
    
    
    
    /**
    
    Main Method Below
    
    */
    
    public static void main(String[] args)
    {
    new PriceCalculator();
    }
    
    }
    
  • 2
    Ответ Хищника совершенно прав; Я просто рекомендую вам использовать IDE, чтобы предотвратить опечатки в классах / методах.
  • 0
    Дубликат stackoverflow.com/questions/25706216/…
Теги:
swing

2 ответа

4

Это потому, что вы неправильно JTextFeild (JTextFeild). Это должен быть JTextField.

Кроме того, setDefaultCloseOperation вместо setDefaultCloseOpperation

  • 2
    Кроме того, получите IDE, как Eclipse. Такая тривиальная ошибка была бы легко обнаружена интеллектуальным редактором кода, который также предлагал бы способы ее исправления (например, предлагая похожие, но правильно написанные известные типы и методы). Вы, кажется, делаете это сложнее, чем необходимо для себя :)
0

Ваша орфографическая ошибка:

JTextFeild вместо JTextField

и setDefaultCloseOpperation(JFrame.EXIT_ON_CLOSE); вместо setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); вы использовали 2 p в Operation.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню