Slider编译更改侦听器问题 [英] Slider compile change listener issues

查看:79
本文介绍了Slider编译更改侦听器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!



我正在使用BlueJ并且我的代码中有这部分问题:

Hello!

I am using BlueJ and having issues with this part of my code:

slideSize = new JSlider(JSlider.HORIZONTAL,1, 10, 5);
       slider.setBorder(BorderFactory.createTitledBorder("Pressure Control"));
       slider.setMinorTickSpacing(1);
       slider.setPaintTicks(true);
       slider.setPreferredSize( new Dimension( 500, 60 ) );
       add(slider,  BorderLayout.PAGE_END);
       slider.addChangeListener(this);







给出这个编译错误:







类javax.swing.Jslider中的方法addChangeListener不能应用于给定类型;


需要
:java .swing.event.ChangeListener
找到
:ExampleSoloution8_2



原因:实际参数ExampleSoloution8_2无法转换为javax .swing.event.ChangeListener通过方法调用转换



您在此处使用的运算符不能用于您使用的值类型。你要么在这里使用拧干类型,要么使用错误的操作符。



任何提示?



谢谢!




Gives this compile error:



method addChangeListener in class javax.swing.Jslider cannot be applied to given types;

required: java .swing.event.ChangeListener
found:ExampleSoloution8_2

reason: actual argument ExampleSoloution8_2 cannot be converted to javax.swing.event.ChangeListener by method invocation conversion

The operator that you use here cannot be used for the type of value that you are using for it. You are either using the wring type here, or the wrong operator.

Any tips?

Thanks!

推荐答案

OP发布:

我在代码之上错过了后者:implements ChangeListener ActionListener 。它现在适用于(这)非常感谢!



发布它以从未答复的列表中弹出它。
OP posted:
I was missing the latter on top of my code: implements ChangeListener, ActionListener . It now works with (this) Thanks very much!

Posting it to pop it out of unanswered list.


这篇关于Slider编译更改侦听器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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