Got a small detail problem that I cannot get to understand myself.
The program, see attachments draws dots on the screen.

There is a dot class for the details of the dots to be stored, that is size, colour, shape (square or round)

Problem is with the colour...Cannot get other dots to have different colours...

Recommended Answers

All 2 Replies

Member Avatar for harsh2327

In File DoodleBoardPanel.java, see method public void mouseDragged(MouseEvent e) {...} .

Here you are storing only the size and shape in ArrayList DOTlist . Hence, each dot is having different size and shape. However, you are not storing the color of each dot anywhere.

Now in the same file see the following method

public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;
		
		for (Shape dot:DOTlist)
		{
			g2.fill(dot);
			g2.draw(dot);
			g2.setColor(getAdotColor());   
			g2.setPaint(getAdotColor());	
		}
		
	}

Here you are setting the color depending on getAdotColor() which returns aDot.setDotColor(Adotcolor); Here aDot is a single object for all the dots, since you are not creating different Dot Objects for each dot created by the user.


Suggestion
--------------
In method public void mouseDragged(MouseEvent e) {...} , Create Dot Objects for each dot created by the user and add them in ArrayList DOTlist .

You might also have to modify your public void paintComponent(Graphics g) a bit.

Hope this was useful.

I GET WHAT YOU MEAN NOW...made much sense when I read it second time and with no haste (was at work the first time I read it, don't know was just excited to see what I was missing)

Thanx DUDE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.