public LinkLabel(String text, ActionListener linkListener) { super(text); this.linkListener = linkListener; linkColor = Color.BLACK; hoverColor = Color.BLUE; setForeground(linkColor); addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { setHoverMode(true); } public void mouseExited(MouseEvent e) { setHoverMode(false); } public void mouseReleased(MouseEvent e) { activateLink(); } }); setFont(Fonts.getMediumDialogFont().deriveFont(Font.BOLD, 14f)); }
private void setHoverMode(boolean b) { if (b && isEnabled()) { setForeground(hoverColor); oldCursor = getCursor(); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { setForeground(linkColor); if (oldCursor != null) { setCursor(oldCursor); } } }
private void activateLink() { Point mousePosition = getMousePosition(); if (isEnabled() && mousePosition != null && contains(mousePosition)) { linkListener.actionPerformed(new ActionEvent(this, 0, getText())); } } }
public LinkLabel(String text, ActionListener linkListener) { super(text); this.linkListener = linkListener; linkColor = PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty(ProtegeProperties.PROPERTY_COLOR_KEY), Color.GRAY); hoverColor = PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty(ProtegeProperties.CLASS_COLOR_KEY), Color.GRAY); setForeground(linkColor); addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { setHoverMode(true); } public void mouseExited(MouseEvent e) { setHoverMode(false); } public void mouseReleased(MouseEvent e) { activateLink(); } }); setFont(getFont().deriveFont(Font.BOLD, 12.0f)); }
public static void main(String[] args) { Box box = new Box(BoxLayout.Y_AXIS); box.add(new LinkLabel("Test link!", new ActionListener() { public void actionPerformed(ActionEvent e) { } })); box.add(Box.createVerticalStrut(30)); box.add(new LinkLabel("Another link", new ActionListener() { public void actionPerformed(ActionEvent e) { } })); JFrame f = new JFrame(); JPanel panel = new JPanel(); panel.setBackground(Color.WHITE); panel.add(box); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(panel); f.pack(); f.setVisible(true); } }
private Component createLicensePanel() { Box box = new Box(BoxLayout.LINE_AXIS); final JLabel label = new JLabel("License: "); final Font font = label.getFont().deriveFont(Font.BOLD); label.setFont(font); label.setAlignmentX(0.0f); box.add(label); licenseLabel = new LinkLabel("", event -> { try { URL url = new URL(licenseLabel.getText()); NativeBrowserLauncher.openURL(url.toString()); } catch (MalformedURLException e) { // do nothing } }); licenseLabel.setFont(font); box.add(licenseLabel); box.add(Box.createHorizontalGlue()); return box; }
LinkLabel createLink = new LinkLabel("Create new " + plugin.getLabel(), new ActionListener() { public void actionPerformed(ActionEvent e) { try { createLink.setName("Create new " + plugin.getId()); box.add(createLink); LinkLabel openLink = new LinkLabel("Open " + plugin.getLabel(), new ActionListener() { public void actionPerformed(ActionEvent e) { try { openLink.setName("Open " + plugin.getId()); box.add(openLink); LinkLabel openFromURILink = new LinkLabel("Open " + plugin.getLabel() + " from URI", new ActionListener() { public void actionPerformed(ActionEvent e) { openFromURILink.setName("OpenfromURI " + plugin.getId()); box.add(openFromURILink); box.add(new LinkLabel(builder.getLabel(), new ActionListener() { public void actionPerformed(ActionEvent e) { if (ProtegeManager.getInstance().handleOpenFromBuilder(builder)) { box.add(new LinkLabel("Open from the " + repository.getName() + " repository", new ActionListener() { public void actionPerformed(ActionEvent e) { handleOpenFromRepository(repository);
public LinkLabel(String text, ActionListener linkListener) { super(text); this.linkListener = linkListener; linkColor = PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty(ProtegeProperties.PROPERTY_COLOR_KEY), Color.GRAY); hoverColor = PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty(ProtegeProperties.CLASS_COLOR_KEY), Color.GRAY); setForeground(linkColor); addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent e) { setHoverMode(true); } public void mouseExited(MouseEvent e) { setHoverMode(false); } public void mouseReleased(MouseEvent e) { activateLink(); } }); setFont(getFont().deriveFont(Font.BOLD, 12.0f)); }
public static void main(String[] args) { Box box = new Box(BoxLayout.Y_AXIS); box.add(new LinkLabel("Test link!", new ActionListener() { public void actionPerformed(ActionEvent e) { } })); box.add(Box.createVerticalStrut(30)); box.add(new LinkLabel("Another link", new ActionListener() { public void actionPerformed(ActionEvent e) { } })); JFrame f = new JFrame(); JPanel panel = new JPanel(); panel.setBackground(Color.WHITE); panel.add(box); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(panel); f.pack(); f.setVisible(true); } }
private void setHoverMode(boolean b) { if (b && isEnabled()) { setForeground(hoverColor); oldCursor = getCursor(); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { setForeground(linkColor); if (oldCursor != null) { setCursor(oldCursor); } } }
private void activateLink() { Point mousePosition = getMousePosition(); if (isEnabled() && mousePosition != null && contains(mousePosition)) { linkListener.actionPerformed(new ActionEvent(this, 0, getText())); } }
private Component createLicensePanel() { Box box = new Box(BoxLayout.LINE_AXIS); final JLabel label = new JLabel("License: "); final Font font = label.getFont().deriveFont(8); label.setFont(font); label.setAlignmentX(0.0f); box.add(label); licenseLabel = new LinkLabel("", new ActionListener(){ public void actionPerformed(ActionEvent event) { try { URL url = new URL(licenseLabel.getText()); NativeBrowserLauncher.openURL(url.toString()); } catch (MalformedURLException e) { // do nothing } } }); licenseLabel.setFont(font); box.add(licenseLabel); box.add(Box.createHorizontalGlue()); return box; }
private void setHoverMode(boolean b) { if (b && isEnabled()) { setForeground(hoverColor); oldCursor = getCursor(); setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { setForeground(linkColor); if (oldCursor != null) { setCursor(oldCursor); } } }
private Component createLicensePanel() { Box box = new Box(BoxLayout.LINE_AXIS); final JLabel label = new JLabel("License: "); final Font font = label.getFont().deriveFont(8); label.setFont(font); label.setAlignmentX(0.0f); box.add(label); licenseLabel = new LinkLabel("", new ActionListener(){ public void actionPerformed(ActionEvent event) { try { URL url = new URL(licenseLabel.getText()); NativeBrowserLauncher.openURL(url.toString()); } catch (MalformedURLException e) { // do nothing } } }); licenseLabel.setFont(font); box.add(licenseLabel); box.add(Box.createHorizontalGlue()); return box; }
add(ontologyIRIPanel, BorderLayout.NORTH); Insets insets = new Insets(0, 4, 2, 0); ontologyIRIPanel.add(new LinkLabel(ONTOLOGY_IRI_FIELD_LABEL, new ActionListener() { public void actionPerformed(ActionEvent e) { showOntologyIRIDocumentation(); ontologyIRIPanel.add(new LinkLabel(ONTOLOGY_VERSION_IRI_FIELD_LABEL, new ActionListener() { public void actionPerformed(ActionEvent e) { showVersionIRIDocumentation();
add(ontologyIRIPanel, BorderLayout.NORTH); Insets insets = new Insets(0, 4, 2, 0); ontologyIRIPanel.add(new LinkLabel(ONTOLOGY_IRI_FIELD_LABEL, e -> { showOntologyIRIDocumentation(); }), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.NONE, insets, 0, 0)); }); ontologyIRIPanel.add(new LinkLabel(ONTOLOGY_VERSION_IRI_FIELD_LABEL, e -> { showVersionIRIDocumentation(); }), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.NONE, insets, 0, 0));
add(ontologyIRIPanel, BorderLayout.NORTH); Insets insets = new Insets(0, 4, 2, 0); ontologyIRIPanel.add(new LinkLabel(ONTOLOGY_IRI_FIELD_LABEL, e -> { showOntologyIRIDocumentation(); }), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.NONE, insets, 0, 0)); }); ontologyIRIPanel.add(new LinkLabel(ONTOLOGY_VERSION_IRI_FIELD_LABEL, e -> { showVersionIRIDocumentation(); }), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.BASELINE_TRAILING, GridBagConstraints.NONE, insets, 0, 0));
recentLinkBox.add(new LinkLabel(desc.getLabel(), new ActionListener() { public void actionPerformed(ActionEvent e) { try {