| Author |
Jbutton on top of fillRect
|
Josh Reev
Greenhorn
Joined: Feb 17, 2011
Posts: 8
|
|
I have several buttons in my applet, however in certain case i use fillRect function to draw my whole applet go black, but i want to leave one Jbutton visible.
The fillRect function hides my button, but the button comes visible if i move mouse cursor on top of it. Is it possible to keep the button on top of fillRect?
|
 |
Javad Rashidi
Ranch Hand
Joined: Feb 13, 2011
Posts: 34
|
|
|
Hi Josh, in which method you use fillRect?
|
http://www.myviwo.com
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
|
|
Why have you got the button on top of the rectangle you are filling black? What sort of Component are you drawing on? Does it have a revalidate method?
I think this discussion would sit better on our Applets forum: moving.
. . . and welcome to the Ranch
|
 |
Josh Reev
Greenhorn
Joined: Feb 17, 2011
Posts: 8
|
|
Here is some code which i hope helps clarify the issue:
the button is first created in Panel function like this:
in paint function there is a check to see if screen should go black:
|
 |
Javad Rashidi
Ranch Hand
Joined: Feb 13, 2011
Posts: 34
|
|
override paintComponent instead of paint.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
|
|
|
Why do you have all those static fields?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32694
|
|
Javad Rashidi wrote:override paintComponent instead of paint.
And insert this line as the first line in paintComponent
|
 |
Josh Reev
Greenhorn
Joined: Feb 17, 2011
Posts: 8
|
|
I have the static's because i have many classes in the application.
Campbell Ritchie wrote:
Javad Rashidi wrote:override paintComponent instead of paint.
And insert this line as the first line in paintComponent
This is a solution but it doesn't really answer the question. The panel1 is left outside the rectangle if paintComponent is used.
|
 |
 |
|
|
subject: Jbutton on top of fillRect
|
|
|