Changeset 14822 in josm for trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java
- Timestamp:
- 2019-03-02T22:39:06+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java
r13853 r14822 8 8 import java.awt.event.MouseListener; 9 9 10 import javax.swing.Icon; 10 11 import javax.swing.JLabel; 11 12 import javax.swing.SwingUtilities; … … 28 29 */ 29 30 public UrlLabel() { 30 addMouseListener(this); 31 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 31 init("", "", 0); 32 32 } 33 33 … … 62 62 * @param url The URL to use 63 63 * @param description The description to display 64 * @param image The image to be displayed by the label instead of text 65 * @since 14822 66 */ 67 public UrlLabel(String url, String description, Icon image) { 68 super(image); 69 init(url, description, 0); 70 } 71 72 /** 73 * Constructs a new {@code UrlLabel} for the given URL, description and font increase. 74 * @param url The URL to use 75 * @param description The description to display 64 76 * @param fontPlus The font increase in 1/72 of an inch units. 65 77 */ 66 78 public UrlLabel(String url, String description, int fontPlus) { 67 this(); 79 init(url, description, fontPlus); 80 } 81 82 private void init(String url, String description, int fontPlus) { 83 addMouseListener(this); 68 84 setUrl(url); 69 85 setDescription(description); … … 76 92 protected final void refresh() { 77 93 if (url != null && !url.isEmpty()) { 78 setText("<html><a href=\""+url+"\">"+description+"</a></html>");79 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));80 setToolTipText(String.format("<html>%s<br/>%s</html>", url, tr("Right click = copy to clipboard")));94 refresh("<html><a href=\""+url+"\">"+description+"</a></html>", 95 Cursor.getPredefinedCursor(Cursor.HAND_CURSOR), 96 String.format("<html>%s<br/>%s</html>", url, tr("Right click = copy to clipboard"))); 81 97 } else { 82 setText("<html>" + description + "</html>"); 83 setCursor(null); 84 setToolTipText(null); 98 refresh("<html>" + description + "</html>", null, null); 85 99 } 100 } 101 102 private void refresh(String text, Cursor cursor, String tooltip) { 103 boolean hasImage = getIcon() != null; 104 if (!hasImage) { 105 setText(text); 106 } 107 setCursor(cursor); 108 setToolTipText(tooltip); 86 109 } 87 110
Note:
See TracChangeset
for help on using the changeset viewer.
