DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); //DefaultListCellRenderer.LEFT; //DefaultListCellRenderer.CENTER; //DefaultListCellRenderer.RIGHT; dlcr.setHorizontalAlignment(DefaultListCellRenderer.RIGHT); jComboBox1.setRenderer(dlcr);
Import this,
import javax.swing.DefaultListCellRenderer;and your done.
I was looking for something like this. thks
ReplyDeleteThank you for this simple and short code. It works perfectly and is much shorter and easier to use than a new render for the JComboBox.
ReplyDeleteThat's what I needed. And very simple. Thank you!
ReplyDeleteI was looking for this...thanks a lot
ReplyDeleteSimple and easy. tnx
ReplyDelete