简体   繁体   中英

MissingResourceException: Can't find bundle for base name

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"));
}

I'm getting the error: "Exception in thread "AWT-EventQueue-0" java.util.MissingResourceException: Can't find bundle for base name Presentation.Bundle, locale pt_PT":

Exception in thread "AWT-EventQueue-0" java.util.MissingResourceException: Can't find bundle for base name Presentation/Bundle, locale pt_PT at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387) at java.util.ResourceBundle.getBundle(ResourceBundle.java:773) at Presentation.IdiomaUI.jComboBox1ActionPerformed(IdiomaUI.java:136) at Presentation.IdiomaUI.access$000(IdiomaUI.java:17) at Presentation.IdiomaUI$1.actionPerformed(IdiomaUI.java:56) at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258) at javax.swing.JComboBox.setSelectedItem(JComboBox.java:586) at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:622) at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:834) at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290) at java.awt.Component.processMouseEvent(Component.java:6525) at javax.swing.JComponent.processMouseEvent(JCo mponent.java:3321) at 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:69 1) 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) at 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) at java.awt.EventDispatchThread.run(EventDispatchThread.java :82)

I've already searched about this and i haven't figured it out what the problem is. Help please!

If your Locale is set to Portuguese then the ResourceBundle will attempt to load content from a properties file called Bundle_pt_PT.properties . According to the screenshot you don't have this in your project.

Take a look here for more information on ResourceBundles/localisation in Java And here for some general information on supported Locales.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM