Get Current Mouse Position

Is there a way to get the current mouse position on the screen? Unfortunately, I cannot use a listener to provide the mouse position, because I don't know what components (if any) that the mouse is over. I am trying to draw in the glass pane during a drag and drop. During a drag and drop, the glass pane does not get mouseEntered or mouseMoved events (which I would have used to get the ouse position if I could). So I was hoping for a static method that I could use within the glass pane's paint method to give me the current absolute position of the mouse.

a time ago i used the glasspane and the mousemotionlistener works perfect. you only should be sure to show ( setVisible(true) ) your glasspane. the best way is to look onto the java tutorial how they did it.
link: http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
tobais

Similar Messages

  • How to get current displayed position of an item in listcontrol ?

    Hi,
    can anyone please help me to get current displayed position of an item in a listbox control in vc++ mfc. I am using CListCtrl class to manipulate.
    Thanks,
    saffiuddin 

    On 4/11/2015 3:45 AM, "David Lowndes [MVP]" wrote:
    can anyone please help me to get current displayed position of an item in a listbox control in vc++ mfc. I am using CListCtrl class to manipulate.
    Have you tried GetItemPosition?
    ... or GetItemRect (a bit more information).
    Igor Tandetnik

  • DnD - Get Drop Mouse Position

    I want to Drag some image file from a JList, and then drop it on a JPanel. The dropping on the panel functions. The problem is, i would like to get the position of the mouse, when the item is dropped on the panel. I use the panel to visualize graphics with Graphics2D, and the image dragged from the list should then be displayed at the position on the panel, where it is dropped. So how could i get this position? I have added a MouseListener to the panel, but it does not react on the mouse events which are caused by the DnD action.

    I am really helpless... Is this a stupid question or does nobody know the answer?
    I just want to get the mouse position of the drop, after a drag and drop.
    I found a MouseDragGestureRecognizer Class, but i am not able to implement. Actually i have just a JList, from which Strings are dragged, and a JPanel, on which the Strings are dropped.
    The drag and dropping functions, but i need the mouse position on the JPanel, when the String is dropped.

  • How to get current file position information in JAVA ?

    Hello,
    I would like to know if someone knows how to get and set current file position information in JAVA ?
    In C I use fgetpos and fsetpos.
    Thanks

    Instead of using a standard java.io.File, use java.io.RandomAccessFile
    This is a great class - you can get the file pointer (getFilePointer()), and set it (seek(long pos) )
    that will do all you need I presume - works the same a file handle in C.
    james

  • Get the mouse position

    If I have a frame and some panels on the frame, it seems I should not add the mouselisteners to the frame, but the panels. Now I can receive the mouse events. But when I try to get the mouse's position, they are the position's related to each panel. How can I get the positions associated with the frame?
    Thanks!

    public class MyFrame exyends JFrame implements MouseListener
    implement all the methods of Interface MouseListener
    e.g.
    public void mouseClicked (MouseEvent e)
    System.out.println("CLICKED AT " + e.getX() + "," + e,getY());

  • Get mouse position during Custom UI Draw event?

    I am building a Custom UI for one of my plugin effect.
    I want to get the mouse position during the Custom UI Draw event (PF_Event_DRAW), but cannot manage to get it.
    From what I understand, it seems we can only get the mouse position during the events PF_Event_DRAG, PF_Event_DO_CLICK, and PF_Event_ADJUST_CURSOR.
    I tried to use PFAppSuite4::PF_GetMouse() too, but this resulted in the error message "After Effects error: internal verification failure, sorry! {PF_GetMouse can only be called during valid events.}".
    Therefore I want to store the mouse position during PF_Event_ADJUST_CURSOR, and use it later during PF_Event_DRAW.
    Where can I store those values in a "clean" way (ensuring there will not be conflicts if two instances of the same effect are running, etc)?
    Or is there an easier method to get the mouse position during a Custom UI Draw event?

    //SequenceDataVars is the name of your data structure
    //this is how you create the sequence data
    out_data->sequence_data = PF_NEW_HANDLE(sizeof(SequenceDataVars));
    SequenceDataVars *seqData =
    (SequenceDataVars*)PF_LOCK_HANDLE(out_data->sequence_data);
    //and now you can store stuff in it.
    seqData->var1 = 7;
    //after it's created, on other calls, you just do a simple cast
    SequenceDataVars *seqData = *(SequenceDataVars **)out_data->sequence_data;
    seqData->var1 = 100;
    //this is how you delete it. (if you don't delete it, it will be saved with
    the project, and loaded on the next session. (if you want)
    PF_DISPOSE_HANDLE(out_data->sequence_data);
    there's more to know, so look up SequenceSetup, SequenceSetdown, ect in the
    sample project.

  • Convert mouse position to image position

    Using a zoomed IMAQ image in an image control, I want to recover the position of the mouse in the co-ords of the underlying image. LastMousePositionX (and Y) give the info I want but they are one click in the past and not the current position. Amazingly, there doesn't appear to be an equivalent CurrentMousePositionX. I can't seem to find the info I need to do the conversion manually. The mousedown event returns the current mouse position and I can get the position in the image container by subtracting off its left and top position. But to convert this to the image position I need to know both the zoom and where the images origin is relative to what is displayed. I can't seem to find that origin position in the list of property nodes. The only thing I can seem to come up with is to extract the info from teh image information string, but this seems like an incredibly poor way to extract such obvious information - espeically since the info must be calculated to put in the string anyway. Can anyone help with this?

    Hi,
    I am confused why you get the mouse position one click in the past because it seems to work ok for me. I've had to use four of the image properties to recreate the effect using the mousemove event, but this seems to give the same values as the Last Mouse Position property so I think it does what you want. I couldn't see an origin property so I did the conversion using the position given at the image center. I wanted to post a snippet here but I'm new to posting and couldn't seem to get it to work for the whole block diagram, so I'm using a screenshot instead. I hope this helps in some way.
    Will
    Attachments:
    mouse position test.vi ‏58 KB

  • Mouse Position at dragDrop event

    I'm dragging and dropping items between canvas containers. When I drop an item, the dragDrop event fires. However, I can't seem to find the mouseX and mouseY values of the drop target container, at the point when the item is dropped. Once the mouseDown event fires to start the drag, it seems as though Flex stops capturing the mouseX and mouseY values.
    I put a mouseMove event listener on the container where I'm dropping, and as soon as the mouseDown event starts, the mouseMove event stops.
    I looked at mouseUp, and while that gives me the correct current mouse position, it is triggered after the dragDrop event, making it too late to use the x and y position of the item I dropped.
    How do I find where the point where I dropped the item?

    As soon as the mouseDown event is triggered, the mouseMove event no longer triggers. Thank you for the link. I've read that many times while working on this. What it doesn't address is the position of the item dropped. The only way I can think of to get around this is to listen for the mouseUp instead of the drapDrog event, but that should not be necessary. Use the code below, as an example. No matter where you drop the panel in the second canvas, it puts it at the y value of the mouse at the moment the doDrag (or mouseDown) event triggered.
    <?xml version="1.0"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
        <mx:Script>
            <![CDATA[
                import mx.managers.DragManager;
                import mx.core.DragSource;
                import mx.events.DragEvent;
                import flash.events.MouseEvent;
                import mx.controls.Alert;
                private function mouseOverHandler(event:MouseEvent):void {
                    var dragInitiator:Panel=Panel(event.currentTarget);
                    var ds:DragSource = new DragSource();
                    ds.addData(dragInitiator, "format");
                    var PanelProxy:Panel = new Panel();
                    PanelProxy.height=myPanel.height;
                    PanelProxy.width=myPanel.width;               
                    DragManager.doDrag(dragInitiator, ds, event, PanelProxy, 0, 0, 1.00);
                private function dragEnterHandler(event:DragEvent):void {
                  if (event.dragSource.hasFormat("format"))
                    DragManager.acceptDragDrop(Canvas(event.currentTarget));
                private function dragOverHandler(event:DragEvent):void
                    if (event.dragSource.hasFormat("format")) {
                        if (event.ctrlKey) {                   
                            DragManager.showFeedback(DragManager.COPY);
                            return;
                        else {
                            DragManager.showFeedback(DragManager.MOVE);
                            return;
                    DragManager.showFeedback(DragManager.NONE);
                private function dragDropHandler(event:DragEvent):void {
                  if (event.dragSource.hasFormat("format")) {
                      var draggedPanel:Panel = event.dragSource.dataForFormat('format') as Panel;
                      var dropCanvas:Canvas = event.currentTarget as Canvas;
                      var newPanel:Panel = new Panel();
                      newPanel.x = 0;
                      newPanel.y = drpTgt.mouseY;
                      newPanel.height = draggedPanel.height;
                      newPanel.width = draggedPanel.height;
                      dropCanvas.addChild(newPanel);
                      Alert.show("Item Dropped at "+newPanel.y);
                private function dragCompleteHandler(event:DragEvent):void {
                    var draggedPanel:Panel =
                        event.dragInitiator as Panel;
                    var dragInitCanvas:Canvas =
                        event.dragInitiator.parent as Canvas;
                    if (event.action == DragManager.MOVE)
                        dragInitCanvas.removeChild(draggedPanel);
            ]]>
        </mx:Script>
        <mx:Canvas
            width="250" height="500" 
            borderStyle="solid"
            backgroundColor="#DDDDDD">
            <mx:Panel id="myPanel" x="10" y="192" width="150" height="150" layout="absolute" title="Test Panel" mouseMove="mouseOverHandler(event);" dragComplete="dragCompleteHandler(event);"/>
        </mx:Canvas>
        <mx:Canvas id="drpTgt"
            width="250" height="500" 
            borderStyle="solid"
            backgroundColor="#DDDDDD"
            dragEnter="dragEnterHandler(event);"
            dragOver="dragOverHandler(event);"
            dragDrop="dragDropHandler(event);" horizontalScrollPolicy="on">       
        </mx:Canvas>
    </mx:WindowedApplication>

  • Mouse position always zero

    Hello!
    I am developing a rather big application in Labview ver 8.2.
    I have a problem with getting the mouse position inside a picture.
    The property node mouse->mouse position always returns (-1, -1) or (0, 0). The (-1, -1) returns if the mouse is positioned over a scrollbar.
    My problem is that the (0, 0) is returned for every position inside the picture.
    Now i  wonder if anybody has any suggestions how to get the mouse position to be returned correctly.
    Best regards
    Erik Johansson

    Are you saying that you cannot reproduce the problem if you reduce it to a very small program (e.g. a loop containing only an image, appropriate property node with indicator and a small wait statement)?
    Where did your code come from? Was it converted from an earlier version or coded from scratch in 8.20? Have you tried deleting the current image indicator and creating a new one?
    LabVIEW Champion . Do more with less code and in less time .

  • Mouse position on screen

    is there any way to get the mouses position on the screen (not a window)?
    Stephen

    Component c = (Component)e.getSource();
    Point p = e.getPoint();
    SwingUtilities.convertPointToScreen(p, c);
    System.out.println(p);

  • How to get  the mouse clicked positions on a movie

    I am doing a project on Objects tracking
    I am capturing the video data using webcamera and playing it using processor in JMF
    my problem is , if i click on the movie that is being played currently, i have to display the co-ordinates of the mouse clicked position.
    can anyone help me?
    Thanks in advance
    Sudha

    hello
    i have attache my coding here
    see to it
    import java.io.*;
    import java.io.IOException;
    import java.net.*;
    import java.net.URL;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import javax.swing.*;
    import javax.media.*;
    import javax.media.util.*;
    import javax.media.Buffer.*;
    import javax.media.format.*;
    import javax.media.Format;
    import javax.media.protocol.*;
    import javax.media.control.*;
    import javax.media.rtp.*;
    import javax.media.protocol.DataSource;
    import com.sun.media.ui.*;
    import javax.media.format.YUVFormat;
    import java.util.*;
    import java.util.Vector;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    class capturing1 extends JInternalFrame implements ActionListener,MouseListener,MouseMotionListener,ControllerListener
    * The entry point of the example
    * @param args The command line arguments
         int mark_flg=0;
         int xpos=0,ypos=0;
         mdetect mde=new mdetect();
         protected boolean transitionOK;
         protected Object synchronizer;
         protected Processor processor;
         JButton mark;
         JButton track;
    capturing1(String fname)
    {     super(fname, true, true, true, true);
         getContentPane().setLayout( new BorderLayout() );
         setSize(320, 10);
         setLocation(50, 50);
         setVisible(true);
         processor = null;
    synchronizer = new Object();
    transitionOK = true;
         mark=new JButton("mark");
         track=new JButton("track");
         mark.setSize(25,25);
         track.setSize(25,25);
         mark.addActionListener(this);
         track.addActionListener(this);
         getContentPane().add("East", mark);
         //getContentPane().add("West", track);
         try {
         UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
         } catch (Exception e) {
         System.err.println("Could not initialize java.awt Metal lnf");
         Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));
         addMouseListener(this);
         addMouseMotionListener(this);
         loadAndStart(fname);
    public void loadAndStart(String fn)
    boolean status;
    status = loadFile(fn);
    if (status) status = configure();
         TrackControl tc[] = processor.getTrackControls();
         if (tc == null) {
                   System.err.println("Failed to obtain track controls from the processor.");
                   System.exit(0);
              // Search for the track control for the video track.
              TrackControl videoTrack = null;
              for (int i = 0; i < tc.length; i++) {
                   if (tc.getFormat() instanceof VideoFormat) {
                   videoTrack = tc[i];
                   break;
              if (videoTrack == null) {
                   System.err.println("The input media does not contain a video track.");
                   System.exit(0);
         try {
         Codec codec[] = {mde};
         videoTrack.setCodecChain(codec);
         } catch (UnsupportedPlugInException e) {
         System.err.println("The processor does not support effects.");
    if (status) status = realize();
    public boolean loadFile(String fn)
    boolean status;
    URL url;
         status = false;
         /*Vector v = CaptureDeviceManager.getDeviceList(new VideoFormat(
    VideoFormat.YUV));
    System.out.println(((CaptureDeviceInfo) v.get(0)).getName());
    try{
         MediaLocator ml = ((CaptureDeviceInfo) v.get(0)).getLocator();
    System.out.println(ml.toString());
         processor = Manager.createProcessor(ml);processor.addControllerListener(this);status = true;
    }catch(Exception e){
    System.err.println("Exception occured\n");
    e.printStackTrace();
         System.exit(0);
    try {
    url = new URL("file:"+
    System.getProperty("user.dir")+
    "/"+fn);
    if (url != null) {
    processor = Manager.createProcessor(url);
         processor.addControllerListener(this);
    status = true;
    } catch (NoProcessorException npe) {
    System.out.println("Unable to create a processor!");
    } catch (IOException ioe) {
    System.out.println("Unable to connect to source!");
    return status;
    public boolean configure()
    boolean status;
    status = false;
    // Put the Processor into the configured state
    processor.configure();
    if (waitFor(processor.Configured)) {               
    // Set the content descriptor to null so that the
    // processor can be used as a player
    processor.setContentDescriptor(null);
    status = true;
    } else {
    System.out.println("Unable to configure the processor!");
    return status;
    public boolean realize()
    boolean status;
    Component c;
    status = false;
    // Put the Processor into the realized state
    processor.prefetch();
    if (waitFor(processor.Prefetched)) {               
    // The Processor has been realized so the
    // components can be layed out
    c = processor.getVisualComponent();
    getContentPane().add("Center", c);
    c = processor.getControlPanelComponent();
    if (c != null)
              getContentPane().add("South", c);
    System.out.println("button added");
    // Start the Processor
              validate();System.out.println("button added");
    processor.start();
    status = true;
    } else {
    System.out.println("Unable to realize the processor!");
    return status;
    protected boolean waitFor(int state)
    // Make this block synchronized
    synchronized(synchronizer) {
    try {
    while ((processor.getState() != state) &&
    (transitionOK)) {
    synchronizer.wait();
    } catch (InterruptedException ie) {
    // Ignore it
    return transitionOK;
    public synchronized void controllerUpdate(ControllerEvent evt)
    if ( (evt instanceof ConfigureCompleteEvent) ||
    (evt instanceof RealizeCompleteEvent) ||
    (evt instanceof PrefetchCompleteEvent) ) {
    // Synchronize this block
    synchronized(synchronizer) {
    transitionOK = true;
    synchronizer.notifyAll();
    } else if (evt instanceof ResourceUnavailableEvent) {
    // Synchronize this block
    synchronized(synchronizer) {
    transitionOK = false;
    synchronizer.notifyAll();
    public void mouseMoved(MouseEvent e) {
    //saySomething("Mouse moved", e);
    public void mouseDragged(MouseEvent e) {
    saySomething("Mouse dragged", e);
    public void mousePressed(MouseEvent e) {
    //saySomething("Mouse pressed; # of clicks: "
    // + e.getClickCount(), e);
    public void mouseReleased(MouseEvent e) {
    //saySomething("Mouse released; # of clicks: "
    // + e.getClickCount(), e);
    public void mouseEntered(MouseEvent e) {
    //saySomething("Mouse entered", e);
    public void mouseExited(MouseEvent e) {
    //saySomething("Mouse exited", e);
    public void mouseClicked(MouseEvent e) {
    saySomething("Mouse clicked (# of clicks: "
    + e.getClickCount() + ")", e);
         xpos=e.getX(); ypos=e.getY();
    void saySomething(String eventDescription, MouseEvent e) {
         System.out.println("The Object is at the point "+"x ,"+e.getX()+ "y" + e.getY());
         if(mark_flg==1){
         mdetect.markObject(xpos,ypos);
         //mark_flg=0;
    public void actionPerformed(ActionEvent e)
         if(e.getSource()==track)
              System.out.println("track pressed");
              processor.start();
         if(e.getSource()==mark)
              mark_flg=1;//processor.stop();
              System.out.println("mark pressed");
    public class track extends Frame
    {     JDesktopPane desktop;
    public track(String f)
         setLayout( new BorderLayout() );
         desktop = new JDesktopPane();
         desktop.setDoubleBuffered(true);
         add("Center", desktop);
         setSize(640, 480);
         capturing1 cap1=new capturing1(f);
         desktop.add(cap1);
         setVisible(true);
    public static void main(String args[])
    new track(args[0]);
    /****************************** mdetect class**********************************************/
    class mdetect implements Effect
         //Processor processor;
    static boolean marked=true; static int mark_flg=0; int a=1;
    static int xpos=0,ypos=0;
    private Format inputFormat;
    private Format outputFormat;
    private Format[] inputFormats;
    private Format[] outputFormats;
    private int[] bwPixels;
    private byte[] bwData;
    private RGBFormat vfIn = null;
    private static int imageWidth = 0;
    private int imageHeight = 0;
    private int imageArea = 0;
    static int[] p1;
    mdetect()
    System.out.println("mdetect called");
    inputFormats = new Format[] {
    new RGBFormat(null,
    Format.NOT_SPECIFIED,
    Format.byteArray,
    Format.NOT_SPECIFIED,
                                  24,
    3, 2, 1,
    3, Format.NOT_SPECIFIED,
    Format.TRUE,
    Format.NOT_SPECIFIED)
    outputFormats = new Format[] {
    new RGBFormat(null,
    Format.NOT_SPECIFIED,
    Format.byteArray,
    Format.NOT_SPECIFIED,
                                  24,
    3, 2, 1,
    3, Format.NOT_SPECIFIED,
    Format.TRUE,
    Format.NOT_SPECIFIED)
         public Format[] getSupportedInputFormats() {
    return inputFormats;
         public Format [] getSupportedOutputFormats(Format input) {
    if (input == null) {
    return outputFormats;
    if (matches(input, inputFormats) != null) {
    return new Format[] { outputFormats[0].intersects(input) };
    } else {
    return new Format[0];
         public Format setInputFormat(Format input) {
    inputFormat = input;
         return input;
         public Format setOutputFormat(Format output) {
    if (output == null || matches(output, outputFormats) == null)
    return null;
    RGBFormat incoming = (RGBFormat) output;
    Dimension size = incoming.getSize();
    int maxDataLength = incoming.getMaxDataLength();
    int lineStride = incoming.getLineStride();
    float frameRate = incoming.getFrameRate();
    int flipped = incoming.getFlipped();
    int endian = incoming.getEndian();
    if (size == null)
    return null;
    if (maxDataLength < size.width * size.height * 3)
    maxDataLength = size.width * size.height * 3;
    if (lineStride < size.width * 3)
    lineStride = size.width * 3;
    if (flipped != Format.FALSE)
    flipped = Format.FALSE;
    outputFormat = outputFormats[0].intersects(new RGBFormat(size,
    maxDataLength,
    null,
    frameRate,
    Format.NOT_SPECIFIED,
    Format.NOT_SPECIFIED,
    Format.NOT_SPECIFIED,
    Format.NOT_SPECIFIED,
    Format.NOT_SPECIFIED,
    lineStride,
    Format.NOT_SPECIFIED,
    Format.NOT_SPECIFIED));
    return outputFormat;
    public synchronized int process(Buffer inBuffer, Buffer outBuffer) {
         int i=0;
         a++;
              //System.out.println("discard buffer"+inBuffer.isEOM());
              //System.out.println("w n h");
              //System.out.println("w"+size.width+"h"+size.height);
              //System.out.println("format"+inBuffer.getFormat());
              //System.out.println("RGB"+outImage.getRGB(3,3));
              //Graphics og = outImage.getGraphics();
              //og.drawImage(stopImage, 0, 0, size.width, size.height, null);
              vfIn = (RGBFormat) inBuffer.getFormat();
         Dimension size = vfIn.getSize();
              if(inBuffer.isEOM()==false)
              BufferToImage stopBuffer = new BufferToImage((VideoFormat) inBuffer.getFormat());
              Image stopImage = stopBuffer.createImage( inBuffer);
              BufferedImage outImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
              if(a==6)
              PictureButton.but(stopImage);
              System.out.println("stop image called");
              //cut
    /*if(a<0)
         for(int rr=0;rr<MAXROWS;rr++)
              for(int cc=0;cc<MAXCOLS;cc++)
                   System.out.print(PixelArray[rr][cc]+" ");
         System.out.println("@");
    a=0;
         int outputDataLength = ((VideoFormat)outputFormat).getMaxDataLength();
    validateByteArraySize(outBuffer, outputDataLength);
    outBuffer.setLength(outputDataLength);
    outBuffer.setFormat(outputFormat);
    outBuffer.setFlags(inBuffer.getFlags());
         byte [] inData = (byte[]) inBuffer.getData();
    byte [] outData =(byte[]) outBuffer.getData();
         Object data = inBuffer.getData();
    int pixStrideIn = vfIn.getPixelStride();
    int lineStrideIn = vfIn.getLineStride();
         imageWidth = (vfIn.getLineStride())/3; //Divide by 3 since each pixel has 3 colours.
         imageHeight = ((vfIn.getMaxDataLength())/3)/imageWidth;
         imageArea = imageWidth*imageHeight;
    int r=0,g=0,b = 0; //Red, green and blue values.
         System.arraycopy(inData,0,outData,0,outData.length);
         bwPixels = new int[outputDataLength/3] ;
         p1=new int[outputDataLength/3];int[] p=new int[outputDataLength/3];
         for (int ip = 0; ip < inData.length; ip+=3) {
              int bw = 0;
                   r = (int) inData[ip] ;
                   g = (int) inData[ip+1] ;
                   b = (int) inData[ip+2];
    bw = (int) ((r + b + g)/ (double) 3);
              p1[ip/3]=bw;
         return BUFFER_PROCESSED_OK;
         public String getName() {
    return "Motion Detection Codec";
    public void open() {
    public void close() {
    public void reset() {
         public Format matches(Format in, Format outs[]) {
         for (int i = 0; i < outs.length; i++) {
         if (in.matches(outs[i]))
              return outs[i];
         return null;
    public Object getControl(String controlType) {
    System.out.println(controlType);
         return null;
    public Object[] getControls() {
    return null;
    byte[] validateByteArraySize(Buffer buffer,int newSize) {
    Object objectArray=buffer.getData();
    byte[] typedArray;
    if (objectArray instanceof byte[]) {     // Has correct type and is not null
    typedArray=(byte[])objectArray;
    if (typedArray.length >= newSize ) { // Has sufficient capacity
    return typedArray;
    byte[] tempArray=new byte[newSize]; // Reallocate array
    System.arraycopy(typedArray,0,tempArray,0,typedArray.length);
    typedArray = tempArray;
    } else {
    typedArray = new byte[newSize];
    buffer.setData(typedArray);
    return typedArray;
    public static void markObject(int x,int y)
    marked=true;
    xpos=x; ypos=y;
    /* int j =0, m=0,n=0;
    int total = p1.length; int col = imageWidth; //int row = imageHeight;
    int[][] twodim = new int[total/col][col];
    System.out.println("p1 arr"+p1.length+","+twodim.length+"col"+col);
    for(j=0;j<total;j++)
    twodim[n][m] = p1[j];
    System.out.print( twodim[n][m]+" ");
    m++;
    if( m ==col)
    m=0; n++;
    System.out.println("@"+n);
    System.out.println("m"+m+"n"+n);*/
    public int markObject()
    //System.out.println("boolean mark called");
    mark_flg=1;
    return mark_flg;
    /*****************************************end of mdetect class*****************************************************/
    /*********************************** Image Icon class ****************************************************************/
    class PictureButton extends JFrame implements MouseMotionListener,MouseListener{
    static Image image;Icon icon2;JButton button2=new JButton("hi"); int[] pixels; Container content;
    public PictureButton(Image img ) {
    super("PictureButton v1.0");
    setSize(200, 200);
    setLocation(200, 200);
    Icon icon = new ImageIcon(img);
    JButton button = new JButton(icon);
         button.addMouseMotionListener(this);
         button.addMouseListener(this);
    button.addActionListener(new ActionListener( ) {
    public void actionPerformed(ActionEvent ae) {
    System.out.println("Urp!");
    content = getContentPane( );
    content.setLayout(new FlowLayout( ));
    content.add(button);
         //content.add(button2);
    public static void but(Image im) {
         image=im;
    JFrame f = new PictureButton(im );
    f.addWindowListener(new WindowAdapter( ) {
    public void windowClosing(WindowEvent we) { System.exit(0); }
    f.setVisible(true);
    public void mouseMoved(MouseEvent e) {
    //saySomething("Mouse moved", e);
    public void mouseDragged(MouseEvent e) {
    saySomething("Mouse dragged", e);
    public void mousePressed(MouseEvent e) {
    //saySomething("Mouse pressed; # of clicks: "
    // + e.getClickCount(), e);
    public void mouseReleased(MouseEvent e) {
    //saySomething("Mouse released; # of clicks: "
    // + e.getClickCount(), e);
    public void mouseEntered(MouseEvent e) {
    //saySomething("Mouse entered", e);
    public void mouseExited(MouseEvent e) {
    //saySomething("Mouse exited", e);
    public void mouseClicked(MouseEvent e) {
    saySomething("Mouse clicked (# of clicks: "
    + e.getClickCount() + ")", e);
    void saySomething(String eventDescription, MouseEvent e) {
    int w=0;int ind=0;
         System.out.println("The Object is at the point "+"x ,"+e.getX()+ "y" + e.getY());
         int[][][] imagePixels = imageIO.loadImage(image);
              final int MAXROWS = imagePixels.length;
              final int MAXCOLS = imagePixels[0].length;
              int[][] PixelArray = new int[MAXROWS][MAXCOLS];
              pixels=new int[MAXROWS*MAXCOLS];
              int cnt=0;
              int pix=0,pix1=0;
    for(int row=0; row<imagePixels.length; row++) {
    for(int col=0; col<imagePixels[0].length; col++) {
    for(int rgbo=0; rgbo<4; rgbo++) {
                   if((cnt<3)&&(rgbo<3))
    w++;
                   pix=pix+imagePixels[row][col][rgbo];
                   cnt++;
                   else
                   {cnt=0;}
    } // for rgbo
    pix1 = pix/3;
    pix = 0;
                   /*if(col<97)
                   {pix1=(byte)192;}*/
    PixelArray[row][col] = pix1;
                   System.out.print(pix1+" ");
    } // for col
                   System.out.println("@");
    } // for row
         System.out.println("pix arr"+PixelArray.length);
         for(int ww=0;ww<MAXROWS;ww++)
         for(int hh=0;hh<MAXCOLS;hh++)
         pixels[ind++]=PixelArray[ww][hh];
         image = createImage (new MemoryImageSource( MAXROWS,MAXCOLS, pixels, 0, MAXROWS));
         System.out.println(" img added");
    /********************************* end of Image Icon class**********************************************************/
    this program will capture the video n play
    if u click on the mark button processor will be stopped
    u can click on the image and get the mouse co-ordinates
    i have also got the pixel values of the current frame at which u had clicked the mark button..do some manipulation on the pixels to get ur stuff work
    hope this will help u in some way
    regards
    sudha

  • How to get the index of the word at current cursor position in the word?

    Dear All
    I am implementing a spell checker of my native language in Word. Whenever I run spell checker it start from the first word. How can I make it to start from the current cursor position? How can I get the index of the word at the current cursor position?
    Thanks in advance.
    Dharam Veer Sharma

    hi Dharam Veer Sharma,
    Thanks for sharing the solultion with us.
    It is helpful for others who have the same issue. And if you have any Office developing issue, please feel free to open a new thread.
    Have a nice day.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get the current caret position of a field

    I would like to mimic a feature known from some UI parts in Eclipse (especially launch configurations) - inserting a predefined variable. It allows to modify the value of a text field by inserting a special value to the position of the caret.
    I'm struggling with how to get the caret position in Sapphire since the model does not propagate such UI-specific info. Is there a way how to implement this which does not involve creating a special field implementation?
    Thanks in advance.

    Sorry for the delay in responding. Currently, there is no API available to implement what you are describing. We should add a TextSelectionService similar to the existing ListSelectionService.

  • Getting mouse position without a listener

    Hi all,
    I'm trying to achieve the equivalent of Component.getMousePosition() that Sun
    so kindly put into 1.5, without forcing all my users to immediately upgrade to 1.5.
    Any ideas? Just the normal relative-to-component mouse position is all I need, but I have to get it even if the mouse hasn't moved, so there are no events.
    Thanks a lot

    I guess the easiest way is still to use a MouseMotionListener that you could add to your top level container. You could then store the value of the last position and still be able to access it even if the mouse hasn't moved.
    You might also want to use the following method : SwingUtilities.convertPointFromScreen(Point p, Component c);

  • How to get the current cursor position in word report?

    I am generating a word report. But I would like to keep the table in one page. However, I did not find the way to do it in labview. Somebody would give me some suggestions? I appreciate a lot.
    One way I think I can do is to find the current cursor position. Since I know the table size so I can figure out if the left space in the current page is enough to hold the table. But I do not know how to locate the curent cursor position in word document in labview programmatically. I appreciate any suggestions on this question.
    Thanks.

    Hi,
    when you insert data in a word document you have to refer to bookmarks rather than cursor position.
    If you are using the Report Generation Toolkit for Office it is explained in the manual chapter 3-1.
    See also the example: Generate Report From Template (Word).vi included in the toolkit.
    If you aren't using the toolkit, you still have to refer to bookmark as reference points to insert and/or fetch data.
    The principle is:
    - First create a document in which you insert bookmarks where you wish and save it as a template
    - In LV open your template document and insert in it your data referring to bookmarks as insertion points
    - At the end save your report with another name, so you still have the template
    I hope I have been clear enough, if not just as
    k!
    Good luck,
    Alberto

Maybe you are looking for