Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2005 > unrolled thread
| Started by | "cool.keanu" <cool.keanu@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:36 +0000 |
| Last post | 2011-04-27 15:36 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.gui
Thinlet and own JPanels "cool.keanu" <cool.keanu@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: Thinlet and own JPane a24900@googlemail.com.remove-dii-this - 2011-04-27 15:36 +0000
| From | "cool.keanu" <cool.keanu@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Thinlet and own JPanels |
| Message-ID | <1184072315.848845.256630@w3g2000hsg.googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | a24900@googlemail.com.remove-dii-this |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: Thinlet and own JPane |
| Message-ID | <1184097587.369947.209980@r34g2000hsd.googlegroups.com> |
| In reply to | #2005 |
To: comp.lang.java.gui
On Jul 10, 2:58 pm, cool.ke...@googlemail.com wrote:
> hopefully you all know thinlet,
It's not so important that one really needs to know.
> (http://thinlet.sourceforge.net). I was trying to parse a simple xml
> file and take one of its components
A Thinlet does not contain separate Components unless you separately
added AWT-based JavaBeans, which you didn't.
> and then put it on my own swing
> panel.
Bad idea in many aspects. Bad on abstract level (mixing of paradigms)
and bad on technical level.
> Sadly I am not able to do this.
Of course not. The Thinlet is a single component, actually a
Container, an AWT Component subclass. The "components" in a Thinlet
are typically String descriptions plus data, not Component objects. A
Thinlet is one big text interpreter when run.
> Object c = thin.find("mainpanel");
"c" contains all you can ever find out about "mainpanel".
> thin.getComponent(c, "name"); // THIS SHOULD GET THE COMPONENT
> mainpanel
No, why should it? And all your shouting will not change it.
getComponent() only looks for JavaBeans, which have the internal
Thinlet-'type' "bean". But you are asking for a "panel" type. While a
"panel" has a "name" attribute, a "bean" doesn't.
> I wanted to get the AWT component named "mainpanel",
There is no such AWT Component in the Thinlet. There is a data
structure labeled "mainpanel" in the Thinlet, which is not an AWT
Component.
> defined in the
> xml file,
You have not define a "mainpanel" AWT Component. Just one single
Thinlet (which is an AWT Container) and which contains text
descriptions of components.
> and then put it on the panel with panel.add().
> Any idea how
> this is done?
It can't be done. What you want is not there. And if it would be there
you would asking for trouble by putting an AWT component on a Swing
JPanel.
Drop that giant hack called Thinlet and learn Swing programming.
> Is it possible to parse the xml file and then use parsed elements on
> your own panels, frames etc.?!
No. Learn Swing programming.
---
* 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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web