简体   繁体   English

在小程序中选择自定义颜色

[英]Selecting a custom color in an applet

I am creating a paint program in java for class.我正在用java为课堂创建一个绘画程序。 The user needs to be able to define custom colors to paint with.用户需要能够定义自定义颜色进行绘画。 I figure the best way to go about this would be to have an icon the user clicks on, resulting in a pop-up selection window with sliders to define the three RGB values of a color.我认为最好的方法是让用户点击一个图标,从而产生一个带有滑块的弹出选择窗口,用于定义颜色的三个 RGB 值。 What would be the best way to go about this?解决这个问题的最佳方法是什么? I've found JSlider but can't figure out how to implement it as a pop-up window as a result of an icon being clicked.我找到了JSlider但无法弄清楚如何通过单击图标将其实现为弹出窗口。

Use a JColorChooser .使用JColorChooser See How to Use Color Choosers for details.有关详细信息,请参阅如何使用颜色选择器。

颜色选择器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM