Hi friend,
If you want to know about the use of BoundedRangeModel interface, then refer following java example:
Code:
import javax.swing.BoundedRangeModel;
import javax.swing.JButton;
public class BoundedRangeModelDM {
public static void main(final String arhgs[]) {
JFrame af = new JFrame("Offset Example");
af.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pn = new JPanel(new BorderLayout());
final JTextField textField = new JTextField();
pn.add(textField, BorderLayout.CENTER);
af.add(pn, BorderLayout.NORTH);
JButton button = new JButton("Get Offset");
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
System.out.println("Offset: " + textField.getScrollOffset());
System.out.println("Visibility: " + textField.getHorizontalVisibility());
BoundedRangeModel model1 = textField.getHorizontalVisibility();
int extent1 = model1.getExtent();
textField.setScrollOffset(extent1);
}
};
button.addActionListener(actionListener);
af.add(button, BorderLayout.SOUTH);
af.setSize(200, 150);
af.setVisible(true);
}
}
Bookmarks