我在ListResourceBundle
中的情况如何,因此当按下按钮时,它会翻译成法语。目前,我已经用按钮设置了GUI。不确定如何添加ListResourceBundle
,以便在按下按钮时将其翻译为法语。
public class ButtonTranslator extends JFrame{
public ButtonTranslator() {
//get value for greeting key value
JButton computeButton = new JButton("Three");
JButton computeButton1 = new JButton("Translate to French");
JButton computeButton2 = new JButton("One");//button key value
JButton computeButton3 = new JButton("Two");
getContentPane().add(computeButton1,BorderLayout.PAGE_START);
getContentPane().add(computeButton2,BorderLayout.LINE_START);
getContentPane().add(computeButton3,BorderLayout.CENTER);
getContentPane().add(computeButton,BorderLayout.LINE_END);
setSize(500,400);
setVisible(true);
}
public static void main(String[] args) {
ButtonTranslator mygui = new ButtonTranslator();
}
}