From 3126bca29629eb95681c13f7ae2a4f232babd5d3 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Thu, 9 Jun 2011 11:34:01 +0000 Subject: [PATCH] Fixes 1.5 compatibility. --- .../impl/gui/utils/ExtendedTooltip.java | 32 ++++++++++--------- .../contactinfo/ContactInfoDetailsPanel.java | 5 +-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java b/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java index fc36b48c9..4889ad888 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ExtendedTooltip.java @@ -28,7 +28,7 @@ public class ExtendedTooltip private final JPanel linesPanel = new JPanel(); - private final JTextArea bottomText = new JTextArea(); + private final JTextArea bottomTextArea = new JTextArea(); private int textWidth = 0; @@ -54,7 +54,7 @@ public ExtendedTooltip(boolean isListViewEnabled) mainPanel.setOpaque(false); centerPanel.setOpaque(false); linesPanel.setOpaque(false); - bottomText.setOpaque(false); + bottomTextArea.setOpaque(false); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); @@ -76,11 +76,11 @@ public ExtendedTooltip(boolean isListViewEnabled) mainPanel.add(titleLabel, BorderLayout.NORTH); } - bottomText.setEditable(false); - bottomText.setLineWrap(true); - bottomText.setWrapStyleWord(true); - bottomText.setFont(bottomText.getFont().deriveFont(10f)); - mainPanel.add(bottomText, BorderLayout.SOUTH); + bottomTextArea.setEditable(false); + bottomTextArea.setLineWrap(true); + bottomTextArea.setWrapStyleWord(true); + bottomTextArea.setFont(bottomTextArea.getFont().deriveFont(10f)); + mainPanel.add(bottomTextArea, BorderLayout.SOUTH); this.add(mainPanel); } @@ -170,7 +170,7 @@ public void addLine(JLabel[] labels) */ public void setBottomText(String text) { - this.bottomText.setText(text); + this.bottomTextArea.setText(text); } /** @@ -237,10 +237,11 @@ public void paint(Graphics g, JComponent c) @Override public void update(Graphics g, JComponent c) { - if(bottomText.getText().isEmpty()) - bottomText.setVisible(false); + String bottomText = bottomTextArea.getText(); + if(bottomText == null || bottomText.length() <= 0) + bottomTextArea.setVisible(false); else - bottomText.setVisible(true); + bottomTextArea.setVisible(true); super.update(g, c); } @@ -274,12 +275,13 @@ public Dimension getPreferredSize(JComponent c) else height = imageHeight + textHeight; - if(!bottomText.getText().isEmpty()) + String bottomText = bottomTextArea.getText(); + if(bottomText != null && bottomText.length() > 0) { // Seems a little messy, but sets the proper size. - bottomText.setSize(width,1); - height += bottomText.getPreferredSize().height; - bottomText.setSize(bottomText.getPreferredSize()); + bottomTextArea.setSize(width,1); + height += bottomTextArea.getPreferredSize().height; + bottomTextArea.setSize(bottomTextArea.getPreferredSize()); } return new Dimension(width, height); diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java index ed8be44a3..70dcaaaa4 100644 --- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java +++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java @@ -488,7 +488,8 @@ else if (detail instanceof TimeZoneDetail) } // Add users status message to extended details if it exists - if(!contact.getStatusMessage().isEmpty()) + String statusMessage = contact.getStatusMessage(); + if(statusMessage != null && statusMessage.length() > 0) { detailLabel = new JLabel(); HTMLTextPane detailValuePane = new HTMLTextPane(); @@ -506,7 +507,7 @@ else if (detail instanceof TimeZoneDetail) detailLabel.setText(Resources.getString( "plugin.contactinfo.USER_STATUS_MESSAGE") + ": "); - detailValuePane.setText(contact.getStatusMessage()); + detailValuePane.setText(statusMessage); } // If the contact's protocol supports web info, give them a button to