What kind of listener do I need?  pass an ActionEvent?

How do I add a listener to ColorChooser? Everytime ColorChooser generates a Color I want to pass the Color to the JFrame setBackground(). Exactly once colorChooser1PropertyChange in the JFrame will do this, but it only does it once.
Somehow, I need to setup a listener but I'm not quite sure how nor what kind. I'm vaguely thinking that an ActionEvent could help here, but I'm not positive. I think that ColorChooser needs to pass an event of some kind, and then the JFrame needs to set up a listener to grab the event.
I'll revisit the Sun tutorial, but would greatly appreciate guidance :)
The ColorChooser is the heart, this is a javabean:
package a00720398.util;
import java.awt.Color;
public class ColorChooser extends javax.swing.JPanel {
    private Color color = new Color(0, 0, 0);
    /** Creates new form ColorChooser */
    public ColorChooser() {
        initComponents();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    private void initComponents() {
        red = new javax.swing.JSlider();
        green = new javax.swing.JSlider();
        blue = new javax.swing.JSlider();
        setLayout(new java.awt.GridLayout(3, 1));
        red.setMaximum(255);
        red.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                redStateChanged(evt);
        add(red);
        green.setMaximum(255);
        green.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                greenStateChanged(evt);
        add(green);
        blue.setMaximum(255);
        blue.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                blueStateChanged(evt);
        add(blue);
    private void redStateChanged(javax.swing.event.ChangeEvent evt) {                                
        //System.out.println(setColor().toString());
        setColor();
    private void greenStateChanged(javax.swing.event.ChangeEvent evt) {
        //System.out.println(setColor().toString());
        setColor();
    private void blueStateChanged(javax.swing.event.ChangeEvent evt) {
        //System.out.println(setColor().toString());
        setColor();
    public void setColor() {
        color = new Color(red.getValue(), green.getValue(), blue.getValue());
        System.out.println(color);
    public Color getColor() {
        return color;
    // Variables declaration - do not modify
    private javax.swing.JSlider blue;
    private javax.swing.JSlider green;
    private javax.swing.JSlider red;
    // End of variables declaration
}the JFrame:
package a00720398.view;
import java.awt.*;
public class Lab2Frame extends javax.swing.JFrame {
    public Lab2Frame() {
        initComponents();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    private void initComponents() {
        top = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        bottom = new javax.swing.JPanel();
        colorChooser1 = new a00720398.util.ColorChooser();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);
        javax.swing.GroupLayout topLayout = new javax.swing.GroupLayout(top);
        top.setLayout(topLayout);
        topLayout.setHorizontalGroup(
            topLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGap(0, 608, Short.MAX_VALUE)
            .addGroup(topLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(topLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        topLayout.setVerticalGroup(
            topLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 159, Short.MAX_VALUE)
            .addGap(0, 159, Short.MAX_VALUE)
            .addGroup(topLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(topLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        getContentPane().add(top);
        bottom.setLayout(new javax.swing.BoxLayout(bottom, javax.swing.BoxLayout.Y_AXIS));
        colorChooser1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                colorChooser1PropertyChange(evt);
        bottom.add(colorChooser1);
        getContentPane().add(bottom);
        pack();
    private void colorChooser1PropertyChange(java.beans.PropertyChangeEvent evt) {
        jTextArea1.setBackground(colorChooser1.getColor());
        System.out.println(evt);
     * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                Lab2Frame frame = new Lab2Frame();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
    private void setBackground() {
        jTextArea1.setBackground(colorChooser1.getColor());
    // Variables declaration - do not modify
    private javax.swing.JPanel bottom;
    private a00720398.util.ColorChooser colorChooser1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JPanel top;
    // End of variables declaration
}thanks,
Thufir

Please stop starting multiple threads about the same concern without even waiting for the reply to first thread.
Please continue discussion here: [http://forum.java.sun.com/thread.jspa?threadID=5313231&tstart=0]

Similar Messages

  • I want to use the Web module to publish to the a website... What kind of server do I need to be able to publish my website?

    I want to use the Web module to publish to the a website... What kind of server do I need to be able to publish my website?

    You don't need a server, you just need a web hosting package such as the ones from GoDaddy or many other hosts. You then send the web gallery directly from LR to your web space.
    As you're asking such basic questions, it might be best if you read articles like this and see if a friend or colleague can get you started.

  • I am moving to the UK, What kind of charger do I need?

    I have a MacBook I got in 2009. Im moving abroad in September and Im trying to figure out what kind of charger I will need. I know you can pop off the little plug part on the adapter, and I saw on amazon that I can buy an extension that fits onto the adapter with a UK head on it. Do you think this will work? Or am I going to have to buy a completely new charger? I hope not because the adapter head on Amazon is only like $10!!! Here is a link to the adapter head which I think might work http://www.amazon.co.uk/extension-power-Adapter-Charger-Macbook/dp/B004S6VIG2/re f=sr_1_3?ie=UTF8&qid=1311011961&sr=8-3
    I guess Im just wondering if anyone else has had experience with this. I know the voltage in the UK is like 220 and in the Sates its only 110, and I obviously dont want to fry my computer or the adapter, so I just want to make sure Im doing the right thing!!!!!!!
    Thanks everyone!

    Thanks guys this is really helpful! Last time I was there I just used an adapter and ended up frying a few things haha so I think I'll get a cord instead!!! Yay, I love my Mac and would never want to hurt it haha, thank goodness they make things so easy

  • What kind of Firewire do I need for the new Mac?

    Hey Apple Community,
    I have a new late 2013 Macbook Pro. I noticed that it has a new firewire port! However, I need to digitize video footage from Mini DV tapes. The camera I'll be using to digitize my footage is a Canon Vixia HV30. Does anyone know what kind of firewire cable I'd need? Will I need an adapter of some sort?
    Thanks for the help!

    What kind of cable would I need exactly? I'd like to look it up and buy what I need today so that I could start my work soon. Here's some reference pictures:
    And do you recommend any particular cable? I'd like to purchase a reliable product.
    Thanks again for the help!

  • What kind of mac would I need for Nexflix, basic search and email? Also, sounds silly, but can I connect an HDMI from Mac to tv?

    What kind of mac would I need for Nexflix, basic search and email? Also, sounds silly, but can I connect an HDMI from Mac to tv?

    Just an FYI.  The Macs named PowerMac date from early 2006 and before.  Use this tip to discover where to post once you get your Mac:
    Site map of Communities and Categories
    The cheapest Mac available new is a Mac Mini.   It is no bigger than many an external hard drive.  But the screen and keyboard and mouse must be purchased separately.  They support USB and Bluetooth keyboards and mice, and pretty much any DVI, HDMI, or displayport display.   Although the iMac is certainly an attractive option if all you want to deal with is deciding on a printer.   I still recommend getting an Apple USB keyboard for the occasional times you may need to troubleshoot startup issues.  Normally not a problem, but as it gets older some issues can be fixed at startup or diagnosed at startup.

  • What kind of screws do I need to replace missing ones on the bottom case of my macbook pro

    what kind of screws do I need to replace the missing ones on the bottom of my macbook pro case?  i see there are 3 mm screws for sale and 13.5 mm screws for sale; which ones do I need?  thanks.

    10 screws, seven 3mm ones and three 13.5 mm ones.

  • What kind of card do i need, and how easy is it to install?

    I bought an airport base station, and found that my 2004 ibook G4 cannot go wireless. I called apple, and they said to buy a card on ebay and installing it won't be too hard. I'd rather do this than buy a new computer, as i just bought tiger. What kind of card do i need and how do i install it? thanks.
    ibook G4   Mac OS X (10.4.4)  

    You will need the original Airport card and not an Airport Extreme card.
    That is incorrect. The iBook G4 requires the AirPort Extreme card.

  • In CS5: what kind of graphic board i need, If I paint it stutter!

    In CS5: what kind of graphic board i need, If I paint it stutter!

    Without any system information nobody can advise. What operating system? What system specs? What graphics hardware do you use currently? What input device? What settings in Photoshop? We could tell you to buy the latest and greatest card out there, but that might not at all resolve your issue because it#s caused by something else....
    Mylenium

  • Hello. I ve got a question. I accidentally bought membership but it doesnt have Adobe Muse that I need. What should I do? Can I extend my membership for the right one, or should I first get the money back. What kind of membership do I need to have Adobe M

    Hello. I ve got a question. I accidentally bought membership but it doesnt have Adobe Muse that I need. What should I do? Can I extend my membership for the right one, or should I first get the money back. What kind of membership do I need to have Adobe Muse software?

    Plans are listed at Creative Cloud pricing and membership plans | Adobe Creative Cloud
    The drop down at individual plans does show that you may subscribe to only Muse
    You probably need to cancel what you have... You need Adobe support to cancel a subscription
    -start here https://forums.adobe.com/thread/1703848
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html
    --and two links which may provide more details, if the above links don't help you
    -http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html

  • What kind of wireless card I need for my Power Mac G5 (late 2005) Dual 2 GH

    hi there,
    I have for sometime now a "Power Mac G5 (late 2005) Dual 2 GHz PowerPC G5", and recently I have been thinking to get an Airport extreme wireless card with a bluetooth on it, which could work on my machine.
    I have already try to deal with apple representatives and Apple sales people to give me a hand on the matter and so far is been a nightmare to approach this guys, tired of wasting time and effort, so that is way I am posting a topic on this section to see if you guys could give a hand on the matter.
    All what I would like to know is what kind of wireless card I need for my Power Mac G5 (late 2005) Dual 2 GHz PowerPC G5 (version 10.4.11) and where I could buy one on line to install myself.
    This is the mac unit I have.
    Dual 2 GHz PowerPC G5.
    Hardware Overview:
    Machine Name: Power Mac G5
    Machine Model: PowerMac11,2
    CPU Type: PowerPC G5 (1.1)
    Number Of CPUs: 2
    CPU Speed: 2 GHz
    L2 Cache (per CPU): 1 MB
    Memory: 4.5 GB
    Bus Speed: 1 GHz
    Boot ROM Version: 5.2.7f1
    Thanks for you time.
    regards
    Toyko koyko

    You're welcome. Funny how Apple works isn't it? If it's any consolation, that Airport/Bluetooth card doesn't show up on the Apple U.S. store either. I don't think they ever intended it to be a user installable part, so perhaps that's why they don't offer it for sale. Do you have any Apple Authorized Service providers in your area? I'd think they'd be able to order the card as a replacement part.
    Can you give a little more detail or a link to the gadget you're referring to? It sounds like a USB dongle to enable Wi-Fi, but that must be a third party solution, since I don't believe Apple ever offered something like that.

  • What kind of charger do I need for my macbook core 2 duo 2 ghz.

    What kind of charger do I need for my macbook core 2 duo 2 ghz. I just bought one used that didn't come with a charger.

    There's 8 different models of MacBooks that are 2.0Ghz. To see which model you have go to the Apple in the upper left corner and select About This Mac, then click on More Info (and then System Report if you’re running 10.7 Lion).When System Profiler comes up check the Model Identifier.
    You can get a new power adapter on eBay forabout $20
    http://www.ebay.com/sch/i.html?_nkw=macbook+power+adapter&_sacat=0&_sop=12&_dmpt =Apple_Laptops&_odkw=macbook+power+adapter&_osacat=111422&_trksid=p3286.c0.m270. l1313

  • Hello, is it possible to connect a iPod shuffle 4 to a car BMW ? What kind of cables do I need ?

    Hello, is it possible to connect a iPod shuffle 4 to a car BMW ? What kind of cables do I need ?

    Is there an AUX port?  If so, you can by the necessary auxillary cable.  It won't work with the USB port connection.
    B-rock

  • HT2534 I want to release an app in the app store. What kind of account do I need?

    I want to release an app in the app store in the UK. What kind of account do I need and how do I set it up?
    Thanks

    https://developer.apple.com/programs/ios/
    Regards.

  • What kind of adapter do I need in South Africa

    What kind of adapter do I need for my I pad and my iPod In South Africa

    This is one easily available for US to South Africa plug adapting:http://www.amazon.com/Grounded-Adapter-Africa-Ireland-Certified/dp/B000BMC57I

  • What kind of Ram do I need for my Mac?

    Hello
    I want to upgrade the speed of my mac by adding a 2GB stick of ram. But what kind of ram do i need? Would this work for my Mac (Mid 2011 21.5 inch) http://www.amazon.co.uk/Crucial-PC3-10600-Desktop-Upgrade-240-pin/dp/B001NA25VS/ ref=sr_1_1?ie=UTF8&qid=1390290563&sr=8-1&keywords=2gb+ram?

    Macs are very, VERY picky about the RAM specs they need.
    That RAM is the wrong pin count and probably for PCs and not a Mac
    Here is the proper RAM spec for your year and model.
    32 GB (Actual) 16 GB (Apple)
    Memory Slots
    4 - 204-pin PC3-10600 (1333 MHz) DDR3 SO-DIMM
    Correct and reliable Mac RAM can be purchased from online Mac RAM sources Crucial memory or OWC (macsales.com).
    http://www.crucial.com/store/listparts.aspx?model=iMac%20(21.5-inch%2C%20Late%20 2011)&Cat=RAM
    http://eshop.macsales.com/shop/memory/iMac/2011/DDR3_21.5_27
    Good Luck!

Maybe you are looking for

  • Firefox 37 keeps crashing, Plugin-hang...aplication error message, & won't let me update Adobe Flash player

    Ever since I updated to Firefox 37 my Firefox has been crashing. It started only doing it periodically, then it got so that if I scrolled down a page it would close. Then it got to the point where as soon as I opened Firefox it would immediately cras

  • How to use Workflow Background Engine in Oracle Apps?

    I have created the development of a custom workflow,tested it in Developer studio in Workflow administrator and has been working correctly. I was hoping to implement this workflow using Workflow background process Concurrent request and move to produ

  • Number Range Interval Deactivated

    Dear Experts, Could anybody suggest on this problem as follows: While configuring Number range interval to GL Account,  the interval buttons(create) is deactivated and error message showing as No. Range is locked by sapuser for maintenace Srinivas

  • What is "swat" where can i find more info.

    Hi everyone, I hope this is the appropriate forum to post this, I need to find out about swat.ReturnCode and swat.cwa and the whole API. Any hint or resources would be very much appriciated. Thanks inadvance

  • Identify Scene number in comment bar

    When viewing the comments listed in the 'comments panel' it would simplify searching to see in each comments bar the actual scene number. This way, you could locate a particular scene quickly and open it. At the moment you have to double click each c