Java用户界面本地化实例探索 - 编程入门网
entPane.add(panel);
//通过获取资源束中*.label的值对三个按钮设置其Label
panel.setCmdRed(bundle.getString("red.label"));
panel.setCmdBlue(bundle.getString("blue.label"));
panel.setCmdGreen(bundle.getString("green.label"));
}
private MyNativePanel panel;
private static final int WIDTH=400;
private static final int HEIGHT=100;
}
class MyNativePanel extends JPanel{
public MyNativePanel(){
layout=new BorderLayout();
setLayout(layout);
txt=new JTextField(50);
add(txt,layout.CENTER);
cmdRed=new JButton();
cmdBlue=new JButton();
cmdGreen=new JButton();
panel.add(cmdRed);
panel.add(cmdBlue);
panel.add(cmdGreen);
add(panel,layout.SOUTH);
cmdRed.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String s = e.getActionCommand();
txt.setBackground(Color.red);
txt.setText(s);
}
});
cmdBlue.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String s = e.getActionCommand();
txt.setBackground(Color.blue);
txt.setText(s);
}
});
cmdGreen.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String s = e.getActionCommand();
txt.setBackground(Color.green);
txt.setText(s);
}
});
}
public void setCmdRed(String s){
cmdRed.setText(s);
}
public void setCmdBlue(String s){
cmdBlue.setText(s);
}
public void setCmdGreen(String s){
cmdGreen.setText(s);
}
JPanel panel=new JPanel();
BorderLayout layout;
private JTextField txt;
private JButton cmdRed,cmdBlue,cmdGreen;
}
//~
Java用户界面本地化实例探索(3)时间:2010-12-16资源文件:
以下是这个程序运行后的截屏! |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |