private void populatePortTable(List ports) { logger.debug("Filling port table"); // get an array of ports final PortInfoController[] portcontrollers = (PortInfoController[]) ports.toArray(new PortInfoController[ports.size()]); // setup the panel boxControllers.removeAll(); // add the ports to the data array for (int index = 0; index < portcontrollers.length; index++) { final int indexFinal = index; SwingUtilities.invokeLater( new Runnable() { public void run() { boxControllers.add(portcontrollers[indexFinal].getView()); } }); } SwingUtilities.invokeLater( new Runnable() { public void run() { boxControllers.add(Box.createVerticalGlue()); } }); }
public void setEntity(java.lang.Object ent) { Method[] methods = ent.getClass().getDeclaredMethods(); box.removeAll(); for (Method m : methods) { if (m.getName().toLowerCase().startsWith("get")) { String attName = m.getName().substring(3); Object result; try { result = m.invoke(ent, new Object[] {}); String value = "null"; if (result != null) value = result.toString(); JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value)); box.add(attPane); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } }