[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 20:27:04 -0500

Very nice - I'm all over that one... ;)

The immediate result of your help was this - doesn't look very "fun," but it 
actually draws the portions of the screen the size I want, and repaints 
mostly right (still have to learn some of the settings related to "preferred 
size" I think:

package map;

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ThisIsTheGame extends JFrame
{
 public static ThisIsTheGame app;
 private static final int APP_WIDTH  = 800;
 private static final int APP_HEIGHT  = 600;
 public Container   map;
 public Container   navigator;
 public long     paintCounter = 0;

 public static void main(String[] args)
 {
  app = new ThisIsTheGame();
  app.setVisible(true);
 }

 public ThisIsTheGame()
 {
  super();

  setSize(new Dimension(APP_WIDTH, APP_HEIGHT));
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  getContentPane().setLayout(new java.awt.BorderLayout());
  buildInterface(getContentPane());
 }

 public void buildInterface(java.awt.Container contentPane)
 {
  navigator = buildNavigatorPane();
  map = buildGamePane();

  contentPane.add(navigator, java.awt.BorderLayout.WEST);
  contentPane.add(map, java.awt.BorderLayout.CENTER);
 }

 public javax.swing.JComponent buildNavigatorPane()
 {
  JPanel board = new JPanel();
  board.setPreferredSize(new Dimension(600, 600));

  return board;
 }

 public javax.swing.JComponent buildGamePane()
 {
  JPanel board = new JPanel();
  board.setPreferredSize(new Dimension(200, 600));

  return board;
 }

 public void paint(Graphics gfx)
 {
  super.paint(gfx);

  Graphics workAreaGfx = map.getGraphics();
  workAreaGfx.setColor(Color.yellow);
  workAreaGfx.fillRect(0, 0, map.getWidth(), map.getHeight());
  workAreaGfx.setColor(Color.black);
  workAreaGfx.drawLine(0, 0, map.getWidth(), map.getHeight());

  workAreaGfx = navigator.getGraphics();
  workAreaGfx.setColor(Color.green);
  workAreaGfx.fillRect(0, 0, navigator.getWidth(), navigator.getHeight());
  workAreaGfx.setColor(Color.blue);
  workAreaGfx.drawLine(0, 0, navigator.getWidth(), navigator.getHeight());
 }
}

Thanks so much! :)
-Mike


----- Original Message ----- 
From: "Dave Slutzkin" <daveslutzkin@xxxxxxxxxxx>
To: <gameprogrammer@xxxxxxxxxxxxx>
Sent: Wednesday, March 30, 2005 8:10 PM
Subject: [gameprogrammer] Re: I wonder if I can go Remedial Applet on you 
all... :)


> On Wed, 30 Mar 2005 19:27:42 -0500, "Mike Gillissie" <Niyoto@xxxxxxxxxx>
> said:
>> 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... ;)
>
> Ah, good, then we're on the same page.
>
> If you haven't seen this yet, have a look on the Sun site at:
> http://java.sun.com/docs/books/tutorial/uiswing/.  That's a good intro
> to the terminology and components that will be used in Swing.
>
>> However, your code looks like you're right on the mark - I'll try it
>> out...
>> thanks VERY much!! :)
>
> No probs, always happy to help.
>
> 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


Other related posts: