jslider

How can I change the size of a figure made in Java Graphics2D with a slider?

痴心易碎 提交于 2020-01-10 06:15:26
问题 I'm trying to make a program with java using Graphics 2D that paints polygons between 3 and 8 sides and that I can resized with a slider but I do not know how to do for change it size with the slider evenly. Here is a example of my pentagon drawn if (sides == 5){ g.drawLine(110+x,135-y, 10+x,205-y); g.drawLine(10+x,205-y, 48+x, 320-y); g.drawLine(48+x,320-y, 170+x,320-y); g.drawLine(170+x,320-y, 205+x,205-y); g.drawLine(205+x,205-y, 110+x,135-y); } Now I want to change its size evenly. (I can

Jpanel resize on repaint

人走茶凉 提交于 2020-01-09 08:17:49
问题 i am having a scaling operation performed in the below code. The two sliders in the form are X and Y parameters for an scaling affine transformation. My ask here is when i change the slider the image is getting scaled, how do i dynamically resize my jpanel in which this image is getting painted. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package newpackage; import java.awt.Graphics; import java.awt.Image; import java.awt.geom

Forcing a GUI update inside of a thread - JSlider updates

廉价感情. 提交于 2020-01-06 13:31:32
问题 I'm trying to simulate betting results on a "horse race" by setting JSlider positions within a loop utilizing random numbers. My problem is that, of course, I can't get the GUI to update while the thread is executing, whereby my JSliders do not seem to be racing, they are going from start to finish. I've tried playing around with the code and separating them out into different methods, but I can't get around the single threaded swing issue. Is there a way to force an update or stop the thread

Forcing a GUI update inside of a thread - JSlider updates

家住魔仙堡 提交于 2020-01-06 13:31:29
问题 I'm trying to simulate betting results on a "horse race" by setting JSlider positions within a loop utilizing random numbers. My problem is that, of course, I can't get the GUI to update while the thread is executing, whereby my JSliders do not seem to be racing, they are going from start to finish. I've tried playing around with the code and separating them out into different methods, but I can't get around the single threaded swing issue. Is there a way to force an update or stop the thread

Forcing a GUI update inside of a thread - JSlider updates

筅森魡賤 提交于 2020-01-06 13:31:19
问题 I'm trying to simulate betting results on a "horse race" by setting JSlider positions within a loop utilizing random numbers. My problem is that, of course, I can't get the GUI to update while the thread is executing, whereby my JSliders do not seem to be racing, they are going from start to finish. I've tried playing around with the code and separating them out into different methods, but I can't get around the single threaded swing issue. Is there a way to force an update or stop the thread

JSlider knob not updating (basic Java)

别来无恙 提交于 2019-12-31 07:26:25
问题 I'm implementing a simple horizontal JSlider in Java. No tick marks or anything like that. Probably as simple as humanly imaginable. When I try to "move" the JSlider left-right by dragging it with the mouse, its numerical value does update (I set up a system.out print statement to report the slider's changing values, and they look fine). However, the slider knob itself does not move. It just stays stuck where it started during initialization. Is there some sort of boilerplate code that "every

How to hide the knob of jSlider?

拟墨画扇 提交于 2019-12-31 03:48:29
问题 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

Set the size of a JSlider thumb

倖福魔咒の 提交于 2019-12-29 06:50:06
问题 How can the size of the thumb be configured for a JSlider ? With the defaults, and a range for the JSlider of 256, the thumb is only a few pixels wide, which makes it quite difficult to control with a mouse. I am using the Windows 7 look and feel and the slider looks like this: Enabling paintTicks with a major and minor tick spacing of 0 gives a better (although not preferred) display: The desired display is shown in the following image - taken from a native Windows 7 application: 回答1: You

JButton, JCheckBox and similar interactors do not change visually

你离开我真会死。 提交于 2019-12-28 04:32:06
问题 Here is a simple graphics programs which adds some stars on the screen. import acm.graphics.*; import acm.program.*; import java.awt.event.*; import javax.swing.*; /** * This program creates a five-pointed star every time the * user clicks the mouse on the canvas. */ public class DrawStarMap1 extends GraphicsProgram { public void init() { /* Initializes the mouse listeners */ addMouseListeners(); /* The check box starts out in the "on" position */ fillCheckBox = new JCheckBox("Filled");

How do I correctly use FloatControl with the Java Sound API?

给你一囗甜甜゛ 提交于 2019-12-25 04:03:17
问题 I am currently writing a test program in Java that I want to be able to control my computer's main SPEAKER with a JSlider on a GUI application. I have read through this page on the AudioSystem class and this page on Controls. It is my understanding that I need to get a Port or line through a mixer and then institute a Control on that line or port. Since I am controlling volume I need to implement a FloatControl . My program compiles with no problem, however when I run it and adjust the