Ejemplo n.º 1
0
 private GridLayoutData getLayoutData(Component component) {
   LayoutData layoutData = component.getLayoutData();
   if (layoutData == null || !(layoutData instanceof GridLayoutData)) {
     return DEFAULT;
   } else {
     return (GridLayoutData) layoutData;
   }
 }
Ejemplo n.º 2
0
 private EnumMap<Location, Component> makeLookupMap(List<Component> components) {
   EnumMap<Location, Component> map =
       new EnumMap<BorderLayout.Location, Component>(Location.class);
   List<Component> unassignedComponents = new ArrayList<Component>();
   for (Component component : components) {
     if (component.getLayoutData() instanceof Location) {
       map.put((Location) component.getLayoutData(), component);
     } else {
       unassignedComponents.add(component);
     }
   }
   // Try to assign components to available locations
   for (Component component : unassignedComponents) {
     for (Location location : AUTO_ASSIGN_ORDER) {
       if (!map.containsKey(location)) {
         map.put(location, component);
         break;
       }
     }
   }
   return map;
 }