public static JComponent createSelectSimpleComponent(
final Object model,
final AttributeSet attrs) {
JComboBox selectElement = new JComboBox();
FormSelectComboBoxModel comboBoxModel = (FormSelectComboBoxModel)model;
// Model
if (comboBoxModel == null) {
comboBoxModel = new FormSelectComboBoxModel(new Form(SimpleAttributeSet.EMPTY),
SimpleAttributeSet.EMPTY);
}
selectElement.setModel(comboBoxModel);
selectElement.setAlignmentY(JComponent.BOTTOM_ALIGNMENT);
// TITLE
if (!Utilities.isEmptyString(comboBoxModel.getTitle())) {
selectElement.setToolTipText(comboBoxModel.getTitle());
}
// DIR
setTextDir(selectElement, attrs);
// Selection
FormViewUtils.resetSimpleSelection(selectElement.getModel());
// Size
final Dimension size = selectElement.getPreferredSize();
selectElement.setMinimumSize(size);
selectElement.setMaximumSize(size);
// DISABLED
if (!comboBoxModel.isEnabled()) {
selectElement.setEnabled(false);
}
return selectElement;
}