java


How to make the following sliders for a RGB program


I need make a program like a RGB selector, i have the sliders(sliderR, sliderG, sliderB) in my window, but i don't know how make that the sliders change the color instantly, the only i have is the following sliders code:
sliderR.addChangeListener(new ChangeListener() {
#Override
public void stateChanged(ChangeEvent ce) {
int x = sliderR.getValue();
int y = sliderG.getValue();
area.setText("value = \n\n "+x);
Color ColorR = new Color(x,y,0);
area.setBackground(ColorR);
}
});
But, this code only varies for sliderR, the sliderG is static. How i can fix this problem?
The problem is probably that you're not adding the listener to both sliders.
Try this:
ChangeListener listener = new ChangeListener() {
#Override
public void stateChanged(ChangeEvent ce) {
int x = sliderR.getValue();
int y = sliderG.getValue();
area.setText("value = \n\n "+x);
Color ColorR = new Color(x,y,0);
area.setBackground(ColorR);
}
});
sliderR.addChangeListener(listener);
sliderG.addChangeListener(listener);
// Add the listener to any other sliders you want to have this behavior.

Related Links

Open Source Continuous Integration tool for solo developer [Java] [closed]
Why is redis throwing NullPointerException running via JUnit with spring and default config?
Why does this python script run out of memory?
JPanel content not displaying
Regarding initialization of class instances
Sending events via code generation with annotations
Automatically generate Retrofit Types
ClassNotFoundException Error Spring + JSF trying to implement Spring Security login
JPA Entity updating database without persist/merge
Android Studio can't find installed SDK packages
Java SOAP client stub generation with service endpoint determined at runtime
Java EE Websocket: How to send keep sending data without receiving message?
Jetty 9.0.6 - java.net.ConnectException: Connection refused: connect
how to export Javassist CtClass to file
Grails create-app error-nothing works out
Setting member variable in a private method or outside?

Categories

HOME
google-chrome-extension
wso2-am
pypi
hashmap
mean-stack
razor
cmd
frameworks
icloud
enterprise-library-5
uber-api
add
adobe-analytics
spring-kafka
offline
static-libraries
hex-editors
visual-studio-cordova
flask-wtforms
pugjs
custom-wordpress-pages
one-hot-encoding
wkwebview
excel-2007
autosys
maxmind
librato
instant-messaging
data-manipulation
caret
openoffice.org
accelerate-framework
http-referer
picasso
http-digest
az-application-insights
trim
ws-security
optix
nxlog
vao
unixodbc
pango
paxos
return-value
brightcove
media-player
linode
mcafee
spring-cache
medium.com
visual-c++-2008
google-feed-api
rvest
bluemix-app-scan
ipconfig
itextpdf
endeca-workbench
content-length
directoryservices
camanjs
android-imagebutton
phalanger
mdt
rdtsc
ruby-datamapper
flash-builder4.5
excel-2003
eventual-consistency
seed
plasma
gil
broken-links
errai
dotnethighcharts
mod-auth
invite
netbeans-7.1
inotifycollectionchanged
datareader
sproutcore-2
dentrix
fixed-width
database-management
audio-capture
sustainable-pace
thread-local-storage

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App