Last Updated: February 25, 2016
·
2.909K
· lindsaybradford

Setting horizontal alignment of editable JComboBox text

When you're initialising your combo box, reach down into its editor component, cast the component into a JTextField, and 'go to town' with the rich UI settings now available:

JTextField editor = 
    (JTextField) getEditor().getEditorComponent(); 
editor.setHorizontalAlignment(JTextField.CENTER);