2013-05-02 55 views
0

这里是我的矩形代码:如何将调整大小滑块添加到Java中的矩形形状?

if(rect){ 
    gphcs.setColor(Color.BLUE); 
    if(orangeshp) 
     gphcs.setColor(Color.ORANGE); 
    if(greenshp) 
     gphcs.setColor(Color.GREEN); 
    gphcs.fillRect(20,35,100,30); 
} 

我想,以便更改矩形的大小增加大小调整滑块。

这里是滑块的样品PIC我想补充:

enter image description here

我只需要任何简单的代码来创建此滑块。

感谢您的时间..

回答

1
JSlider size = new JSlider(JSlider.HORIZONTAL, 0, 250, 100); 
+0

顺便说一句 - 如果这不是问题的答案,我建议你编辑的问题(以使其更具体)。 – 2013-05-02 19:32:46

1
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 250, 100); 
slider.addChangeListener(this); 


public void stateChanged (ChangeEvent event){ 
JSlider slider = (JSlider)event.getSource(); 
int value = slider.getValue(); 
//manipulate the value in the proption you wants to increase your coordinate of rectangle 
//change the size of rectangle here  
}