更改menuItem的标题

时间:2015-10-27 15:50:57

标签: java

我在创建菜单项的标题时遇到了一些问题。

我试过这个:

MenuItem nativeItem = new MenuItem(nativeTitle);
nativeItem.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e) {
      if(menuItemEnable.isSelected()){
         nativeItem.setTitle("Enable Native Hook"); //This is not working
      }else{
         nativeItem.setTitle("Disable Native Hook"); //This is not working
      }
   }
});
menu.add(nativeItem);

1 个答案:

答案 0 :(得分:0)

Thx gla3dr

Use this

setLabel("Hello");