Results 1 to 8 of 8
- 06-07-2010, 01:09 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 12
- Rep Power
- 0
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
Java 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);Last edited by Ravanelly; 06-07-2010 at 01:13 PM.
- 06-07-2010, 01:28 PM #2
Where does your code build the panels?
There isn't enough code shown to be able to help.
- 06-07-2010, 03:38 PM #3
Member
- Join Date
- Aug 2009
- Posts
- 12
- Rep Power
- 0
Hy,
The code from class that I past code before :
And here is the code for ShowAlarmsDialogHelper..constructAlarmPanel :Java Code:final JPanel alarmspaPanel = new JPanel(new BorderLayout()); alarmspaPanel.setBorder(BorderFactory .createTitledBorder("alarmspaPanel")); alarmsTabbedPane = new JTabbedPane(); alarmspaPanel.add(alarmsTabbedPane, BorderLayout.CENTER);
Hope you refer to these :)Java Code:public class ShowAlarmsDialogHelper { private static final Insets insets = new Insets(5, 5, 5, 5); private ShowAlarmsDialogHelper() { } /** * Constructs a panel showing given alarm. * * @param alarmData * Map: * <ul> * <li>key - column name (String)</li> * <li>value - column's value (DataItem)</li> * </ul> * @param translator * the translator used. * @return */ public static JPanel constructAlarmPanel(Map alarmData, TranslatorInterface translator) { JPanel alarmsPanel = new JPanel(new GridBagLayout()); alarmsPanel.setBorder(BorderFactory.createTitledBorder("")); int dcnY = 0; // alarmId dcnY += 1; alarmsPanel .add(new FieldLabel(alarmId, translator), new GridBagConstraints(0, dcnY, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); JTextField alarmIdTf = new JTextField(20); DataItem alarmId = (DataItem) alarmData .get(alarmId); alarmIdTf.setText(alarmId == null ? "" : alarmId.getValue()); alarmIdTf.setEnabled(false); alarmsPanel .add(alarmIdTf, new GridBagConstraints(1, dcnY, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); return alarmsPanel; } }
Thanks
- 06-07-2010, 10:37 PM #4
What does happen then? Do you mean when you press a tab on the JTabbedPane?problem is that sometime in a tab (example with key "1") it isn't display the Jpanel
- 06-08-2010, 01:38 PM #5
Member
- Join Date
- Aug 2009
- Posts
- 12
- Rep Power
- 0
Yes, when I click tab (JTabbedPane)"1" for example I have a Jpanel who is empty like in picture attach and on others tabs"2", "3"..everything is ok, is not empty
- 06-08-2010, 04:49 PM #6
The question then is why is the panel for tab "1" empty?when I click tab (JTabbedPane)"1" for example I have a Jpanel who is empty
Have you tried putting something in that panel that is sure to show?
Have you tried creating a special one panel screen using the panel for "1" to see if it shows OK?
- 06-08-2010, 09:51 PM #7
Member
- Join Date
- Aug 2009
- Posts
- 12
- Rep Power
- 0
Yes is have something, is like others tabs "2" or "3"....
Sometime is empty and sometime it isn't...this is way I'm asking :D...it takes information from ShowAlarmsDialogHelper.constructAlarmPanel like others tabs...
I don't know why sometime is empty and sometime not?
It have some connection with threads or with SwingUtilities.invokeLater?I don't know much about it...or how to look to see?I've try but without luck.
Thanks
- 06-08-2010, 10:19 PM #8
Similar Threads
-
Cannot display in JPanel
By atch in forum New To JavaReplies: 2Last Post: 02-05-2010, 02:21 PM -
How to add JFrame inside JPanel
By niteshwar.bhardwaj in forum Java 2DReplies: 8Last Post: 12-13-2009, 08:41 PM -
display a new jpanel in an applet
By toymachiner62 in forum Java AppletsReplies: 6Last Post: 10-18-2009, 11:10 PM -
can't get anything to display on my JPanel
By v1nsai in forum AWT / SwingReplies: 9Last Post: 08-25-2009, 08:25 AM -
Display output in Jframe or JPanel
By rammurugesan in forum AWT / SwingReplies: 12Last Post: 04-14-2009, 01:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks