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: img flowlayout

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Location
    Sweden
    Posts
    19
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default img flowlayout

    Hi,

    I use this to draw up an image file on the JFrame. But instead of giving x and y pos I want the img to go with the flowlayout like the rest of my code (JButtons and such). How do I do?

    public void paint(Graphics g) {
         g.drawImage(img, 50,93, this);
     
    }  //  public void paint()

    Best regards.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,266
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: img flowlayout

    First, you don't provide context in what you are doing but it is typically recommended to override the paintComponent method rather than paint. Second, a JLabel might be what you are looking for - instantiating with an ImageIcon (which is in turn instantiated from the Image). See How to Use Icons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

Similar Threads

  1. Help using Flowlayout
    By PaulPeter in forum AWT / Java Swing
    Replies: 0
    Last Post: April 5th, 2010, 02:30 PM