XML -> Swing



  • Hallo

    ich muss eine sehr variable gui schreiben d.h. eine gui die auf sehr vielen Plattformen (PC, PDA, etc) laufen muss. Hauptsächlich unterscheiden sich diese in der Bildschirmauflösung aber ein dynamisches Layout mit skalierbarer Fenstergrössen reicht mir hier nicht aus.

    Am liebesten wäre mir ein xml dokument in dem ich die gesammte gui beschreiben kann und dann ein Mechanismus welcher mir diese xml Daten in swing code transformiert. jeasy bietet z.B. solche Klassen ist allerdings nicht open source.

    Kennt jemand von euch solch eine OS Alternative? Ich habe irgendwo mal gehört das solch ein Konzept in java 1.5 umgesetzt werden soll. Weiss da jemand etwas.

    Falls Ihr andere Vorschläge habt wie man das mit der gui eleant lösen könnte bin ich natürlich auch interessiert.

    mfg Heiner



  • Hi.
    Ich weiss zwar nicht ob es Dir weiterhilft, aber geh mal auf http://www.jgraph.com

    Das ist ein Grafiksystem, welches mit Java arbeitet und zu XML kompatibel sein soll.
    Schaus Dir einfach mal an.
    Grüsse.



  • Du meinst wie folgt?

    <?xml version="1.0" encoding="UTF-8" ?>
    
    <Form version="1.0" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
      <Properties>
        <Property name="title" type="java.lang.String" value="%s in progress ..."/>
        <Property name="defaultCloseOperation" type="int" value="0"/>
        <Property name="enabled" type="boolean" value="false"/>
      </Properties>
      <SyntheticProperties>
        <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,1 00,116,104,120,112,0,0,1,44,0,0,1,-112"/>
        <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
        <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
        <SyntheticProperty name="generatePosition" type="boolean" value="true"/>
        <SyntheticProperty name="generateSize" type="boolean" value="true"/>
        <SyntheticProperty name="generateCenter" type="boolean" value="true"/>
        <SyntheticProperty name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,1 00,116,104,120,112,0,0,1,44,0,0,1,-112"/>
      </SyntheticProperties>
    
      <Events>
        <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
      </Events>
    
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
      <SubComponents>
        <Container class="javax.swing.JPanel" name="jPanel1">
          <Properties>
            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
              <Color blue="9b" green="a9" red="b2" type="rgb"/>
            </Property>
          </Properties>
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="North"/>
            </Constraint>
          </Constraints>
    
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
        </Container>
        <Container class="javax.swing.JPanel" name="jPanel2">
          <Properties>
            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
              <Color blue="9b" green="a9" red="b2" type="rgb"/>
            </Property>
          </Properties>
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="East"/>
            </Constraint>
          </Constraints>
    
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
        </Container>
        <Container class="javax.swing.JPanel" name="jPanel3">
          <Properties>
            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
              <Color blue="9b" green="a9" red="b2" type="rgb"/>
            </Property>
          </Properties>
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="South"/>
            </Constraint>
          </Constraints>
    
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
          <SubComponents>
            <Component class="javax.swing.JButton" name="jButton1">
              <Properties>
                <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
                  <ResourceString bundle="de/sahinc/jmail/gui/text.properties" key="Cancel" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}", JMail.locale).getString("{key}")"/>
                </Property>
                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
                  <Color blue="9b" green="a9" red="b2" type="rgb"/>
                </Property>
              </Properties>
    
              <AuxValues>
                <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new FlatButton();"/>
              </AuxValues>
            </Component>
          </SubComponents>
        </Container>
        <Container class="javax.swing.JPanel" name="jPanel4">
          <Properties>
            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
              <Color blue="9b" green="a9" red="b2" type="rgb"/>
            </Property>
          </Properties>
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="West"/>
            </Constraint>
          </Constraints>
    
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
        </Container>
        <Container class="javax.swing.JPanel" name="jPanel5">
          <Properties>
            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
              <Color blue="9b" green="a9" red="b2" type="rgb"/>
            </Property>
          </Properties>
          <Constraints>
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
              <BorderConstraints direction="Center"/>
            </Constraint>
          </Constraints>
    
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout">
            <Property name="verticalGap" type="int" value="5"/>
          </Layout>
          <SubComponents>
            <Component class="javax.swing.JTextArea" name="jTextArea1">
              <Properties>
                <Property name="wrapStyleWord" type="boolean" value="true"/>
                <Property name="lineWrap" type="boolean" value="true"/>
                <Property name="editable" type="boolean" value="false"/>
                <Property name="text" type="java.lang.String" value="%Message"/>
                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
                  <Color blue="9b" green="a9" red="b2" type="rgb"/>
                </Property>
              </Properties>
              <Constraints>
                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                  <BorderConstraints direction="North"/>
                </Constraint>
              </Constraints>
            </Component>
            <Container class="javax.swing.JPanel" name="jPanel6">
              <Properties>
                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
                  <Color blue="9b" green="a9" red="b2" type="rgb"/>
                </Property>
              </Properties>
              <Constraints>
                <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                  <BorderConstraints direction="Center"/>
                </Constraint>
              </Constraints>
    
              <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
              <SubComponents>
                <Component class="javax.swing.JProgressBar" name="jProgressBar1">
                  <Properties>
                    <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
                      <Color blue="ff" green="66" red="66" type="rgb"/>
                    </Property>
                    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
                      <Color blue="dd" green="f1" red="ff" type="rgb"/>
                    </Property>
                    <Property name="stringPainted" type="boolean" value="true"/>
                  </Properties>
                  <Constraints>
                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
                      <BorderConstraints direction="North"/>
                    </Constraint>
                  </Constraints>
                </Component>
              </SubComponents>
            </Container>
          </SubComponents>
        </Container>
      </SubComponents>
    </Form>
    

    Bisschen viel ich weiss aber ... so sieht das dann aus in diesem Fall von NetBeans generiert. Abgespeckte Versionen davon lassen sich sicherlich mit relativ wenig Aufwand selbst programmieren. Ein extra Package dafür einzusetzen empfinde ich als Overkill.


Anmelden zum Antworten