Re: Swing Battleship Game




"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



.



Relevant Pages

  • Re: Newbie: Where to start
    ... Locos and rolling stock of this nature can negotiate very tight radius ... interest and minimise space requirements. ... If attending exhibitions is something of interest, your layout can be ... and small scale. ...
    (rec.models.railroad)
  • Re: Garden railways
    ... Lima and Palitoy both made that mistake a long time ago. ... And somebody mentioned Trix, with their own intermediate scale. ... The street is at one end of the layout going from front to back. ...
    (uk.rec.models.rail)
  • Re: Noisy track
    ... I glued the track down with a single bead of white glue and put ... in sewing pins to hold the track in place. ... My next layout will be the same. ... I was always too anxious to spend time on the full scale. ...
    (rec.models.railroad)
  • Re: Details that change when scaling down
    ... Does anyone know why some things look less realistic when modelled to exact scale on a model rail layout? ... ballast should usually be coarser than scale and locos that are painted in gloss don't look correct at ... scrolled church style windows out of plasticard is definitely not a task ...
    (uk.rec.models.rail)
  • Resetting to default gnome setup
    ... My GNOME desktop, panels, menus etc. are in a real mess. ... What I would like to do is get back to a new user's layout. ...
    (Fedora)