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

Thread: How to make picture appear in the same window as the rest of drawings?

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to make picture appear in the same window as the rest of drawings?

    0 down vote favorite


    I am trying to learn Java and while i was playing a bit with the basic knowledge that i have i encountered a problem. When i run the program, the lines and the picture appear in two separate windows when i compile the program. how can i make them appear in the same? The code is this:

    public class Game
    {
     
    private int x;
    private Picture pic;
    public Game()
    {int i=0;
     int distance=10;   
     Line s1= new Line(100,100,100,500);
     s1.draw();
     Line s2= new Line(200,100,200,500);
     s2.draw();
     Line s3= new Line(300,100,300,500);
     s3.draw();     
     Line s4= new Line(400,100,400,500);
     s4.draw();
     Line s5= new Line(500,100,500,500);
     s5.draw();
     
     Line o1=new Line(100,100,500,100);
      o1.draw();
     Line o2=new Line(100,200,500,200);
      o2.draw();
     Line o3=new Line(100,300,500,300);
      o3.draw();
     Line o4=new Line(100,400,500,400);
      o4.draw();
     Line o5=new Line(100,500,500,500);
      o5.draw();
     
     Picture pic2=new Picture("stickman.jpg");
     pic=pic2;
     pic.translate(110,110);
     pic.draw();
     
    }
     
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to make picture appear in the same window as the rest of drawings?

    Quote Originally Posted by Gliga View Post
    0 down vote favorite
    I suppose you copied this directly from another website then?

    Ah, here it is: http://stackoverflow.com/questions/2...e-rest-in-java
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to make picture appear in the same window as the rest of drawings?

    What package(s) does the program use? How is the program being executed? The code does not look like it uses the java SE classes and it does not have a main() method that is used by the java command to execute the class.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to make picture appear in the same window as the rest of drawings?

    i am quite puzzled how you knew that this post was on stackoverflow as well but yes, I posted my question there as well

    --- Update ---

    @norm i don't really understand what you want me to tell you. i used some classes provided by the tutorial from udacity, do you need me to post them here as well?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to make picture appear in the same window as the rest of drawings?

    The code you posted does not use normal java classes. You'll get better results asking your question on the udacity site.

    You are more likely to get responses here if the programs you are trying to write use the java SE classes.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Feb 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to make picture appear in the same window as the rest of drawings?

    ok thank you!

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How to make picture appear in the same window as the rest of drawings?

    Quote Originally Posted by Gliga View Post
    i am quite puzzled how you knew that this post was on stackoverflow as well but yes, I posted my question there as well[
    I'm just good like that. For more info on why you should at least let us know you've posted your question in multiple places, read this: http://www.javaprogrammingforums.com...s-posting.html
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] How do I make a picture-part interact with a user?
    By SOG in forum What's Wrong With My Code?
    Replies: 9
    Last Post: September 12th, 2013, 08:34 PM
  2. HELP - placing picture on top of another picture in Java - JLayerPane
    By smasm in forum What's Wrong With My Code?
    Replies: 39
    Last Post: April 27th, 2012, 07:16 PM
  3. How To Make JCreator Output in a Command Window
    By Kimimaru in forum Java Theory & Questions
    Replies: 4
    Last Post: October 4th, 2010, 09:36 PM
  4. Help with a program to make a landscape picture
    By noseeds in forum Java Theory & Questions
    Replies: 1
    Last Post: December 15th, 2009, 10:25 PM
  5. how to make a simple JButton on a JFrame window?
    By chronoz13 in forum AWT / Java Swing
    Replies: 8
    Last Post: November 20th, 2009, 10:08 PM

Tags for this Thread