BuddySupport { public static boolean isBuddy(Component c, JTextField textField) { return buddies(Position.LEFT, textField).contains(c) || buddies(Position.RIGHT, textField).contains(c); }  static void addLeft(Component c, JTextField textField); static void addRight(Component c, JTextField textField); static void add(Component c, Position pos, JTextField textField); static void addGap(int width, Position pos, JTextField textField); static void setRight(JTextField textField, List<Component> rightBuddies); static void setLeft(JTextField textField, List<Component> leftBuddies); static void set(List<Component> buddies, Position pos, JTextField textField); static List<Component> getLeft(JTextField textField); static List<Component> getRight(JTextField textField); static List<Component> getBuddies(Position pos, JTextField textField); static boolean isBuddy(Component c, JTextField textField); static void remove(JComponent c, JTextField textField); static void removeAll(JTextField textField); static void setOuterMargin(JTextField buddyField, Insets margin); static Insets getOuterMargin(JTextField buddyField); static void ensureBuddiesAreInComponentHierarchy(JTextField textField); static Component createGap(int width); static final String OUTER_MARGIN; }
@Test public void testIsBuddy() throws Exception { JButton button = new JButton(); assertFalse(BuddySupport.isBuddy(button, tf)); tf.add(button); assertFalse(BuddySupport.isBuddy(button, tf)); BuddySupport.addLeft(button, tf); assertTrue(BuddySupport.isBuddy(button, tf)); tf.remove(button); }