[gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- From: "Mike Gillissie" <Niyoto@xxxxxxxxxx>
- To: <gameprogrammer@xxxxxxxxxxxxx>
- Date: Wed, 30 Mar 2005 19:27:42 -0500
Actually, when I say "Applet," I probably should be saying "Stand-Alone GUI
Java Application" - I'm still dealing with a few terminology issues,
obviously... ;)
However, your code looks like you're right on the mark - I'll try it out...
thanks VERY much!! :)
-Mike
----- Original Message -----
From: "Dave Slutzkin" <daveslutzkin@xxxxxxxxxxx>
To: <gameprogrammer@xxxxxxxxxxxxx>
Sent: Wednesday, March 30, 2005 7:06 PM
Subject: [gameprogrammer] Re: I wonder if I can go Remedial Applet on you
all... :)
> On Wed, 30 Mar 2005 06:59:38 -0500, "Mike Gillissie"
> <Mike_Gillissie@xxxxxxxxxx> said:
>> Hi guys - I've recently begun making my first foray into Swing-based game
>> development - I'm an applications developer by trade, and while I'm OK
>> with Servlets and Java in general, I haven't quite made the Applet
>> connection yet.
>> Basically, I think it's the layout managers that are confusing me the
>> most. What I'm hoping to do is to start with a three-panel interface -
>> the main one displaying tiled images representing terrain. Then a
>> side-navigator (right or left, doesn't really matter) in which I can set
>> up the commands and status displays, along with a mini-map of sorts.
>
> I've never done any Applet stuff in Java, just stand-alone apps, so
> there may be some issues I'm not aware of. Ignore any of this that you
> already know.
>
>> So far, the closest thing I've had to success is creating a couple of
>> JPanels and placing them where I want them - without using a layout
>> manager.
>
> Generally not a good idea unless you have full control over everything
> (sizes of fonts, screen resolution, etc) as otherwise any small change
> can throw out all your alignment.
>
>> What I really want, though, is to find out how Applet
>> programmers typically design a nice interface with, say, a 150 pixel
>> "navigator" pane, and the rest of the frame/window used for the "game"
>> pane.
>
> Well, not sure how Applet programmers do it, but here's what I'd do.
>
>> Can anybody just suggest the combination of Swing objects and layout
>> managers I should be using?
>
> Don't know what your game will be, but I'm assuming your game pane will
> be a JPanel with no children or layout manager, where you do all custom
> rendering. Your navigator pane should also be a JPanel - you could do
> this all with custom rendering, but I think it's more likely you'll want
> Swing controls here, so it will have need some layout manager (to be
> determined later). In general, any JPanel where you're going to do
> custom rendering should have nothing else in it, otherwise they don't
> play very nicely.
>
> BorderLayout should be sufficient for a high-level layout manager.
> BorderLayout has 5 'slots' in which to put things - NORTH, SOUTH, EAST,
> WEST, CENTER. The things in each slot get their preferred size
> (set/getPreferredSize()) if possible - that is, if the JPanel is at
> exactly the correct size. If the size if bigger or smaller than exactly
> the correct size, the NORTH and SOUTH bits (top and bottom) will be
> stretched/squashed horizontally, the EAST and WEST bits (left and right)
> will be stretched/squashed vertically, and the CENTER bit will be
> stretched/squashed in both directions.
>
> The upshot of this for you is that CENTER gets as much bigger as it can,
> while WEST won't change in size horizontally. So if you want your
> navigator pane to have a (relatively) fixed horizontal size, put that in
> BorderLayout.WEST. The game pane should be in BorderLayout.CENTER, so
> it gets the rest of the space.
>
> Code would look something like this:
>
> public class ThisIsTheGame
> extends javax.swing.JApplet
> {
> public ThisIsTheGame()
> {
> super();
>
> // This is not actually necessary because the content pane uses
> // BorderLayout by default.
> getContentPane().setLayout(new java.awt.BorderLayout());
> buildInterface(getContentPane());
> }
>
> public void buildInterface(java.awt.Container contentPane)
> {
> javax.swing.JComponent navigatorPane = buildNavigatorPane();
> javax.swing.JComponent gamePane = buildGamePane();
>
> contentPane.add(navigatorPane, java.awt.BorderLayout.WEST);
> contentPane.add(gamePane, java.awt.BorderLayout.CENTER);
> }
>
> public javax.swing.JComponent buildNavigatorPane()
> {
> // Build and return the navigator pane.
> }
> public javax.swing.JComponent buildGamePane()
> {
> // Build and return the game pane.
> }
> }
>
> Is that what you're looking for, or have I missed the mark?
>
> Dave.
> --
> Dave Slutzkin
> Melbourne, Australia
> daveslutzkin@xxxxxxxxxxx
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- From: Dave Slutzkin
- References:
- [gameprogrammer] I wonder if I can go Remedial Applet on you all... :)
- From: Mike Gillissie
- [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- From: Dave Slutzkin
Other related posts:
- » [gameprogrammer] I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- » [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- From: Dave Slutzkin
- [gameprogrammer] I wonder if I can go Remedial Applet on you all... :)
- From: Mike Gillissie
- [gameprogrammer] Re: I wonder if I can go Remedial Applet on you all... :)
- From: Dave Slutzkin