Circle « Graphics « Java Swing Q&A





1. circle packing - java    stackoverflow.com

I have a task to draw a circle and then fill in with the most amount of circles without touching the sides. I can draw the circle, and I can make ...

2. How do I create a "jumping" circle in Java GUI?    stackoverflow.com

I would like to have a red filled circle at some place in my window. After the click on the circle, the circle should jump from the original place to a ...

3. How to draw a filled circle in Java?    stackoverflow.com

I have a JPanel with a Grid Layout. In the "cells" of the grid I can put different elements (for example JButtons). There is no problems with that. But now I ...

4. Drawing a circle    coderanch.com

Thanks Mr Zukowski for your reply, however the when you run it it says that using what you suggested img = createImage(new MemoryImageSource(w,h, pix,0, w)) then get a graphic context to draw can only be done with createImage(w, h). However what i really wanted to do is there is an image then on top of this would be another image to ...

5. how to implement non rectangular components e.g.Circle    coderanch.com

i have a circular component i dont want it to be cliked when mouse has been clicked outside its circular boundary. i know most of u will reply that in mouse click event check if x&y cordinates r within the circular boundary. but the problem is i have many circular components overlaping each other and i want them to recive mouse ...

6. Circle looks bad    coderanch.com

Hi, It sure looks like a circle to me at 12x12. Maybe if you go smaller, it looks like a rounded rectangle. One way to make the circle look real smooth is to use anti-aliasing. Refer to the code attached. One shows a circle w/o anti-aliasing and the other with it. Hope that helps. regards, Raj import java.awt.Dimension; import java.awt.FlowLayout; import ...

7. Graphics Graphics Graphics - Where are my circles?    coderanch.com

Why won't this paint the circles??? This program is supposed to paint the number of circles that I enter into the JText field (I will max it at 99 circles probably), but as it stands, it will not even paint the one circle in the following code. I have tried adding if circle != null in the paintComponent to catch the ...

8. increasing the effect of the filled circles    coderanch.com

I'm not quite sure what you are asking. Do you want to make the oval thicker, or to have it a different color, or maybe paint a second oval with a different color which is a pixel or two smaller/larger? All of this can be done with the methods in Graphics. In any event, this is purely about AWT, not applets, ...

9. How to make circle?    coderanch.com





10. drawing a good circle!    coderanch.com

So yes drawing a circle is a rather painless problem. However, when I draw my circle there is still a bit of aliasing going on and it irritates me and does not look good. Here is my code, its the paintComponent method followed by the paintBorder method... public void paintComponent(Graphics g){ //Simply painting onto an image. if(static_image == null || static_image.getWidth() ...

11. Drawing circles using the coordinate values that are stored in an ArrayList.    coderanch.com

I have incorporated the changes asked: Though, i still dont knwo how to finish it import java.awt.*; import java.awt.geom.*; import java.util.ArrayList; import javax.swing.*; class DisplayPanel extends JPanel { Main m = new Main(); int total1; int x[]; int y[]; ArrayList> totalList1 = new ArrayList>(); final ArrayListcoordinates = new ArrayList(); public void displayOriginal(int total, ArrayList totalList){ //called by another method in another ...

12. How to draw circles whose center coordinates are stored in an array?    coderanch.com

hi, can anyone post an example on how to draw n number of circles on a JPanel present within a JFrame, whose center coordinates are stored in an x[] and y[] arrays, where x[] holds the x coordinates and y[] holds y coordinates of the circles, using paintComponent(). I want something like: A class, say classA, which will have a method, ...

13. Different Colour for different group of overlapping circles.    coderanch.com

HI. I have displayed circles on a JPanel, and the total number of circles (say n) to be displayed is set by user along with the radius and their center coordinates. When any of the circle overlap with another one, both are displayed in red colour, else they are drawn in blue colour. i.e all circles that overlap with each other ...

14. How do i add a circles without the black corners    coderanch.com

How do i add a circles without the black corners? the setBounds(int,int) method creates a square (or rectangular) shape meaning overlapping circles display a small corner. i tried setting the foreground and/or background color to null and to the actual background. is there a way to set the colour of setbounds to transparent or something? public void mouseClicked(MouseEvent m0) { System.out.print(m0.getX()); ...

15. Moving Circles    coderanch.com

Hi. I have 3 circles -A, B, and C (the radii is already known). I want them to move them in a specified direction with a specified velocity, and stop them when they reach the boundary. At any time t, i want to know the x and y coordinates of these circles. Is that possible? Any hint on how to do ...

16. Bouncing Circles    coderanch.com





17. cannot get the green circle to smear    coderanch.com

Hi, I am trying to do a simple animation, in which a green circle moves diagonally in a smeared pattern on a widget named panel which is an instance of a class MyPanel which extends JPanel. The JFrame has a start button, which when pressed is supposed to start the animation by calling the actionPerformed method (in which i call the ...

19. how to unpaint my circle    java-forums.org

i animated a circle that goes down the page and when it goes down. It does not erase the previous circle. I was wondering if there was a certain function for it. Code: Java Code: import javax.swing.*; import java.awt.*; import java.awt.geom.Ellipse2D; public class ball extends JFrame implements Runnable { int y = 0; final int Delay = 5; Thread anima; public ...