Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-24-2011, 07:56 PM   PM User | #1
Thrillseeker
New Coder

 
Join Date: Aug 2011
Posts: 30
Thanks: 4
Thanked 0 Times in 0 Posts
Thrillseeker is an unknown quantity at this point
Trying to put paint() method into a layout manager

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 is offline   Reply With Quote
Old 01-03-2012, 08:25 PM   PM User | #2
Thrillseeker
New Coder

 
Join Date: Aug 2011
Posts: 30
Thanks: 4
Thanked 0 Times in 0 Posts
Thrillseeker is an unknown quantity at this point
FIXED.

(Without doing anything, it seems =s)

Last edited by Thrillseeker; 01-04-2012 at 07:47 PM..
Thrillseeker is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:41 AM.


Advertisement
Log in to turn off these ads.