我制作了一个GUI,它使用滑块来上下缩放对象.(在本例中为矩形).我想知道是否还有一种方法可以使用滑块来指定旋转度.因此,将有2个滑块用于控制比例,另一个用于控制旋转.如果有人能帮助我做到这一点,这将是我迄今为止只有比例滑块.
import javax.swing.*;
public class Parker
{
public static void main(String[] args)
{
TheWindow w = new TheWindow();
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //X wont close the window with out this line
w.setSize(1280,720);
w.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class TheWindow extends JFrame
{
private JSlider slider; //declare slider
private drawRect myPanel; //declare/ create panel
public TheWindow()
{
super("Slider Example"); //make title
myPanel = new drawRect();
myPanel.setBackground(Color.cyan); //change background color
slider = new JSlider(SwingConstants.VERTICAL, 0, 315, 10);// restrains the slider …Run Code Online (Sandbox Code Playgroud)