/** * Update the visibility model with the associated JTextField (if there is one) to reflect the * current visibility as a result of changes to the document model. The bounded range properties * are updated. If the view hasn't yet been shown the extent will be zero and we just set it to be * full until determined otherwise. */ void updateVisibilityModel() { Component c = getContainer(); if (c instanceof JTextField) { JTextField field = (JTextField) c; BoundedRangeModel vis = field.getHorizontalVisibility(); int hspan = (int) getPreferredSpan(X_AXIS); int extent = vis.getExtent(); int maximum = Math.max(hspan, extent); extent = (extent == 0) ? maximum : extent; int value = maximum - extent; int oldValue = vis.getValue(); if ((oldValue + extent) > maximum) { oldValue = maximum - extent; } value = Math.max(0, Math.min(value, oldValue)); vis.setRangeProperties(value, extent, 0, maximum, false); } }
/** * Get the maximum accessible value of this object. * * @return The maximum value of this object. */ public Number getMaximumAccessibleValue() { // TIGER - 4422362 BoundedRangeModel model = JSlider.this.getModel(); return Integer.valueOf(model.getMaximum() - model.getExtent()); }