1 28 29 package org.objectweb.util.explorer.plugin.java.map.swing; 30 31 import java.awt.Color ; 32 import java.util.Map ; 33 34 import javax.swing.BoxLayout ; 35 import javax.swing.JPanel ; 36 import javax.swing.JScrollPane ; 37 import javax.swing.JTable ; 38 39 import org.objectweb.util.explorer.api.Panel; 40 import org.objectweb.util.explorer.api.TreeView; 41 42 51 public class MapPanel 52 implements Panel { 53 54 60 63 protected JPanel panel_; 64 65 71 75 public MapPanel(){ 76 panel_ = new JPanel (); 77 panel_.setBackground(Color.white); 78 panel_.setLayout(new BoxLayout (panel_, BoxLayout.Y_AXIS)); 79 } 80 81 87 93 98 public void selected(TreeView treeView) { 99 String [] titre = {"Keys","Values"}; 100 Map map = (Map )treeView.getSelectedObject(); 101 String [][] contenu = new String [map.size()][2]; 102 Object [] keys = map.keySet().toArray(); 103 Object [] elements = map.entrySet().toArray(); 104 for (int i = 0; i < keys.length; i++) { 105 contenu[i] = new String []{keys[i].toString(), elements[i].toString()}; 106 } 107 panel_.add(new JScrollPane (new JTable (contenu,titre))); 108 } 109 110 115 public Object getPanel() { 116 return panel_; 117 } 118 119 124 public void unselected(TreeView treeView) { 125 } 127 128 } | Popular Tags |