Java Code Examples for javax.swing.JLabel#setCursor()

The following examples show how to use javax.swing.JLabel#setCursor() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FoxTelem   File: HelpAbout.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void addUrl(String pre, final String url, String text, String post, JPanel panel) {
JLabel website = new JLabel();
//website.setFont(new Font("SansSerif", Font.PLAIN, Config.displayModuleFontSize));
website.setForeground(Color.BLACK);
panel.add(website);

       website.setText("<html>"+pre+"<a href=\"\">"+text+"</a>"+post+"</html>");
       website.setCursor(new Cursor(Cursor.HAND_CURSOR));
       website.addMouseListener(new MouseAdapter() {
           @Override
           public void mouseClicked(MouseEvent e) {
                   try {
                           DesktopApi.browse(new URI(url));
                   } catch (URISyntaxException ex) {
                           //It looks like there's a problem
                   	ex.printStackTrace();
                   }
           }
       });
   }
 
Example 2
@Nonnull
protected JLabel makeLinkLabel(@Nonnull final String text, @Nonnull final Runnable onClick,
                               @Nonnull final String toolTip, @Nonnull final Icon icon) {
  final JLabel result = new JLabel(text, icon, JLabel.RIGHT);
  final Font font = result.getFont().deriveFont(Font.BOLD);
  final Map attributes = font.getAttributes();
  attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
  result.setFont(font.deriveFont(attributes));
  result.setForeground(UiUtils.DARK_THEME ? Color.YELLOW : Color.BLUE);
  result.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  result.setToolTipText(toolTip);
  result.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(@Nonnull final MouseEvent e) {
      onClick.run();
    }
  });
  result.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 16));
  return result;
}
 
Example 3
Source Project: importer-exporter   File: DatePicker.java    License: Apache License 2.0 6 votes vote down vote up
private JPanel createLinkPanel() {
    linkPanel = new JPanel();
    linkPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    todayLink = new JLabel();
    todayLink.setForeground(new Color(16, 66, 104));
    todayLink.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkPanel.add(todayLink);

    todayLink.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                Action delegate = getActionMap().get(e.getClickCount() != 2 ? JXDatePicker.HOME_NAVIGATE_KEY : JXDatePicker.HOME_COMMIT_KEY);
                if (delegate != null && delegate.isEnabled())
                    delegate.actionPerformed(null);
            }
        }
    });

    return linkPanel;
}
 
Example 4
Source Project: openAGV   File: PaletteToolBarBorder.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void paintBorder(Component component, Graphics gr, int x, int y, int w, int h) {
  Graphics2D g = (Graphics2D) gr;

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
  g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

  if ((component instanceof JToolBar) /* && ((((JToolBar) component).getUI()) instanceof PaletteToolBarUI) */) {
    JToolBar c = (JToolBar) component;

    if (c.isFloatable()) {
      int borderColor = 0x80ff0000;
      float[] stops = ENABLED_STOPS;
      Color[] stopColors = ENABLED_STOP_COLORS;

      g.setColor(new Color(borderColor, true));
      LinearGradientPaint lgp = new LinearGradientPaint(
          new Point2D.Float(1, 1), new Point2D.Float(19, 1),
          stops, stopColors,
          MultipleGradientPaint.CycleMethod.REPEAT);
      g.setPaint(lgp);
      g.fillRect(1, 1, 7 - 2, h - 2);
      ImageIcon icon = new ImageIcon(getClass().getResource("/org/opentcs/guing/res/symbols/toolbar/border.jpg"));

      if (c.getComponentCount() != 0 && !(c.getComponents()[0] instanceof JLabel)) {
        JLabel label = new JLabel(icon);
        label.setFocusable(false);
        c.add(label, 0);
        label.getParent().setBackground(label.getBackground());
        label.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
      }
    }
  }
}
 
Example 5
private JPanel createVersionPanel() {
    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(versionText);

    Version specVersion = Version.parseVersion(engineModuleInfo.getSpecificationVersion().toString());
    String versionString = String.format("%s.%s.%s", specVersion.getMajor(), specVersion.getMinor(), specVersion.getMicro());
    String changelogUrl = releaseNotesUrlString + versionString;

    final JLabel releaseNoteLabel = new JLabel("<html><a href=\"" + changelogUrl + "\">Release Notes</a>");
    releaseNoteLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    releaseNoteLabel.addMouseListener(new BrowserUtils.URLClickAdaptor(changelogUrl));
    panel.add(releaseNoteLabel);
    return panel;
}
 
Example 6
Source Project: netbeans   File: LafPanel.java    License: Apache License 2.0 5 votes vote down vote up
private JComponent createRestartNotificationDetails() {
    JPanel res = new JPanel( new BorderLayout( 10, 10) );
    res.setOpaque( false );
    JLabel lbl = new JLabel( NbBundle.getMessage( LafPanel.class, "Descr_Restart") ); //NOI18N
    lbl.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
    res.add( lbl, BorderLayout.CENTER );
    final JCheckBox checkEditorColors = new JCheckBox( NbBundle.getMessage( LafPanel.class, "Hint_ChangeEditorColors" ) ); //NOI18N
    if( isChangeEditorColorsPossible() ) {
        checkEditorColors.setSelected( true );
        checkEditorColors.setOpaque( false );
        res.add( checkEditorColors, BorderLayout.SOUTH );
    }
    lbl.addMouseListener( new MouseAdapter() {
        @Override
        public void mouseClicked( MouseEvent e ) {
            if( null != restartNotification ) {
                restartNotification.clear();
                restartNotification = null;
            }
            if( checkEditorColors.isSelected() ) {
                switchEditorColorsProfile();
            }
            LifecycleManager.getDefault().markForRestart();
            LifecycleManager.getDefault().exit();
        }
    });
    return res;
}
 
Example 7
Source Project: JWT4B   File: JLabelLink.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void addURL(String content, String tooltip) {
	JLabel label = new JLabel("<html>" + content + "</html>");
	label.setCursor(new Cursor(Cursor.HAND_CURSOR));
	label.setToolTipText(tooltip);
	addMouseHandler(label);
	pan.add(label);
}
 
Example 8
private void initSiteLink(JLabel label, MouseListener mouseListener) {
	if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
		return;
	}

	label.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
	label.setForeground(Color.blue);
	label.addMouseListener(mouseListener);
}
 
Example 9
Source Project: pgptool   File: AboutView.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void initLinkAction(JLabel label, MouseListener mouseListener) {
	if (!Desktop.isDesktopSupported() || !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
		return;
	}

	label.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
	label.setForeground(Color.blue);
	// Font font = lblLinkToSite.getFont();
	// Map attributes = font.getAttributes();
	// attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
	// lblLinkToSite.setFont(font.deriveFont(attributes));
	label.addMouseListener(mouseListener);
}
 
Example 10
Source Project: gepard   File: AboutDialog.java    License: MIT License 5 votes vote down vote up
private JLabel getLinkJLabel(String caption) {
	JLabel ret = new JLabel("<html><u>" + caption + "</u></html>");
	Font oldFont = ret.getFont();
	ret.setFont(new Font(oldFont.getName(), 
			oldFont.getStyle() &~ Font.BOLD, oldFont.getSize() ));
	ret.setForeground(Color.BLUE);
	ret.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
	ret.addMouseListener(this);
	return ret;
}
 
Example 11
Source Project: zap-extensions   File: LearnMorePanel.java    License: Apache License 2.0 5 votes vote down vote up
private JLabel getOnlineLink(String key, String url) {
    JLabel label = ulJLabel(Constant.messages.getString(key));
    label.setIcon(ExtensionQuickStart.ONLINE_DOC_ICON);
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    label.addMouseListener(
            new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    DesktopUtils.openUrlInBrowser(url);
                }
            });
    return label;
}
 
Example 12
Source Project: javamelody   File: ChartsPanel.java    License: Apache License 2.0 5 votes vote down vote up
final JPanel createJRobinPanel(Map<String, byte[]> jrobins) {
	final JPanel centerPanel = new JPanel(new GridLayout(-1, NB_COLS));
	centerPanel.setOpaque(false);
	for (final Map.Entry<String, byte[]> entry : jrobins.entrySet()) {
		final String jrobinName = entry.getKey();
		final byte[] imageData = entry.getValue();
		final ImageIcon icon = new ImageIcon(imageData);
		final JLabel label = new MTransferableLabel(icon);
		// ce name sera utilisé comme nom de fichier pour le drag and drop de l'image
		label.setName(getString(jrobinName));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setCursor(HAND_CURSOR);
		label.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				final MWaitCursor waitCursor = new MWaitCursor(centerPanel);
				try {
					showZoomedChart(jrobinName);
				} catch (final IOException ex) {
					showException(ex);
				} finally {
					waitCursor.restore();
				}
			}
		});
		centerPanel.add(label);
	}

	final JPanel graphicsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	graphicsPanel.setOpaque(false);
	graphicsPanel.add(centerPanel);
	return graphicsPanel;
}
 
Example 13
private void initComponents()
{
	setLayout(new BorderLayout());

	componentLabel = new JLabel(getMember().toString());
	componentLabel
			.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
	componentLabel.addMouseListener(new LinkMouseAdapter(this));
	componentLabel.setToolTipText("Double-click to look-up in FIXwiki");
	if (isRequired)
	{
		componentLabel.setForeground(Color.BLUE);
	}

	componentLabel.setFont(new Font(componentLabel.getFont().getName(),
			Font.BOLD, componentLabel.getFont().getSize()));

	membersPanel = new JPanel();
	if (isRequired)
	{
		membersPanel.setBorder(new LineBorder(Color.BLUE));
	} else
	{
		membersPanel.setBorder(new LineBorder(Color.BLACK));
	}
	loadMembers();

	add(componentLabel, BorderLayout.NORTH);
	add(membersPanel, BorderLayout.SOUTH);
}
 
Example 14
private void initComponents() {
	Dimension windowSize = new Dimension(windowWidth, windowHeight);
	setMinimumSize(windowSize);
	setMaximumSize(windowSize);

	controlPanel = new JPanel();
	controlPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5));
	// controlPanel.setBounds(0,5, windowWidth, 30);

	closeLabel = new JLabel();
	closeLabel.setIcon(IconUtil.getIcon(this, "/image/close.png"));
	closeLabel.setHorizontalAlignment(JLabel.CENTER);
	// closeLabel.setPreferredSize(new Dimension(30,30));
	closeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));

	titleLabel = new JLabel();
	titleLabel.setText("登录 XyTalk");
	titleLabel.setFont(FontUtil.getDefaultFont(16));

	downloadLabel = new JLabel();
	downloadLabel.setText("下载客户端软件");
	downloadLabel.setFont(FontUtil.getDefaultFont(14));
	
	remberPsw = new JCheckBox("记住密码", true);
	remberPsw.setFont(FontUtil.getDefaultFont(14));
	
	offlineLogin = new JCheckBox("断网离线登陆", false);
	offlineLogin.setFont(FontUtil.getDefaultFont(14));

	editPanel = new JPanel();
	editPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 5, true, false));

	Dimension textFieldDimension = new Dimension(200, 35);
	usernameField = new RCTextField();
	usernameField.setPlaceholder("用户名");
	usernameField.setPreferredSize(textFieldDimension);
	usernameField.setFont(FontUtil.getDefaultFont(14));
	usernameField.setForeground(Colors.FONT_BLACK);
	usernameField.setMargin(new Insets(0, 15, 0, 0));
	usernameField.setText("wangxin");

	passwordField = new RCPasswordField();
	passwordField.setPreferredSize(textFieldDimension);
	passwordField.setPlaceholder("密码");
	// passwordField.setBorder(new RCBorder(RCBorder.BOTTOM,
	// Colors.LIGHT_GRAY));
	passwordField.setFont(FontUtil.getDefaultFont(14));
	passwordField.setForeground(Colors.FONT_BLACK);
	passwordField.setMargin(new Insets(0, 15, 0, 0));
	passwordField.setText("1");

	loginButton = new RCButton("登 录", Colors.MAIN_COLOR, Colors.MAIN_COLOR_DARKER, Colors.MAIN_COLOR_DARKER);
	loginButton.setFont(FontUtil.getDefaultFont(14));
	loginButton.setPreferredSize(new Dimension(300, 40));

	statusLabel = new JLabel();
	statusLabel.setForeground(Colors.RED);
	statusLabel.setText("密码不正确");
	statusLabel.setVisible(false);
	
	usernameField.setText(readName());
	passwordField.setText(readPassword());
}
 
Example 15
Source Project: netbeans   File: StatusLineComponent.java    License: Apache License 2.0 4 votes vote down vote up
private void createLabel() {
    discardLabel();
    label = new JLabel();
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    label.addMouseListener(mouseListener);
}
 
Example 16
Source Project: netbeans   File: StatusLineComponent.java    License: Apache License 2.0 4 votes vote down vote up
private void createExtraLabel() {
    discardExtraLabel();
    extraLabel = new JLabel();
    extraLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    extraLabel.addMouseListener(mouseListener);
}
 
Example 17
public Category(String caption, String tooltip,
                boolean initialState, Component[] items,
                int index, int categoriesCount) {

    expanded = initialState;

    setOpaque(false);
    setLayout(new BorderLayout());

    headerLabel = new JLabel(caption);
    headerLabel.setForeground(new JMenuItem().getForeground());
    headerLabel.setToolTipText(tooltip);
    headerLabel.setIconTextGap(5);
    headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    headerLabel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    headerLabel.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            expanded = !expanded;
            updateState();
        }
    });
    
    JMenuBar menuBar = new JMenuBar();
    menuBar.setBorder(BorderFactory.createEmptyBorder());
    menuBar.setBorderPainted(false);
    menuBar.setLayout(new BorderLayout());
    menuBar.add(headerLabel, BorderLayout.CENTER);
    
    itemsContainer = new JPanel() {
        public void setEnabled(boolean enabled) {
            Component[] components = getComponents();
            for (Component c : components) c.setEnabled(enabled);
        }
    };
    itemsContainer.setOpaque(false);
    itemsContainer.setLayout(new VerticalLayout(false));

    for (int i = 0; i < items.length; i++)
        itemsContainer.add(items[i]);

    add(menuBar, BorderLayout.NORTH);
    add(itemsContainer, BorderLayout.CENTER);

    updateState();

}
 
Example 18
Source Project: sc2gears   File: SharedUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates a label which looks like a link and has a hand mouse cursor.
 * @param text text of the label (link)
 * @return a label which looks like a link
 */
public static JLabel createLinkStyledLabel( final String text ) {
	final JLabel label = new JLabel( createHtmlLink( text ) );
	label.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
	return label;
}
 
Example 19
private void initComponents()
{
	setLayout(new GridBagLayout());

	layerUI = new FieldValidationLayerUI(getFrame());

	groupLabel = new JLabel(getMember().toString());
	groupLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
	groupLabel.addMouseListener(new LinkMouseAdapter(this));
	groupLabel.setToolTipText("Double-click to look-up in FIXwiki");
	if (isRequired)
	{
		groupLabel.setForeground(Color.BLUE);
	}

	JPanel groupValuePanel = new JPanel();
	groupValuePanel.setLayout(new BoxLayout(groupValuePanel,
			BoxLayout.X_AXIS));

	groupTextField = new JFormattedTextField(
			NumberFormat.getIntegerInstance());
	groupTextField.setFocusLostBehavior(JFormattedTextField.COMMIT);
	if (initialNoOfGroups > 0)
	{
		groupTextField.setText(String.valueOf(initialNoOfGroups));
	}
	setButton = new JButton("Set");
	setButton.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			getFrame().displayMainPanel();
		}
	});

	groupValuePanel.add(new JLayer<JFormattedTextField>(groupTextField,
			layerUI));
	groupValuePanel.add(setButton);

	groupPanels = new JPanel();
	groupPanels.setLayout(new GridBagLayout());

	loadMembers();

	add(groupLabel, createGridBagConstraints());
	add(groupValuePanel, createGridBagConstraints());
	add(groupPanels, createGridBagConstraints());
}
 
Example 20
@Override
public void actionPerformed(ActionEvent e)
{
	JPanel panel = new JPanel();
	panel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.HORIZONTAL;
	c.weightx = 0.5;
	c.weighty = 0.0;
	c.ipadx = 2;
	c.ipady = 2;

	JLabel titleLabel = new JLabel("<html><b>QuickFIX Messenger</b></html>");
	JLabel nameLabel = new JLabel("<html><i>by Jan Amoyo</i></html>");
	JLabel emailLabel = new JLabel("<html>[email protected]</html>");
	JLabel webpageLabel = new JLabel(
			"<html><a href=''>quickfix-messenger</a></html>");
	webpageLabel.addMouseListener(new LinkMouseAdapter(this, frame
			.getMessenger().getConfig().getHomeUrl()));
	webpageLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

	JLabel licenseLabel = new JLabel("<html><b>License</b></html>");

	JTextArea licenseText = new JTextArea(readLicenseFile(), 15, 60);
	licenseText.setWrapStyleWord(true);
	licenseText.setLineWrap(true);
	licenseText.setEditable(false);

	JScrollPane licenseTextScrollPane = new JScrollPane(licenseText);
	licenseText.setPreferredSize(new Dimension(400, 400));
	licenseTextScrollPane.setBorder(new EtchedBorder());

	c.gridx = 0;
	c.gridy = 0;
	panel.add(titleLabel, c);

	c.gridx = 0;
	c.gridy = 1;
	panel.add(nameLabel, c);

	c.gridx = 0;
	c.gridy = 2;
	panel.add(emailLabel, c);

	c.gridx = 0;
	c.gridy = 3;
	panel.add(webpageLabel, c);

	c.gridx = 0;
	c.gridy = 4;
	panel.add(Box.createRigidArea(new Dimension(50, 10)), c);

	c.gridx = 0;
	c.gridy = 5;
	panel.add(licenseLabel, c);

	c.gridx = 0;
	c.gridy = 6;
	panel.add(licenseTextScrollPane, c);

	JOptionPane.showMessageDialog(frame, panel, "About QuickFIX Messenger",
			JOptionPane.PLAIN_MESSAGE);
}