Questions tagged [java-2d]

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

1076 questions
0
votes
3 answers

java.lang.NoClassDefFoundError while reading a svg file as BufferedImage

i have a .svg file to create a Map which will have Listeners relevant to boundaries (i guess its called "nodes" of a scalable vector graphic). However, i'm trying to add this file as a BufferedImage over a JPanel. (i'm a newbie about swing…
quartaela
  • 2,579
  • 16
  • 63
  • 99
0
votes
1 answer

Resize scrollbar in JScrollPane when drawing with Java2D graphics?

I have a JScrollPanel with viewport on a JPanel. I want to do something really simple: draw little vertical lines in this fashion: | | | | | | | | | | I'm doing this by painting each of these lines on the Jpanel And when there are too many of them,…
mak
  • 1,384
  • 1
  • 13
  • 21
0
votes
4 answers

Java 2D API: Null Pointer Exception

Please have a look at the following code package java2D; import java.awt.BasicStroke; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.*; import java.awt.*; public class Joins extends JFrame { …
PeakGen
  • 21,894
  • 86
  • 261
  • 463
0
votes
2 answers

AffineTransform() rotates rectangle way too fast

I am trying to draw a rectangle with java awt and make it rotate with mouse cursor by mouse dragging. When I was testing it out, the rectangle was rotating ridiculously fast. My Rectangle(): private Rectangle2D rec = new…
jasonkim
  • 696
  • 1
  • 7
  • 27
0
votes
1 answer

Duplicate and Mirror GeneralPath

Is there a way to duplicate a generalpath, mirror it, and move it? I was creating a cartoon character, and I realized her left side of the hair, body is the same as the right side. For example: I have done the left part of her hair and body and the…
de.vina
  • 116
  • 10
0
votes
1 answer

custom shape rotation issue

I am trying to rotate a custom shape around its center, but can not get the result as expected. what i want is *shape should be rotated around its center without moving itself.* what my solution is currently doing is rotating a whole shape…
Mihir
  • 2,480
  • 7
  • 38
  • 57
0
votes
1 answer

Rotating text in Java2D on Mac

Here is the problem I am currently facing: I want to draw a String on a JPanel using Java2D. The String has to be rotated of a user-defined angle. Under that String, I also paint the background in a given color to facilitate reading (plenty of other…
Ben
  • 6,321
  • 9
  • 40
  • 76
0
votes
1 answer

How to know when all Java2D rendering is finished, after a repaint() call?

I have a standard paintComponent() method that draw some shapes on a Swing JPanel, via Java2D. Initially, the JPanel surface is displayed with a clean white background. After the user select a file, I build the shapes (in a separated thread) based…
ranieribt
  • 1,280
  • 1
  • 15
  • 33
0
votes
1 answer

Java ball collision detection using keyboard

I created a java program to draw out 2 circle and using keyboard to move..and i need to test the collision...once the two ball go together..it will pop up the message "Collision detected" import java.awt.*; import java.awt.event.*; import…
0
votes
3 answers

Java Change shape of JPanel

I'm trying to do something which I'd think would be fairly easy but can't find a straight forward answer to. Basically I want to change a JPanel's default shape to a circular shape (or any other shape other than a rectangle).
yanman1234
  • 1,009
  • 9
  • 27
0
votes
1 answer

Java - Make an object follow drawn lines

So i have 4 points, p1,p2,p3 and p4. These move constantly to the left and move back to the far right (window width + 100) whenever they reach too far left (x-100). Their Y is random. I also have lines drawn between each point, this makes a fluent…
0
votes
3 answers

Java: Merging 2 images is not working

I'm trying to read 2 image files, then merge image2 on top of image1, but the code below does not seem to work. After saving, I only see image1 as original. Both images are PNG. String url= uploadPath + filename; BufferedImage im =…
jeet
  • 745
  • 3
  • 10
  • 15
0
votes
1 answer

Image not being displayed properly in applet

i want to add a image at 615,50 in my applet . image name is logo1.jpg . but the following code only prints d image.. when i compile and then run using applet viewer. only the image logo1 shows at d spot. the rest code doesnt work. however if i…
0
votes
1 answer

How to paint on to a JPanel (class extend) from other class

public class Main extends JPanel implements Runnable { private static final int WIDTH = 1000; private static final int HEIGHT = 800; TerranGenartor gen = new TerranGenartor(); public Main() { setSize(WIDTH, HEIGHT); …
0
votes
3 answers

Image is not displaying inside JPanel

I want to display an image inside a panel. So I pass the path of the image to this method, open image file and pass it to the method of a private class dedicated to draw image inside the panel. The problem is the panel remains empty all the time and…
Umer Farooq
  • 31
  • 1
  • 6