滚动条事件处理,如何保持抓取的数字静态
正如标题所示,我有一个带有滚动条界面的程序。问题是该程序对四组不同的数字使用相同的三个滚动条,一旦对另一组数字进行更改,滚动条将保持与前一组数字相同的值
float RedAmount1 = lightDimmer1.getValue();
float GreenAmount1 = lightDimmer2.getValue();
float BlueAmount1 = lightDimmer3.getValue();
diffuseSwitch[0] = RedAmount1;
diffuseSwitch[1] = GreenAmount1;
diffuseSwitch[2] = BlueAmount1;
float StoreColours1[] = {RedAmount1,GreenAmount1,BlueAmount1};
int StoreColourRed = (int)StoreColours1[0];
int StoreColourGreen = (int)StoreColours1[1];
int StoreColourBlue = (int)StoreColours1[2];
if(diffuseSwitch[0] != StoreColourRed)
{
lightDimmer1.setValue(StoreColourRed);
}
这段代码被放置在滚动条事件处理部分,因此尝试比较 float StoreColourRed 和 diffuseSwitch[0] 的数字不断更改为最新一组数字的值,而不是保留之前的一组值。
任何帮助将不胜感激
As the title suggests I have a program with a scrollbar interface. The problem is that the program uses the same three scrollbars for four sets of different numbers, once the change has been made to another set of numbers the scrollbar remains on the same values from the previous set of numbers
float RedAmount1 = lightDimmer1.getValue();
float GreenAmount1 = lightDimmer2.getValue();
float BlueAmount1 = lightDimmer3.getValue();
diffuseSwitch[0] = RedAmount1;
diffuseSwitch[1] = GreenAmount1;
diffuseSwitch[2] = BlueAmount1;
float StoreColours1[] = {RedAmount1,GreenAmount1,BlueAmount1};
int StoreColourRed = (int)StoreColours1[0];
int StoreColourGreen = (int)StoreColours1[1];
int StoreColourBlue = (int)StoreColours1[2];
if(diffuseSwitch[0] != StoreColourRed)
{
lightDimmer1.setValue(StoreColourRed);
}
This piece of code is placed within a scrollbars event handling section so the number am trying to compare float StoreColourRed and diffuseSwitch[0] keep being changed to the values of the latest set of numbers instead of keeping the previous set of values.
any help would be much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用一个非常简单的类来保存您的值,例如:
您应该能够使用
getValueIsAdjusting()
和setValueIsAdjusting()
确定值何时稳定。您可能还需要我们JRadioButton
或
JComboBox< /code>
选择正在操作的值集。
附录:我粗心地假设
JSlider
阅读问题时。此外,调整可能无关紧要。JTabbedPane
是选择要操纵哪组值的另一种选择。Use a very simple class to hold your values, for example:
You should be able to use
getValueIsAdjusting()
andsetValueIsAdjusting()
to determine when the values are stable. You may also want to usJRadioButton
orJComboBox
to select which set of values is being manipulated.Addendum: I carelessly assumed
JSlider
when reading the question. Also, adjusting is probably irrelevant.JTabbedPane
is another choice for selecting which set of values is being manipulated.