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

program making the whole screen to be blue instead of drawing  RSS feed

 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help with a code please I need to draw a Mandelbrot set.



But the problem is that it draws colors the whole screen in blue color. So, it means that the counter is always less than 10. When I am debugging it the value of
is always 0. However, I think, according to my code when it is in the middle of the screen it should be 0 and counter =100. Don't know please anyone help!;(
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) public void paint(Graphics g) {

don't override paint in Swing, always override
public void paintComponent(Graphics g) {

and generally the first line should be
super.paintComponent(g);

2) this.setSize(700, 700);

if a layoutManager is used, this line will do nothing.
change to this
this.setPreferredSize(new Dimension(700, 700));
and pack() the frame

3) x < this.getWidth()

will return 0, unless visible on screen
use
this.getPreferredSize().width

4) you have way too much in paint()/paintComponent()
it is called numerous times, check by running this, then dragging the frame a liitle wider
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!