@Override
	public void layoutContainer(Container container) {
		Component[] components = container.getComponents();
		if (components.length == 0) {
			return;
		}
		Insets insets = container.getInsets();
		if (components.length == 1) {
			Dimension size = components[0].getPreferredSize();
			components[0].setBounds(insets.left, insets.top, size.width, size.height);
			return;
		}

		Dimension containerSize = container.getSize();
		int width = containerSize.width - insets.left - insets.right;
		int height = containerSize.height - insets.top - insets.bottom;

		Dimension comp1PrefSize = components[0].getPreferredSize();
		Dimension comp2PrefSize = components[1].getPreferredSize();

		// always give comp1 its preferredWidth;

		int comp1Width = comp1PrefSize.width;
		int remainingWidth = Math.max(0, width - comp1Width - hGap);
		int comp2Width = Math.min(comp2PrefSize.width, remainingWidth);
		remainingWidth = Math.max(0, remainingWidth - comp2Width);

		int y = insets.top;

		int comp1X = insets.left;
		int comp2X = comp1X + comp1Width + hGap;
		if (rightAlign) {
			comp1X += remainingWidth;
			comp2X += remainingWidth;
		}

		components[0].setBounds(comp1X, y, comp1Width, height);
		components[1].setBounds(comp2X, y, comp2Width, height);

	}
Layout for two components laid out horizontally where the first component gets its preferred width
and the second component gets the remaining space up to its preferred width.
Ghidra/Framework/Gui/src/main/java/ghidra/util/layout/RightSidedSquishyBuddyLayout.java