1 26 27 package org.objectweb.util.browser.plugin.java.map; 28 import java.awt.Color ; 29 import java.util.Map ; 30 31 import javax.swing.BoxLayout ; 32 import javax.swing.JPanel ; 33 import javax.swing.JScrollPane ; 34 import javax.swing.JTable ; 35 36 import org.objectweb.util.browser.api.Panel; 37 import org.objectweb.util.browser.api.TreeView; 38 39 48 public class MapPanel 49 implements Panel { 50 51 57 58 protected JPanel panel_; 59 60 66 70 public MapPanel(){ 71 panel_ = new JPanel (); 72 panel_.setBackground(Color.white); 73 panel_.setLayout(new BoxLayout (panel_, BoxLayout.Y_AXIS)); 74 } 75 76 82 88 93 public void selected(TreeView treeView) { 94 String [] titre = {"Keys","Values"}; 95 Map map = (Map )treeView.getSelectedObject(); 96 String [][] contenu = new String [map.size()][2]; 97 Object [] keys = map.keySet().toArray(); 98 Object [] elements = map.entrySet().toArray(); 99 for (int i = 0; i < keys.length; i++) { 100 contenu[i] = new String []{keys[i].toString(), elements[i].toString()}; 101 } 102 panel_.add(new JScrollPane (new JTable (contenu,titre))); 103 } 104 105 110 public JPanel getPanel() { 111 return panel_; 112 } 113 114 119 public void unselected(TreeView treeView) { 120 } 122 123 } | Popular Tags |