• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JScrollBar that takes doubles

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I require a JScrollBar that takes doubles instead of ints. I would like to be able to set it to be from, say -0.4 to +0.7, with extent 0.1. Does anyone know of code out there that does this, open source I guess is important.
Thanks for any help,
Hugh
Here is my go at it, but it does not seem to generate events -
public class JScrollBar extends javax.swing.JScrollBar
{
JScrollBar(int orientation, int value, int extent, int min, int max)
{
super(orientation, value, extent, min, max);
}
public BoundedRangeModel getModel()
{
BoundedRangeModel model = super.getModel();
System.out.println("model get = " + model);
AdjustmentListener[] listeners = super.getAdjustmentListeners();
for(int i=0; i<listeners.length; ++i)
{
System.out.println("listeners " + i + " = " + listeners[i]);
}
DefaultBoundedRangeModel retMod = new DefaultBoundedRangeModel(model.getValue() / 100,
model.getExtent() / 100,
model.getMinimum() / 100,
model.getMaximum() / 100);
return retMod;
}
public void setModel(BoundedRangeModel model)
{
DefaultBoundedRangeModel set = new DefaultBoundedRangeModel(model.getValue() * 100,
model.getExtent() * 100,
model.getMinimum() * 100,
model.getMaximum() * 100);
System.out.println("model = " + model + "\n set = " + set);
//fireAdjustmentValueChanged(0, 0, model.getValue());
super.setModel(set);
}
}
reply
    Bookmark Topic Watch Topic
  • New Topic