Re: Swing Battleship Game
- From: "visionset" <spam@xxxxxxxxxxxx>
- Date: Sun, 27 May 2007 13:42:09 GMT
"Andrew Thompson" <u32984@uwe> wrote in message news:72ca3e01634d2@xxxxxx
isionset wrote:
..
..Layouts (same as you would use in AWT).
I would say the opposite.
I would say..
Otherwise you end up doing a lot of fighting against layout managers and
components. But I guess we all do it once to really appreciate that...
(I've done it several times!)
.you need to invest more time in understanding layouts,
rather than settle for the far less adequate solution of ...
Choose a null layout ...
.a null layout.
In this specific instance, a GridLayout is perfect for the job.
Can you show code that can make an 11x11 grid of
components, from a null layout,
No you use layout managers for components.
I said *not* to use components.
You simply draw on the Graphics object.
and be x-plat and robust
through different Java versions, screen sizes and default font
sizes? More simply than the code I posted?
It isn't just about simplicity, but it isn't much more complex and certainly
it is a more capable and extendable approach.
It is the way anything more than a trivial game board style app is done.
If you want screen size compatibility all you do is scale the graphics
object, a few lines of code for that, and a few more to scale mouse event
Points.
Your component approach is limited and not as xplatform as you think. You
will have images on these components, and they are a fixed size, so then
you'll need to scale them anyway, all of a sudden you've got a mish mash of
components and painting. It really does end up a real mess.
To be honest there are a host of other reasons I've forgotten, it was a
while ago.
Like I said a component approach is fine if it really is very simple and the
OP's intents may well be just that. But real code develops and then it's a
bad choice.
(And yes, that is more than simply a philosophical
question - if the answer is 'yes' - back it up with code).
No. I explained how it would be done and that is sufficient, if the OP
wants a detail clarifying I'm more than happy to oblige if possible.
--
Mike W
.
- References:
- Swing Battleship Game
- From: KDawg44
- Re: Swing Battleship Game
- From: visionset
- Swing Battleship Game
- Prev by Date: Re: Swing Battleship Game
- Next by Date: Re: Swing Battleship Game
- Previous by thread: Re: Swing Battleship Game
- Next by thread: Re: Swing Battleship Game
- Index(es):
Relevant Pages
|
|