Re: Working optionpane tag example?

[email protected] Sun, 24 Apr 2005 21:06:35 +0200
Newsgroups gmane.comp.embedded.carlsbad-cubes
Message-ID <[email protected]>
Hello,

[email protected] wrote:
> Does anyone have a working example of using the optionpane tag?

> I tried the XML at the end of this email but no dialog displays.  In the

This is correct, your xml does not contain a dialog. The optionpane 
cannot be used that way. Have a look at the Javadocs of JOptionPane for 
that. IMHO the joptionpane tag should'nt be a valid swixml tag anyway.

> Java code, I've tried setVisible(true) and show() on the object returned
> from render().  There are no errors or messages that I can tell.  If I
> change the optionpane to dialog or frame, I can get the window to appear
> with no problem.  

Remove the <optionpane>-Element around your elements with a panel first. 
Then give the returned container to a JOptionPane.showXxxxDialog(...) as 
the message parameter (Object type). This is the way I usually render 
small (four, six elements) swixml files.

Yours,

Frank

PS: Sorry for the late reply, I was on a holiday for three weeks ;)


> 
> Any help or suggestions is appreciated!
>       
> 	try {
>         ScenarioModel sm = new ScenarioModel();
>         SwingEngine sw = new SwingEngine( sm );
>         Container c = sw.render("newScenario.xml");
>         c.setVisible(true);
>       } catch (Exception e) {
>         e.printStackTrace();
>       }
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <optionpane id="newScenario" layout="BorderLayout" 
>   optiontype="JOptionPane.OK_CANCEL_OPTION"
> messagetype="JOptionPane.INFORMATION_MESSAGE"
>   defaultcloseoperation="WindowConstants.DISPOSE_ON_CLOSE" >
> 	<panel name="pnl" constraints="BorderLayout.CENTER"
> layout="GridBagLayout">
>     <label text="Name">
>       <gridbagconstraints id="gbc_0" insets="0,0,0,0" gridx="0" gridy="0"
> ipadx="0" ipady="0" weightx="1" weighty="1"/>
>     </label>
>     <textfield id="scenarioName" Columns="20" Text="Scenario name Here">
>       <gridbagconstraints use="gbc_0" gridx="1"/>
>     </textfield>
>     
>     <label name="label0" text="Type">
>       <gridbagconstraints id="gbc_1" insets="2,2,2,2" gridx="0" gridy="1"
> ipadx="0" ipady="0" weightx="1" weighty="1"/>
>     </label>
>   </panel>
> </optionpane>
> 
> Thanks in advance,
> Michael Los
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Forum mailing list
> [email protected]
> http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com