之前很辛苦的,自己努力建立一個RGB和HSV的調色盤……
然後又遇到電腦當機,整個資料全無等痛苦……不過這又是另一個故事了……
結果……JAVA已經有了啊(JColorChooser)……
絕望啊!我對JAVA這麼好用絕望啊!
以下是我的JColorChooser的測試檔。
顏色分配嘛……是根據eclipse設的……
_,._
゚Å゚)<明明就是你JAVA只有初級者程度的關係
⊂彡☆))Д′)<相信這個應該比我找到的範例(http://ww...emo.htm)好懂多了……
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ColorchooserTest extends JFrame implements ActionListener{
JButton button;
public ColorchooserTest(){
button = new Jbutton("Click Me");
button.addActionListener(this);
JPanel pane = new JPanel();
pane.setLayout(new GridLayout(1,1));
pane.add(button);
Container cpane = getContentPane();
cpane.setLayout(new GridLayout(1,1));
cpane.add(pane);
setTitle("TEST");
setSize(320, 240);
setVisible(true);
}
public void actionPerformed(ActionEvent arg0) {
if(arg0.getSource() == button){
Color c = null;
c =JColorchooser.showDialog(button,"a Color", button.getBackground());
System.out.print(c);
button.setBackground(c);
}
}
public static void main(String[] args) {
new ColorchooserTest();
}
}
沒有留言:
張貼留言
小提示:留言時,可以使用粗體(<b>)、斜體(<i>)、超連結(<a href="網址"> </a>)。另外,以「名稱/網址」留言時,網址可以留空的。