Results 1 to 4 of 4
- 06-03-2012, 06:25 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 19
- Rep Power
- 0
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 06:28 PM.
- 06-03-2012, 06:33 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
Re: how do i display a image using the GUI?
Read about it in the API documentation for the Graphics class.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 06-03-2012, 06:34 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 19
- Rep Power
- 0
Re: how do i display a image using the GUI?
could u please give me a link?
- 06-04-2012, 04:30 AM #4
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: how do i display a image using the GUI?
Here is a link to the javadoc: Java Platform SE 7.
Website: Learn Java by Examples
Similar Threads
-
Display image
By asai in forum New To JavaReplies: 16Last Post: 04-03-2012, 01:15 PM -
to display image
By asmitarnd in forum AWT / SwingReplies: 6Last Post: 04-07-2011, 11:17 AM -
image display
By asmitarnd in forum AWT / SwingReplies: 3Last Post: 04-07-2011, 11:17 AM -
How to display image ?
By Birkoff in forum AWT / SwingReplies: 7Last Post: 06-09-2008, 07:58 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks