<?xml version="1.0" encoding="UTF-8"?>
<properties>
<config>
<seperator>
<entry key ="fileSeprator">|</entry>
</seperator>
<columncount>
<entry key ="colcount">4</entry>
</columncount>
<columnName>
<entry key ="0">ClientID</entry>
<entry key ="1">ID</entry>
<entry key ="2">FirstName</entry>
<entry key ="3">LastName</entry>
</columnName>
<exception>
<entry key ="0">ClientID_Blank_Null</entry>
<entry key ="1">ID_Blank_Null_incorrect</entry>
<entry key ="2">FName_IS_Null</entry>
<entry key ="3">LName_IS_Null</entry>
</exception>
</config>
</properties>
//I have above xml property file. How to read in java code. Here Key =0 is the Position in the file. File do not have Column Name, but position is fix.I just want how to read this in Java code. And if value is blank then put the exception from the property file. Just help me to read this file in java.
Here is the code, when you click the different button, it will show the different checkbox.
import java.awt.BorderLayout;
import java.awt.Checkbox;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class DynamicCheckBox extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel north;
private JPanel center;
public DynamicCheckBox() {
north = new JPanel();
JButton first = new JButton("First");
JButton second = new JButton("Second");
north.add(first);
north.add(second);
center = new JPanel();
center.setLayout(new FlowLayout(FlowLayout.CENTER, 100, 20));
first.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
center.removeAll();
Checkbox[] box = createCheckBox(new String[]{"1", "2"});
for (int i = 0; i < box.length; i++) {
center.add(box[i]);
}
center.repaint();
DynamicCheckBox.this.revalidate();
}
});
second.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
center.removeAll();
Checkbox[] box = createCheckBox(new String[]{"3", "4"});
for (int i = 0; i < box.length; i++) {
center.add(box[i]);
}
center.repaint();
DynamicCheckBox.this.revalidate();
}
});
this.add(north, BorderLayout.NORTH);
this.add(center, BorderLayout.CENTER);
this.setSize(new Dimension(300, 300));
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new DynamicCheckBox();
}
public Checkbox[] createCheckBox(String[] values) {
Checkbox[] box = new Checkbox[values.length];
for (int i = 0; i < values.length; i++) {
box[i] = new Checkbox(values[i]);
}
return box;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments