public static void addPreferenceItem(String text, JComponent field, Container container) {
		LayoutManager layout = container.getLayout();
		
		JLabel label = new JLabel(text);
		field.setMaximumSize(field.getPreferredSize());
		
		if (layout instanceof GridBagLayout) {
			GridBagLayout gridbag = (GridBagLayout) layout;
			
			c.weighty = 0;
			
			c.weightx = 0;
			c.fill = GridBagConstraints.NONE;
			c.anchor = GridBagConstraints.EAST;
			c.gridwidth = 1; //reset to the default
			gridbag.setConstraints(label, c);
			container.add(label);
			
			c.weightx = 1;
			c.fill = GridBagConstraints.BOTH;
			c.anchor = GridBagConstraints.WEST;
			c.gridwidth = GridBagConstraints.REMAINDER; //end row
			gridbag.setConstraints(field, c);
			container.add(field);
		} else {
			Box box = Box.createHorizontalBox();
			box.add(Box.createHorizontalGlue());
			box.add(label);
			box.add(Box.createRigidArea(prefDim));
			box.add(field);
			container.add(box);
		}
	}