Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    30
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    30
    Thanks
    4
    Thanked 0 Times in 0 Posts
    FIXED.

    (Without doing anything, it seems =s)
    Last edited by Thrillseeker; 01-04-2012 at 08:47 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •