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 5 of 5

Thread: cant rotate image

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

    Default cant rotate image

    Hi i am learning java right now and i ran into problem where i cant rotate images. It just doesnt work, i have tryed many examples from the internet. For example:
        public void paint(Graphics g){
     
            super.paint(g);
     
     
     
            g2d.drawImage(img, x, y,this);
             g2d.translate(x, y);
             g2d.rotate(1);  
     
     
     
            Toolkit.getDefaultToolkit().sync();
            g.dispose();
        }


  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: cant rotate image

    Can you make a small complete program that compiles, executes and shows the problem.
    The posted code does not show what is in g2d
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cant rotate image

    What is g2d? And it's rare that you'd want to override the paint() method, but it's hard to tell that it's completely inappropriate in the tiny bit of context you've given us.

  4. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: cant rotate image

    G2d is graphics2D. I am not sure whye didnt i wrote it here. I am currently not on computer so i cant give the full code. But can u just write the code you would use if you wanted to rotate image? And i am really sorry about not giving more details, i am new to java.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: cant rotate image

    There are several examples on the amazing Internet available for your study. You might also take time to understand the relationship of one graphics context to another, for example understanding how the Graphics2D object comes to be and the significance of that to what you're trying to accomplish is essential. The Custom Painting Lesson is a good place to start and is fundamental.

Similar Threads

  1. how to rotate one by one jbuttton
    By DanaMax in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 8th, 2013, 03:28 AM
  2. Selecting and dragging a image from multiple image in Java Applet
    By CY5 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 26th, 2013, 02:44 PM
  3. rotate in java
    By game06 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 23rd, 2013, 06:14 PM
  4. API/Tool to rotate Rtf document
    By sreelakshmi.p in forum Java Theory & Questions
    Replies: 4
    Last Post: February 4th, 2013, 08:49 AM
  5. Replies: 3
    Last Post: May 5th, 2012, 08:33 AM