Change colour of a circle whether mousePressed is an even or odd number

Right this is sort've difficult to explain. I have implemented a grid of circles for a Connect 4 game with the help of you fine people :) Now to add to this, I am looking to change the colour of a circle depending on whether it's an even or odd mousePressed. Basically this is like playing somebody else, so each player takes it in turns. If there is an easier way to do this then I would greatly appreciate it.
public class CircleGrid extends JPanel implements MouseListener
        boolean ifRed;
        public CircleGrid()
          ifRed = true;
          addMouseListener(this);
        public void toggleColor()
          ifRed = !ifRed;
          repaint();
        public void paintComponent(Graphics g)
          if (ifRed)
            g.setColor(Color.RED);
          else
            g.setColor(Color.BLUE);
          g.fillOval(0, 0, 50, 50);
        public void mousePressed(MouseEvent evt)
           toggleColor();
        public void mouseClicked(MouseEvent evt)
        public void mouseReleased(MouseEvent evt)
        public void mouseEntered(MouseEvent evt)
        public void mouseExited(MouseEvent evt)
     }That is the code which draws the ovals and such on to my gameCenter JPanel.
I was thinking something like:
pesudo code --
if mousePressed is an even number
then set g.setColor = blue
else
g.setColor = red
Thank you guys. I would appreciate any help. I'm still very much a newbie and some of my questions, I'm sure, are trivial to most of you but we all have to start somewhere.

Hey LW, cheers buddy. :)
I used your idea.
Here's my working code:
if (clicks == 0)
                    ifRed = true;
                    repaint();
                    clicks = 1;
               else if (clicks > 0)
                    ifRed = false;
                    repaint();
                    clicks = 0;
               }

Similar Messages

  • Newbie Quesion: Best way to change colour of a movie

    Hi,
    Could someone tell me the best way to change the colour of
    one element of a
    movieclip in AS2?
    Say for example I had a filled white circle in the middle of
    a black square,
    how can I change just the colour of the circle?
    I have tried this.myColor.setRGB( color ); but that sets the
    entire clip to
    be of one colour. Do I need ( as I suspect ) one clip on top
    of another or
    is there any way of keeping details of the clip being
    changed?
    TIA
    Wil

    Cheers jdh,
    This is one method I'd considered.
    I'll give it a bash.
    Wil
    "jdh239" <[email protected]> wrote in
    message
    news:ens1vd$ahn$[email protected]..
    > Don't know if this will help, but this code changes the
    color of my
    > "LOADING"
    > text while it is loading. Should have the essential code
    to do what you
    > are
    > looking for.
    >
    > Make the white circle a movie clip and pick the
    following code apart to
    > get it
    > to change colors:
    >
    >
    >
    > stop();
    > loading.gotoAndPlay(1);
    > import flash.geom.ColorTransform;
    > import flash.geom.Transform;
    > var colorTrans:ColorTransform = new ColorTransform();
    > var trans:Transform = new Transform(loading);
    > trans.colorTransform = colorTrans;
    > loadI = setInterval(loadF, 100);
    > function loadF() {
    > percent =
    Math.floor(_root.getBytesLoaded()/_root.getBytesTotal()*100);
    > if (percent<=39) {
    > colorTrans.rgb = 0x0000FF;
    > // blue
    > trans.colorTransform = colorTrans;
    > } else if ((percent>39) && (percent<60)) {
    > colorTrans.rgb = 0x00FF00;
    > // green
    > trans.colorTransform = colorTrans;
    > } else if ((percent>60) && (percent<80)) {
    > colorTrans.rgb = 0xFF8000;
    > // orange
    > trans.colorTransform = colorTrans;
    > } else if ((percent>80) && (percent<99)) {
    > colorTrans.rgb = 0xFF0000;
    > // red
    > trans.colorTransform = colorTrans;
    > } else if (percent>=99) {
    > clearInterval(loadI);
    > _root.gotoAndPlay(16);
    > } else {
    > loading.gotoAndPlay(1)
    > }
    > }
    >

  • Using rgb to change colour!

    at the moment this program changes the colour of the circle when i click the button. I want to enter 3 rgb values and the click the button to change the colour to the entered rgb value. Can anyone help with the coding? thanx
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Panel2 extends JPanel
         boolean blue;
         public Panel2(boolean blueColor)
              blue = blueColor;
         public void paintComponent(Graphics g)
              super.paintComponent(g);
         if (!blue)
         g.setColor(Color.red);
         else
         g.setColor(Color.blue);
         g.fillOval(50, 50, 150, 150);
    public class Panel1 extends JApplet
         TextField[] Text; // added for textbox
         int R, G, B;
         Color C;
         public void init()
              Panel2 panel = new Panel2(false);
         ButtonHandler handler = new ButtonHandler(panel);
         JButton button = new JButton("Press");
         button.addActionListener(handler);
              Text = new TextField[] {new TextField(3),new TextField(3),new TextField(3)}; //Make 3 textfields
         Container c = getContentPane();
         c.setLayout(new BorderLayout());
         c.add(panel, BorderLayout.CENTER);
         c.add(button, BorderLayout.SOUTH);
         //c.add(Text, BorderLayout.NORTH);
         class ButtonHandler implements ActionListener
              private Panel2 panel;
              ButtonHandler(Panel2 app)
                   panel = app;
              public void actionPerformed(ActionEvent e)
                   panel.blue = !panel.blue;
              panel.repaint();
         }

    here are the basic steps:
    1) create 3 separate textfields.
    2) create a button
    3) when the button is pushed: (in actionEvent) typecast the strings from the texfields into integers(r,g,b). something similar to int r = int (texfield1.getValue());
    4) create a new color; Color mycolor = new Color(r,b,g);
    5) change your oval color
    6)draw your oval
    7) repaint();

  • Changing Colour Display for Temperatur​e Distributi​on

    Hi everyone,
    I am currently involved in reading a series of temperatures along a length of pipe as part of an experiment.  I thought it would be a nice touch for my VI to have a diagram of the pipe which changes colour to show the temperature distribution along it.
    I have attached my initial solution.  I would have posted a VI snippet but this seemed to effect the my references in the property nodes.  
    Issues
    The code 'works' in the sense that the foreground colour of each tab control will change based on the value of the corresponding temperature.
    The solution does not scale well.  I need 'n-1' case structures for 'n' colours/temperatures.  I considered using an enum input to a single case structure, but was not sure how to compare this to the for loop index.
    Unsure whether changing a tab control background is the most efficient way to do this.  Not sure of an alternative.
    I am looking for suggestions as to how to do this more efficiently as there will be up to 16 temperatures in the final system.
    Many thanks in advance,
    Pete
    Regards,
    Peter D
    Attachments:
    Temperature Display.vi ‏16 KB

    Tabs are probably the weirdest choice here. Why not use e.g. a simple colorbox or button?
    In any case, try to learn about autoindexing, it will dramatically simplify your code (see attached in yellow box).
    I probably would use an array of clusters, each containing a colorbox and a numeric with transparent background. Modify as needed. (see attached in green box).
    Of course you probably would want to make it a it prettier than my draft.
    For a larger ramp, I would use a plain array of flat colorboxes. Now simply index into a color ramp to generate it according to your temperatures.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Temperature DisplayMOD.vi ‏18 KB

  • How do I stop text from changing colour when hovering over it?

    Hello, I have downloaded a template for Dream Weaver CS6 (Which is the version i am usig). When you hover over one of the boxes the top text changes colour to black instead of staying white... does any one know how i can make it so the text stays the same colour. I will post a print screen of it.
    Before clicking:
    View image: 1
    When hovering over it:
    http://postimg.org/image/wdsii9mab/
    I will post the code of the index page aswell: <!DOCTYPE html> <html lang="en"> <head> <title>Home</title> <meta ch - Pastebin.com
    Any help is appreciated. Thanks.

    Your unwanted pink hover color comes from style.css line 181 here
    .btn_{
        background: none repeat scroll 0 0 #cf3046;    border: medium none;
        border-radius: 3px;
        box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
        color: #ffffff;
        font-family: "Open Sans",sans-serif;
        font-size: 12px;
        font-weight: bold;
        line-height: 15px;
        margin-top: 20px;
        padding: 7px 13px 8px;
        text-decoration: none;
        text-shadow: none;
        text-transform: uppercase;

  • Is there a PS setting where it can read my Canon Mark 3 5D's monochrome setting so that the files will also appear in monochrome instead of colour? Or do I have to change from RAW each time to Monochrome within PS (even if I have set up for Monochrome in

    Is there a PS setting where it can read my Canon Mark 3 5D's monochrome setting so that the files will also appear in the same monochrome structure (instead of appearing in colour as it is now when i open in PS, not even monochrome)? Or do I have to change from RAW each time to Monochrome within PS (even if I have set up for Monochrome in my 5D)?
    1. Basically I am taking photos with a monochrome setting with my 5D and the screen shows monochrome.
    2. when i import this onto my computer and open with PS, it opens in colour.
    3. when I change this to Monochrome in PS. (It cannot read my monochrome setting with my preference of the greyscale mix when I viewed it on my 5D)
    4. my question is: is there a way so that PS can read the monochrome setting from my 5D and display the same monochrome setting as my 5D instead of a different one from PS.
    Lily

    you need camera raw 6.7 or better.
    i don't know what version of ps you have so i can't say if it can be updated to use that, but update anyway.
    pre cc updates:  http://www.adobe.com/downloads/updates/
    cc updates:  http://prodesigntools.com/adobe-cc-updates-direct-links-windows.html
    cc 2104 updates:  http://prodesigntools.com/adobe-cc-2014-updates-links-windows.html
    if you can't update your cr sufficiently, use the dng converter. DNG Converters:
    Win
    Mac

  • Why doesn't the icon change when I go to different websites-example yahoo doens't change to the purpe circle with the y inside?

    When I pull up mozilla, I have a gray circle in front of the att homepage. When I go to yahoo, this icon doesn't change to the purple circle. The gray circle remains in the address bar before any website . -possibly only unsecured websites since I see that I have a picture of a lock when I was directed to this website. This recently happened and it occurs every time I pull up the browser.

    I have been going crazy trying to figure out what was wrong. I was ready to take my computer in. Thanks so much for informing me of this -now I can rest easy . have a great day. Angela

  • Is there a way to format multiple images at once? Change colour mode or resolution?

    Is there a way to format multiple images at once? Change colour mode or resolution?

    It's very easy to make an action.
    Go to window > actions
    In the actions panel, simply click the 'create a new action' button, it starts recording as soon as you've created it (when you've given it a name).
    Now you can apply the changes you want to make to the images on the file you have opened.
    After you've done all you need to do. You click the 'stop' button. The action is now ready to use. And you can apply the changes you made on all the other files.
    Then you can continue how gener7 explained.
    I usually include a save and close command, so that the whole batch doesn't end up opened after running the script.
    But if you do that you have to create a new file, and save it to your computer before you start recording the action, otherwise the save command will be replaced by each file. And you'll end up with one edited file in the end. At least for as far as I know!

  • Camera raw images change colour in adobe bridge

    I have photoshop CS4 and import my camera raw images into Adobe Bridge.  When I view the thumbnails in bridge my raw images look vibrant and exactly like they appear on the camera but when I go to open them in camera raw edit they change colour and look washed out before I've made any changes.  Can anyone help me figure out how to correct this?

    ssprengel wrote:
    My camera is set to shoot sRGB JPGs and is set to all zeros for the brightness/contrast/saturation parameters.
    What is your camera set to as far as these basic toning settings, as well as any automatic things like DLighting or highlight compression and perhaps any custom curves or whatever that is called for Nikons?
    First paragraph - so is mine.
    Second paragraph - all other settings are neutral/zeroed/turned off, as per my post to which you responded. That is, no additional tone curves - Active D-Lighting turned OFF (why anyone would let the camera decide what to do do with highlights and shadows is beyond my level of trust) , Jpg compression is Optimal (least possible) et cetera.
    Think I now have an explanation for the different displays in ACR (and Bridge) that I have been experiencing. Took a new duplicate Jpg/Raw shot with the in-camera Picture Control set to Neutral. Now, when both the Jpg and .NEF Raw are viewed in ACR, with the ACR Camera profile set to Camera Neutral, they appear, ASAICT, identical. Saved Camera Neutral as the default ACR Camera profile. Now back in Bridge, the images also appear pretty much identical.
    I think what was happening previously was that I had failed to save Camera Standard in ACR as the default Camera profile, and it was defaulting to Adobe Standard, and hence it was rendering Raw thumbnails for Bridge to that Camera profile - hence the difference in appearance between the Jpg and Raw in Bridge. Unless I have got it completely wrong,  I think my problem is now solved.

  • Thunderbolt display changes colour temperature when in full screen mode

    27" Thunderbolt Display connected to MacBook Air (2011) changes colour temperature when in full screen mode. Switching any setting in System Preferences/Displays changes it back to the correct colour. I have also seen this on a 24" LED Display (Display Port) connected to a Mac Book Pro (2011).

    I describe my problem here. I think it's similar, can you see if the console gives you the same error?
    https://discussions.apple.com/message/20162986#20162986

  • Exported PDF changes colour depending on software its viewed on

    Hi
    I've searched on the forums but can't find a solution to my problem. I export my design to PDF in indesign CS6 and looks fine on my Windows 8.1 laptop, but when the printer company open it up in their software it changes colour. I can replicate it viewing on my iphone for some reason.
    Please see the below pictures to see what I mean:
    Correct colours:
    Dropbox - Correct Colour.png
    Incorrect colours:
    Dropbox - Incorrect colour.png
    PDF export settings:
    Dropbox - PDF Settings.png
    Please let me know if you need anymore details.
    Thanks
    Stephen

    @Stephen – you told us where you see the incorrect colors. But you did not tell us where the printing company sees the incorrect color. What is there application? An iPhone has no color management. It is no color proofing device. Not at all!
    As Willi already pointed out: Acrobat Pro will qualify, Adobe Reader will qualify.
    "Correct color" is a wide field… ;-)
    And on not-callibrated monitors or devices the numbers of individual colors count (always coupled with their output intent, of course).
    Uwe

  • Is it possible to make a cell change colour of a period of time with rules?

    Is it possible to make a cell change colour of a period of time? for example
    Date
    Company
    Pick Up
    Destination
    Total
    Paid
    Sat, 5 Apr 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    FALSE
    Is it possible for B7 to change colour if 2 weeks have passed from the date in B1 and Paid is still FALSE and green if it's TRUE?
    Many thanks.

    Hi NeoNapster,
    This may be a start. Conditional Highlighting of a cell that depends upon the values in other cells can be tricky, but we can work on that.
    Date
    Company
    Pick Up
    Destination
    Total
    Weeks
    Paid?
    OK?
    Sat 5 Apr 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    29.0
    FALSE
    Overdue by 29.0 weeks
    Sat 4 Oct 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    3.0
    TRUE
    OK
    Wed 1 Oct 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    3.4
    FALSE
    Overdue by 3.4 weeks
    Wed 8 Oct 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    2.4
    FALSE
    Overdue by 2.4 weeks
    Mon 20 Oct 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    0.7
    FALSE
    OK
    Sat 25 Oct 2014
    COMPANY NAME
    PICK UP POINT
    THE DESTINATION
    £100.00
    0.0
    FALSE
    OK
    Table with one Header Row
    Formula in F2 (Weeks) and Fill Down
    =DUR2WEEKS(TODAY()−A2)
    That shows the Duration in weeks from the Date in column A until TODAY. You can hide this column.
    Column G can contain the text TRUE or FALSE or could be checkboxes.
    Formula in H2 and Fill Down
    =IF(G2,"OK",IF(F2>2,"Overdue by "&F2&" weeks","OK"))
    IF a cell in G is TRUE, then insert "OK". No need for any more checking.
    Else IF a cell in F is greater than 2, then insert "Overdue by" and the number of weeks
    Else insert "OK" (the invoice is less than 2 weeks old).
    Conditional Highlighting of the Body Cells in column H. Select the cells.
    Add a Rule...
    text is
    OK
    Green Fill
    Add a Rule...
    text is not
    OK
    Red Fill.
    Column H with the Conditional Highlighting rules:
    OK?
    Overdue by 29.0 weeks
    OK
    Overdue by 3.4 weeks
    Overdue by 2.4 weeks
    OK
    OK
    (And I have just discovered that colours do paste into this forum ).
    Regards,
    Ian.

  • Hyperlinks don't change colour

    I'm a real newbie with iweb, don't really understand the tech stuff. However, I made a site based on a template with some custom made texts which I made hyperlinks to the other pages. Thing is, when the mouse goes over them they don't change colour. When I made a previous experiment, on a diff template, they worked fine. The hyperlinks on the template change colour fine but not my custom ones.
    Also, all the links work on the design page but when I preview in Safari, one doesn't!

    Tod ~ Yes, you would have to upgrade to iWeb 2 in iLife '08. Then in Inspector's Link tab, you'll have a Format tab via which you can specify the colors of your hyperlinks. This video tutorial shows that Format tab, although its use is not demonstrated:

  • Bottom edge of border of lower third changes colour on render

    Hi,
    Adobe Pr Pro CS3 system
    I am not at my machine so please forgive if I haven't got the exact terminology correct, but the essence of my query does not change.
    I am doing some "lower thirds" (banners) in the titler for a DVD of a music concert. Basically I'm creating a rectanglar box filled with near-opacity black and adding text on top of this. The black rectanglar box has its left and right edges outside the screen area so are not relevant. However, I have added a coloured edge to the top of bottom of the "banner" (I think this is an outer stroke with size 3.0) The thing is, it looks fine on screen, but when the video is rendered, the lower edge of the box has changed colour. It was originally a yellow/gold (as the top still is) but the bottom is now a pinkier shade.
    Any thoughts. I will try to add a screen cap shortly in case it helps.
    Thanks in advance.
    Daniel

    The footage with lower third was rendered to a new AVI within Premiere and imported. The colour change then appears on whatever system is used to view it (even the new render on the timeline shows it), on screen, preview monitor, subsequent DVD burned from Encore, etc.
    Thanks

  • 3d Text not changing colour in Photoshop CS6 Extended-Any Thoughts?

    Hi,
    I'm trying 3d text for the 1st time in Photoshop Cs6 Extended and thought I'd post my query on here as I've always found people to be really friendly and helpful.
    The problem is every time I create new text and and change the colour it's always showing up as black. Nothing I do seems to alter this. Someone suggested a memory problem but I really don't know
    Any solutions would be greatly appreciated

    Did a complete reinstall and that seemed to allow me to change colours.Interestingly when I did the offered upgrade it reverted back to the way it was.Although I can't seem to see the widget(with grid) that allows me to easily move the text around.Is that in CS6? There is an example at 57 seconds here:
    http://www.youtube.com/watch?v=CvtluKm6P-0&feature=player_embedded#!
    Many Thanks

Maybe you are looking for

  • SOFS Throughput Issues

    A question very similar to mine exists here. I have a SOFS cluster (3 hosts). I connected each without nic teaming at first and later tested with nic teaming. I'm using a single 10GbE Netgear M7100-24X switch. The CSV is configured as a 2-way mirror

  • Can I  have Apple TV on more than one tv?

    Can I have Apple TV on more than one tv and can I use one netflix subscription on both tvs (connected to Apple TV)?

  • Trying to get a Wasp 800 to work with an iPad 2

    Good Morning All, Recently, my department has purchased a few iPad 2's, and we'd like to use a bluetooth scanner.  One of our guys purchased a Wasp 800 thinking it would work because it's bluetooth.  I tried it and called customer support twice this

  • How can I duplicate a signature?

    The project I am working on has a few times where this shows up. The signature on the first page carries over to the second and 3rd pages. I know how to duplicate the other fields with the Global option but is it possible to allow a signature to do t

  • Replaced HDD in MacBook Pro - Cannot Install OS X

    I upgraded my brother's 2007 MacBook Pro with a new 500GB hard drive. The installation went smoothly, hardware-wise it wasn't too difficult. The real issues (of course) begin where you think it will be easiest - the software. My brother told me that