Results 1 to 4 of 4
  1. #1
    vicu1 is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default how do i display a image using the GUI?

    hi
    so i was wondering how would i display a i image using the GUI?
    i am trying to make a connect four program and i and never imported a image before
    i think i just dont know how to output it.
    is there like a addImage method that would do this?

    this is my code so far:

    Java Code:
     package connect;
    
    import java.awt.Image;
    
    import javax.swing.*;
    
    import BreezySwing.*;
    
    public class ConnectFour extends GBFrame
    {
    	private JLabel title;
    	private JButton column1;
    	private JButton column2;
    	private JButton column3;
    	private JButton column4;
    	private JButton column5;
    	private JButton column6;
    	public ImageIcon Icon;
    	public Image ConnectFour;
    	
    	
    	public ConnectFour()
    	{
    		title = addLabel ("Connect Four" , 1,3,1,1);
    		column1 = addButton ("column1" , 2,1,1,1);
    		column2 = addButton ("column2" , 2,2,1,1);
    		column3 = addButton ("column3" , 2,3,1,1);
    		column4= addButton ("column4" , 2,4,1,1);
    		column5 = addButton ("column5" , 2,5,1,1);
    		column6 = addButton ("column6" , 2,6,1,1);
    		
    		
    		ImageIcon Icon = new ImageIcon("/Users/Victor/Desktop/Board5Connect4.png");
    		ConnectFour = Icon.getImage();
    		
    	}
    	
    	public ImageIcon getConnectImage() 
    	{
    		return Icon;
    	}
    	
    	
    	
    	
    	
    	public static void main(String[] args)
    	{
    		ConnectFour theGUI = new ConnectFour();
    		theGUI.setSize (550, 200);
    		theGUI.setVisible (true);
    	}
    
    }
    Last edited by vicu1; 06-03-2012 at 07:28 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: how do i display a image using the GUI?

    Read about it in the API documentation for the Graphics class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    vicu1 is offline Member
    Join Date
    Nov 2011
    Posts
    19
    Rep Power
    0

    Default Re: how do i display a image using the GUI?

    could u please give me a link?

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: how do i display a image using the GUI?

    Here is a link to the javadoc: Java Platform SE 7.

Similar Threads

  1. Display image
    By asai in forum New To Java
    Replies: 16
    Last Post: 04-03-2012, 02:15 PM
  2. to display image
    By asmitarnd in forum AWT / Swing
    Replies: 6
    Last Post: 04-07-2011, 12:17 PM
  3. image display
    By asmitarnd in forum AWT / Swing
    Replies: 3
    Last Post: 04-07-2011, 12:17 PM
  4. How to display image ?
    By Birkoff in forum AWT / Swing
    Replies: 7
    Last Post: 06-09-2008, 08:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •