aspose file tools*
The moose likes Applets and the fly likes Jbutton on top of fillRect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Jbutton on top of fillRect" Watch "Jbutton on top of fillRect" New topic
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: 36590
    
  16
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: 36590
    
  16
Why do you have all those static fields?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36590
    
  16
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jbutton on top of fillRect
 
Similar Threads
layout
JButton with no Border
AWT Applet vrs SWING applet
Java Applet & Sound
Paint Method