List of usage examples for javax.swing JLabel setCursor
public void setCursor(Cursor cursor)
From source file:Main.java
/** * Create a HTML hyperlink in JLabel component * * @param label//from ww w.j a v a2 s .c o m * @param url * @param text */ public static void createHyperLink(JLabel label, final String url, String text) { label.setToolTipText(url); label.setText("<html><a href=\"\">" + text + "</a></html>"); label.setCursor(new Cursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { Desktop.getDesktop().browse(new URI(url)); } catch (IOException ex) { throw new RuntimeException(ex); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } } }); }
From source file:Main.java
/** * Configures a label as if it was an hyperlink. * //from w ww. j a va 2 s .c o m * @param label * the label to configure. */ public static void configureLabelAsHyperlink(JLabel label) { if (label == null) { return; } StringBuffer html = new StringBuffer(); html.append("<html><font color=\"blue\"><u>"); html.append(label.getText()); html.append("</u></font></html>"); label.setText(html.toString()); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); }
From source file:Main.java
private void ShowDialog() { JLabel label = new JLabel("Move mouse here for hand cursor"); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); JOptionPane pane = new JOptionPane(label); pane.setOptions(new Object[] { "OK" }); JDialog dialog = pane.createDialog(this, "Test Dialog"); dialog.setVisible(true);//from w ww . ja v a 2 s . c o m }
From source file:com.antelink.sourcesquare.gui.view.CopyrightPanel.java
private JLabel createJLabelWithHyperlink(String text, final String href) { JLabel label = new JLabel("<html><a href=\"\">" + text + "<a/></html>"); label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseListener() { @Override//from www. ja va 2 s . co m public void mouseReleased(MouseEvent arg0) { } @Override public void mousePressed(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseClicked(MouseEvent arg0) { try { Desktop.getDesktop().browse(new URI(href)); } catch (IOException e) { logger.error("Error opening the browser", e); } catch (URISyntaxException e) { logger.error("Error opening the browser", e); } } }); return label; }
From source file:com.willwinder.ugs.nbp.core.services.SettingsChangedNotificationService.java
private JComponent createRestartNotificationDetails() { JPanel panel = new JPanel(new BorderLayout(10, 10)); panel.setOpaque(false);/* w ww. j ava 2 s. c o m*/ JLabel label = new JLabel(Localization.getString("platform.window.restart.changed.settings")); //NOI18N label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); panel.add(label, BorderLayout.CENTER); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (null != restartNotification) { restartNotification.clear(); restartNotification = null; } LifecycleManager.getDefault().markForRestart(); LifecycleManager.getDefault().exit(); } }); return panel; }
From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java
private void createInterface() { setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = 2;// w w w .j ava 2s. c o m constraints.gridx = 0; constraints.gridy = -1; constraints.weightx = 1.0D; add(Box.createGlue()); JLabel usernameLabel = new JLabel("Pseudo : "); Font labelFont = usernameLabel.getFont().deriveFont(1); Font smalltextFont = usernameLabel.getFont().deriveFont(labelFont.getSize() - 2.0F); usernameLabel.setFont(labelFont); add(usernameLabel, constraints); add(this.usernameField, constraints); add(Box.createVerticalStrut(10), constraints); JLabel passwordLabel = new JLabel("Mot de passe :"); passwordLabel.setFont(labelFont); add(passwordLabel, constraints); add(this.passwordField, constraints); JLabel forgotPasswordLabel = new JLabel("(oubli ?)"); forgotPasswordLabel.setCursor(new Cursor(12)); forgotPasswordLabel.setFont(smalltextFont); forgotPasswordLabel.setHorizontalAlignment(4); forgotPasswordLabel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { try { Util.openLink(Variables.lost); } catch (Exception e1) { LogInForm.this.login.getLauncher().getLogger() .error("Impossible d'ouvrir le lien pour les logins oublis"); JOptionPane.showMessageDialog(LogInForm.this.login.getLauncher().getPanel(), "Impossible d'ouvrir la page\nRendez-vous sur le site de NaheulCraft pour rcuprer vos identifiants", "Impossible d'ouvrir l'URL", 0); } } }); add(forgotPasswordLabel, constraints); createUserDropdownPanel(labelFont); add(this.userDropdownPanel, constraints); add(Box.createVerticalStrut(10), constraints); }
From source file:com.ssn.ui.custom.component.SSNImageThumbnailControl.java
public SSNImageThumbnailControl getSsnImageThumbnailControl(String imagePath, int index) { //this.setLayout(); iF = 0;//from w w w. j a v a 2s . c om BufferedImage thumbImg1 = null; this.index = index; BufferedImage image; String[] videoSupported = SSNConstants.SSN_VIDEO_FORMAT_SUPPORTED; final List<String> videoSupportedList = Arrays.asList(videoSupported); try { // add code to check file is video or image if video then write code to create thumbnail String fileExtention = imagePath.substring(imagePath.lastIndexOf(".") + 1, imagePath.length()); if (videoSupportedList.contains(fileExtention.toUpperCase())) { IMediaReader reader = null; try { if (true) { reader = ToolFactory.makeReader(imagePath); reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR); reader.addListener(new MediaListenerAdapter() { @Override public void onVideoPicture(IVideoPictureEvent event) { setVideoFrame(event.getImage()); iF++; } }); while (reader.readPacket() == null && iF == 0) ; thumbImg1 = SSNHelper.resizeImage(getVideoFrame(), 50, 50); } } catch (Throwable e) { e.printStackTrace(); } finally { if (reader != null) reader.close(); } } else { image = ImageIO.read(new File(imagePath)); thumbImg1 = SSNHelper.resizeImage(image, 50, 50); } } catch (IOException ex) { Logger.getLogger(SSNImageThumbnailControl.class.getName()).log(Level.SEVERE, null, ex); } ImageIcon imageIcon = new ImageIcon(thumbImg1); JLabel thumbnailLabel = new JLabel(imageIcon, SwingConstants.HORIZONTAL); JLabel closeLabel = new JLabel(new ImageIcon(getClass().getResource("/icon/remove-icon.png")), SwingConstants.HORIZONTAL); closeLabel.setFocusable(true); closeLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.add(thumbnailLabel); this.add(closeLabel); closeLabel.addMouseListener(this); this.setFocusable(true); this.setSize(new Dimension(50, 50)); this.setBackground(new Color(0, 0, 0, 1)); return this; }
From source file:org.apache.taverna.activities.xpath.ui.contextualview.XPathActivityMainContextualView.java
@Override public JComponent getMainFrame() { jpMainPanel = new JPanel(new GridBagLayout()); jpMainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2), BorderFactory.createEmptyBorder())); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.weighty = 0;/* w w w .j a v a 2 s . c om*/ // --- XPath Expression --- c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 5, 5, 5); JLabel jlXPathExpression = new JLabel("XPath Expression:"); jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD)); jpMainPanel.add(jlXPathExpression, c); c.gridx++; c.weightx = 1.0; tfXPathExpression = new JTextField(); tfXPathExpression.setEditable(false); jpMainPanel.add(tfXPathExpression, c); // --- Label to Show/Hide Mapping Table --- final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings..."); jlShowHideNamespaceMappings.setForeground(Color.BLUE); jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR)); jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible()); jlShowHideNamespaceMappings.setText( (spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings..."); thisContextualView.revalidate(); } }); c.gridx = 0; c.gridy++; c.gridwidth = 2; c.weightx = 1.0; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; jpMainPanel.add(jlShowHideNamespaceMappings, c); // --- Namespace Mapping Table --- xpathNamespaceMappingsTableModel = new DefaultTableModel() { /** * No cells should be editable */ public boolean isCellEditable(int rowIndex, int columnIndex) { return (false); } }; xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix"); xpathNamespaceMappingsTableModel.addColumn("Namespace URI"); jtXPathNamespaceMappings = new JTable(); jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel); jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90)); // TODO - next line is to be enabled when Taverna is migrated to Java // 1.6; for now it's fine to run without this // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure // that when the dedicated area is larger than the table, the latter is // stretched vertically to fill the empty space jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set // relative // sizes of // columns jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300); c.gridy++; spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings); spXPathNamespaceMappings.setVisible(false); jpMainPanel.add(spXPathNamespaceMappings, c); // populate the view with values refreshView(); return jpMainPanel; }
From source file:com.konifar.material_icon_generator.MaterialDesignIconGenerateDialog.java
private void initLabelLink(JLabel label, final String url) { label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent event) { if (event.getClickCount() > 0) { if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); try { URI uri = new URI(url); desktop.browse(uri); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); }/* w w w.j av a 2 s.co m*/ } } } }); }
From source file:com.github.cric.app.ui.SettingPanel.java
private Component helpLabel() { JLabel help = new JLabel(HELP_TEXT); help.addMouseListener(new MouseAdapter() { @Override// www.j a v a 2 s. c om public void mouseEntered(MouseEvent e) { help.setCursor(new Cursor(Cursor.HAND_CURSOR)); } @Override public void mouseExited(MouseEvent e) { help.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } @Override public void mouseClicked(MouseEvent e) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(HELP_PAGE); } catch (Exception ex) { LOG.warn("unable to open link", ex); } } } }); return help; }