• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot super.paintComponents(g) of JDialog

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


There is no super.paintComponent(g) to call within JDialog, but it is overridable?
And also setOpaque is not allowed too.
How come?
Thanks
Jack
 
Ranch Hand
Posts: 174
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- painting to Top-Level Containers (inherits, nested on AWT methods) is accesible only from AWTs paint()

- put there JPanel (in the case that will be container for JComponents) or plain JComponent

- by default there isn't any problem to painting transparent or translucent image in Swing

- note thre are a few awfull changes for translucency in Java7, important is code ordering, changing L&F for decorated Top-Level Containers isn't possible without dirty hacks
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are overriding paintComponents() and not paintComponent() - note the 's' .
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Tookey wrote:You are overriding paintComponents() and not paintComponent() - note the 's' .



Hello Richard,
Okay, I see that typo.
But there aren't any setOpaque to call. Do I use setOpacity(1.0); instead?
Thanks
Jack
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jacky Luk wrote:

Richard Tookey wrote:You are overriding paintComponents() and not paintComponent() - note the 's' .



Hello Richard,
Okay, I see that typo.
But there aren't any setOpaque to call. Do I use setOpacity(1.0); instead?
Thanks
Jack



As always you use whatever methods the component allows! Check the Javadoc.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know why I have new'ed the color1 property, but I
still get null pointer exception.
Does anyone spot any errors?
I also wonder do I override paintComponent(Graphics g) instead, but I don't think there is one to override.
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- you are ignoring (btw as always) all mentioned points in previous posts

- your code is GPU killer, don't to set whatever different as paitning in paint, paintComponent, paintChildren

- again put there JPanel override paintComponent

EDIT

- never extends anything, nor Top-Level Containers

- code ordering should be (as aside note in Java7 isn't possible to create undecorated container) important, runnable in Java7,I'm leaving important workaroung for Java7

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, Korbel.
And thanks
Jack
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The gradient paint works now.
But One problem I am facing is when I override the paint method of JDialog
and adding JPanels and JLayeredPane's to this JDialog
The original contents of the JPanels and JLayeredPane's are overwritten,
How can I make the Gradient stay in the background?
Thanks
Jack
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While using Swing, it is recommended you override paintComponent instead of paint. In this case the contentPane's paintComponent should be overridden.

All the panels you add to the dialog should be set to setOpaque(false) for the gradient paint to show.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic