Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
We can paint the background of a Jcomponent in swing and can also place background image. I want to know which is the better way to minimize the memory usage? Can anyone help?
In case you are repainting the area again and again ,then its always better to only repaint the required portion instead of painting entire region.
Filthy Rich Clients by RomainGuy and Chet Hasse is an excellent learning source for swing painting techniques
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm creating Conway's game of life in java, and I want to make a clickable on screen grid to toggle the cells on/off before pressing start. What is the best way to do this? A grid of JButtons won't do it for me as it looks horrible (unless theres a way of changing how they look?)
any help is greatly appreciated - thanks!
I would use raw graphics 2D draw commands to manually draw rectangles in AWT for Conway's Game of Life. You can still listen to click events for the frame and then use the x and y coordinates to calculate the cell. It will be a lot faster than using UI components, as well.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to place some images on a JPanel and make them "relocatable" so I can click on one of the images and move to somewhere else on the JPanel while holding the button. It works fine with one image but I just can't come up with a solution for more images than one. I have checked many examples and tried many different ways. If you have any idea please share with me. Thanks!
It works fine with one image but I just can't come up with a solution for more images than one.
You can use the Component Mover. You register the component with the class and then you can move any component.
Or if you don't need the full features of the ComponentMover class you can just use the basic listener for dragging a component.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I was wondering is it possible to add a window to another window? Like can you add that window, like an internal frame to another window. The reason why I am asking this is because I want the image window (which is produced by ImageJ) to be displayed in a desktop frame or window. Also how would you go about doing this. Thanks in advance.
You can call the getContentPane() method of a JFrame, or more generally the getComponents() method of Container (e.g., in the case of java.awt.Frame or java.awt.Dialog windows) and then set it as the content pane of a JInternalFrame.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I need to develop a Java programe using NetBeans. And In a JFrame I need to add a a image of planetary system and when the user sets a date and a time, Planets should rotate to their relevant positions. I don't have any idea about this yet. What is the possible way to do this? Please tell me soon
There are literally dozens of ways this might be achieved.
You could use:
Swing Timer
The Timing Framework
Trident
java-universal-tween-engine
The last three are animation engines. Personally, I use the Timing Framework, but that's more to do with what I'm familiar with and my needs at the time.
You'll probably need to do a lot of custom painting to get this to work, take a look at:
Custom Painting
2D Graphics
For more details
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
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 new one (disappear from the old place and appear on the new one). What would be the best way to do it?
I also would like to know how to draw a filled circle in Java. Are there any simple tools to do it? Or may be the easiest way is to use an image created by some other software?
ADDED:
For the beginning I would like to have just a redraw (a circle disappear and at "the same moment" it appears on the new position). I think it will be simple that some visual effects and I would like to start from the simples possible choice.
This can be done using Swing, Graphics2D and a custom JPanel. The tutorial contains a similar example:
http://java.sun.com/docs/books/tutorial/uiswing/painting/step3.html