Thinlet and own JPanels
To: comp.lang.java.gui
Hi NG,
hopefully you all know thinlet, the XML parser fo user interfaces
(http://thinlet.sourceforge.net). I was trying to parse a simple xml
file and take one of its components and then put it on my own swing
panel. Sadly I am not able to do this. This is what I was trying to do
public class UserInterface extends JFrame {
Thinlet thin;
JPanel panel;
public UserInterface() {
thin = new Thinlet();
try {
thin.add(thin.parse("..\\..\\myfile.xml"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setTitle("ThinletUI");
this.setSize(700, 300);
panel = new JPanel();
panel.setPreferredSize(new Dimension(700, 300));
this.add(panel);
this.setVisible(true);
this.processThinlet();
}
public void processThinlet() {
Object c = thin.find("mainpanel");
thin.getComponent(c, "name"); // THIS SHOULD GET THE COMPONENT
mainpanel
// now put the component on the panel
// ...
}
}
I wanted to get the AWT component named "mainpanel", defined in the
xml file, and then put it on the panel with panel.add(). Any idea how
this is done?
Main problem is: thin.getComponent(c, "name"); causes the following
exception
Exception in thread "main" java.lang.IllegalArgumentException: string
at thinlet.Thinlet.getDefinition(Thinlet.java:5773)
at thinlet.Thinlet.get(Thinlet.java:6006)
at thinlet.Thinlet.getComponent(Thinlet.java:5898)
at thinletui.UserInterface.processThinlet(UserInterface.java:40)
at thinletui.UserInterface.<init>(UserInterface.java:35)
at thinletui.ThinletUI.main(ThinletUI.java:10)
My XML file looks like this
<panel name="mainpanel" columns="2" gap="4" top="4" left="4">
<label text="Ihr Name:" alignment="right" />
<textfield columns="20" />
<label text="Passwort:" alignment="right" />
<passwordfield columns="20" />
<label />
<button text="Login" />
</panel>
Is it possible to parse the xml file and then use parsed elements on
your own panels, frames etc.?!
Thanks and have a nice day,
Keanu
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24