我正在尝试更多地了解基本Java和不同类型的Throwables,有人能告诉我异常和错误之间的区别吗?
我有一个JPanel,其中包含JSlider和JLabel。我想对其进行配置,以便当用户更改JSlider的值时,新值将由JLabel反映出来。
我了解可以使用Slider触发ChangeEvents,但是我不知道如何向JLabel添加ChangeListener。这是我的代码片段。
scaleSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event)
{
int currentTime = ((JSlider)event.getSource()).getValue();
doSomething(currentTime);
fireStateChanged(event);
}
JLabel timeValue = new JLabel("Time: " + scaleSlider.getValue());
timeValue.add???
Run Code Online (Sandbox Code Playgroud)
(我现在不知道该怎么做以反映滑块中的更改)
我是否正朝着正确的方向前进?在此先感谢您的帮助。
我的引用数组指向另一个数组时遇到问题.这是我的代码片段:
# @bah is a local variable array that's been populated, @foo is also initialized as a global variable
$foo[9] = \@bah;
# this works perfectly, printing the first element of the array @bah
print $foo[9][0]."\n";
# this does not work, nothing gets printed
foreach (@$foo[9]) {
print $_."\n";
}
Run Code Online (Sandbox Code Playgroud)