creating an xml from the values in a Dialog in Java Swing
I have to create an xml file based on the value of attributes set by user in dialog of Java Swing.There are five attributes name,age,sex,date of birth and place. when the user clicks on OK button of the Dialog box an xml file should be created in the t开发者_如何学JAVAemp directory of the user.
Kindly help me as I am new to Java Swing
Regards, Kumar
Create a GUI with controls to collect the data you specified. Create a class to generate the XML output. Call this class.
To build a Swing GUI, you start with a JFrame
.
Within this JFrame
, you have a master JPanel
.
The attributes will each have JLabel
components and JTextField
components. You will use a layout manager to arrange the label and text field components.
You have a JButton
so that the user can tell your program that she's entered all of the attributes.
You should be able to look up all these Swing components and build a GUI.
Then, as jzd said, you create a class to generate the XML output and call this class from the GUI.
精彩评论