Results 1 to 4 of 4
Thread: Displaying an array on a Jpanel
- 03-02-2012, 10:45 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
Displaying an array on a Jpanel
I am developing a game called "Angry Tank", 2 tanks on a landscape trying to destroy eachother as fast as possible. I am adding a GUI but i have no idea how to display my landscape (stored in an array made out of elements, 26 (rows) *100(columns)). A friend of mine advised me to override the paintComponent method and draw your my elements ("x" = landscap eelement," " = ai, "A" = tankA element, "B" = tankB element , "°" = shotelement).
I am not familiar with those paintComponent method and its very hard to find good information on the web for my situation.
I would be very pleased if somebody could come some basic stuff that i can use in my application.
Thanks in advance!
- 03-02-2012, 11:02 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: Displaying an array on a Jpanel
Landscape sense do you want to draw the background of the game? Is your background interact with the game (like obstacles and all)?
- 03-02-2012, 11:08 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 2
- Rep Power
- 0
Re: Displaying an array on a Jpanel
every element of the array has a draw method wich returns a char ( public char teken() { return 'x';} ) all elements implements the element interface so normally i can do like this:
landscapearray[2][30].teken
i only want to show what element (char) is on each coordinate on my panel using the "teken" method.
- 03-02-2012, 09:46 PM #4
Re: Displaying an array on a Jpanel
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
JPanel not displaying after adding JMenu logic
By AMCNovember in forum New To JavaReplies: 1Last Post: 12-18-2011, 05:44 AM -
Displaying text in a JPanel
By DrKilljoy in forum New To JavaReplies: 7Last Post: 04-15-2011, 07:28 PM -
Help Displaying an Array
By Spyderpig in forum New To JavaReplies: 1Last Post: 03-15-2011, 01:08 PM -
displaying JSplitPane in JPanel
By sandysm in forum AWT / SwingReplies: 4Last Post: 07-26-2010, 09:13 AM -
Jpanel and displaying graphics
By jdsflash in forum New To JavaReplies: 6Last Post: 11-21-2009, 01:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks