java错误找不到符号
importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassBargainAgentex...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;
public BargainAgent()
{private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
bpriceL=new JLabel("请输入你还的价格:",SwingConstants.RIGHT);
spriceL=new JLabel("agent报价:",SwingConstants.RIGHT);
timesL=new JLabel("剩余议价次数:",SwingConstants.RIGHT);
bpriceTF=new JTextField(10);
spriceTF=new JTextField(10);
timesTF=new JTextField(10);
bargainB=new JButton("议价");
bargainBActionEnentHandler bbHandler=new bargainBActionEventHandler(); //找不到符号
bargainB.addActionListener(bbHandler);
okayB=new JButton("接受议价");
okayBActionEventHandler obHandler=new okayBActionEventHandler(); //找不到符号
okayB.addActionListener(obHandler);
exitB=new JButton("拒绝议价");
exitBActionEventHandler ebHandler=new exitBActionEventHandler(); //找不到符号
exitB.addActionListener(ebHandler);
setTitle("议价界面");
Container pane=getContentPane();
pane.setLayout(new GridLayout(5,2));
pane.add(bpriceL);
pane.add(bpriceTF);
pane.add(spriceL);
pane.add(spriceTF);
pane.add(timesL);
pane.add(timesTF);
pane.add(bargainB);
pane.add(okayB);
pane.add(exitB);
setSize(WIDTH,HEIGTH);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[]args)
{
BargainAgent rectObject=new BargainAgent();
}
}
这是我做的一个界面的代码,事件响应程序没写,但编译时出现了找不到符号的问题,哪位高手能帮忙指出错在什么地方啊,先谢谢了! 展开
import java.awt.event.*;
import javax.swing.*;
public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;
public BargainAgent()
{private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
bpriceL=new JLabel("请输入你还的价格:",SwingConstants.RIGHT);
spriceL=new JLabel("agent报价:",SwingConstants.RIGHT);
timesL=new JLabel("剩余议价次数:",SwingConstants.RIGHT);
bpriceTF=new JTextField(10);
spriceTF=new JTextField(10);
timesTF=new JTextField(10);
bargainB=new JButton("议价");
bargainBActionEnentHandler bbHandler=new bargainBActionEventHandler(); //找不到符号
bargainB.addActionListener(bbHandler);
okayB=new JButton("接受议价");
okayBActionEventHandler obHandler=new okayBActionEventHandler(); //找不到符号
okayB.addActionListener(obHandler);
exitB=new JButton("拒绝议价");
exitBActionEventHandler ebHandler=new exitBActionEventHandler(); //找不到符号
exitB.addActionListener(ebHandler);
setTitle("议价界面");
Container pane=getContentPane();
pane.setLayout(new GridLayout(5,2));
pane.add(bpriceL);
pane.add(bpriceTF);
pane.add(spriceL);
pane.add(spriceTF);
pane.add(timesL);
pane.add(timesTF);
pane.add(bargainB);
pane.add(okayB);
pane.add(exitB);
setSize(WIDTH,HEIGTH);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[]args)
{
BargainAgent rectObject=new BargainAgent();
}
}
这是我做的一个界面的代码,事件响应程序没写,但编译时出现了找不到符号的问题,哪位高手能帮忙指出错在什么地方啊,先谢谢了! 展开
2个回答
展开全部
你程序里有
bargainBActionEventHandler
okayBActionEventHandler
exitBActionEventHandler
这几个类吗,没有的话肯定找不到符号了。
还有你的构造方法里怎么还有private修饰的变量。
程序不是你做的吧!
我给你改了,你运行一下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;
public BargainAgent()
{
bpriceL=new JLabel("请输入你还的价格:",SwingConstants.RIGHT);
spriceL=new JLabel("agent报价:",SwingConstants.RIGHT);
timesL=new JLabel("剩余议价次数:",SwingConstants.RIGHT);
bpriceTF=new JTextField(10);
spriceTF=new JTextField(10);
timesTF=new JTextField(10);
bargainB=new JButton("议价");
ActionListener bbHandler=new ActionListener(){
public void actionPerformed(ActionEvent e) {
//这里写入"议价"事件响应代码
System.out.println("议价");
}
}; //找不到符号
bargainB.addActionListener(bbHandler);
okayB=new JButton("接受议价");
ActionListener obHandler=new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//这里写入"接受议价"事件响应代码
System.out.println("接受议价");
}
};
okayB.addActionListener(obHandler);
exitB=new JButton("拒绝议价");
ActionListener ebHandler=new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//这里写入"拒绝议价"事件响应代码
System.out.println("拒绝议价");
}
};
exitB.addActionListener(ebHandler);
setTitle("议价界面");
Container pane=getContentPane();
pane.setLayout(new GridLayout(5,2));
pane.add(bpriceL);
pane.add(bpriceTF);
pane.add(spriceL);
pane.add(spriceTF);
pane.add(timesL);
pane.add(timesTF);
pane.add(bargainB);
pane.add(okayB);
pane.add(exitB);
setSize(WIDTH,HEIGTH);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[]args)
{
BargainAgent rectObject=new BargainAgent();
}
}
bargainBActionEventHandler
okayBActionEventHandler
exitBActionEventHandler
这几个类吗,没有的话肯定找不到符号了。
还有你的构造方法里怎么还有private修饰的变量。
程序不是你做的吧!
我给你改了,你运行一下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;
public BargainAgent()
{
bpriceL=new JLabel("请输入你还的价格:",SwingConstants.RIGHT);
spriceL=new JLabel("agent报价:",SwingConstants.RIGHT);
timesL=new JLabel("剩余议价次数:",SwingConstants.RIGHT);
bpriceTF=new JTextField(10);
spriceTF=new JTextField(10);
timesTF=new JTextField(10);
bargainB=new JButton("议价");
ActionListener bbHandler=new ActionListener(){
public void actionPerformed(ActionEvent e) {
//这里写入"议价"事件响应代码
System.out.println("议价");
}
}; //找不到符号
bargainB.addActionListener(bbHandler);
okayB=new JButton("接受议价");
ActionListener obHandler=new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//这里写入"接受议价"事件响应代码
System.out.println("接受议价");
}
};
okayB.addActionListener(obHandler);
exitB=new JButton("拒绝议价");
ActionListener ebHandler=new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//这里写入"拒绝议价"事件响应代码
System.out.println("拒绝议价");
}
};
exitB.addActionListener(ebHandler);
setTitle("议价界面");
Container pane=getContentPane();
pane.setLayout(new GridLayout(5,2));
pane.add(bpriceL);
pane.add(bpriceTF);
pane.add(spriceL);
pane.add(spriceTF);
pane.add(timesL);
pane.add(timesTF);
pane.add(bargainB);
pane.add(okayB);
pane.add(exitB);
setSize(WIDTH,HEIGTH);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[]args)
{
BargainAgent rectObject=new BargainAgent();
}
}
展开全部
给你报一个错误太便宜你了
public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;
public BargainAgent()
{private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
上面已经定义了 JLabel 等 下面为什么还要定义?不报错都难
bargainBActionEnentHandler 这是个什么东东?
吧你NEW 的那个奇怪的东西替换成:
bargainB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
//这里写时间相应时的代码
}
});
public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;
public BargainAgent()
{private JLabel bpriceL,spriceL,timesL;
private JTextField bpriceTF,spriceTF,timesTF;
private JButton bargainB,okayB,exitB;
上面已经定义了 JLabel 等 下面为什么还要定义?不报错都难
bargainBActionEnentHandler 这是个什么东东?
吧你NEW 的那个奇怪的东西替换成:
bargainB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
//这里写时间相应时的代码
}
});
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询