[messages] [Module Support] Drawing Java Components On Game Pieces

Joe12 j.sheppard88 at gmail.com
Wed May 7 17:22:21 CEST 2014


I'm making a new Vassal game which is based on a free board game I like
which is like the Civilisation PC games.

I don't yet want to announce what game I'm working on but when I do
announce it I will create a forum topic for it and I will open source
its development.

I've decided that I want this game's unit pieces to have a
AttributesOverlay trait which will be responsible for drawing attribute
labels and icons on unit pieces having looked up what the attributes for
each unit piece should be by obtaining them from this game's "Unit"
enumeration class. This trait will align attribute labels with their
icons in a JPanel and then it will draw the contents of the JPanel on to
games pieces.

I know I could instead use the Vassal module editor's property, label
and layer traits to display the attributes and their icons: this is how
attributes are displayed in the current WIP version of this game. One
reason why I want to make this change is because I want as much of this
game to be implemented in Java code as possible with the Vassal modules
and traits just being responsible for GUI rendering.

I've not been able to make the contents of the attributes JPanel be
drawn on to game pieces, so I've been trying to start by making a JLabel
be drawn on game pieces but my trait's implementation of the Decorator
draw() function isn't drawing the label:


	public void draw(Graphics g, int x, int y, Component obs, double zoom) 
		piece.draw(g, x, y, obs, zoom);
		JLabel test = new JLabel("test");
		test.setLocation(x, y);

Read this topic online here:

More information about the messages mailing list