我想将正确的ResourceBundle传递给我的Jasper报告,但我不确定该怎么做。到目前为止,这是我的代码:
public void HandleFocusChangedEvent(IUIAutomationElement sender)
{
// A focus changed event has been sent by the the active window or some descendant of it.
// Check that this event hasn't arrived around the time we're removing the event handler on shutdown.
if (!_fAddedEventHandler)
{
return;
}
// All the event handler needs to do is notify the main UI thread that the
// list of elements should be refreshed to make sure it's showing the most current list.
// We only want to do this once every second So use a timer/counter
if (focusChangedCounter == 0)
{
controllerDispatcher.BeginInvoke(_focusChangedEventHandlerDelegate);
focusChangedCounter = 1;
if (focusChangedBufferTimer == null)
{
focusChangedBufferTimer = new System.Windows.Forms.Timer();
focusChangedBufferTimer.Tick += new EventHandler(focusChangedBufferTimer_Tick);
focusChangedBufferTimer.Interval = 1000;
focusChangedBufferTimer.Start();
}
}
}
private void focusChangedBufferTimer_Tick ( object sender, EventArgs e)
{
focusChangedCounter = 0;
focusChangedBufferTimer.Stop();
focusChangedBufferTimer = null;
}
但这给了我
Locale locale = Locale.getDefault();
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("Bundle.properties").getFile());
URL[] urls = {file.toURI().toURL()};
ClassLoader loader = new URLClassLoader(urls);
ResourceBundle rb = ResourceBundle.getBundle("bundle", locale, loader);
错误:(
我的捆绑文件在这里:
java.util.MissingResourceException: Can't find bundle for base name bundle, locale XX_XX
谢谢!
答案 0 :(得分:0)
首先,我认为您应该使用classLoader
,而不是loader
。我猜loader
只是一个失败的解决方法,所以我建议你删除它。
其次,后备捆绑文件可能应该被称为bundle.properties
,而不是Bundle.properties
。