2
0

Improve rendering of user name.

This commit is contained in:
Maarten Billemont 2018-04-25 22:49:58 -04:00
parent 94ac8b1460
commit dc19806e02

View File

@ -40,10 +40,11 @@ import javax.swing.plaf.metal.MetalComboBoxEditor;
/** /**
* @author lhunath, 2014-06-11 * @author lhunath, 2014-06-11
*/ */
public class ModelAuthenticationPanel extends AuthenticationPanel implements ItemListener, ActionListener, DocumentListener { public class ModelAuthenticationPanel extends AuthenticationPanel<MPFileUser> implements ItemListener, ActionListener, DocumentListener {
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
private static final Logger logger = Logger.get( ModelAuthenticationPanel.class ); private static final Logger logger = Logger.get( ModelAuthenticationPanel.class );
private static final long serialVersionUID = 1L;
private final JComboBox<MPFileUser> userField; private final JComboBox<MPFileUser> userField;
private final JLabel masterPasswordLabel; private final JLabel masterPasswordLabel;
@ -73,6 +74,17 @@ public class ModelAuthenticationPanel extends AuthenticationPanel implements Ite
userField.setFont( Res.valueFont().deriveFont( 12f ) ); userField.setFont( Res.valueFont().deriveFont( 12f ) );
userField.addItemListener( this ); userField.addItemListener( this );
userField.addActionListener( this ); userField.addActionListener( this );
userField.setRenderer( new DefaultListCellRenderer() {
private static final long serialVersionUID = 1L;
@Override
@SuppressWarnings("unchecked")
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index,
final boolean isSelected, final boolean cellHasFocus) {
String userValue = ((MPUser<MPFileSite>) value).getFullName();
return super.getListCellRendererComponent( list, userValue, index, isSelected, cellHasFocus );
}
} );
userField.setEditor( new MetalComboBoxEditor() { userField.setEditor( new MetalComboBoxEditor() {
@Override @Override
protected JTextField createEditorComponent() { protected JTextField createEditorComponent() {