jslider

Change displayable labels for a JSlider?

做~自己de王妃 提交于 2019-12-04 13:08:16
I have a JSlider with a min of 0 and a max of 10,000. I have the major tick marks set at 1,000. If I were to paint the labels now they would show up as 0, 1000, 2000, 3000, 4000, etc. What I would like to be shown would be 0, 1, 2, 3, 4, 5, etc. What would be a good way to accomplish this task? using JSlider.setLabelTable(Dictionary) EDIT Alternatively you can rely on predefined label UI and just change the label text: Enumeration e = jSlider.getLabelTable().keys(); while (e.hasMoreElements()) { Integer i = (Integer) e.nextElement(); JLabel label = (JLabel) jSlider.getLabelTable().get(i);

Remove value displaying over thumb in JSlider

只愿长相守 提交于 2019-12-04 07:49:45
I have a little problem with my JSlider, that I haven't been able to solve. To explain the situation a little, I have to do a JSlider going from 0 to 20, through 0.1 steps. I tricked my way out of problems by creating a JSlider from 0 to 200, and redefined the labels under the slider to display the corrent percentages instead of the integer values. But I have one last problem : I'm using a custom L&F (that I can't change, obviously, as it is from the client), that displays the value over the slider thumb. However, this value is displayed...in its standard way, as an integer. From what I've

get JSlider's input and changes

偶尔善良 提交于 2019-12-02 19:25:21
问题 I need to use JSlider with getting input live, meaning that it will return an input without pressing any button. I have this piece of code for the slider: JPanel panel = new JPanel(); JSlider js = new JSlider(JSlider.VERTICAL, 0, 20, 10); js.setMajorTickSpacing(2); js.setPaintTicks(true); Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(js.getMinimum()), new JLabel("x0")); labelTable.put(new Integer((js.getMinimum() + js.getMaximum()) / 2), new JLabel("x1")); labelTable.put

how to put an image over jslider's knob image when mouse is present over the knob's image

蓝咒 提交于 2019-12-02 18:02:55
问题 I need to put an image over jslider's knob image when mouse is present over the knob's image. I have done something like this.: slider = new Slider(); s= new mySliderUI(slider ,"slider.png" ); slider.setUI(s); slider.addMouseListener(new MyMouseAction()); public class MyMouseAction implements MouseListener{ public void mouseEntered(MouseEvent e) { try { s.knobImage = ImageIO.read(new File("slider_roll.png")); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace();

How to remove the Border of jSlider

拜拜、爱过 提交于 2019-12-02 16:02:35
问题 I`ve customized an jSlider facing a little problem- After changing values, on my custom jSlider is a border shown. Sorry, I´ve made pictures but Iàm not allowed to post it. The not customized jSlider do not show such border after click on it. Is there an Method i have to Override to get rid of this border? Thank you in advance! Sorry for my english! Hope anyone can help me! This is my Customized UI: public class RedGreenSliderUI extends BasicSliderUI{ Image knobImage ; private BasicStroke

How to draw 2d arrows with Java Swing?

岁酱吖の 提交于 2019-12-02 13:10:28
I'm trying to draw some rotatable arrows with Swing 2d, there are some sample code online, so I copied and combined them into one app, but there is something wrong with each of the 3 methods : 1st one doesn't rotate from it's center, the other 2 don't look correctly in the arrow head, can someone show me how to fix them ? import java.awt.*; import java.awt.geom.*; import javax.swing.*; import javax.swing.event.*; public class Arrow_Test extends JPanel implements ChangeListener { Path2D.Double arrow = createArrow(); double theta = 0; public void stateChanged(ChangeEvent e) { int value = (

how to put an image over jslider's knob image when mouse is present over the knob's image

六眼飞鱼酱① 提交于 2019-12-02 10:26:56
I need to put an image over jslider's knob image when mouse is present over the knob's image. I have done something like this.: slider = new Slider(); s= new mySliderUI(slider ,"slider.png" ); slider.setUI(s); slider.addMouseListener(new MyMouseAction()); public class MyMouseAction implements MouseListener{ public void mouseEntered(MouseEvent e) { try { s.knobImage = ImageIO.read(new File("slider_roll.png")); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } public void mouseExited(MouseEvent e) { try { s.knobImage = ImageIO.read( new File("slider.png"));

get JSlider's input and changes

岁酱吖の 提交于 2019-12-02 07:40:39
I need to use JSlider with getting input live, meaning that it will return an input without pressing any button. I have this piece of code for the slider: JPanel panel = new JPanel(); JSlider js = new JSlider(JSlider.VERTICAL, 0, 20, 10); js.setMajorTickSpacing(2); js.setPaintTicks(true); Hashtable labelTable = new Hashtable(); labelTable.put(new Integer(js.getMinimum()), new JLabel("x0")); labelTable.put(new Integer((js.getMinimum() + js.getMaximum()) / 2), new JLabel("x1")); labelTable.put(new Integer(js.getMaximum()), new JLabel("x2")); js.setLabelTable(labelTable); js.setPaintLabels(true);

making a playable jslider in java

 ̄綄美尐妖づ 提交于 2019-12-02 07:06:31
问题 I'm making a grapher by using eclipse and windowbuilder that gets an mathematical expression from the user(for example ADD(MUL(X,Y),Z) ) and at one point asks the user to designate one of its variables as time . then the user will be asked to choose the starting point and the range of that variable. then the program will show a frame (and a panel) that has a jslider and a play button .when the user clicks the button the program should start drawing the expression . It should look like a

How to hide the knob of jSlider?

对着背影说爱祢 提交于 2019-12-02 02:04:46
I need to customize the knob of JSlider. I need to put my own knob's image over default knob of Jslider. The problem is that currently two knobs are coming in response. One my own knob and second the default knob. Please tell me how i can i hide the default knob or any other solution. Below code is used to do so. public class ImageTest { JSlider slider; JLabel label; public ImageTest() { JPanel panel = new BackgroundPanel(); slider = new BackgroundSlider(); slider.setMaximum(300); slider.setMinimum(0); slider.setValue(50); slider.setExtent(10); slider.addChangeListener(new MyChangeAction());