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

Why am i getting incompatible types error?
Undefined label in java android
If I have a class called 'exceptions' and it has only static classes, is this breaking Java standards?
Convert json map to java hashmap [duplicate]
Specific return type on AspectJ around call
Environment variables in Ubuntu Tomcat, Apache and Java
Array out of bound in Java
Why are we allowed to have a final main method in java?
Soap request with namespace
NamingException: jta.UserTransaction
BadParcelable Exception occasionally causing app to crash
Error when reading Excel in R: java.lang.OutOfMemoryError: Java heap space [duplicate]
Loading Hive table from Windows machine (Load data local inpath)
Java no abstract and does not override error
How to prevent Gradle from including the resource files in the JAR
ProgressMonitorDialog and user interaction

Categories

HOME
pandas
xamarin
vim
pypi
netbeans
activiti
relative-path
jira
google-oauth
cmd
acquia
adfs
maude-system
spring-kafka
handsontable
google-pagespeed
abi
ehcache
web-sql
firebase-crash-reporting
p-value
microsoft-sync-framework
vlsi
windowbuilder
subdomains
c++-amp
google-rich-snippets
jspresso
gtrendsr
theano.scan
unobtrusive-validation
hue
opshub
graphenedb
hp-ux
google-closure
nxlog
qcombobox
babel-core
long-polling
jsch
dotcover
qsslsocket
prolog-setof
boost-multi-index
clean-architecture
dandelion
jxcore
typed-lambda-calculus
akka-cluster
gcsfuse
color-profile
webdriverjs
database-optimization
transmitfile
simplewebrtc
cloudbees
phpcas
natvis
jfugue
wireshark-dissector
method-parameters
appfabric-cache
sankey-diagram
lustre
dia
operator-precedence
gadt
file-copying
rdtsc
valuechangelistener
rtmfp
algebraic-data-types
listings
file-locking
dataadapter
hungarian-algorithm
type-equivalence
jelly
twrequest
appconkit
netbeans-6.9
nsobject
yetanotherforum
calling-convention
site.master
digest-authentication
sortable-tables
revisions
ext3
privilege

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