Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

the code does not call paint method  RSS feed

 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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=/


 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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();
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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???=/
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently continued here.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!