aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JScrollBar that takes doubles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JScrollBar that takes doubles" Watch "JScrollBar that takes doubles" New topic
Author

JScrollBar that takes doubles

Hugh Morgan
Greenhorn

Joined: Mar 24, 2003
Posts: 1
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);
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JScrollBar that takes doubles