我使用git处理一个项目,其中多个机器的编码可能不同。获取按钮变量的名称
如果我设置:
private JButton translationButton1 = new JButton("←");
translationButton1.addActionListener(this);
然后我设置监听器:
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
我知道这是可能通过使用e.getActionCommand()
获得“←”,但我怕,如果有人谁没有与我一样的编码(例如Cp1252),我不确定要得到“←”。
可以在actionPerformed method
(if(???.equals("translationButton1")
)中获得按钮的名称? (我不希望使用anonymous inner type
,因为我有几个的ActionListener设置)
感谢
麻烦,这是更清洁理由为无论什么,然后有什么问题,也不能找到Encoding(不包括东亚和南亚) – mKorbel 2013-04-30 15:07:20