Questions tagged [java-2d]

Java 2D is an API for drawing two-dimensional graphics using the Java programming language.

1076 questions
0
votes
1 answer

Print a JFrame to a page Java

How would you print a jFrame in java? e.g JFrame myJFrame = new JFrame("Window"); printClass.print(myJFrame);
0
votes
3 answers

How to draw a circle within a circle?

I'm trying to get a bunch of small circles that have varying shades of green to be drawn within a big circle to get a "bush" look, but I can't figure out how to get all the small circles within the shape of a big circle. I can only figure out how to…
stumped
  • 3,235
  • 7
  • 43
  • 76
0
votes
1 answer

Java - Layering issues with Lists and Graphics2D

So I have a DisplayPanel class that extends JPanel and that also paints my numerous images for my program using Graphics2D. In order to be able to easily customly use this I set it up so that every time the panel is repainted it uses a List, that I…
0
votes
0 answers

My applet displays part of the screen behind it

So when I alt-tab between the applet and something else, may it be another window or just the desktop, the applet ends up looking like this when I come back to it: This is the Embed gadget I use on the google site I host my applet on. Normally it…
liboan1997
  • 53
  • 4
0
votes
2 answers

Showing a clock on a panel

For some reason, my ClockComponent object does not show up when I add it to a JPanel object. It DOES show up when I add it to a JFrame object but not a JPanel object... I don't understand why and I've looked it up before posting this question here…
user1800967
  • 953
  • 1
  • 6
  • 11
0
votes
2 answers

Static variable messing everything up

Probably a very basic Java problem but I have two variables in a entity class: public class Entity { int posX; int posY; public Entity(int posX, int posY){ this.posX = posX; this.posY = posY; } public void update(){ } public void…
user1650305
0
votes
1 answer

Adding path2d to a jpanel

Im having a lot of problems with this really trivial thing. I want to take a path2d object and add it to a jpanel and display it in my gui. Can I get some guidance as to what I am doing incorrectly. I used the search here and with google and…
user583507
0
votes
1 answer

Java: mouse hit detection with overlapping JComponents

I have a JPanel with null layout. On this panel I draw some custom JComponents as markers, little red rounds, and lines. When the line is not horizontal or vertical, the JComponent's "sensitive area" is a rectangle which has as hypotenuse the line…
Marco Fedele
  • 2,090
  • 2
  • 25
  • 45
0
votes
1 answer

Parsing a string to a shape

I'm making a paint application, and for the input of the shapes that were saved, I came across an issue. You see, I am using a while loop to run through each line of a string saved by the program at an earlier time. I also have identifiers of what…
The_Steve13
  • 119
  • 2
  • 11
0
votes
2 answers

Java Path2D.Double on JPanel are painted with a 'tail'

I have a strange behaviour when drawing a Path2D on a JPanel. Some of the shapes get kind of a tail as you can see on this screenshot: When I change the type to Line2D.Double, it is as I'd expect it: Here's the code that draws the path /…
klib009
  • 263
  • 5
  • 18
0
votes
1 answer

drawImage() smears image on JPanel but why?

I'm following this tutorial and when I animate my aliens from a PNG image using drawImage() my image smears on the JPanel and I'm not sure why that is, anyone know? [more description of issue] As I move the image from the right side of the JPanel to…
user772401
  • 2,754
  • 3
  • 31
  • 50
0
votes
1 answer

Java polygons and Area

Ok so I have a number of polygons (outlined in white in the image). In an attempt to add all the polygons together so that I get one polygon, which is the outer bounds of all of them, I have converted each Polygon (java class) to an Area(java…
user1135469
  • 1,020
  • 11
  • 22
0
votes
3 answers

Drawing a line from 2 mouse clicks

I am trying to draw a line from a series of mouse clicks. For example, when i click from one point on the screen to the next, it connects up the lines, and then i can keep clicking to next points where it continues to draw a continuous drawing…
DommyCastles
  • 435
  • 3
  • 8
  • 21
0
votes
1 answer

reading image file with unknown image data *.ITW

I just want to read and load image data into Java 2D class Any hint will be great. This has been cross posted at java2D forum ( oracle forum) https://forums.oracle.com/forums/thread.jspa?threadID=2434586&stqc=true
Alan M
  • 616
  • 5
  • 15
0
votes
1 answer

Why is fill3DRect not working correctly on other computers besides my own?

I am working on a visual sorting algorithm project and I am drawing them in a JPanel: public void paint(Graphics g) { super.paint(g); g.setColor(Color.WHITE); for (int i = 0; i < array.length; i++) { g.fill3DRect(i * barWidth,…