1

I need a java swing tool that will build a form dynamically based on an XML file and then write a new XML file. The XML file contains information such as field types and values.

For example, the tool will read an XML that defines textboxes for user name, id and login. The form displays this and when the save button is clicked, it will save the user inputted values for each of the fields into a new XML file.

Its a pretty simple tool and I was guessing there might be something already out there. Would anyone know of similar examples?

edit: (example of XML file added)

The incoming XML file to READ:

[XML]
  [PARAMS]
    [PARAM]
      [LABEL]Enter your user id:[/LABEL]
      [TYPE]textbox[/TYPE]
      [VALUE][/VALUE]
    [/PARAM]
    [PARAM]
      [LABEL]Enter the system id:[/LABEL]
      [TYPE]textbox[/TYPE]
      [VALUE][/VALUE]
    [/PARAM]
    [PARAM]
      [LABEL]Run all system checks?:[/LABEL]
      [TYPE]checkbox[/TYPE]
      [VALUE][/VALUE]
    [/PARAM]
  [/PARAMS]
[/XML]

Then an example output XML file would be generated based on the user selections.

[XML]
  [PARAMS]
    [PARAM]
      [LABEL]Enter your user id:[/LABEL]
      [TYPE]textbox[/TYPE]
      [VALUE]johndoe01[/VALUE]
    [/PARAM]
    [PARAM]
      [LABEL]Enter the system id:[/LABEL]
      [TYPE]textbox[/TYPE]
      [VALUE]system01[/VALUE]
    [/PARAM]
    [PARAM]
      [LABEL]Run all system checks?:[/LABEL]
      [TYPE]checkbox[/TYPE]
      [VALUE]true[/VALUE]
    [/PARAM]
  [/PARAMS]
[/XML]

Again - the incoming XML could have multiple parameters / blocks.

John Lee
  • 1,357
  • 1
  • 13
  • 26

1 Answers1

0

here is what i have done so far but still needs a bit of modifications,its use of pure logic.I have not included my xml parser,but i have created my parser that reads and returns the key and value objects.

Frame.xml
<ui_login>
    <ui_type>
        JFrame
    </ui_type>
    <ui_width>
    750
    </ui_width>
    <ui_height>
    150
    </ui_height>
    <ui_visible>
    true
    </ui_visible>
</ui_login>

CreateFrame.java
if (key.equals("ui_type")) {
   jFrame = new JFrame();
}
if (key.equals("ui_width")) {
    width = Integer.parseInt(value);
}
if (key.equals("ui_height")) {
    // height = screenSize.height;
   height = Integer.parseInt(value);
   jFrame.setSize(width, height);
}
if (key.equals("ui_visible")) {
    jFrame.setVisible(true);
}