I'd take advantage of the Actions API
For example...
public class SelectWindowAction extends AbstractAction {
private JInternalFrame frame;
public SelectWindowAction(JInternalFrame frame) {
putValue(NAME, frame.getTitle());
}
public void actionPerformed(ActionEvent evt) {
frame.setSelected(true);
}
}
Then you can simple create a JMenuItem
using something like...
JMenuItem mi = new JMenuItem(new SelectWindowAction(frame));