Draw « Component « Java Swing Q&A





1. Java swing drawing: how to clear background when animating object    stackoverflow.com

I've written some java swing code that animates some balls in a JPanel using a Timer and some other crap, and it doesn't refresh the background, so it has a streaking ...

2. how to draw lines without change background's image?    coderanch.com

import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.io.*; import java.net.*; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.Timer; public class GraphicImageTest { public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new GraphicImagePanel()); f.setSize(400,400); f.setLocation(200,200); f.setVisible(true); } } class GraphicImagePanel extends JPanel { Image image; Ellipse2D.Double ball; int dx, dy; public GraphicImagePanel() { loadImage(); dx = 3; dy = 2; ...

3. How to draw a image in background    coderanch.com

5. Draw lines over background's image, save image & edit lines    coderanch.com

Hi All, I am developing an application where we have an requirement to set background image (for ex. screen shot of Google map), we want to allow user to draw a line or rectangle on top of map to show travel direction and also allow them to move line on map until they freeze image version. User will be uploading background ...

6. In the background drawing thread, which is the better option?    coderanch.com

Hello All, I am programming some games in Swing, everything is good. But in main Loop Drawing Thread. What option should I use? Basically there are 2 options as far as I know: 1) Swing Timer class, which is easy to help you to setup the repeated thead. But the timer thread also put into the EDT to wait and get ...