1 26 27 package org.objectweb.util.browser.plugin.java; 28 29 import java.awt.Color ; 30 import java.util.Collection ; 31 import java.util.Iterator ; 32 33 import javax.swing.BoxLayout ; 34 import javax.swing.JPanel ; 35 import javax.swing.JScrollPane ; 36 import javax.swing.JTable ; 37 38 import org.objectweb.util.browser.api.Panel; 39 import org.objectweb.util.browser.api.TreeView; 40 41 50 public class CollectionPanel 51 implements Panel { 52 53 59 60 protected JPanel panel_; 61 62 68 72 public CollectionPanel(){ 73 panel_ = new JPanel (); 74 panel_.setBackground(Color.white); 75 panel_.setLayout(new BoxLayout (panel_, BoxLayout.Y_AXIS)); 76 } 77 78 84 90 95 public void selected(TreeView treeView) { 96 String [] titre = {"Class name","Instance"}; 97 Collection collection = (Collection )treeView.getSelectedObject(); 98 String [][] contenu = new String [collection.size()][2]; 99 Iterator iterator = collection.iterator(); 100 int cpt = 0; 101 while (iterator.hasNext()) { 102 Object element = iterator.next(); 103 contenu[cpt] = new String []{element.getClass().getName(), element.toString()}; 104 cpt++; 105 } 106 panel_.add(new JScrollPane (new JTable (contenu,titre))); 107 } 108 109 114 public JPanel getPanel() { 115 return panel_; 116 } 117 118 123 public void unselected(TreeView treeView) { 124 } 126 127 } | Popular Tags |