...

View Full Version : Trying to put paint() method into a layout manager



Thrillseeker
12-24-2011, 07:56 PM
Hey,

I've got a paint method which paints two images (one at first, then the other once an event is run)


public void paint (Graphics g) {
Image elevation = store.getDataAsImage(a);
Graphics gc = canvas.getGraphics();
setSize(800,450);
gc.drawImage(elevation, insets.left+20, insets.top+50, this);

if (test == 1) {
Image gradients = store.getDataAsImageTwo(b);
gc.drawImage(gradients, 300, 0, this);
}
}

I want to put two labels above the images but at the moment its putting them off to the right, outside of the canvas. Any idea how I'd put them above the canvas? I've started a gridbaglayout but haven't really used it yet. I tried putting the contents below in Paint() but it didn't like that..


public void start() {
GridBagLayout gridbag = new GridBagLayout();
setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();

Label elevation = new Label("Elevation");
Label gradient = new Label("Gradient");
add(elevation);
add(gradient);
}

I'm using GridBagLayout to set them up

Thrillseeker
01-03-2012, 08:25 PM
FIXED.

(Without doing anything, it seems =s)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum