You are here:

Java/origami/ flat fold and cut


Hi Artemus,

I wanna ask you, if I want to draw a flat plane with some animation just like draw a piece of paper and do flat folding, cut, and unfolding again, do you know any references related to this things? if you know some please let me know so I can know how to start to make that thing.


What you need to do is:
Create your own subclass of JPanel.
Add fields that keep track of what you are rending in the animation, and what frame you are at. E.g. You could have a step variable and a frame variable.
Override the paintComponent method.
In paint component draw the frame of animation based on your field variables.
Add a Timer field variable to your class (use javax.swing.Timer)
When you want to start the animation (maybe in a start button call), assign the timer something like:

timer = new Timer(100, new ActionListener() {
  public void actionPerformed(ActionEvent e) {
     //Put code here to update your fields to advance 1 frame of animation.
     //If your at the end of the animation you can stop the timer.

Finally, add your subclass to a JFrame, or a JApplet, and show it on the screen.


All Answers

Answers by Expert:

Ask Experts


Artemus Harper


I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.


I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Washington State University

MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2016 All rights reserved.