Skip to main content

problems w/ the graphcis context?

3 replies [Last post]
azurianarcher
Offline
Joined: 2006-02-17
Points: 0

i have a really big problem and i can seem to fix it. I created an application using swing, and when i use any Look And Feel it cuts off a pane i have, when i use GTK, it not only cuts off the pane, but it paints the pane with little pieces of a desktop i have, and a JMenu bar. After research and some analysis it seems like the graphics contexts used for painting are overlapping. Is this possible? if so can i correct it?, also is there any way to include a screen shot of the problem

~Amx

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
azurianarcher
Offline
Joined: 2006-02-17
Points: 0

thanks a lot, it turns out all i needed to do was setOpaque(true);

~Amx

Scott Violet

On Sun, Nov 23, 2003 at 08:30:22PM -0500, swing-feedback@javadesktop.org wrote:
> i have a really big problem and i can seem to fix it. I created an
> application using swing, and when i use any Look And Feel it cuts
> off a pane i have, when i use GTK, it not only cuts off the pane,
> but it paints the pane with little pieces of a desktop i have, and a
> JMenu bar. After research and some analysis it seems like the
> graphics contexts used for painting are overlapping. Is this
> possible? if so can i correct it?, also is there any way to include
> a screen shot of the problem

Beyond the LayoutManager problem that was suggested if you are seeing
what appears to be garbage in your custom JComponent/JPanel subclass
it's likely that you're not honoring the opaque setting. By that I
mean if your widget has the opaque property set to true but is not
filling in the background than you can get what appears to be visual
garbage. If you override paintComponent you should do:

[code]
protected void paintComponent(Graphics g) {
if (isOpaque()) {
g.setBackground(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
}
// custom painting code goes here
}
[/code]

Alternatively if your component always paints in the background in an
opaque manner you should invoke setOpaque(true).

-Scott

zander
Offline
Joined: 2003-06-13
Points: 0

Which layout manager are you using?

see
http://wiki.java.net/bin/view/Javapedia/LayoutManager