1

I'm relatively new to programming GUI's, and for my project I'm using a SpringLayout, since the others don't make much sense to me.

Now if I do:

layout.putConstraint(SpringLayout.NORTH, sMenu, 0, SpringLayout.SOUTH, sControls);

everything works as intended. Adding the same code directly underneath simply overrides it.

layout.putConstraint(SpringLayout.NORTH, sMenu, 0, SpringLayout.SOUTH, sControls);
layout.putConstraint(SpringLayout.NORTH, sMenu, 20, SpringLayout.SOUTH, sControls);

But I want to access the constraint some time later, which doesn't seem to be overwriting the old one.

//Testing constraint overwrite
Timer t = new Timer();
t.schedule(new TimerTask() {
    @Override
    public void run() {
        layout.putConstraint(SpringLayout.NORTH, sMenu, 100, SpringLayout.SOUTH, sControls);
        System.out.println("Doing' stuff");
    }
}, 2000);

What am I doing wrong?

Shapi
  • 5,493
  • 4
  • 28
  • 39
Xatlor
  • 13
  • 3

0 Answers0