Adjustments to the chat contact panel to fit better in the window.

cusax-fix
Yana Stamcheva 18 years ago
parent 6743228443
commit b3f5212a06

@ -27,6 +27,10 @@ public class ChatContact
{
private Logger logger = Logger.getLogger(ChatContact.class);
private static final int AVATAR_ICON_HEIGHT = 45;
private static final int AVATAR_ICON_WIDTH = 40;
private String name;
private String address;
@ -209,9 +213,15 @@ else if(contact != null)
if(contactImage != null)
{
Image image = ImageLoader.getBytesInImage(contactImage);
return new ImageIcon(image.getScaledInstance(
40, 45, Image.SCALE_SMOOTH));
if( image.getHeight(null) > AVATAR_ICON_HEIGHT
|| image.getWidth(null) > AVATAR_ICON_WIDTH)
return new ImageIcon(image.getScaledInstance(
AVATAR_ICON_WIDTH,
AVATAR_ICON_HEIGHT,
Image.SCALE_SMOOTH));
else
return new ImageIcon(image);
}
else
return null;

@ -33,7 +33,7 @@ public class ChatContactListPanel
KeyListener
{
private JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
private JScrollPane contactsScrollPane = new JScrollPane();
private JPanel mainPanel = new JPanel(new BorderLayout());
@ -43,13 +43,12 @@ public class ChatContactListPanel
ImageLoader.getImage(ImageLoader.ADD_TO_CHAT_ROLLOVER_BUTTON),
ImageLoader.getImage(ImageLoader.ADD_TO_CHAT_ICON), null);
private JPanel contactsPanel = new JPanel();
private LinkedHashMap chatContacts = new LinkedHashMap();
private ChatPanel chatPanel;
/**
* Creates an instance of <tt>ChatContactListPanel</tt>.
*/
@ -58,40 +57,44 @@ public ChatContactListPanel(ChatPanel chat)
super(new BorderLayout(5, 5));
this.chatPanel = chat;
this.contactsPanel.setLayout(
new BoxLayout(contactsPanel, BoxLayout.Y_AXIS));
this.setMinimumSize(new Dimension(150, 100));
//this.setMinimumSize(new Dimension(150, 100));
this.contactsPanel.setLayout(new BoxLayout(this.contactsPanel,
BoxLayout.Y_AXIS));
this.contactsScrollPane.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.mainPanel.add(contactsPanel, BorderLayout.NORTH);
this.contactsScrollPane.getViewport().add(this.mainPanel);
this.add(contactsScrollPane, BorderLayout.CENTER);
if(chatPanel instanceof ConferenceChatPanel)
{
this.buttonPanel.add(addToChatButton);
this.add(buttonPanel, BorderLayout.SOUTH);
addToChatButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ChatInviteDialog inviteDialog
= new ChatInviteDialog(chatPanel);
inviteDialog.setVisible(true);
}
});
}
this.addKeyListener(this);
}
/**
* Adds a <tt>ChatContact</tt> to the list of contacts contained in the
* chat.

@ -56,6 +56,8 @@ public class ChatContactPanel
.getImage(ImageLoader.CHAT_CONTACT_SEND_FILE_BUTTON), ImageLoader
.getImage(ImageLoader.CHAT_SEND_FILE_ROLLOVER_BUTTON));
private JPanel personPhotoPanel = new JPanel(new BorderLayout());
private JLabel personPhotoLabel = new JLabel();
private JLabel personNameLabel = new JLabel();
@ -89,11 +91,13 @@ public ChatContactPanel(ChatPanel chatPanel, ChatContact contact)
// menu.
this.addMouseListener(this);
this.setPreferredSize(new Dimension(100, 55));
this.mainPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
this.setOpaque(false);
this.mainPanel.setOpaque(false);
this.buttonsPanel.setOpaque(false);
this.personPhotoPanel.setOpaque(false);
this.personNameLabel.setText(chatContact.getName());
this.personNameLabel.setFont(this.getFont().deriveFont(Font.BOLD));
@ -115,13 +119,17 @@ public ChatContactPanel(ChatPanel chatPanel, ChatContact contact)
this.buttonsPanel.add(infoButton);
this.buttonsPanel.add(callButton);
this.buttonsPanel.add(sendFileButton);
this.buttonsPanel.setVisible(false);
this.mainPanel.add(buttonsPanel, BorderLayout.NORTH);
this.mainPanel.add(personNameLabel, BorderLayout.CENTER);
this.add(personPhotoLabel, BorderLayout.WEST);
this.personPhotoPanel.setBorder(
BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.personPhotoPanel.add(personPhotoLabel, BorderLayout.NORTH);
this.add(personPhotoPanel, BorderLayout.WEST);
this.add(mainPanel, BorderLayout.CENTER);
// Disabled all unused buttons.
@ -301,7 +309,7 @@ public void renameContact(String newName)
public void setContactPhoto(ImageIcon contactPhoto)
{
this.contactPhotoIcon = contactPhoto;
this.personPhotoLabel.setIcon(contactPhotoIcon);
}

Loading…
Cancel
Save