Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java--找不到符号时出错_Java_Swing - Fatal编程技术网

Java--找不到符号时出错

Java--找不到符号时出错,java,swing,Java,Swing,我不明白为什么在几个地方出现“错误找不到符号”。谁能解释一下这个简单的问题吗 java:18:错误:找不到符号--private jtextfield priceFeild1 java:19:错误:找不到符号--private jtextfield priceFeild2 java:41:错误:找不到符号--setDefaultCloseOperation(JFrame.EXIT\u ON\u CLOSE) java:44:错误:找不到符号--buildPanel() 这是因为你拼写错了(j

我不明白为什么在几个地方出现“错误找不到符号”。谁能解释一下这个简单的问题吗

  • java:18:错误:找不到符号--private jtextfield priceFeild1
  • java:19:错误:找不到符号--private jtextfield priceFeild2
  • java:41:错误:找不到符号--setDefaultCloseOperation(JFrame.EXIT\u ON\u CLOSE)
  • java:44:错误:找不到符号--buildPanel()


    • 这是因为你拼写错了(
      jtextfield
      )。它应该是
      JTextField


      另外,
      setDefaultCloseOperation
      而不是
      setDefaultCloseOperation

      这是因为拼写错误(
      jtextfield
      )。它应该是
      JTextField


      另外,
      setDefaultCloseOperation
      而不是
      setDefaultCloseOperation

      您的拼写错误:

      JTextField
      而不是
      JTextField

      setDefaultCloseOperation(JFrame.EXIT\u ON\u CLOSE)
      
      而不是
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
      您在
      操作中使用了2
      p
      您的拼写错误:

      JTextField
      而不是
      JTextField

      setDefaultCloseOperation(JFrame.EXIT\u ON\u CLOSE)
      
      而不是
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
      你在
      操作中使用了2
      p
      猛禽的答案完全正确;我只是建议您使用IDE来防止类/方法中的拼写错误;我只是建议您使用IDE来防止类/方法中的拼写错误。另外,请使用类似Eclipse的IDE。这样一个小错误很容易被智能代码编辑器发现,它还将提供如何修复它的建议(比如提供类似但拼写正确的已知类型和方法)。你似乎让它变得比你自己需要的更难:)另外,获得一个像Eclipse这样的IDE。这样一个小错误很容易被智能代码编辑器发现,它还将提供如何修复它的建议(比如提供类似但拼写正确的已知类型和方法)。你似乎让自己变得更难:)
      
      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();
      }
      
      }