• 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

the code does not call paint method

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone please help with a code. It does not call paint method on Julia myJulia.:p Can anyone help=/


 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that's because your Julia object isn't part of the GUI.
 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:I think that's because your Julia object isn't part of the GUI.


Sorry I did not get your point. what do you mean not part of my GUI?=/ is not this part of the code is responsible for putting Julia?

or I messing something up as usual??=/
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bobby Marvikuan wrote:is not this part of the code is responsible for putting Julia?



No, it isn't. What it adds to the GUI is an empty JPanel which you create inside the Julia class. I don't know why you did that -- the obvious approach would be to first create the Julia object, which is already a GUI component with paintComponent overridden, and then to add it to the GUI.
 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Bobby Marvikuan wrote:is not this part of the code is responsible for putting Julia?



No, it isn't. What it adds to the GUI is an empty JPanel which you create inside the Julia class. I don't know why you did that -- the obvious approach would be to first create the Julia object, which is already a GUI component with paintComponent overridden, and then to add it to the GUI.


thanks and Sorry again

I made it like this and added

but now it draws on the second part of my Grid the same thing as in the first part but it calls the method System.out.printl();
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Get rid of the entire JPanel inside your Julia class. It's a JPanel itself so you can use it instead of the existing JPanel.
2) Always call super.paintComponent(g) as the first statement when you override paintComponent.
 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:1) Get rid of the entire JPanel inside your Julia class. It's a JPanel itself so you can use it instead of the existing JPanel.
2) Always call super.paintComponent(g) as the first statement when you override paintComponent.


I have done part number 2 of your comment bur I cannot get rid of JPanel because if I do so myJulia will not work because it needs parameters of the panel on which it is going to draw. Do you think the problem is in this sentence???=/
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently continued here.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic