This main method allows the class to be demonstrated standalone
// Specify the name of the class as a command-line argument
Class beanClass = null;
try {
// Use reflection to get the Class from the classname
beanClass = Class.forName(args[0]);
}
catch (Exception e) { // Report errors
System.out.println("Can't find specified class: "+e.getMessage());
System.out.println("Usage: java PropertyTable <bean class name>");
System.exit(0);
}
// Create a table to display the properties of the specified class
JTable table = new PropertyTable(beanClass);
// Then put the table in a scrolling window, put the scrolling
// window into a frame, and pop it all up on to the screen
JScrollPane scrollpane = new JScrollPane(table);
JFrame frame = new JFrame("Properties of JavaBean: " + args[0]);
frame.getContentPane().add(scrollpane);
frame.setSize(500, 400);
frame.setVisible(true);