Example usage for java.awt Cursor CROSSHAIR_CURSOR

List of usage examples for java.awt Cursor CROSSHAIR_CURSOR

Introduction

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

Prototype

int CROSSHAIR_CURSOR

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

Click Source Link

Document

The crosshair cursor type.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    aWindow.setVisible(true);//  ww w.  j av  a  2 s  .  c o  m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    aWindow.setVisible(true);//  w  w w .jav  a  2 s  .  co m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Cursor cursor = Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
    System.out.println(cursor.toString());

    aWindow.setVisible(true);/*  w  w w. j  ava  2  s.  c  o  m*/
}

From source file:MainClass.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    aWindow.getContentPane().setBackground(Color.PINK);
    aWindow.setVisible(true);/*w w  w.ja va2  s  .  c o m*/
}

From source file:CreatingCursors.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame("This is the Window Title");
    Toolkit theKit = aWindow.getToolkit(); // Get the window toolkit
    Dimension wndSize = theKit.getScreenSize(); // Get screen size
    // Set the position to screen center & size to half screen size
    aWindow.setBounds(wndSize.width / 4, wndSize.height / 4, // Position
            wndSize.width / 2, wndSize.height / 2); // Size
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
    aWindow.setVisible(true); // Display the window
}

From source file:Main.java

private MouseListener getListener() {
    return new MouseAdapter() {
        @Override//  w w w  . j a v  a 2s  . c om
        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            pane.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            super.mouseReleased(e);
            pane.setCursor(Cursor.getDefaultCursor());
        }
    };
}

From source file:com.cburch.draw.tools.LineTool.java

@Override
public Cursor getCursor(Canvas canvas) {
    return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.SimpleScatterPlot.java

public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel, String yLabel) {
    super(null, true);

    setBackground(Color.white);/*from   www .  j a  v  a 2 s  .c  o m*/
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    xAxis = new NumberAxis(xLabel);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setUpperMargin(0);
    xAxis.setLowerMargin(0);

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

    xyDataset = new DefaultXYZDataset();
    int length = Math.min(xValues.length, yValues.length);
    double[][] data = new double[3][length];
    System.arraycopy(xValues, 0, data[0], 0, length);
    System.arraycopy(yValues, 0, data[1], 0, length);
    System.arraycopy(colors, 0, data[2], 0, length);
    xyDataset.addSeries(SERIES_ID, data);

    XYDotRenderer renderer = new XYDotRenderer() {
        @Override
        public Paint getItemPaint(int row, int col) {
            double c = xyDataset.getZ(row, col).doubleValue();
            return Color.getHSBColor((float) c, 1.0f, 1.0f);
        }
    };

    renderer.setDotHeight(3);
    renderer.setDotWidth(3);

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

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

    super.setChart(chart);
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.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);//  www  .ja  v a 2  s  . co  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<>();

    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) {
            double c = colorDataset.get(row);
            return Color.getHSBColor((float) c, 1.0f, 1.0f);
        }
    };

    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: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 w  w w . j av a2s  . c o m*/
        setCursor(Cursor.getDefaultCursor());
}