Example usage for java.awt Cursor HAND_CURSOR

List of usage examples for java.awt Cursor HAND_CURSOR

Introduction

In this page you can find the example usage for java.awt Cursor HAND_CURSOR.

Prototype

int HAND_CURSOR

To view the source code for java.awt Cursor HAND_CURSOR.

Click Source Link

Document

The hand cursor type.

Usage

From source file:Main.java

@Override
public void mouseMoved(MouseEvent event) {
    boolean isHyperlink = isHyperlink(event);
    if (isHyperlink) {
        tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {//  w w  w .ja  va2 s  . c  o m
        tree.setCursor(Cursor.getDefaultCursor());
    }

}

From source file:com.igormaznitsa.sciareto.ui.tabs.TabTitle.java

public TabTitle(@Nonnull final Context context, @Nonnull final TabProvider parent,
        @Nullable final File associatedFile) {
    super(new GridBagLayout());
    this.parent = parent;
    this.context = context;
    this.associatedFile = associatedFile;
    this.changed = this.associatedFile == null;
    this.setOpaque(false);
    final GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1000.0d;//  w ww.  j a va  2 s.c o m

    final TabTitle theInstance = this;

    this.titleLabel = new JLabel() {
        private static final long serialVersionUID = 8689945842487138781L;

        @Override
        protected void processKeyEvent(@Nonnull final KeyEvent e) {
            theInstance.getParent().dispatchEvent(e);
        }

        @Override
        public String getToolTipText() {
            return theInstance.getToolTipText();
        }

        @Override
        public boolean isFocusable() {
            return false;
        }
    };
    this.add(this.titleLabel, constraints);

    final Icon uiCloseIcon = UIManager.getIcon("InternalFrameTitlePane.closeIcon");

    this.closeButton = new JButton(uiCloseIcon == null ? NIMBUS_CLOSE_ICON : uiCloseIcon) {
        private static final long serialVersionUID = -8005282815756047979L;

        @Override
        public String getToolTipText() {
            return theInstance.getToolTipText();
        }

        @Override
        public boolean isFocusable() {
            return false;
        }
    };
    this.closeButton.setToolTipText("Close tab");
    this.closeButton.setBorder(null);
    this.closeButton.setContentAreaFilled(false);
    this.closeButton.setMargin(new Insets(0, 0, 0, 0));
    this.closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    this.closeButton.setOpaque(false);
    this.closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(@Nonnull final ActionEvent e) {
            doSafeClose();
        }
    });
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 0.0d;
    constraints.insets = new Insets(2, 8, 2, 0);

    this.add(this.closeButton, constraints);

    updateView();

    ToolTipManager.sharedInstance().registerComponent(closeButton);
    ToolTipManager.sharedInstance().registerComponent(this.titleLabel);
    ToolTipManager.sharedInstance().registerComponent(this);
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.LineGeometryEditor.java

public void moved(final GM_Point p) {
    m_startPoint = null;/*from w ww.  ja v  a  2  s .  c o m*/

    final GM_Point movedPoint = m_pointSnapper.moved(p);
    if (movedPoint != null) {
        m_curve = m_positionMap.get(movedPoint.getPosition());

        m_handles = collectHandles();

        m_mapPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else
        m_mapPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    repaintMap();
}

From source file:VrmlPickingTest.java

protected void addCanvas3D(Canvas3D c3d) {
    setLayout(new BorderLayout());
    add(c3d, BorderLayout.CENTER);
    doLayout();/*from w w  w. j av a  2s  .  c  om*/

    if (m_SceneBranchGroup != null) {
        c3d.addMouseListener(this);

        pickCanvas = new PickCanvas(c3d, m_SceneBranchGroup);
        pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
        pickCanvas.setTolerance(4.0f);
    }

    c3d.setCursor(new Cursor(Cursor.HAND_CURSOR));
}

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new image button./*from   ww  w.  j a  va  2 s  .c  om*/
 * 
 * @param icon
 *            the normal icon
 * @param rolloverIcon
 *            the rollover icon
 * @param action
 *            the action
 * 
 * @return the newly created image button
 */
public static JButton newImageButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JButton button = new JButton(action);
    button.setToolTipText(button.getText());
    button.setText(null);
    button.setContentAreaFilled(false);
    button.setBorder(new EmptyBorder(0, 0, 0, 0));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setFocusable(false);

    button.setIcon(icon);
    button.setRolloverIcon(rolloverIcon);
    button.setRolloverSelectedIcon(rolloverIcon);
    button.setSelectedIcon(rolloverIcon);
    return button;
}

From source file:com.ssn.ui.custom.component.SSNImageThumbnailControl.java

public SSNImageThumbnailControl getSsnImageThumbnailControl(String imagePath, int index) {
    //this.setLayout();
    iF = 0;//from  ww  w . j  a v a  2 s .co m
    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.jets3t.gui.JHtmlLabel.java

/**
 * Changes the mouse cursor to a hand to indicate when the mouse moves over a clickable
 * HTML link./*from  w  w  w .ja  v  a  2s.  c  o m*/
 *
 * @param e event
 */
public void mouseMoved(MouseEvent e) {
    AccessibleJLabel acc = (AccessibleJLabel) getAccessibleContext();
    int stringIndexAtPoint = acc.getIndexAtPoint(e.getPoint());
    if (stringIndexAtPoint < 0) {
        return;
    }
    javax.swing.text.AttributeSet attr = acc.getCharacterAttribute(stringIndexAtPoint);
    if (attr.getAttribute(HTML.Tag.A) == null) {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } else {
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
}

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;//from  w  w  w.jav a  2s.c  o  m

    // --- 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:org.yccheok.jstock.gui.analysis.WizardDownloadIndicatorJPanel.java

private void jLabel3MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseEntered
    this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}

From source file:io.github.jeddict.jpa.modeler.widget.JavaClassWidget.java

protected void addOpenSourceCodeAction() {
    this.getImageWidget().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    this.getImageWidget().getActions().addAction(new OpenSourceCodeAction(() -> getFileObject(),
            this.getBaseElementSpec(), this.getModelerScene().getModelerFile()));
}