Questions tagged [java-2d]

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

1076 questions
-1
votes
2 answers

custom paint function in java

i am a newbie in java. i am working on an assignment in which i am reading commands from file and drawing the shapes on jpanel. the file is like FRAME 200 100 // open a frame, note: parser must ignore any comments COLOR 255 0 0 // set…
-1
votes
1 answer

# java how to insert images in a canvas

i am developing a car simulation in java. my coding is as below. I want to put a panel and in it to be the line rotating together with a speedometer image of 180 degrees. My question is how do i do this? public class House extends JPanel implements…
-1
votes
1 answer

Can't figure out why my Line shape won't re-size

I'm making a drawing applet and I just can't get my line shape to re-size. Rectangle and oval re-size just fine but not line. I believe I have the correct code for the method of re-size to allow line to be re-sized but it just will not work. I hope…
user2124033
  • 315
  • 1
  • 2
  • 3
-1
votes
1 answer

Why does java.awt.Polygon only work with integers?

I'm doing a project in which I use the AWT library with shapes a lot. Most of the classes implementing Shape work with both Double and Float, except Polygon. Why? Why in Gods name and grace?! Am I correct in saying that I can achieve the same…
Tim Kuipers
  • 1,705
  • 2
  • 16
  • 26
-1
votes
3 answers

Pacman open/close mouth animation

I want to make the pacman open/close mouth animation using the easiest method. Here is my recent code: The problem is, nothing is happening? package ordner; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import…
Scary Mary
  • 11
  • 1
  • 5
-1
votes
2 answers

Java Swing - Paint to canvas created in other class

*Note: * I'm new here. If you're going to downvote please tell me why. I'm writing a java chess program using swing. I'm able to display the board, initialize pieces, and store them in a two dimensional array. However, I can't figure out how to…
Ein_Bear
  • 47
  • 1
  • 7
-1
votes
2 answers

How to adjust font size on image resize?

Possible Duplicate: How to edit a text that is converted into image? or any other approach to realize/edit text What I am trying to achieve is that... I have a text in textpane which I am converting to BufferedImage and resizing the size of the…
user001
  • 991
  • 6
  • 16
  • 34
-1
votes
1 answer

Random circular movement like when fairy flies?

I want to write a code to make a fairy fly all around screen in java/scala, like when tinker bell moves, only my game is 2D so no need for z attribute. I sound very lazy to ask this but can anyone refer/write me some code to start with? I suck at…
Elonoa
  • 467
  • 7
  • 19
-1
votes
1 answer

How to create a pause menu for a simple side-scroller game in Java

I'm trying to create a simple sideScroller in java, so far my game runs as expected but i have no idea on how to create a pause menu to go to the main menu and stuff (haven't got any idea on how to create a main manu for that mater) what do you…
-2
votes
3 answers

Rectangle and Oval don't appear exactly where I position them?

When I draw lines in my program the position is perfect, but when I use those same coordinates for a square or oval they are way off the mark. My code is: g2d.drawRect(one1, one2, two1, two2); g2d.drawOval(one1, one2, two1, two2); And the points…
James MV
  • 8,569
  • 17
  • 65
  • 96
-2
votes
2 answers

How to make code move the ball?

I try to make a ping pong game but my ball don't move so how to make the ball is move? This is my code package test; import java.awt.*; import java.awt.event.*; import java.util.logging.Level; import java.util.logging.Logger; import…
백형신
  • 1
  • 2
-2
votes
4 answers

Why is my for loop not going though my LinkedList?

I created a few points and added them to a LinkedList. I am trying to loop through each point, drawing a line between it and all the other points. I created these 2 for loops to do just that, however, only the second one loops through the…
user3196284
-2
votes
1 answer

How to continue draw something on JPanel after clicked the button without repaint?

I have define the JPanel named drawPanel, and a button named Jbutton1 with an ActionListener. I want to continue draw something on the drawPanel after clicked the Jbutton1. And I do not want to clear the drawPanel first and draw more things, I just…
-2
votes
1 answer

Create an Image in Java with Rectangles

I am new to JAVA 2D, what is the good tutorial to follow to learn from basics to advance level. I want to draw rectangles having text in it. Thanks in advance
-2
votes
1 answer

two balls bouncing java code

Hello Guys I'm Trying Two Create a Program Which Has a Two ball in it. The One is Going right and the one is going down. i have a code but i don't know how to make the other ball going down... any help is much appreciate thanks... import…
Reiqn
  • 11
  • 1