1 Attachment(s)
JPanel inside Jtabbed isn't display
Hello,
I have
I have the fowling code from below.
Explication:I have a HashMap(alarmsTabbedPane) and here I add a key and a JPanel for every key. And here in every tab I add a Jpanel who is create with :alarmPanels.put(key, ShowAlarmsDialogHelper..constructAlarmPanel(alarmD ata, translator));
ShowAlarmsDialogHelper..constructAlarmPanel is a class who create a Jpanel with some Jtext area.
My problem is that sometime in a tab (example with key "1") it isn't display the Jpanel, I don't see nothing inside Jpanel like in picture that I attach.
Do you now why?It have connection with SwingUtilities.invokeLater.
Thank you in advanced
Code:
final Map alarmPanels = new HashMap(alarmKeys.size())
for (int i = 0; i < alarmKeys.size(); i++) {
String key = (String) alarmKeys.get(i);
Map alarmData;
if ((alarmData = (Map) alarms.get(key)) != null) {
try {
alarmPanels.put(key, ShowAlarmsDialogHelper
.constructAlarmPanel(alarmData, translator));
addNotify();
// repaint();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
alarmsTabbedPane.removeAll();
for (int i = 0; i < alarmKeys.size(); i++) {
String key = (String) alarmKeys.get(i);
JPanel panel = (JPanel) alarmPanels.get(key);
if (panel == null) {
continue;
}
String title = (String) titles.get(key);
title = title == null ? "Unknown Counter" : title;
alarmsTabbedPane.add(title, panel);
pack();
}
});
new Timer("Validator").schedule(new TimerTask() {
public void run() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
pack();
}
});
}
}, 50);