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

The following examples show how to use javax.swing.JLabel#setCursor() . 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 File: DatePicker.java    From importer-exporter with 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 2
Source File: AbstractPlUmlEditor.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@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 File: HelpAbout.java    From FoxTelem with 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 4
Source File: SnapAboutBox.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
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 5
Source File: ComponentPanel.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 6
Source File: ChartsPanel.java    From javamelody with 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 7
Source File: LearnMorePanel.java    From zap-extensions with 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 8
Source File: AboutDialog.java    From gepard with 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 9
Source File: AboutView.java    From pgptool with 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 File: CheckForUpdatesView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
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 11
Source File: JLabelLink.java    From JWT4B with 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 12
Source File: LafPanel.java    From netbeans with 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 13
Source File: PaletteToolBarBorder.java    From openAGV with 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 14
Source File: CategoryList.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
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 15
Source File: StatusLineComponent.java    From netbeans with 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 16
Source File: SharedUtils.java    From sc2gears with 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 17
Source File: StatusLineComponent.java    From netbeans with 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 18
Source File: LoginFrame.java    From xyTalk-pc with GNU Affero General Public License v3.0 4 votes vote down vote up
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 19
Source File: GroupPanel.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
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
Source File: AboutActionListener.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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);
}