MissingResourceException:找不到基本名称的包

时间:2015-12-01 15:42:03

标签: java netbeans

this is my working tree

Object selecao = jComboBox1.getSelectedItem();
if(selecao.equals("English")){
    //Locale local = new Locale("en", "EN");
    this.bundle = ResourceBundle.getBundle("Presentation.Bundle", Locale.UK);
    this.jLabel1.setText(bundle.getString("IdiomaUI.jLabel1.text"));
    this.confirmarBt.setText(bundle.getString("IdiomaUI.confirmarBt.text"));
    this.cancelarBt.setText(bundle.getString("IdiomaUI.cancelarBt.text"));
}else if(selecao.equals("Português")){
    this.bundle = ResourceBundle.getBundle("Presentation.Bundle");
    this.jLabel1.setText(bundle.getString("IdiomaUI.jLabel1.text"));
    this.confirmarBt.setText(bundle.getString("IdiomaUI.confirmarBt.text"));
    this.cancelarBt.setText(bundle.getString("IdiomaUI.cancelarBt.text"));
}

我收到错误:“线程中的异常”AWT-EventQueue-0“java.util.MissingResourceException:无法找到基本名称为Presentation.Bundle的bundle,locale pt_PT”:

  

线程中的异常“AWT-EventQueue-0”java.util.MissingResourceException:无法找到基本名称Presentation / Bundle的bundle,locale pt_PT       at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)       在java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)       在java.util.ResourceBundle.getBundle(ResourceBundle.java:773)       在Presentation.IdiomaUI.jComboBox1ActionPerformed(IdiomaUI.java:136)       在Presentation.IdiomaUI.access $ 000(IdiomaUI.java:17)       在Presentation.IdiomaUI $ 1.actionPerformed(IdiomaUI.java:56)       在javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258)       在javax.swing.JComboBox.setSelectedItem(JComboBox.java:586)       在javax.swing.JComboBox.setSelectedIndex(JComboBox.java:622)       在javax.swing.plaf.basic.BasicComboPopup $ Handler.mouseReleased(BasicComboPopup.java:834)       在java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)       at java.awt.Component.processMouseEvent(Component.java:6525)       在javax.swing.JComponent.processMouseEvent(JComponent.java:3321)       在javax.swing.plaf.basic.BasicComboPopup $ 1.processMouseEvent(BasicComboPopup.java:498)       at java.awt.Component.processEvent(Component.java:6290)       at java.awt.Container.processEvent(Container.java:2234)       at java.awt.Component.dispatchEventImpl(Component.java:4881)       at java.awt.Container.dispatchEventImpl(Container.java:2292)       at java.awt.Component.dispatchEvent(Component.java:4703)       at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)       at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)       at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)       at java.awt.Container.dispatchEventImpl(Container.java:2278)       at java.awt.Window.dispatchEventImpl(Window.java:2739)       at java.awt.Component.dispatchEvent(Component.java:4703)       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)       at java.awt.EventQueue.access $ 400(EventQueue.java:97)       at java.awt.EventQueue $ 3.run(EventQueue.java:697)       at java.awt.EventQueue $ 3.run(EventQueue.java:691)       at java.security.AccessController.doPrivileged(Native Method)       at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)       at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:86)       at java.awt.EventQueue $ 4.run(EventQueue.java:719)       at java.awt.EventQueue $ 4.run(EventQueue.java:717)       at java.security.AccessController.doPrivileged(Native Method)       at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)       在java.awt.EventQueue.dispatchEvent(EventQueue.java:716)       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)       在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我已经搜索了这个,我还没弄清楚问题是什么。求救!

1 个答案:

答案 0 :(得分:0)

如果您的Locale设置为葡萄牙语,则ResourceBundle将尝试从名为Bundle_pt_PT.properties的属性文件中加载内容。根据截图,您在项目中没有这个。

有关使用Java的ResourceBundles /本地化的更多信息,请查看herehere获取有关受支持的语言环境的一般信息。