GLabeledBox, take 1

Here’s the code for my first version of the GLabeledBox class.  This is what I mean by starting with a simple version and building up.  This just provides the necessary GObject overrides, and trows a fixed size box and a fixed text message up on the screen at a fixed location.

Very unusable for my intended purpose, but it works- I have the basic infrastructure up in very little time.  If inheriting from GObject as opposed to GLabel or GRect was not a feasible strategy, there’s a good chance that even in this minimal version of GLabeledBox, this would be apparent. I could change strategy without having too much invested in the current design.  Code itself behind a cut.

This code requires the acm library, information on the library and a download are found here:

/*Class to draw a box with a text label centered inside*/

import java.awt.Graphics;

public class GLabeledBox extends GObject{
	private GRect box;
	private GLabel label;

		box = new GRect(100, 100, 100, 100);
		label = new GLabel("Hello!", 100, 100);

	public GRectangle getBounds() {
		return box.getBounds();

	public void paint(Graphics arg0) {


One Response to GLabeledBox, take 1

  1. Pingback: GLabeledBox Part 2 | Behind Blue Eyes

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: