Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jbutton on top of fillRect

 
Josh Reev
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Josh, in which method you use fillRect?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49457
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
override paintComponent instead of paint.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49457
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have all those static fields?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49457
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javad Rashidi wrote:override paintComponent instead of paint.
And insert this line as the first line in paintComponent
 
Josh Reev
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic