Java - 错误找不到符号 [英] Java -- Error cannot find symbol

查看:657
本文介绍了Java - 错误找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么我在几个地方得到错误找不到符号。有人可以对这个简单的问题有所了解。

I don't understand why I get the "Error cannot find symbol" in several spots. Can somebody please shed some light on this simple problem.


  • PriceCalculator.java:18:错误:找不到符号---私有JTextFeild priceFeild1 ;

  • PriceCalculator.java:19:错误:找不到符号---私有JTextFeild priceFeild2;

  • PriceCalculator.java:41:错误:找不到符号--- setDefaultCloseOpperation(JFrame.EXIT_ON_CLOSE);

  • PriceCalculator.java:44:错误:找不到符号--- buildPanel();

  • PriceCalculator.java:18: error: cannot find symbol --- private JTextFeild priceFeild1;
  • PriceCalculator.java:19: error: cannot find symbol --- private JTextFeild priceFeild2;
  • PriceCalculator.java:41: error: cannot find symbol --- setDefaultCloseOpperation(JFrame.EXIT_ON_CLOSE);
  • PriceCalculator.java:44: error: cannot find symbol --- 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();
}

}


推荐答案

这是因为你拼错了( JTextFeild )。它应该是 JTextField

It is because you spell it wrong (JTextFeild). It should be JTextField.

此外, setDefaultCloseOperation 代替 setDefaultCloseOpperation

这篇关于Java - 错误找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆