Thread Subject: Changing Tick Color in JSlider

Subject: Changing Tick Color in JSlider

From: Matthew Whitaker

Date: 30 Oct, 2008 23:03:01

Message: 1 of 1

Hello,

I've been messing around for some time trying to change the color of the tick marks in a JSlider. I'm trying to do a white on black look but I'm having no luck. I've tried using the setClientProperty method inherited from JComponent

The rest of the code looks something like:

h = figure;
rm = javax.swing.DefaultBoundedRangeModel(1,0,1,10);
js = javax.swing.JSlider(rm);
ht = java.util.Hashtable();
set(js,'Background',[0,0,0],'Foreground',[1,1,1]);
tickLabel{1} = javax.swing.JLabel(java.lang.String('1'));
set(tickLabel{1},'Foreground',[1,1,1]);
tickLabel{2} = javax.swing.JLabel(java.lang.String('10'));
set(tickLabel{2},'Foreground',[1,1,1]);

ht.put(java.lang.Integer(1), tickLabel{1});
ht.put(java.lang.Integer(10), tickLabel{2});

js.setLabelTable(ht);
js.setSnapToTicks(true);
js.setMinorTickSpacing(1);
js.setMajorTickSpacing(2);
js.setPaintTicks(true);
js.setPaintLabels(true);
[jsh, container] = javacomponent(js);
set(container,'Position', [100, 100, 100, 40]);
set(container,'Units', 'normalized');

Anybody have any ides. I'm using R2006b with Java VM Version: Java 1.5.0

Thanks iin advance

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
java Matthew Whitaker 30 Oct, 2008 19:05:05
jslider Matthew Whitaker 30 Oct, 2008 19:05:05
rssFeed for this Thread

Contact us at files@mathworks.com