Changeset 14822 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-03-02T22:39:06+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r14746 r14822 13 13 import java.awt.event.ActionEvent; 14 14 import java.awt.event.KeyEvent; 15 import java.awt.event.MouseAdapter;16 import java.awt.event.MouseEvent;17 15 import java.io.BufferedReader; 18 16 import java.io.File; … … 69 67 } 70 68 71 @Override 72 public void actionPerformed(ActionEvent e) { 69 protected JPanel buildAboutPanel() { 73 70 final JTabbedPane about = new JTabbedPane(); 74 71 … … 133 130 } 134 131 135 136 132 about.addTab(tr("Info"), info); 137 133 about.addTab(tr("Readme"), createScrollPane(readme)); … … 154 150 JLabel.CENTER), GBC.std().insets(0, 5, 0, 0)); 155 151 panel.add(about, GBC.std().fill()); 152 return panel; 153 } 154 155 @Override 156 public void actionPerformed(ActionEvent e) { 157 JPanel panel = buildAboutPanel(); 156 158 157 159 GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize()); … … 172 174 173 175 OpenDirAction(String dir) { 174 super();175 176 putValue(Action.NAME, "..."); 176 177 this.dir = dir; … … 215 216 216 217 private static JLabel createImageLink(String tooltip, String icon, final String link) { 217 JLabel label = new JLabel(ImageProvider.get("dialogs/about", icon, ImageSizes.LARGEICON)); 218 label.setToolTipText(tooltip); 219 label.addMouseListener(new MouseAdapter() { 220 @Override 221 public void mouseClicked(MouseEvent e) { 222 OpenBrowser.displayUrl(link); 223 } 224 }); 225 return label; 218 return new UrlLabel(link, tooltip, ImageProvider.get("dialogs/about", icon, ImageSizes.LARGEICON)); 226 219 } 227 220 -
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.