jslider

How to set a JSlider to the duration of an audio file?

好久不见. 提交于 2019-12-13 09:29:45
问题 Is this event possible to implement in a JSlider or not? Also, can one be able to move the slider to a certain point in the audio file? To Elaborate, the user can drag the slider to any point in the JSlider which causes the playback to "rewind" or "skip". 回答1: In situation like this, you google. No I'm serious. I used the answer from java wav player adding pause and continue. and How do I get a sound file's total time in Java? and combined them into a solution which allows a JSlider to

How do I make a JSlider background transparent? or How do I properly overlay JComponents in JLayeredPane?

旧巷老猫 提交于 2019-12-13 02:26:22
问题 I am trying to overlay a JSlider on top of a JProgressBar. I am using a JLayeredPane to hold the two components. I am adding the JProgressBar to the JLayeredPane and then adding the JSlider. So far, I have attempted to make the JSlider transparent by setting opaque to false and overriding the paintComponent method. What I end up with is that the slider handle is the only part that becomes transparent while the background stays opaque. It is possible that I am not using the JLayeredPane

Using JSlider to create a date chooser?

血红的双手。 提交于 2019-12-12 21:33:09
问题 I want to implement a date chooser using a JSlider. The user should be able to use the slider to freely choose between two previously known dates. I've seen examples like this one: But I want to do the same, using only one slider. The minimal distance between two points (tick) should be one day. Any hints how to implement that? 回答1: If you want to have a slider with min = 1.1.2012 and max = 10.1.2012 just create a slider with min = 0 and max = number of days in between, then add the selected

Tooltip in labels in JSlider

陌路散爱 提交于 2019-12-12 14:13:05
问题 I want to create a JSlider with labels, which have a tooltip. JSlider slider = new JSlider(); JLabel label = new JLabel("First"); slider.setPaintLabels(true); Hashtable<Integer, JLabel> labels = new Hashtable<Integer, JLabel>(); label.setToolTipText("Tooltip"); labels.put(new Integer(0), label); slider.setLabelTable(labels); But, this code does not work. I think it's because we can add tooltip to JSlider, and it "covered" all others. Is there a method, how I can resolve my problem? 回答1: You

image brightness slider Java

假装没事ソ 提交于 2019-12-11 20:28:50
问题 i have: BufferedImage image; //few lines of code public void stateChanged(ChangeEvent e) { for (int i = 0; i < image.getWidth(); i++) { for (int j = 0; j < image.getHeight(); j++) { Color color = new Color(image.getRGB(i, j)); int r, g, b; val = sliderBrightness.getValue(); r = color.getRed() + val; g = color.getGreen() + val; b = color.getBlue() + val; } } I haven't got any idea how to solve this problem, what should i modify that Image will react on JSlider brightness? 回答1: public void

Multiple JSliders - identifying changes

爱⌒轻易说出口 提交于 2019-12-11 19:17:07
问题 Am I able to add a change listener and define it on creation of a new JSlider? The order in which I need to create and add JSliders means I can't define them beforehand, so I don't really have a way to store them beforehand. Essentially: I don't have named JSliders, but need a way to identify which one has been altered. Will add to this with some example code later if it's not too clear what I am questioning about EDIT: Specifically, imagine I have one JSlider to represent a minimum value,

How to specify a range of valid values in a Java GUI

一世执手 提交于 2019-12-11 16:47:26
问题 I am creating an IMDB application which displays and organizes movies found on you computer (by looking up the metadata via an IMDB API). In my search panel I want to give the user the option of looking for movies that were released in a specific range of years (e.g. between 1990 and 2005). Currently I use for this two JSpinners, one for the minimum year and one for the maximum year and use cross validation to check whether maxYear >= minYear && minYear <= maxYear However I don't think this

Display Modified JSlider Value Above Thumb

拟墨画扇 提交于 2019-12-11 14:28:43
问题 Is there an easy way to change the value displayed in the label above a JSlider while using certain "look and feel"s? To be clear, I'm talking about this value: Specifically, I would like to show the value divided by 1000 instead of the value itself. I know I can set labels for the tick if I display them, but then the user would have to guess the actual value. I also know that I could remove the label using this answer, and then implement my own label that updates with the slider, but that is

Java Slider - how to make custom ticks?

不羁的心 提交于 2019-12-11 09:01:55
问题 I have an audio track with an image slideshow - e.g. there's image 1 at 0:00, image 2 at 0:45, image 3 at 1:03 etc. I'm currently using a JSlider to change position in the track. I'd like to have ticks on the slider in the points where images change - but the spacing between ticks is not uniform, so setPaintTicks is not an option. Is there a way to do this with javax.swing.JSlider , or could you recommend a different slider control? 回答1: I had this problem and didn't find a way to customise

How to change default/start value of JSlider

帅比萌擦擦* 提交于 2019-12-11 06:34:08
问题 I am wondering how I can change my start value of the JSlider I am using. My code looks like this: public ScaleController() { // SLIDER 1: // -------------------------------------------------------------------- setOrientation(SwingConstants.VERTICAL); addChangeListener(this); setMajorTickSpacing(10); setPaintTicks(true); setMaximum(50); setMinimum(-50); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); labelTable.put(new Integer(50), new JLabel("Zoom +5")); labelTable