簡體   English   中英

如何在java中將調整大小滑塊添加到矩形形狀?

[英]How to add resizing slider to rectangle shape in 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);
}

我想添加一個調整大小滑塊以更改矩形的大小。

這是我要添加的滑塊的示例圖片:

在此輸入圖像描述

我只需要任何簡單的代碼來創建這個滑塊。

謝謝你的時間..

JSlider size = new JSlider(JSlider.HORIZONTAL, 0, 250, 100);
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     
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM