# drawImage and buttonlistener

**URL:** <https://forum.juce.com/t/drawimage-and-buttonlistener/7662>\
**Category:** General JUCE discussion\
**Created:** [November 5, 2011, 2:13pm UTC](https://forum.juce.com/t/drawimage-and-buttonlistener/7662 "2011-11-05T14:13:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tony666](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tony666](https://forum.juce.com/u/tony666)\
**Post date:** [November 5, 2011, 2:13pm UTC](https://forum.juce.com/t/drawimage-and-buttonlistener/7662/1 "2011-11-05T14:13:02Z")

</div>

I’m trying to display 2 Images . When a Togglebutton is checked it should display the first image , unchecked the second image .

I’m using the jucer to load the images .  
But the togglebutton seems to return "false " always ?  
The code is inside the paint (graphics& g) : is this the way to do this?

[quote]if(toggleButton-\>getToggleState())  
{  
g.setColour (Colours::black);  
g.drawImageWithin (cachedImage\_knop1\_jpg,  
19, 163, 200, 55,  
RectanglePlacement::centred,  
false);  
}  
else  
{

```
g.setColour (Colours::black);
g.drawImage (cachedImage_knop2_jpg,
             243, 163, 100, 60,
             0, 0, cachedImage_knop2_jpg.getWidth(), cachedImage_knop2_jpg.getHeight());
}[/quote]
```

---

<div class="post-metadata">

**Author:** ![tony666](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tony666](https://forum.juce.com/u/tony666)\
**Post date:** [November 7, 2011, 10:07pm UTC](https://forum.juce.com/t/drawimage-and-buttonlistener/7662/2 "2011-11-07T22:07:42Z")

</div>

got it :roll:

[http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=5087&hilit=buttonlistener](http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=5087&hilit=buttonlistener)
