JSlider « JSlider « Java Swing Q&A





1. Overlay multiple JSliders in Swing    stackoverflow.com

Is it possible to overlay multiple JSliders so I can see the "thumbs" on both (I've tried disabling the painting of the track and setting opacity to false but one still ...

2. JSlider key bindings    stackoverflow.com

So I'm a bit nonplussed at the JSlider default key bindings for vertical sliders.

  • Home: goes to the bottom (why not the top?)
  • End: goes to the top (why not the bottom?)
  • PageUp/PageDown: direction ...

3. swing: JSlider but with coarse/fine controls?    stackoverflow.com

I have a JSlider with 65536 different values. It works great for coarse adjustments and for very fine adjustments (+/-1 using up/down arrow) but is very poor in the middle. Is there ...

4. Custom Jslider Initialization Problem    stackoverflow.com

I am working on a custom JSlider that has a custom Track Rectangle. I want the ability to set the color of the track rectangle when first declaring the slider. Here's a ...

5. JSlider for doubles    stackoverflow.com

I am making a GUI (using swing) for a poker framework and need some sort of slider to allow players to select a bet size. However the Swing JSlider only works ...

6. quick jslider question    stackoverflow.com

I have a JSlider in my gui that goes from 0 to 100, for some reason, there is a text above the slider position that reads the current value ...

7. java/swing: JSlider.setValue is blocking    stackoverflow.com

my call to JSlider.setValue is sometimes blocking the thread which results ins a deadlock of the whole application. here is the stacktrace of the blocking thread.

Thread [RenderThread] (Suspended)   
JSlider(Component).getMousePosition() line: ...

8. jSlider code causes the application to hang    stackoverflow.com

This jSlider code causes the application to hang.

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:         ...

9. JSlider sliding direction    stackoverflow.com

i would like to know if it is possible to know on which side of the slider the thumb is moving. I have to implement a zoom function based on ...





10. problem with setLabelTable method to customize JSlider's lables    stackoverflow.com

According to this tutorial, one should do the following to customize JSlider's lables:

JSlider framesPerSecond = new JSlider(JSlider.VERTICAL,
             ...

11. Custom JSlider - Java program    stackoverflow.com

I'm trying to make a custom JSlider and I don't want the thumb (the little triangle thing on the slider that shows the position) to show up. So, I have a CustomSlider ...

12. Circle JSlider - Java program    stackoverflow.com

Can someone show me code that will set up a JSlider except, instead of a thumb, it is a circle? Specifically, instead of that little triangle which points to the current ...

13. Java JSlider precision problems    stackoverflow.com

I have a list of N JSliders (N does not change procedurally, only as I add more features. Currently N equals 4). The sum of all the sliders values must equal ...

14. Using a JSlider as custom InplaceEditor    forums.netbeans.org

All, I'm attempting to provide a jslider component within a property sheet so that when properties that have a fixed range are edited, they are selected via a slider rather than ...

15. multiple windows and multiple jsliders    forums.netbeans.org

Hi I am just learning Java and using Netbeans. There are two things I am trying to do. 1. Have the user input a number, like 4 and then hit the button "go" which opens another window. 2. In the second window it takes the number 4 and creates 4 jsliders. I created two gui's using netbeans but want to link ...

16. use JSlider (SWING)    coderanch.com





17. JInternalFrames + JSliders    coderanch.com

18. Help!!! - Intermitent display of JSlider    coderanch.com

I am convinced that the issue here is not with the layout of the components, as i can run the application a number of times without any recompilation and observe a random pattern of visibility of the JSliders. Also, when the sliders are not visible, clicking on the grey space that they should occupy, still fires ChangeEvents.

19. JSlider    coderanch.com

20. JSlider    coderanch.com

21. Jslider - Button    coderanch.com

this draws an imabe as the thumb, but sliding/repainting kills it import java.awt.*; import javax.swing.*; import javax.swing.plaf.basic.BasicSliderUI; import java.net.URL; import javax.imageio.ImageIO; class Testing extends JFrame { public Testing() { setDefaultCloseOperation(EXIT_ON_CLOSE); setLocation(200,100); JSlider slider = new JSlider(0,100,0); slider.setUI(new MyBasicSliderUI(slider)); slider.setMajorTickSpacing(10); slider.setMinorTickSpacing(5); slider.setPaintTicks(true); slider.setPaintLabels(true); JPanel jp = new JPanel(); jp.add(slider); getContentPane().add(slider); pack(); } class MyBasicSliderUI extends BasicSliderUI { Image im; public MyBasicSliderUI(JSlider js) ...

22. Java 5 JSlider compile issue    coderanch.com

23. JSlider question    coderanch.com

It seems like a simple question but the answer can be complicated. Some information: 1 setSize is used mainly for toplevel containers, has no affect on a component until after realization and maybe not then depending on the layout manager of its parent, and is used in absolute positioning (null layout). 2 Swing components respond to the setPreferredSize method ...

24. Rendering JSlider Problem    coderanch.com

> I dont see any waste code out there.. OK, I'm always willing to learn something. How does a mouseListener possibly affect the orientation when the program starts? I won't read the code because it's not formatted, so I tried to run it to see what it was doing, but could only compile as far as new Square(). If you want ...

25. JSlider Change on Release    coderanch.com

Hi. Is there any easy way to make a JSlider fire its change listener when the slider is released by the user, rather than being fired each time the value changes during the dragging. I have a JSlider, that when changed, performs some visual tweaking of an image based on the position of the slider. This can sometimes be an intense ...

26. Making JSpinner act like JSlider    coderanch.com

maybe you can roll-your-own something like this - needs major testing import javax.swing.*; import java.awt.*; import java.awt.event.*; class Testing { boolean valueIsAdjusting = false; public void buildGUI() { JPanel p = new JPanel(); final JSpinner spinner = new JSpinner(new SpinnerNumberModel(50, 0, 100, 5)); spinner.setUI(new MyUI()); p.add(spinner); JFrame f = new JFrame(); f.getContentPane().add(p); f.pack(); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); spinner.addChangeListener(new javax.swing.event.ChangeListener(){ public void stateChanged(javax.swing.event.ChangeEvent ...

27. JSlider is not working.    coderanch.com

I am going to plot a 2d, a combox and a JSlider.but JSlider is not working. Please help me. thanks import java.io.*; import java.awt.Font; import java.awt.Color; import java.awt.Graphics; import java.awt.geom.*; import java.awt.*; import java.awt.BorderLayout; import javax.swing.*; import java.util.Hashtable; import java.awt.event.*; import javax.swing.event.*; import java.applet.Applet; public class TestLayout extends JApplet { private Drawing drawing; private JComboBox comb; private JComboBox alfa; private JSlider ...

28. JSlider is not working.    coderanch.com

I am going to plot a 2d, a combox and a JSlider.but JSlider is not working. Please help me. thanks import java.io.*; import java.awt.Font; import java.awt.Color; import java.awt.Graphics; import java.awt.geom.*; import java.awt.*; import java.awt.BorderLayout; import javax.swing.*; import java.util.Hashtable; import java.awt.event.*; import javax.swing.event.*; import java.applet.Applet; public class TestLayout extends JApplet { private Drawing drawing; private JComboBox comb; private JComboBox alfa; private JSlider ...

29. JSlider issue    coderanch.com

Hi, I am new to Swing components. I am trying a scenario where in using a loop, I have an object(ball), which moves from one end to another end (source -- destination). Accordingiy, I want to keep a slider to view/control the movement of ball(just like a progress bar). Below is my code. The ball is moving well and there is ...

30. Movie-like timeline with JSlider    coderanch.com

Dear all, The code below is an example of how I want to include a movie-like timeline component in my application. I thought the easiest would be to make use of a JSlider. But somehow, I need to adjust the maximum/minimum of the JSlider when the user is dragging the handle. I tried to simplify this a little bit, by only ...

31. JSlider not displaying    coderanch.com

Rob Prime wrote:Why have you overridden the paint method, and then made it completely empty? Because this way the applet cannot paint anything on the screen. So yes, just remove the method - your applet sub class still inherits the paint method from its parent class (Applet). It is only empty because I tried to pare the applet down to the ...

32. JSlider ChangeEvent problem    coderanch.com

33. To make JSlider frozen    coderanch.com

34. JSlider    coderanch.com

I just want to create Slider with my own graphics. I write this but the slider doesn't displayed. I really don't know how i should to started with this UI. class frame extends JFrame { public frame() { setSize(500, 500); JSlider s = new JSlider(); MSlider m = new MSlider(); s.setUI(m); add(s); } } class MSlider extends MetalSliderUI { public void ...

35. JSlider setActionCommand ?    coderanch.com

36. JSlider (to NOT cont'd trigger statechanged )    java-forums.org

Java Code: import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.util.Hashtable; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.event.*; public class MySlidingScale extends JPanel { Dimension size; BufferedImage source; BufferedImage scaled; double scale = 1.0; public MySlidingScale(BufferedImage image) { source = image; size = new Dimension(source.getWidth(),source.getHeight()); scaleImage(); } protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(scaled, 0, 0, this); } public Dimension getPreferredSize() { return ...

37. Scale 2 or more pictures using a JSlider    java-forums.org

Hi everybody, I posted this message in general Java, I'am not sure if it is right or not. I would like to know how I can display 2 or more images and then make scale in these images on the same time. Thank you. Francisco I found this code here in Java Forums this is my reference: import java.awt.*; import java.awt.event.*; ...

38. How to improve Jslider    java-forums.org

I'm using the following to control a dimmer. The problem is very slow to react. I would like some suggestions of how to improve this code. I would like to open a socket and keep it open and send str value from slider to output stream. I guess what I would like to do is bind the value from slider to ...

39. Adding transparent JSlider    java-forums.org

Hi! I added a JSlider to a jpanel that already got an image as background. Now the JSlider fills in it's area in the screen with ugly beige color. I want it to be transparent so that only the slider is visible with it's sticks and parts. Using button I could assign setContentAreaFilled(false); Now I cant, so any idea how to ...

40. How do I make a JSlider update my canvas with a separate thread?    forums.oracle.com

I want to have the option to update my canvas slowly (Thread.sleep commands), so I need a separate thread to do this. My problem is: I want the slider to make the canvas update continuously as the user moves the slider, but right now, I'm ending up with countless new threads being created... How do I: 1) keep it at only ...

41. JSlider - How?    forums.oracle.com

Interesting comments you made to start: Have you ever seen a window with a slider? Where did it reside in the object? That also might be a good place for your JSlider to go. Where you get the random number for the size of the circle, you should read the slider and scale it's size to be appropriate for your project. ...

42. JSlider    forums.oracle.com

For me the Java tutorial is clear, you have to add a ChangeListener in the GUI object listeneing for slider changes. // from http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html When you move the slider's knob, the stateChanged method of the slider's ChangeListener is called. For information about change listeners, refer to How to Write a Change Listener. Here is the change listener code that reacts to ...

43. JSlider    forums.oracle.com

Hi, I am working on a project to create a pinball game using Java. I have been told to use JSlider to create the spring where the ball fires off from and I am struggling with this part as I haven't used JSlider properly before. The details are written below: i have been told to add a JSlider that acts as ...

44. JSLIDER BUG - PLEASE HELP!!    forums.oracle.com

I just glanced at your code, but I think your error is the following. You should have one component that does the drawing (call it X) and another separate Container for holding X and the slider. This container's layout manager will guarantee that X and the slider will not overlap. You defined HistogramPanel and gave it the jobs of both X ...

45. JSlider Interrupt    forums.oracle.com

46. about JSlider    forums.oracle.com

hi i want use Jslider about speed(low and fast) of paramter shus as a JPanel speedPanel = new JPanel(); speedPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); JSlider speedSlider = new JSlider(JSlider.HORIZONTAL); speedSlider.setBackground(new Color(228, 241, 250)); speedPanel.add("North",new JLabel("Speed:")); speedPanel.add(new JLabel(" Slow")); speedPanel.add("Center",speedSlider); speedPanel .add(new JLabel("Fast")); speedPanel.setBackground(new Color(228, 241, 250)); i want tell me how to use below function with JSlider: public void stateChanged(ChangeEvent e) { } in ...

47. again about JSlider    forums.oracle.com

hi i want use Jslider about speed(low and fast) of paramter shus as a JPanel speedPanel = new JPanel(); speedPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); JSlider speedSlider = new JSlider(JSlider.HORIZONTAL); speedSlider.setBackground(new Color(228, 241, 250)); speedPanel.add("North",new JLabel("Speed:")); speedPanel.add(new JLabel(" Slow")); speedPanel.add("Center",speedSlider); speedPanel .add(new JLabel("Fast")); speedPanel.setBackground(new Color(228, 241, 250)); i want tell me how to use below function with JSlider: public void stateChanged(ChangeEvent e) { } in ...

48. JSlider    forums.oracle.com

Hi, I have created a JSlider and set the snap to ticks to be on. I have five different lables on my slider. What I am trying to do is use my slider as a rotate for the shapes that I have created. I am not sure how to do this. Any suggestions on how to do it?

49. JSlider    forums.oracle.com

I am creating a project in my programming class and I was wondering (since my teacher is no help at all). I want to make a JFrame window with 2 buttons that generate rectangle and oval(random each time). Is it possible to make a JSlider for randomly generated oval or it has to be there on the screen already like it ...

50. JSlider    forums.oracle.com

51. JSlider    forums.oracle.com

Hi, I am developing a java GUI and on the main page it has a setting button that takes you to the setting page. The setting Page is a separate JFrame. On this JFrame I have a JSlider. For some reason whenever I open the setting page without touching the JSlider, it triggers the state changed method. Is it because I ...

52. how to set preferred JSlider length?    forums.oracle.com

How to set preferred JSlider length?? Here's file foo.html: Here's file foo.java: public class foo extends JApplet { public void init() { setLayout(new BorderLayout()); add("Center", new JPanel()); JSlider s = new JSlider(); add("East", s); validate(); Dimension d = s.getSize(); d.width = 400; s.setSize(d); validate(); } } The JPanel should fill as much ...

53. JSlider Help    forums.oracle.com

I really don't understand what you are asking but I suggest you start by reading the JSlider API. There you will find: a) the setValue(...) method which may be what you want to increase the value by 10 b) a link to the Swing tutorial on "How to Use Sliders" In the future, Swing related questions should be posted in the ...

54. JSlider in JTable    forums.oracle.com

55. Non-integer JSlider?    forums.oracle.com

Hi, I am using a JSlider for a user to select values in an application. It works fine for integer values, so mySlider = new JSlider(JSlider.VERTICAL, 0,20,5) works fine. But, some of the values are very small fractions. So for example this... mySlider = new JSlider(JSlider.VERTICAL, 1e-7,1e-6,5e-7) doesn't give the expected result. I notice that the constructor in the Javadocs is ...

56. How to break the limitations in jSlider?    forums.oracle.com

Is it possible to get higher Max than Maximum? Today, Im limited by the int data type, long would be nice. Ive seen some classes that extends jSlider to DoubleJSlider, FloatJslider, but they all resides in the limits of int. Is it any idea/solution to copy the JSlider.java and rewrite it to use another data type? Any pointers in any directions ...

57. Re: JSlider help    forums.oracle.com

Thinak about it carefully int terms of the scope - or visibility - of the variable. You want a variable that is visible outside of the stateChaged() method and that is also visible to the code in your calcPercent() method. What sort of variable do you think would allow you to fulfill both of these requirements? My best first guess would ...

58. Do a discret JSlider    forums.oracle.com

59. JSlider    forums.oracle.com

hi iam very sorry i want use Jslider for speed(low and fast) code: JPanel speedPanel = new JPanel(); speedPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); JSlider speedSlider = new JSlider(JSlider.HORIZONTAL); speedSlider.setBackground(new Color(228, 241, 250)); speedPanel.add("North",new JLabel("Speed:")); speedPanel.add(new JLabel(" Slow")); speedPanel.add("Center",speedSlider); speedPanel .add(new JLabel("Fast")); speedPanel.setBackground(new Color(228, 241, 250)); public void stateChanged(ChangeEvent e) { } i need help about what write in side function stateChanged thanks