Wednesday, 15 July 2015

java - jtable in jtree with different row count -


I'm trying to create a JTree that consists of JTables. So far, I have been successful in making a jetty with jetties. But, I can not change the row number of a table of a specific tree node. Whenever I used the line tries to adjust the calculation would, all tree nodes of line changes calculations

I address the following link:

I wrote the following code on the recommendation of Trashgod, but it did not work; Can you please give some working code ..

  Package HelperPack; Import java.awt.borderLayout; Import java.util.ArrayList; Import javax.swing.JFrame; Import javax.swing.JScrollPane; Import javax.swing.JTable; Import javax.swing.JTree; Import javax.swing.SwingUtilities; Import javax.swing.table.DefaultTableModel; Import javax.swing.tree.DefaultMutableTreeNode; Public class JTreeTrial spreads JFrame {/ ** * @param arg * / public static void {SwingUtilities.invokeLater (New Runnable) {Public Zero Run} {DefaultMutableTreeNode parentNode = New DefaultMutableTreeNode ("node") ; JTree tree = new JTree (parentNode); JTable table = new JTable (); table.setModel (new DefaultTableModel () {private static final long serialVersionUID = 1L; @Override public int getRowCount () {return 2;} @Override public integer getColumnCount () {return 2;} @Override public object getValueAt (int row, int column) {return "" + "row" + ":" + column;}}); DefaultMutableTreeNode node = (DefaultMuta bleTreeNode) tree.. getModel () getRoot (); node.setUserObject (table); JTreeTrial test = new JTreeTrial (); trial.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); jScrollPane jsp = new JScrollPane (tree); trial.add (jsp , BorderLayout.CENTER); Prikshnkpak (); test Ksetvijibl (true); test Ksetlainsriletto (void);}}); }}   

Example:

| Node1 |

  | A | B | C. D.   

| Node 2

  | E F |   

| Node 3

  | G. H | | I J | | Kashmir | Meter | Instead of rendering the trees  in  tables,    

Add a tree selection listener and update an JTable in one of the adjacent components. Each TreeNode Enter Tablemodel in, and JTable to setModel (to update) uses. Several related examples have been cited.

No comments:

Post a Comment