Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Whats wrong with my code?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Whats wrong with my code?

    import javax.swing.*;
     
    public class AnimateJInternalFrame {
     
        JFrame jf=new JFrame();
        JInternalFrame jif=new JInternalFrame();
        Timer t;
     
        public AnimateJInternalFrame() {
     
            jf.setSize(700,700);
            jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            jf.setLayout(null);
     
     
            jif.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            jif.setLayout(null);
            jif.setBounds(50,50,300,300);
     
     
            jf.setVisible(true);
            jf.add(jif);
     
            t=new Timer(30,null);
            t.start();
            for(int i=50;i<500;i++){
                jif.setBounds(50,i,300,300);
                jif.setVisible(true);
                }
     
        }
        public static void main(String[] args) {
            new AnimateJInternalFrame();
     
        }
     
    }

    I want that JInternalFrame to animate smoothly downwards but it is'nt working.

    Whats the problem with my code?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Whats wrong with my code?

    but it is'nt working.
    Can you explain what the code does and what you want it to do differently?

    to animate smoothly
    Use a Timer to change a component's position at specific times and display it at the new position before moving it to a new position.

    --- Update ---

    Also posted at: Animating JInternalFrame
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Whats wrong with my code?
    By green001 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 10th, 2014, 06:02 PM
  2. whats wrong with my code
    By abhi1402 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 6th, 2013, 09:17 AM
  3. Whats wrong with this code?????
    By bambam in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 16th, 2013, 11:22 PM
  4. [SOLVED] Im not sure whats wrong with my code
    By tomlisi92 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: January 25th, 2013, 10:08 PM