I've just commited the code for a new Swing TableModel which allows XML
information to be displayed in a Swing JTable easily.

org.dom4j.swing.XMLTableModel.

You can explicitly construct an XMLTableDefinition via java code (as
demonstrated in samples/swing/JTableDemo.java) or an XML document can be
used to define the table model itself.

e.g. here's an example table model to display information from the periodic
table in a Swing JTable.

<table select="/PERIODIC_TABLE/ATOM">
  <column select="NAME">Name</column>
  <column select="SYMBOL">Symbol</column>
  <column select="ATOMIC_WEIGHT" type="number">Weight</column>
  <column select="ATOMIC_NUMBER" type="number">Number</column>
  <column select="OXIDATION_STATES">Oxidation States</column>
</table>

You can see examples of these in xml/swing. In addtion the use of XPath
variables can be used to refer to other column values in a row, such as
notice the use of $Name in the following table which displays the servlets
available in a web.xml document...

<table select="/web-app/servlet">
  <column select="servlet-name">Name</column>
  <column select="servlet-class">Class</column>
  <column
select="../servlet-mapping[servlet-name=$Name]/url-pattern">Mapping</column>
</table>

There is a sample program to display a JTable for a given table definition
XML config file and a source XML documet at samples/swing/JTableTool.java

The above is all available in CVS and the daily build. I hope any Swing
developers out there might find this useful.

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to