The variable panel1 is only in the scope of your constructor, in order for it to be in both your button handler's and your constructors scope, you will have to make it a global* variable, such as
...