Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

Rendering des CENTER Panels abh?ngig vom ComboBox Item

Thread view: 
Erik Mautsch - 22 Dec 2003 19:24 GMT
Ich erzeuge mittels Swixml ein einfaches Swing GUI.

Ein Frame mit Menue, panel--> BorderLayout.NORTH besitzt eine
Combobox, nach deren Inhalten ich das panel-->BorderLayout.CENTER
füllen möchte.

Das Haupt-XML File sieht folgendermaßen aus.

Pseudo:
<xml... />
<frame>
<menuebar>
.
.
.
</menubar>
<panel id=north"...>
<combobox />
</panel>
<panel id="center" ... include="ein_anderes_file.xml#bla"/>
</frame>

ein_anderes_file.xml:

<ein_tag>
<panel id="bla"..>
<button id="anim1" />
<button id="anim2" />
</panel>
</ein_tag>

Das Includen funktioniert. Zur Laufzeit included er mir das
ein_anderes_file.xml File in mein Hauptdokument und die Buttons sind
sichtbar.
Das Buttons XML File kann ich nach belieben von aussen verändern, ohne
jedesmal das Hauptdokument anzufassen.
Nur möchte ich jetzt abhängig von der Comboboxauswahl den
Centerbereich neu rendern.
Dazu hatte ich mir ein Hauptdokument_2 erstellt, was sich nur darin
vom Originalen unterscheidet, dass es ein anderes,
ein_anderes_file_2.xml, included, wo dann die Buttons anim3/anim4
enthalten sind.

Wird dann das jeweilige Event ausgelöst (Combobox), dann lasse ich das
zweite Hauptdokument (mit der anderen XML Datei-->Button3/4) rendern.
Nur habe ich da ein Denkfehler. Es müsste ja das bestehende GUI erst
geschlossen/invalidate() gesetzt werden, bevor das neue erzeugt und
auf visible(true) gesetzt werden kann...
Abhängig ist diese Variante auch von der Peformance, obwohl wir hier
ja von "ms" reden. :-)

Hatte auch schon überlegt, alle Buttons gleich ins Hauptdokument zu
schreiben und komplett rendern zu lassen, jedoch auf visible(false) zu
lassen und erst dann nach Comboboxauswahl anzeigen zu lassen.
Nur hatte ich einen Tipp bekommen, dass der GC damit nicht so gut
umgehen kann. Ab einer gewissen Anzahl gibt es dann auch eine
OutOfMemoryException.

Als letzte Alternative fiel mir dann noch folgendes ein, wenn eine
andere Auswahl in  der Combo getroffen
wird, dann  panel_north.invalidate(), dann panel_north.removeALL(),
dann müsste der Centerbereich neu gerendert/gefüllt werden, dann
panel_north.validate().

Kennt sich jemand mit Swixml aus und hat einen kleinen Tipp?

Danke
Erik
Erik Mautsch - 23 Dec 2003 08:35 GMT
> Ich erzeuge mittels Swixml ein einfaches Swing GUI.

Sorry, I thought, that is is an german speaking group (like the d.c.l.java).

I've tried the following (I'm using the Swixml Library):

First Example:

.
.
.
SwingEngine swix = new SwingEngine("xml/animation1.xml");
.
.
.
if (Combo Item...............){
center_panel.invalidate();
center_panel.removeALL();
center_panel.add(swix.find("anim1")); /*anim1 is the id from the button
<button id="anim1" icon="....." />*/
center_panel.validate();
}

#################################

Second Example:
.
.
.
SwingEngine swix = new SwingEngine();
.
.
.
if (Combo Item...............){
swix.getIdMap().clear()
center_panel.invalidate();
center_panel.removeALL();
swix.insert("xml/anim1.xml", center_panel);
/*the first tag in the xml file is a "dummy tag", therefore the panel tag
should be insert in my existing panel.
<dummy>
<panel>
<button id="anim1" />
<button id="anim2" />
</panel>
</dummy>*/
center_panel.validate();
}

Both Samples, didn't solve my problem.

After the Combo Choice, all components were removed from the
center_panel, but
there aren't new components, that should be there after the add(..),
swix.insert(...).

The find(String id) method returns "null", but the id/Button exists in
the xml
File.

What's wrong in the above samples?

Regards
Erik


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.