Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4992
| From | Knute Johnson <nospam@knutejohnson.com> |
|---|---|
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Setting extent in JSlider model |
| Date | 2012-02-07 10:24 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <jgrq94$sf1$1@dont-email.me> (permalink) |
| References | <827e3c5b-e403-43b5-aaf5-c15e50dd719a@3g2000pbd.googlegroups.com> |
On 2/3/2012 12:35 PM, Fred wrote:
> How can I set how much a slider will change when the user hits the
> PageUp of PageDown key, and when the user clicks in the slider's
> trough?
>
> The javadoc for JSlider's model (BoundedRangeModel) setExtent() method
> states:
>
> When used with a slider, the extent determines how much the value
> can "jump", for
> example when the user presses PgUp or PgDn.
>
> However, setExtent() seems to have no effect. When I use the PgUp or
> PgDn key, the value always changes 10% of the range regardless of the
> value I request for extent.
>
> As for clicking in the trough, metal L&F always seems to increment (or
> decrement) the value by one, and for Nimbus it is the same as PgUp/
> PgDn.
> --
> FredK
It can be very annoying when the L&F prevents a change to a value that
has a setter method. You might look to see if you can find a UI
property that could change that. The problem is that I've found even if
there is a UI property the methods in the L&F may not honor them. I
extended a menu item class to be able to do that but it may or may not
work in the future. I just figured it was a quick fix for the moment
and if it didn't work in the future I could take it out.
This program will list all the UIDefaults:
import java.util.Enumeration;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
public class ListUIProperties {
public static void main(String args[]) throws Exception {
UIManager.LookAndFeelInfo looks[] =
UIManager.getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo info : looks) {
UIManager.setLookAndFeel(info.getClassName());
UIDefaults defaults = UIManager.getDefaults();
Enumeration newKeys = defaults.keys();
while (newKeys.hasMoreElements()) {
Object obj = newKeys.nextElement();
System.out.printf("%50s : %s\n", obj, UIManager.get(obj));
}
}
}
}
--
Knute Johnson
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Setting extent in JSlider model Fred <fred.l.kleinschmidt@gmail.com> - 2012-02-03 12:35 -0800
Re: Setting extent in JSlider model Knute Johnson <nospam@knutejohnson.com> - 2012-02-07 10:24 -0800
Re: Setting extent in JSlider model "John B. Matthews" <nospam@nospam.invalid> - 2012-02-07 15:23 -0500
csiph-web