Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To make label for sum value to change while I move slider  RSS feed

 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, I have a problem again

I'm trying to make some calculations and to calculate this equation:

Tl = Tt + Tp + Tq.

I have drawn each of this fields as labels and 2 of them take values from JSliders and 3rd from JCombo box. Here is the corresponding code:



It works just fine with values Tt, Tp and Tw, but it doesnt animate while I move slider in TL (sum value). Where to put variable for Tl and how to make that sum value changing while I change other parameters? I have made variable valfinal which takes this value valfinal=valu/300000+valu1/valu2+counter/0.1. It is actually the sum of these 3 fields, but the problem is where to place it...?
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tl, being the sum, would be better as a JLabel or non-editable JTextField. (The latter allows copying it.) For both you convert the sum to a String and call setText.
 
maja neskovic
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I solved the problem

It gets the sum value and changes as other values change.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!