Java 编译时出错?

Java 编译时出错?,java,compiler-errors,jframe,components,identifier,Java,Compiler Errors,Jframe,Components,Identifier,因此,我一直在编写一个关于JPizza.java的代码,我已经到了出现这个错误的地步: JPizza.java:38: error: cannot find symbol music = getAudioClip(getCodeBase(),"katy_perry-roar.mid"); ^ symbol: method getCodeBase() location: class JPizza 1 error 我一直在想

因此,我一直在编写一个关于
JPizza.java
的代码,我已经到了出现这个错误的地步:

    JPizza.java:38: error: cannot find symbol
  music = getAudioClip(getCodeBase(),"katy_perry-roar.mid");
                       ^
  symbol:   method getCodeBase()
  location: class JPizza
  1 error
我一直在想为什么它会给我这些错误,但是 我在这里找不到主要问题?是因为我忘了定义吗 一种方法?对于getCodeBase()和CodeBase(),我尝试将其定义为
CodeBase()=getCodeBase()
,然后将错误转移到getAudioClip

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class JPizza extends JFrame implements ItemListener, ActionListener
 {
  FlowLayout flow = new FlowLayout();
  JLabel companyName = new JLabel("PizzaPalooza");
  JComboBox<String> sizeBox = new JComboBox<String>();
  JLabel sizeList = new JLabel("Size List");
  JComboBox<String> toppingBox = new JComboBox<String>();
  JLabel toppingList = new JLabel("Topping List");
  JTextField totPrice = new JTextField(10);
  JLabel orderName = new JLabel("Name of Order");
  JTextField oName = new JTextField(15);
  JLabel listenLabel = new JLabel("Listen to our theme!");
  JButton playButton = new JButton("Play");
  JButton stopButton = new JButton("Stop");
  JLabel headLabel = new JLabel ();
  AudioClip music;
  int totalPrice = 0;
  int sizeNum, toppingNum;
  int sPrice, tPrice, sumPrice;
  int[] sizePrice = {0,7,9,11,14};
  int[] toppingPrice = {0,0,1,1,1,1};
  String output;
   public void init()
    {
     Container con = getContentPane();
     con.setLayout (new FlowLayout());
     con.add(headLabel);
     con.add(listenLabel);
     con.add(playButton);
     con.add(stopButton);
     playButton.addActionListener(this);
     stopButton.addActionListener(this);
     music = getAudioClip(getCodeBase(),"katy_perry-roar.mid");
    }

     public void actionPerformed(ActionEvent e)
     {
      Object source = e.getSource();
      if(source == playButton)
       music.loop();
      else
       music.stop();
     }
import javax.swing.*;
导入java.awt.*;
导入java.awt.event.*;
导入java.applet.*;
公共类JPizza扩展JFrame实现ItemListener、ActionListener
{
FlowLayout流量=新的FlowLayout();
JLabel companyName=新JLabel(“PizzaPalooza”);
JComboBox sizeBox=新JComboBox();
JLabel sizeList=新的JLabel(“尺寸列表”);
JComboBox toppingBox=新的JComboBox();
JLabel toppingList=新的JLabel(“toppingList”);
JTextField totPrice=新的JTextField(10);
JLabel orderName=新JLabel(“订单名称”);
JTextField oName=新的JTextField(15);
JLabel listenLabel=newjlabel(“倾听我们的主题!”);
JButton playButton=新JButton(“播放”);
JButton stopButton=新JButton(“停止”);
JLabel海岬标=新JLabel();
音频剪辑音乐;
int totalPrice=0;
int-sizeNum,toppingNum;
int sPrice、tPrice、sumPrice;
int[]sizePrice={0,7,9,11,14};
int[]toppingPrice={0,0,1,1,1};
字符串输出;
公共void init()
{
容器con=getContentPane();
con.setLayout(新的FlowLayout());
补充条款(海岬标);
con.add(列表标签);
con.add(播放按钮);
con.添加(停止按钮);
playButton.addActionListener(此);
stopButton.addActionListener(这个);
music=getAudioClip(getCodeBase(),“katy_perry-roar.mid”);
}
已执行的公共无效操作(操作事件e)
{
对象源=e.getSource();
如果(源==播放按钮)
music.loop();
其他的
音乐。停止();
}

对于这一点,但我不明白这意味着什么?

编译问题就在上面这一行。您在这一行中缺少了JLabel构造函数的括号和分号

  JLabel headLabel = new JLabel
应该是:

  JLabel headLabel = new JLabel();

看看上面的那一行,
JLabel hightabel=new JLabel
这一行看起来有点修剪过。这可能是问题所在。它应该是
JLabel hightabel=new JLabel(“一些字符串”);
您在哪里定义了方法
getCodeBase
?或者它是内置到类中的(哪一个?)?@Flight我假设因为你是从另一个来源输入歌曲,所以你会使用getCodeBase,它是在
java.awt.event.*
中定义的,这是我的java教授说的。你能帮我处理
JPizza.java:38:错误:找不到符号music=getAudioClip(getCodeBase(),“katy_perry-roar.mid”)吗^symbol:method getCodeBase()位置:class JPizza
错误?我仍然不明白,对于getCodeBase()和CodeBase(),我尝试将其定义为CodeBase()=getCodeBase(),然后将错误转移到getAudioClip
JFrame
不是
小程序。