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.

4
  • Since you think it's so simple, why don't you write the XML that will be used as input and the XML that you're expecting as output and add the XML files to your question? Commented Jun 24, 2013 at 17:42
  • I thought that I've heard of something like this in the past, but right now can't find any reference to it. Commented Jun 24, 2013 at 21:07
  • Take a look at this thread Commented Jun 25, 2013 at 2:13
  • Are there any examples out there on how to dynamically create a JFrame? Commented Jun 26, 2013 at 20:12

1 Answer 1

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.