Delete unnecessary setters and make ContactList class members representing UI components final.
@@ -59,16 +59,18 @@ import org.jxmpp.util.XmppStringUtils;
public class ContactItem extends JPanel {
private static final long serialVersionUID = 1514044406550293152L;
- private JLabel imageLabel;
- private JLabel displayNameLabel;
- private JLabel descriptionLabel;
+ private final JLabel imageLabel;
+ private final JLabel displayNameLabel;
+ private final JLabel descriptionLabel;
+ private final JLabel specialImageLabel;
+ private final JLabel sideIcon;
+
private String nickname;
private String alias;
private final BareJid jid;
- private JLabel specialImageLabel;
private Icon icon;
private String status;
@@ -82,8 +84,6 @@ public class ContactItem extends JPanel {
private File contactsDir;
- private JLabel sideIcon;
-
int fontSize;
private int iconSize;
@@ -135,13 +135,11 @@ public class ContactItem extends JPanel {
displayNameLabel.setHorizontalAlignment(JLabel.LEFT);
//displayNameLabel.setText(nickname);
-
descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
descriptionLabel.setForeground((Color) UIManager.get("ContactItemDescription.foreground"));
descriptionLabel.setHorizontalTextPosition(JLabel.LEFT);
descriptionLabel.setHorizontalAlignment(JLabel.LEFT);
-
this.setOpaque(true);
add(imageLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 15, 0, 0), 0, 0));
@@ -152,6 +150,13 @@ public class ContactItem extends JPanel {
setDisplayName();
}
+ else {
+ imageLabel = null;
+ displayNameLabel = null;
+ descriptionLabel = null;
+ specialImageLabel = null;
+ sideIcon = null;
+ }
}
/**
@@ -620,22 +625,10 @@ public class ContactItem extends JPanel {
return displayNameLabel;
}
- protected void setDisplayNameLabel(JLabel displayNameLabel) {
- this.displayNameLabel = displayNameLabel;
- }
-
- protected void setDescriptionLabel(JLabel descriptionLabel) {
- this.descriptionLabel = descriptionLabel;
- }
-
public JLabel getSpecialImageLabel() {
return specialImageLabel;
}
- protected void setSpecialImageLabel(JLabel specialImageLabel) {
- this.specialImageLabel = specialImageLabel;
- }
-
public JLabel getSideIcon() {
return sideIcon;
}
