Help with getting button color.

I'm trying to make a little paint program. i want to be able to click on a color button and then assign the color of that button to a variable Color brushColor.
funny thing is, when i compile this, it tells me that
C:\java\javaprograms\TryPainting.java:21: getBackground() in java.awt.Component cannot be applied to (java.awt.Button)
          brushColor = paintTheBrush(getBackground(source));
strange, getBackground is explicitly listed as a method that Button inherits from Component in the API.
any suggestions on a way to accomplish this?
thanks in advance,
jason
------code follows-------
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
//colored buttons of "paint"
class OilPaint extends Button{
Color brushColor = Color.white;
OilPaint(String label, Color color) {
     setLabel(label);
     setForeground(color);
     setBackground(color);
     addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent e) {
     Button source = (Button)e.getSource();
     brushColor = getBackground(source);
     public Color paintTheBrush(Color color) {
          return color;
// canvas to paint on - this isn't working yet. can't even get the
// setSize to work, though it does compile.
class Canvas extends JPanel{
     Canvas(){
          setBackground(Color.white);
          Dimension canSize = new Dimension(300,300);
          setSize(canSize);
// displays the lsit of color button choices in a small panel at bottom
// of window
class ColorChoices extends JPanel{
     ColorChoices() {
          setBackground(new Color(220,255,255));
          add(new OilPaint("paint",Color.blue));
          add(new OilPaint("paint",Color.red));
          add(new OilPaint("paint",Color.green));
          add(new OilPaint("paint",Color.white));
          add(new OilPaint("paint",Color.black));
//this is the main class of the program TryPainting.java
class TryPainting {
     public static void main(String[] args) {
          JFrame window = new JFrame();
          Toolkit toolkit = window.getToolkit();
          Dimension winSize=toolkit.getScreenSize();
          window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          window.setBounds(5,5,winSize.width/2,winSize.height/2);
          Container content = window.getContentPane();
          content.setLayout(new BorderLayout());
          content.add("North",new Canvas());
          content.add("South",new ColorChoices());
          window.setVisible(true);

duh.. thanks man, that did the trick. i'm pretty new at this. i really appreciate the help. i got stuck thinking of the getBackground() as a function, rather than a method. this oop stuff is wacky weird fun!
jason

Similar Messages

  • Need help with a button

    Hello,
    I need help with a button. I created a button and set it up
    so that when you click and hold it, the button becomes lighter in
    color (I used Alpha). I want the button to stay this light color
    after i release the click. Right now it goes back to the normal
    color when I release the click. Can somone help we this?
    Thanks!

    rpofclt wrote:
    > Hello,
    >
    > I need help with a button. I created a button and set it
    up so that when you
    > click and hold it, the button becomes lighter in color
    (I used Alpha). I want
    > the button to stay this light color after i release the
    click. Right now it
    > goes back to the normal color when I release the click.
    Can somone help we
    > this?
    you can't use the button itself if you want to maintain the
    DOWN state after
    release as button automatically resets itself once the mouse
    lives the HIT zone.
    Use movie clip instead and on press simply send it to a frame
    where there
    is DOWN state like image.
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • I have been having a issue with getting the colors on my monitor to match the colors fro my print lab. I now have the monitor calibrated to match the prints but when I open elements it doesn't use the same colors. If i have it use the calibrated profile b

    I have been having a issue with getting the colors on my monitor to match the colors fro my print lab. I now have the monitor calibrated to match the prints but when I open elements it doesn't use the same colors. If i have it use the calibrated profile by changing the color management settings, the color picker no longer shows true white or black. How do I get elements 12 to honor the new calibrated settings?

    Ok so I've done what you said and this is what it's come back ....
    I don't know that these are the errors , but they're the things which don't look right ...
    Throughout the shut down there is a recurring line ;
    It says ;
    Com.apple.launchd 1 0x100600e70.anonymous.unmount 301 PID still valid
    Then there are 2 more which I think are related ;
    Com.apple.securityd 29 PID job has I overstayed its welcome , forcing removal.
    Then the same with fseventd 48 and diskarbitrationd 13
    Oh and on Launchd1 : System : stray anonymous job at shut down : PID 301 PPID13 PGID 13 unmount...
    Then the last process says "about to call: reboot (RB_AUTOBOOT).
    Continuing...
    And stops ...
    Hope this means something to you ... Thanks again for your help so far :-)

  • Help with linking buttons to Scenes

    Hey,
    Rookie to Flash and AS3. Just needed some help with my buttons. Im making a flash program about pancakes (random I know). I have a "Mainmenu" scene and then a "Recipe" scene. I have a button on my mainmenu which takes me to the recipe page when I click it, the code behind the button is
    "stop();btn_recipe.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);function mouseDownHandler(event:MouseEvent):void {
    gotoAndStop(1, "Recipe");
    Then when I arrive at my recipe page I have a button which will take me back to my MainMenu, the code behind that button is:
    "stop();btn_home.addEventListener(MouseEvent.MOUSE_DOWN, mouse5DownHandler);function mouse5DownHandler(event:MouseEvent):void {
    gotoAndPlay(1, "MainMenu");
    So I run my program and the first button works and takes me to recipe page but the button to get to the main menu does nothing, click it and no response or anything
    Please help

    First, hopefully having all your code mushed onto the same line is a copy/paste error, otherwise it should look like...
    stop();
    btn_recipe.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    function mouseDownHandler(event:MouseEvent):void {
         gotoAndStop(1, "Recipe");
    If the intention is to click the buttons to make them work, then you should use CLICK instead of MOUSE_DOWN.  MOUSE_DOWN can be a persistent state whereas CLICK involves releasing it afterwards.
    As for the code to get you back home, where is it located on the timeline?  Are you getting any error messages when you try to use it?
    One thing you should learn to use is the trace() function.  It is useful for troubleshooting.  You can use it now to see if your second button is talking to the function at all...
    stop();
    btn_home.addEventListener(MouseEvent.CLICK, mouse5DownHandler);
    function mouse5DownHandler(event:MouseEvent):void {
         trace("the button works okay");
         gotoAndPlay(1, "MainMenu");
    If you don't get that message in the output panel, you'll know the button is not properly coded to work.
    Most folks here will recommend you get away from using scenes in a design that includes navigation--they have a history of being problematic.  Instead of using scenes, divide the one main timeline up into sections or use movieclips for the sections and manage their visibility... or do a bit of both.

  • HT4199 I need help with getting my printer to print, PLEASE.

    I need help with getting my printer to print, Please.

    What have you done so far?
    I suggest you connect it via a usb  cable first.  Once you get the printer working, move to wifi.  You will have to use an existing printer usb cable or purchase a cable.  Be sure to get the correct cable.  Ask for help.
    The warrenty indicates there is phone support.  Give HP a call.
    Warranty
    One-year limited hardware warranty; 24-hour, 7 days a week phone support
    Robert

  • Need help with encore buttons - highlights

    Hi All
    I am seeking help with Encode CS5. I have a project working fine except that I dont have highlights for buttons, at least I think thats what its called. So when the mouse or remote control navigates up/down toa button it changes colour.
    In the properties of my button, the highlight option is greyed out.
    How do I apply highlights ?
    many thanks
    Chris Anderson

    Hi Bill
    Thanks for your reply.
    Here are 2 screen prints. One from encore the other from photoshop.
    First time I have inserted images, and they seem a little small on this message - if you have any problems reading I could email to you.
    I have highlighted the first button - which is called 'Highlights' - same issue with all the other buttons.
    Do you have to use photoshop to add highlighting? or can you do this in encore - i dont have much experience with photoshop.
    Not sure how to check 'Color Set' ? can you tell me how to get that for you - same for transparency for states? - I havent experienced them or changed them as I dont know how to
    Yes it was duplicated - have left a message not to reply
    Thanks again
    Chris

  • Help with getting a better understanding on how APEX submits its pages

    Hi,
    I have implemented jquery with my app and have just applied the jquery UI plugins.
    I have the jquery UI dialog function working which gives the users some options. Now as an example, I have a cancel and a continue button. If the user clicks cancel it simply stops the page from submitting. Which works perfectly however, I cannot get the continue button to carry on with the request.
    I gather that I will need to determine what the href was of the link/button that was clicked before the dialog box appears.
    I know Apex uses a javascript function call doSumit() which simply submits the page but what does it use for other href like links to other pages?

    The problem is that you're taking a camcorder format that Premiere Elements is able to work with and converting it to a format that it can NOT work with.
    That Canon camcorder produces AVCHD video. You should shoot any video you want to edit in Premiere Elements only in MXP or FXP mode. Then, when you're ready to edit the video in Premiere Elements, you should set up a project for AVCHD 1920x1080 stereo. (Unless you're shooting in 5.1 audio. This cam shoots in a number of formats.)
    DO NOT CONVERT YOUR VIDEO BEFORE YOU PUT IT IN PREMIERE ELEMENTS.
    You can then use these specs to output high-quality video for YouTube.
    http://forums.adobe.com/thread/623549?tstart=0
    If you need some basic help with the program, be sure to check out my free 8-part Basic Training tutorial series at Premiere Elements support site Muvipix.com.
    http://forums.adobe.com/thread/537685?tstart=0

  • Little bit of help[ with a button.

    Good day all!
    I need help making a button. This is what I want to happen.
    I have a bunch of text, One of the words "merino" is bule as
    to say there is a link hear! And I want an image of the "merino" to
    come up, like a "ALT" box. Or have an image in the "ALT" box?
    I know how to do this in "Flash" i.e just drop in the image
    on the over state of the button event. Easy as pie! This is why I
    cant get to grips with Dreamweaver! I hate it!
    But I am willing to learn and maybe in time love???
    Thanks all!

    "satrop" <[email protected]> wrote in
    message
    news:f0o4t7$954$[email protected]..
    > Good day all!
    >
    > I need help making a button. This is what I want to
    happen.
    >
    > I have a bunch of text, One of the words "merino" is
    bule as to say there
    > is a
    > link hear! And I want an image of the "merino" to come
    up, like a "ALT"
    > box.
    >
    > I know how to do this in "Flash" i.e just drop in the
    image on the over
    > state
    > of the button event. Easy as pie! This is why I cant get
    to grips with
    > Dreamweaver! I hate it!
    >
    > But I am willing to learn and maybe in time love???
    HTML is a lot different from Flash! :-)
    I believe you could do this using DW's Show-Hide layer
    behavior - have
    mousing over the link trigger a layer with the image to
    appear. Someone else
    may have a better idea.
    Just FYI, having to mouse over a link in order to get more
    information about
    it isn't usually appreciated by users. You *might* want to
    re-think this
    plan..
    Patty Ayers | Adobe Community Expert
    www.WebDevBiz.com
    Free Articles on the Business of Web Development
    Web Design Contract, Estimate Request Form, Estimate
    Worksheet

  • UWL - Help with Decision Buttons

    Hello SDNers,
    I'm customizing the UWL iView to show approval itens only, and their respective decision buttons.
    Everything looks ok, but when someone try to submit the decisions it shows the message:
    "reject wasn't correct"
    Where "reject" is the name I gave to the action.
    It also happens with the approval action.
    Below is the XML I've created.
    Does someone have a clue in what that message means, or what I've done wrong?
    Thanks in advance!!

    Hi There,
    Make sure that your decisionKeys are correct.  I have seen issues with this many times.  Log on to the backend system and call  SAP_WAPI_DECISION_READ or SWK_DECISION READ for a specific workitem  (You can get the details of the workitem id from the support information on the UWL - enable this and you can check this specific workitem)  The decision key is an internal value (typically a numeric value) corresponding to the selected decision used by the provider.
    You will need to ensure that you have x amount of decisions configured in the xml file, where x = the amount of decisions configured in the backend system.
    For additional help with this topic please see the userDecision Action Handler documentation:
    http://help.sap.com/saphelp_nw70/helpdata/en/7a/df014b037141ca9afc6433ed42b519/content.htm
    Beth Maben
    EP - Senior Support Consultant II
    AGS Primary Support
    Global Support Centre Ireland
    Please see the UWL Wiki @
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/bpx/uwl+faq  ***

  • Help with get-aduser -filter command

    Hi! I'm having problems with getting user info from displayname
    function searchuzv {
    $uzvinfo=$InputBoxuzv.text;
    $uzvcheck = Get-ADUser -filter "DisplayName -like '*$uzvinfo*'"
    If i run Get-ADUser -filter "DisplayName -like '*$uzvinfo*'" line separately, everything is ok, and working, but when I run function, I m getting error "Get-ADUser : The search filter cannot be recognized"
    My objective is get user info when only part of displayname is provided.
    I suppose there is problem with syntax, but I can't find anything about this.
    Any suggestions?
    Bert regards,
    Ronald

    Hi Ronald,
    Try this.
    function searchuzv
    $uzvinfo=$InputBoxuzv.text
    $uzvDisp = "*"+$uzvinfo+"*"
    $uzvcheck = Get-ADUser -filter "DisplayName -like $uzvDisp"
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • I need help with a button animation!

    Hi,
    I hope someone can help with a simple-looking problem which
    nonetheless has me stumped!
    I have a feeling that I've missed something obvious.
    I've created a movie clip to act as a button (I've called it
    "abs_button") and placed it on the stage.
    My main movie has one frame.
    Within the "abs_button" movie clip there are 5 layers.
    Labels, actions, default button state, rollover state and rollout
    state.
    Technically, default button state, rollover state and rollout
    state could be on the same layer as they don't overlap, but I've
    given each animation its own layer for clarity.
    FRAME 01.
    Default button state is one frame with a graphic of the
    button. Just a label at the start ("abs_up") and a "stop();" action
    at the end.
    FRAME 02 to 31.
    Rollover state is a 30 frame animation. Label at start
    ("abs_over"), "stop()"; action at the end.
    FRAME 32 to 62.
    Rollout state is a 30 frame animation. Label at start
    ("abs_out"), "stop()"; action at the end.
    All animations were achieved with tweens.
    My initial "abs_button" code:
    on (release) {
    getURL("targetPage.htm", "_self");
    on (rollOver) {
    gotoAndPlay("abs_button", "abs_over");
    on (rollOut) {
    gotoAndPlay("abs_button", "abs_out");
    As it stands, the animation jumps to frame 1 of "abs_out" on
    rollout.
    I need the "abs_over" animation to always play through to the
    end, as the "abs_out" is "abs_over" in reverse (i.e. image grows
    large on rollover and shrinks again on rollout.
    I've tried for 2 days to solve this, but I clearly need help.
    My experiments with variables simply didn't work.
    I would be grateful if someone could tell me where I'm going
    wrong!
    Thanks,
    Andy

    use this:
    on (rollOver) {
    gotoAndPlay("abs_over");
    Since the code is attached directly to the movieclip, you
    don't have to
    identify the clip. A gotoAndPlay() function takes a frame
    number or a
    frame label name as its argument, never the name of the clip
    that
    contains the frame number or name.
    Rob
    Rob Dillon
    Adobe Community Expert
    http://www.ddg-designs.com
    412.243.9119

  • Help With Radio Buttons -- URGENT!!

    Hi i am new to using UI compents in flash.
    Basically i havnt a clue where to start.
    Just some simple action script will help and be much
    appreciated if someone can give me it.
    Basically i have a question to ask which requires radio
    buttons to answer the question.
    I have a question and the answers are A, B, C, D.
    I want:
    A to equal 1
    B to equal 2
    C to equal 3
    D to equal 4
    E to equal 5
    Would someone be able to tell me how to set up the radio
    button so that the value of the radio button is stored into an
    array called SCORE.
    i dont need a tutor for arrays, i can do them, i just need
    help with the radio buttons so a reference to an array would be
    enough, eg how to store the answer from the radio button in an
    array.
    Thank you

    Place the radio buttons on the stage and set their parameters
    to what you need. Make sure that for each group of radio buttons
    you give them the same group name. Then you could use something
    like this:
    var listenerObject:Object = new Object();
    var answerArr:Array = new Array();
    listenerObject.click = function(eventObj:Object) {
    answerArr.push(eventObj.target.selectedData);
    trace(answerArr);
    radioGroup.addEventListener("click", listenerObject);
    radioGroup refers to the group name for the buttons.
    eventObj.target will refer to the actual radio button
    clicked.
    Tim

  • Help with making buttons work within mc/shape tween

    hi,
    i've created a movie clip for a navigation link named
    "Products". when you mouse over the "Products" mc, the movie clip
    has a sub-navbar that tweens horizontally out of the movie clip.
    when the subnav is done coming out and stops, i have buttons that
    appear that i would like the user to be able to click on.
    everything works out fine until i roll over the button the rollover
    state doesn't work. i have a feeling it is because the button is
    nested, but not sure.
    i set up a simple example here:
    http://kurtcom.com/examples/jeannettes_damn_navbar.html
    let me know if you want me to email you the file as well,
    thanks!

    A single Path would just be an out line of your three shapes.  As you knew to create  the above using vectors requires three shape layers.  Shapes can only be filled  with a single color or pattern.  They also can be stroked and have layer styles added. Additional strokes may be need to highlight the green area like you show above..
    With CS6 you can merge shape layers into a single shape layer your result would be a single color shape however the merged paths would be the outlining path you seem to want. you can save the path in the path palette when the merged shape is the active layer.
    adding an empty layer and stroking the merged path,
    Message was edited by: JJMack

  • Need help with "get info" dialog box

    Hi Everyone!
    I need some help with trying to figure out what some of the options are in the "Get Info" dialog box. I've searched the iTunes help and these forums, but can't find anything.
    So, in the options tab,
    1. What does "Part of compilation" Y/N, do for me?
    2. Same for "Remember Position"
    3. And finally, "Gapless album"
    Thanks, Vince.

    1. when you import a compilation album (like an 80's compilation or something), itunes will import it as
    song 1, artist 1, 80's greatest hits
    song 2, artist 2, 80's greatest hits etc
    Click part of a compliation means that, it means that it would keep them altogether rather than having lots of songs everywhere
    2. If you start playing a song, then stop, part way through, when you next come to the song, itunes will remember where you left off
    3. Albums like jean michel jarre, classical, mike oldfield, etc, have many songs which merge into each other. Having gapless album ticked will ensure that, when playing the album, there are no gaps between songs

  • Help with Social buttons ...

    Hi,
    I'm designing a muse site with social buttons that are created when you embed code from a site such as facebook, and others. They look like this on my site ...
    I would like to build a 'social' area on my site that looks like this instead ...
    So, to clarify when my user clicks on the 'f' in the lower of the two graphics above I'd like my website to behave as if the user had clicked on the 'f share' icon generated by the embedded html from facebook.
    How?
    Many Thanks!
    Gary

    Hi Gary
    This would be a customization with codes for share.
    You can use Share This and use the embed code for the same view that you have mentioned , which will allow users to share the page where you will insert the code.
    http://www.sharethis.com
    - Select Website
    - Select the layout
    - Generate the code
    Thanks,
    Sanjit

Maybe you are looking for

  • DNS Requirements in Exchange 2013: Which RR's to create & what do they do?

      Hi Experts, I had been primarily a RHEL guy in the past. Currently, I have 3 Node (All-in-one) Exchange 2013 DAG (all 3 nodes are virtualized in Hyper-V 2012 and are a part of HyperV2012 Cluster). In DNS, I have created 3 A records for mail.domain.

  • Flash games, serious problem with windows 7 bootcamp

    when you open a webpage that has a flash game, windows 7 bootcamp stucks from time to time, with no reason! why is this happening? using firefox. tried safari the same thing, and tried latest flash player on both. try facebook games or google random

  • Full screen mode: How to switch between open windows?

    Hi There, Is there way to get CMD + ` working in full screen mode? Other shortcuts like CMD + OPT [ ] to switch between open tabs and CMD + TAB to switch apps seem to work - but without the ability to switch between open windows within the same app,

  • HT201342 change apple id on my iPad

    how i can change appl id on my ipad?

  • ECC 6.0 Installation, help me to find packages

    Dear Friends, I am trying to install ECC 6.0 on a Windows 2008 Server 64-bit with Oracle 10.2. SAPinst asks for "UC Kernel NW 7.0 SR3" and "Oracle Client" packages. but i cant find them in Service Marketplace, does anybody know the zip file name for