javax.swing.JLabel#setCursor ( )源码实例Demo

下面列出了javax.swing.JLabel#setCursor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FoxTelem   文件: HelpAbout.java
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();
                   }
           }
       });
   }
 
源代码2 项目: netbeans-mmd-plugin   文件: AbstractPlUmlEditor.java
@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;
}
 
源代码3 项目: importer-exporter   文件: DatePicker.java
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;
}
 
源代码4 项目: openAGV   文件: PaletteToolBarBorder.java
@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));
      }
    }
  }
}
 
源代码5 项目: snap-desktop   文件: SnapAboutBox.java
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;
}
 
源代码6 项目: netbeans   文件: LafPanel.java
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;
}
 
源代码7 项目: JWT4B   文件: JLabelLink.java
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);
}
 
源代码8 项目: pgptool   文件: CheckForUpdatesView.java
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);
}
 
源代码9 项目: pgptool   文件: AboutView.java
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);
}
 
源代码10 项目: gepard   文件: AboutDialog.java
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;
}
 
源代码11 项目: zap-extensions   文件: LearnMorePanel.java
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;
}
 
源代码12 项目: javamelody   文件: ChartsPanel.java
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;
}
 
源代码13 项目: quickfix-messenger   文件: ComponentPanel.java
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);
}
 
源代码14 项目: xyTalk-pc   文件: LoginFrame.java
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());
}
 
源代码15 项目: netbeans   文件: StatusLineComponent.java
private void createLabel() {
    discardLabel();
    label = new JLabel();
    label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    label.addMouseListener(mouseListener);
}
 
源代码16 项目: netbeans   文件: StatusLineComponent.java
private void createExtraLabel() {
    discardExtraLabel();
    extraLabel = new JLabel();
    extraLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    extraLabel.addMouseListener(mouseListener);
}
 
源代码17 项目: visualvm   文件: CategoryList.java
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();

}
 
源代码18 项目: sc2gears   文件: SharedUtils.java
/**
 * 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;
}
 
源代码19 项目: quickfix-messenger   文件: GroupPanel.java
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());
}
 
源代码20 项目: quickfix-messenger   文件: AboutActionListener.java
@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);
}