I want to use Jmenu as buttons to change what is showed in the frame but when the menu is selected the selection is not released. 下面是 Jmenu 实例的代码,它改变了两个字段和标签的位置。
mnAddUser.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent e) {
// TODO Auto-generated method stub
lblUserId.setBounds(150, 86, 111, 30);
userIDField.setBounds(273, 80, 268, 43);
lblUserName.setBounds(150, 165, 111, 30);
userNameField.setBounds(273, 159, 268, 43);
lblUserName.setVisible(true);
userNameField.setVisible(true);
btnAddUser.setBounds(187, 235, 150, 43);
btnReset.setBounds(390, 235, 150, 43);
btnAddUser.setText("Add User");
}
@Override
public void menuDeselected(MenuEvent e) {
// TODO Auto-generated method stub
}
@Override
public void menuCanceled(MenuEvent e) {
// TODO Auto-generated method stub
}
});