简体   繁体   中英

JFrame build panel is not working

I have tried everything possible to fix this error. Every time I compile the program, the error

KiloConverter.java:25: error: cannot find symbol 

How to resolve this error?

import javax.swing.*; // Needed for swing classes

public class KiloConverter extends JFrame
 {
     private JPanel panel;
     private JLabel messageLabel;
     private JTextField kiloTextField;
     private JButton calcButton;
     private final int WINDOW_WIDTH = 310;
     private final int WINDOW_HEIGHT = 100;


     //constructor 

     public KiloConverter()
     {
        setTitle("Kilometer Converter");

        setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //bulid the panel and add it to the frame
        buildPanel();

        //Add the panel to the frame's content page
        add(panel);

        setVisible(true);  

     }

     //the bulid panel method adds a label, a text field,
     //and a button to a panel

     private void bulidPanel()
     {
         //Create a label to display instructions.

         messageLabel = new JLabel("Enter a distance " + "in kilometers");

         //Create a text field 10 characters wide.
         kiloTextField = new JTextField(10);

         //create a button with the caption CALCULATE
         calcButton = new JButton("Calculate");

         //create a JPanel object and let the panel field reference it
         panel = new JPanel();


         //Add the label, text fieldm and button components to the panel
         panel.add(messageLabel);
         panel.add(kiloTextField);
         panel.add(calcButton);
     }



    public static void main (String[] args) 
    {

        new KiloConverter();
    }
}

The source code seen, incorrectly spells 'build' as 'bulid' in two comments and one method name. Correcting the spelling in the method name should fix the problem, but change all three instances.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM