Re: Using TabbedPane
Bruno Lima <[email protected]> Thu, 10 Feb 2005 18:55:33 -0200
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
Sorry by the incomplete code.
Well, i explained what i have: 3 xml files. I render they separated,
first the main.xml, then tab1.xml and tab2.xml.
Seems that all code is right. But, it is not. This is the exception
taht occurs when i try to run the code:
SwixML 1.2 (#140)
Exception in thread "AWT-EventQueue-0"
java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(BasicTabbedPaneUI.java:592)
at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(BasicTabbedPaneUI.java:547)
at javax.swing.plaf.metal.MetalTabbedPaneUI.paint(MetalTabbedPaneUI.java:827)
at javax.swing.plaf.metal.MetalTabbedPaneUI.update(MetalTabbedPaneUI.java:716)
at javax.swing.JComponent.paintComponent(JComponent.java:740)
at javax.swing.JComponent.paint(JComponent.java:1003)
My code is something like that:
========== JAVA CODE ==============
public class FrameExampleEngine {
private SwingEngine xmlEngine = new SwingEngine( this );
public JTabbedPane tab_opcao;
private String FILE_XML_FRAME = "swixml/xml/frameExample.xml";
private String FILE_XML_TAB_ASSOCIADOS =
"swixml/xml/frameExample-Associados.xml";
private String FILE_XML_TAB_PAGAMENTOS =
"swixml/xml/frameExample-Pagamentos.xml";
public FrameExampleEngine() throws Exception{
xmlEngine.render(FILE_XML_FRAME).setVisible(true);
loadTabs();
}
private void loadTabs() throws Exception {
xmlEngine.insert(FILE_XML_TAB_ASSOCIADOS, tab_opcao);
}
}
========== JAVA CODE ==============
I have the field "tab_opcao" that is the same name given to the id
attribute in the xml file. I tested if this variable were being
loadded, and it is. I can access the tab throught code.
If i do this
panel = (JPanel)xmlEngine.render(FILE_XML_TAB_ASSOCIADOS);
tab_opcao.add(panel);
instead of
xmlEngine.insert(FILE_XML_TAB_ASSOCIADOS, tab_opcao);
works perfectly! I thought that xmlEngine.insert() would do like i did
in code, but not.
Is it the right way to add TABs to a tabbedpane, where may TABs are
panels in their own XML files ?
Tks!
Bruno
On Thu, 10 Feb 2005 21:39:47 +0100, Frank Meissner <[email protected]> wrote:
> Bruno Lima wrote:
>
> >
> > private void loadTabs() throws Exception {
> > xmlEngine.insert(FILE_XML_TAB_ASSOCIADOS, tab_option);
> > xmlEngine.insert(FILE_XML_TAB_PAGAMENTOS, tab_option);
> > }
>
> Please post a more complete snippet of your code. The statement "does
> not work" needs some explanation too. What happens? Error messages,
> thrown exceptions???
>
> Frank
>
> _______________________________________________
> Forum mailing list
> [email protected]
> http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
>
--
Bruno R. Lima