Complex (for Me) Dialogpanel Problem

I have a DialogPanel that contains 2 objects: a JavaScriptButton and a (cancel) Button. If the JavaScriptButton is selected, I want to do 2 things with the java script: open another browser and close the DialogPanel. If the Button is selected, I just want to close the DialogPanel.

I can't figure out how to reference my (cancel) Button from my JavaScriptButton (even though I know that my (cancel) Button is called a_22 the first time, a_25 the second time, etc... I know this from viewing the page source

Here's my code snippet...

JavaScriptButton button = new JavaScriptButton("Bring up a Window");
button.setScript("var x = window.open(<url>, <name>); x.focus(); <CLOSE MY DIALOG HERE>");
dialogpanel.add(button);

Button cancelButton = new Button("Cancel");
cancelButton.addActionListener(new ActionListener(){
  public void actionPerformed(ActionEvent e)
  {
    dialogpanel.close();
  }
});
dialogpanel.add(cancelButton);

pane.add(dialogpanel);

Thanks in advance