Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

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

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:aurelienribon.gdxsetupui.ui.panels.ConfigUpdatePanel.java

public ConfigUpdatePanel(final MainPanel mainPanel) {
    initComponents();//  w ww . ja va 2 s.c  om

    browseBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            browse();
        }
    });

    advancedSettingsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    advancedSettingsLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (clicToShowSettings && mainPanel.showAdvancedSettings()) {
                clicToShowSettings = false;
                advancedSettingsLabel.setText("< Hide advanced settings");
            } else if (mainPanel.hideAdvancedSettings()) {
                clicToShowSettings = true;
                advancedSettingsLabel.setText("Show advanced settings >");
            }
        }
    });

    Style.registerCssClasses(headerPanel, ".header");
    Style.registerCssClasses(numberLabel, ".headerNumber");
    Style.registerCssClasses(advancedSettingsLabel, ".linkLabel");
    Style.registerCssClasses(statusCoreLabel, ".statusLabel");
    Style.registerCssClasses(statusAndroidLabel, ".statusLabel");
    Style.registerCssClasses(statusDesktopLabel, ".statusLabel");
    Style.registerCssClasses(statusHtmlLabel, ".statusLabel");
    Style.registerCssClasses(browseBtn, ".center");

    Ctx.listeners.add(new Ctx.Listener() {
        @Override
        public void cfgUpdateChanged() {
            updateClasspaths();
        }
    });
}

From source file:MouseDragActionPanel.java

public void mouseMoved(MouseEvent evt) {
    int x = evt.getX();
    int y = evt.getY();

    if (getSquare(x, y) >= 0)
        setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    else/*from   www. j ava  2s .  co  m*/
        setCursor(Cursor.getDefaultCursor());
}

From source file:org.jcurl.demo.editor.LocationController.java

/**
 * // w  w  w.jav  a 2 s .  c  o  m
 * @param model
 *            final. Sets the <code>panel</code>'s model.
 * @param panel
 *            required for wc <->dc conversion. Repaint is triggered via
 *            {@link org.jcurl.core.base.RockSet#notifyChange()}.
 */
public LocationController(final PositionSet model, final PositionDisplay panel) {
    panel.addMouseMotionListener(this);
    panel.setPos(model);

    this.panel = panel;
    locations = model;
    // this.model.addPropertyChangeListener(this);
    CursorDefault = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    CursorIn = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
}

From source file:Main.java

protected void setState(boolean active) {
    isActive = active;/*  w  w w. java  2 s .com*/
    repaint();
    if (active) {
        if (button != null)
            button.setState(false);
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {
        button = null;
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override//from   w  ww .  j a va2 s.  c  om
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java

public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info,
        List<NavigableMap<Double, Double>> modelPeaks) {
    super(null, true);

    setBackground(Color.white);/* w  w  w.ja va  2s.  c o m*/
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    NumberAxis xAxis = new NumberAxis("Retention Time");
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setUpperMargin(0);
    xAxis.setLowerMargin(0);

    NumberAxis yAxis = new NumberAxis("Intensity");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setUpperMargin(0);
    yAxis.setLowerMargin(0);

    xyDataset = new XYSeriesCollection();
    colorDataset = new ArrayList<>();
    toolTips = new ArrayList<>();
    widths = new ArrayList<>();

    int seriesID = 0;

    for (int i = 0; i < clusters.size(); ++i) {
        List<NavigableMap<Double, Double>> cluster = clusters.get(i);
        double color = colors.get(i);

        for (int j = 0; j < cluster.size(); ++j) {
            XYSeries series = new XYSeries(seriesID++);

            for (Entry<Double, Double> e : cluster.get(j).entrySet())
                series.add(e.getKey(), e.getValue());

            xyDataset.addSeries(series);
            colorDataset.add(color);
            toolTips.add(info.get(i).get(j));
        }
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
        @Override
        public Paint getItemPaint(int row, int col) {
            String type = xyDataset.getSeries(row).getDescription();

            Paint color;

            if (type.equals(PeakType.MODEL.name()))
                color = COLORS[row % COLORS.length];
            else
                color = new Color(0, 0, 0, 50);

            return color;
        }

        @Override
        public Stroke getSeriesStroke(int series) {
            XYSeries s = xyDataset.getSeries(series);
            String type = s.getDescription();

            float width;
            if (type.equals((PeakType.MODEL.name())))
                width = 2.0f;
            else
                width = 1.0f;

            return new BasicStroke(width);
        }
    };

    renderer.setDefaultShapesVisible(false);
    renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            try {
                return toolTips.get(series);
            } catch (NullPointerException | IndexOutOfBoundsException e) {
                return "";
            }
        }
    });

    XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false);
    chart.setBackgroundPaint(Color.white);

    super.setChart(chart);
}

From source file:lu.lippmann.cdb.graph.mouse.CadralGraphMouse.java

/**
 * {@inheritDoc}/*from w  w w  .  ja v  a 2  s  .co m*/
 * Mode.PICKING      : Move node & edge
 * Mode.EDITING      : Add  node & edge
 * Mode.TRANSFORMING : Move graph layout
 */
@Override
public void mousePressed(MouseEvent e) {
    before.clear();
    //System.out.println("Before map cleared");
    if (!mode.equals(Mode.EDITING)) {
        @SuppressWarnings("unchecked")
        final VisualizationViewer<CNode, CEdge> vv = (VisualizationViewer<CNode, CEdge>) e.getSource();
        final Point2D p = e.getPoint();
        final Layout<CNode, CEdge> layout = vv.getModel().getGraphLayout();
        final GraphElementAccessor<CNode, CEdge> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            final CNode vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
            final CEdge edge = pickSupport.getEdge(layout, p.getX(), p.getY());

            if (mode.equals(Mode.TRANSFORMING)) {
                if (vertex != null || edge != null) {
                    setMode(Mode.PICKING);
                    vv.setCursor(Cursor.getPredefinedCursor(12));
                }
                if ((vertex == null && edge == null) && (e.isShiftDown())) {
                    setMode(Mode.PICKING);
                    vv.setCursor(Cursor.getPredefinedCursor(12));
                }
            } else if (mode.equals(Mode.PICKING) && !e.isShiftDown()) {
                if (vertex == null && edge == null) {
                    setMode(Mode.TRANSFORMING);
                }
            }
            //Final choosen mode is transforming ! -> Deselect all nodes
            if (mode.equals(Mode.TRANSFORMING)) {
                commandDispatcher.dispatch(new DeselectAllCommand());
            }

            //Save initial positions
            if (mode.equals(Mode.PICKING)) {
                if (vertex != null) {
                    saveInitialPositionOfPickedNodes(vv);
                }
            }
        }
    }

    //will call either :
    // - CadralEditingGraphMousePlugin.mousePressed(e)
    // - CadralPickingGraphMousePlugin.mousePressed(e)
    super.mousePressed(e);

    //System.out.println("Coords clicked : " + e.getPoint());
}

From source file:net.sf.mzmine.modules.visualization.twod.TwoDPlot.java

TwoDPlot(RawDataFile rawDataFile, TwoDVisualizerWindow visualizer, TwoDDataSet dataset, Range rtRange,
        Range mzRange) {/*ww  w .j a  va 2 s.c om*/

    super(null, true);

    this.rawDataFile = rawDataFile;
    this.rtRange = rtRange;
    this.mzRange = mzRange;

    setBackground(Color.white);
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    // set the X axis (retention time) properties
    xAxis = new NumberAxis("Retention time");
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setNumberFormatOverride(rtFormat);
    xAxis.setUpperMargin(0);
    xAxis.setLowerMargin(0);

    // set the Y axis (intensity) properties
    yAxis = new NumberAxis("m/z");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setNumberFormatOverride(mzFormat);
    yAxis.setUpperMargin(0);
    yAxis.setLowerMargin(0);

    // set the plot properties
    plot = new TwoDXYPlot(dataset, rtRange, mzRange, xAxis, yAxis);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // chart properties
    chart = new JFreeChart("", titleFont, plot, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title
    chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);

    chartSubTitle = new TextTitle();
    chartSubTitle.setFont(subTitleFont);
    chartSubTitle.setMargin(5, 0, 0, 0);
    chart.addSubtitle(chartSubTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set crosshair (selection) properties
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairPaint(crossHairColor);
    plot.setDomainCrosshairStroke(crossHairStroke);

    // set rendering order
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    peakDataRenderer = new PeakDataRenderer();

    JMenuItem plotTypeMenuItem = new JMenuItem("Toggle centroid/continuous mode");
    plotTypeMenuItem.addActionListener(visualizer);
    plotTypeMenuItem.setActionCommand("SWITCH_PLOTMODE");
    add(plotTypeMenuItem);

    JPopupMenu popupMenu = getPopupMenu();
    popupMenu.addSeparator();
    popupMenu.add(plotTypeMenuItem);

}

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 ww  w .  j a va2  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:EditorPaneExample4.java

public EditorPaneExample4() {
    super("JEditorPane Example 4");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//  w w  w  . j ava2  s .com
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");
                textField.setEnabled(true); // Allow entry of new URL
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });
}