Who paints the background of JInternalFrame?

  • Follow


Hello all,

Im new to Swing / plaf, and I have a probably simple question.

Im trying to make an internal frame that has rounded corners.
Therefore I do not want the background color to fill the entire
background. Actually I'd like to paint the background myself.


I have extended and installed my own BasicInternalFrameUI. In
installUI(JComponent c) I call c.setOpaque(false). And would now
expect to be able to control the painting of the background by
overriding BasicInternalFrameUI.paint :

public void paint(Graphics g, JComponent c) {
g.setColor(Color.black);
g.fillRoundRect(0,0, c.getWidth(),c.getHeight(),10,10);
}

(Disregard the fact that I paint on top of the title too - this
example is only to keep it simple)

But the JInternalFrame shows it's background color all the same, and
not my black rect.
It seems like the only way I can change the painting of the
JInternalFrame is by overriding JInternalFrame.paint :

public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.blue);
g.fillRoundRect(0,0, getWidth(), getHeight(),10,10);
}

But that's not really look&feel...

Could someone please enlighten me? How do I paint the background of an
JInternalFrame the proper way?
0
Reply droida38 10/8/2003 8:45:25 PM

droida38@yahoo.com (Bastard) writes:
> Could someone please enlighten me? How do I paint the background of an
> JInternalFrame the proper way?

I don't know much of internal frames - I avoid MDI like the plague -
but I guess you see Swing's opaque painting behavior. See

    http://java.sun.com/products/jfc/tsc/articles/painting/index.html#opacity_definition

for details and check the component's opaque attribute
[set|get]Opaque().

HTH

/Thomas
-- 
0
Reply nobody 10/9/2003 7:07:24 AM


Hello!

Bastard <droida38@yahoo.com> wrote:

> (Disregard the fact that I paint on top of the title too - this

Do you really?

 
> But the JInternalFrame shows it's background color all the same, and
> not my black rect.
> It seems like the only way I can change the painting of the
> JInternalFrame is by overriding JInternalFrame.paint :
> 
> public void paint(Graphics g) {
> super.paint(g);
> g.setColor(Color.blue);
> g.fillRoundRect(0,0, getWidth(), getHeight(),10,10);
> }

And that does work???


> 
> But that's not really look&feel...
> 
> Could someone please enlighten me? How do I paint the background of an
> JInternalFrame the proper way?


The content pane typically also paints its background and covers most of
the internal frame.



Christian
0
Reply usenet 10/12/2003 5:09:47 PM

Yes that works... hmmm..

I had the hunch that it was JDesktoppane was the one responsible for
drawing the background, but what still puzzles me, is that I can
prevent this by overriding paint in the JInternalFrame.

Anyway, I think I can solve it by drawing a rounded border thus not
having to worry about the painting of the background..

Thanks anyway..

/B


usenet@chka.de (Christian Kaufhold) wrote in message news:<0t3f898a89i4569n1f4@simia.chka.de>...
> Hello!
> 
> Bastard <droida38@yahoo.com> wrote:
> 
> > (Disregard the fact that I paint on top of the title too - this
> 
> Do you really?
> 
>  
> > But the JInternalFrame shows it's background color all the same, and
> > not my black rect.
> > It seems like the only way I can change the painting of the
> > JInternalFrame is by overriding JInternalFrame.paint :
> > 
> > public void paint(Graphics g) {
> > super.paint(g);
> > g.setColor(Color.blue);
> > g.fillRoundRect(0,0, getWidth(), getHeight(),10,10);
> > }
> 
> And that does work???
> 
> 
> > 
> > But that's not really look&feel...
> > 
> > Could someone please enlighten me? How do I paint the background of an
> > JInternalFrame the proper way?
> 
> 
> The content pane typically also paints its background and covers most of
> the internal frame.
> 
> 
> 
> Christian
0
Reply droida38 10/13/2003 5:22:14 PM

3 Replies
688 Views

(page loaded in 0.356 seconds)

Similiar Articles:













7/22/2012 7:47:40 AM


Reply: