Get absolute position of mouse.

Hi,
I want to move mouse by specified offset. I'd like to use method of Robot class, but it need absolute coordinates on the screen.
So I need get absolute coordinates of mouse to count new coordinates from given offset.
Know somebody how I can get it ?
Thanks,
Vasek.

There are two static methods in the class SwingUtilities: convertPointFromScreen() and
convertPointToScreen().
Mitch Goldstein
Author, Hardcore JFC (Cambridge Univ Press)
[email protected]

Similar Messages

  • Getting absolute position of component

    hi
    i want to take a screenshot of the content of a specific JFrame in my ui
    what the code below does is take a screenshot of my screen starting at its (0, 0) coordinates
    but not starting at the so called (0, 0) of the JFrame
         Robot robot = new Robot();
         Dimension dimension = getJFrame().getSize();
         Rectangle rectangle = new Rectangle(dimension);
         BufferedImage screenShot = robot.createScreenCapture(new Rectangle(rectangle));how can i calculate the offset to the JFrame ?
    i already tried all kinds of things
    and didn't find any reference online
    thanks

    You use this on the JFrame:
    //from the API
    getLocationOnScreen
    public Point getLocationOnScreen()Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.
    Returns:
    an instance of Point representing the top-left corner of the component's bounds in the coordinate space of the screen
    Throws:
    IllegalComponentStateException - if the component is not showing on the screen
    See Also:
    setLocation(int, int), getLocation()Then use your component location as an offset from the JFrame location.

  • Box model/none absolute positioning with flash

    In recent years none-absolute positioning (or box model positioning) has become the norm with HTML/CSS
    this is uselfull for dynamic functions which appear on an event (such as an object which appears when a button is clicked on or a error message that appears when a form box is given invalid input because it automatically inserts itself it the right place.)
    One very important example of this is when you have a form which automatically produces an error message and the error message appears bellow the input area which caused it and the rest of the page is pushed down.
    With none absolute positioning the developer does not need to worry about this.
    But if the objects are given absolute position then it becomes a massive problem, the developer has to go about giving the objects differetn positions dependant on if dynamic objects appear or not
    potentially the developer has to consider all possible variables, and code if statements which determine the position of all static objects for all possible variables which dynamic objects could take.
    so does flash have a "none absolute positioning" solution to this problem.

    Before you get all happy and pleased with yourself, APDivs or Layers seldom work well as a primary layout method. Here are some reasons why:
    http://apptools.com/examples/pagelayout101.php
    You're much better off using default CSS positioning (which is no positioning at all) along with CSS margins, padding and floats.  If you don't believe me, check your page in non-IE browsers with increased/decreased text-sizes (zoom, text only).
    From  Tables to CSS Web Design Part 1 -
    http://www.adobe.com/devnet/dreamweaver/articles/table_to_css_pt1.html
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • Rendering bug with absolutely positioned button tags

    I'm using Firefox 10.0.1 and I've found a bug regarding button elements that are absolutely positioned. The problem is setting both the right and left CSS attributes does not affect the width of the button as it should.
    Here is some example code to show what I mean (the forum is mangling the html, hopefully you can get the gist of it):<br />
    <br />
    <pre><nowiki><html>
    <body>
    <div style="width: 500px; position: relative;">
    <button style="position: absolute; left: 0; right: 0;">Test</button>
    </div>
    </body>
    </html></nowiki></pre>
    In all other browsers the button will be 500px wide. In Firefox, it will fit to the text.

    Why don't you give that button a width:100% if you want it to take the full width of that DIV container?

  • Why is a table td not suitable as a containing block for absolute positioning of an element when other browsers allow that CSS feature?

    Absolute positioning requires a containing element. I'm taking a class on HTML5 and CSS3 from ed2go.com. A photo display using thumbnails in a table shows the full size picture with its corner in the center of the thumbnail when you hover over the thumbnail.
    Snippet of code for one td
    <pre><nowiki><td>
    <img src="pix2/flower01.png" alt="" class="small">
    <img src="pix2/flower01.png" alt="" class="left"></td></nowiki></pre>
    The "small" class makes the picture a thumbnail. The "left" class positions the full size picture with its corner in the center of the thumbnail when the mouse hovers over the thumbnail. This works correctly in Internet Explorer but not Firefox. The reason is that Firefox does not consider a td to be a containing element by using position:relative so the large picture corner is in the center of the viewport. Although td is not a block element it would seem that allowing absolute positioning with respect to a td would be a good default implementation.
    The "problem" can be "fixed" by simply placing the two &lt;img&gt; inside a &lt;p&gt;&lt;/p&gt;.<br />
    You can see the two different implementations at http://s179350112.onlinehome.us/temp6.htm and http://s179350112.onlinehome.us/temp7.htm
    Is Firefox implementing the Standard correctly? Would a default implementation as in Internet Explorer be allowed by the Standard?

    Yes, I see the same on the temp7 page.
    Maybe someone at the MozillaZine "Web Development/Standards Evangelism" forum knows more about this.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the MozillaZine forum site in order to post at that forum.

  • Bayside Beat Tutorial - Part 4 - Absolute positioning

    I am stuck on the Absolute positioning section. My image is supposed to be spread out across the screen and the text is supposed to be at 36% as a layer on top of the image. Here are the instructions:
    To keep related styles together, select #wrapper in the Selectors pane, and click the plus button to create a new selector called #hero after it.
    In the Layout category, set the position property to relative.
    With #hero still selected in the Selectors pane, create a new selector called #hero article to style the <article>element nested inside the hero <div>.
    In the Layout category, set the width property to 36%, and left and right padding to 10px.
    Set the position property to absolute.
    The moment I set steps 4 & 5, I get the following layout:
    It should look like this:

    Looking at your screenshot, it looks as though you have wrapped the <article> around the hero <div> in the underlying HTML. The problem isn't with your CSS, but the HTML structure.
    Compare your HTML file with the version in the completed folder.

  • How to force absolute positioning

    Hi
    I am trying to force absolute positioning when I export to Dreramweaver.
    How can I do this.  Ive been trying to overlap my images and hence slices when I export but I never get the warning up about absolute positioning.
    Any ideas
    Thanks

    Create the images in Fireworks and export them to the images folder of the site you have properly defined in Dreamweaver. Build the pages with the images in Dreamweaver. Fireworks can only export images "overlapping" on states which are animations, or buttons, or image swaps.

  • Looking for confirmation regarding absolute positioning...

    Absolutely-positioned elements *never* interrupt the flow,
    regardless of
    what that element is.
    As such, scrollbars completely ignore said elements at *all*
    times, as if
    they weren't there at all.
    Are both those statements considered pretty much factual?

    > Would there be any way *at all* to place a div outside
    the viewport
    > WITHOUT generating a scrollbar?
    Yes - place it to the left of the left margin, or above the
    top margin. 8)
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Mike" <[email protected]> wrote in message
    news:g8rohn$8go$[email protected]..
    > "Murray *ACE*" <[email protected]>
    wrote in message
    > news:g8rgne$rdc$[email protected]..
    >>> Absolutely-positioned elements *never* interrupt
    the flow, regardless of
    >>> what that element is.
    >>
    >> Absolutely positioned elements are REMOVED from the
    flow, so yes, they
    >> can never affect anything that is located by the
    normal flow.
    >>
    >>> As such, scrollbars completely ignore said
    elements at *all* times, as
    >>> if they weren't there at all.
    >>
    >> Curiously not. Place an absolutely positioned
    element 2000px to the
    >> right of the page's right margin and you'll get a
    horizontal scrollbar.
    >
    > How strange.
    >
    > Would there be any way *at all* to place a div outside
    the viewport
    > WITHOUT generating a scrollbar?
    >

  • Absolute Position of Component

    hi!
    i'm currently creating a formvalidator.
    is a field-validation failed, the validator paints a small red dot on the glasspane over the lower left corner of the field/component.
    my problem now is the following:
    is the component i want to validate in a container, the getLocation()-method of the component does not give me the absolute position of the component... so my red dot is painted on the false position.
    does anybody know how i could get the absolute position of my component? (absolute; relative to my topcontainter, the JFrame or the JDialog)
    thx a lot!
    greetz
    swissManu

    Hi,
    have a look here :
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/SwingUtilities.html#convertPoint(java.awt.Component,%20int,%20int,%20java.awt.Component)
    it should permit you converting coordinates relatively to anything ;-)
    Nico

  • Find browser or applets absolute position

    Hi,
    I am designing an applet where I open a number of small pop up windows at the beginning of the applet. Users of this system have two monitors, thus I need to determine where they have positioned the browser so that the windows will open above the browser. At the time the windows open there is nothing else on the screen so getLocation doesn't work.
    If I can determine the absolute position of the applet this would also do.
    All help would be greatly appreciated.

    I use the following to get a reference to a Frame which I pass to a JDialog constructor to ensure that the Dialog is always centred over an Applet no matter where the Applet is positioned on screen. Maybe you can adapt it for your needs.
    public Frame getDialogFrame()
              /* creates and positions a Frame used by dialogs
              *  to ensure that dialog is modal and centred over the Applet
              Object parent = this.getParent();
              while(!(parent instanceof Frame))
        parent=((Component)parent).getParent();
              Frame dialogFrame = (Frame) parent;
              Point p = this.getLocationOnScreen();
              dialogFrame.setLocation(p.x, p.y);
              return dialogFrame;
         }

  • How can I tell if my iPad's GPS is even attemping to get a position fix?

    MC773LL/A  iOS 7.0.4
    The main reason I purchased an iPad was to use it as backup for GPS navigation electronics aboard my boat. I've used it several times just to test it, with purchased nav apps, starting from my home port, and everything worked as expected. Recently I didn't power up the iPad until I was at sea but only 15 miles from home port. It could not seem to obtain a position fix, and the GPS arrow indicator did not appear. I had no way of knowing if it was even trying to get a fix. My other GPS devices at least tell me they're trying. Is there some way know if an iPad is even trying to get a first fix? When I returned home, I powered up the iPad and everything worked fine. All the location services settings and others, including wi-fi, were left untouched.
    Is there some trick to wake up the iPad's on-board GPS to get it working?
    And how would I know that it's activated and trying to get a first fix?
    Thanks.

    My iPad has onboard true GPS. It's Model MC773LL/A
    The app is iNavX.  The GPS and the app usually work just fine. But, as noted in my original posting, I had an incident where the GPS did not seem to activate. And I could not tell if there was some way to see if it was even trying to get a position fix. The GPS arrow didn't appear. More details in my original posting. My questions remain:
    Is there some trick to wake up the iPad's on-board GPS to get it working?
    And how would I know that it's activated and trying to get a first fix?

  • How do i add a Scroll Bar to a  JList Component using absolute positioning?

    I've got a applet whose content pane is set to null. I've create a jlist component on this applet and using absolute positioning set the bounds at
    ListBox1.setBounds(380,10, 500, 500);.
    My problem is creating add a scroll bar to the list box.
    JScrollPane scrollPane = new JScrollPane(ListBox1);
    C.add(scrollPane);
    The above code is what i use and when i run this applet i don't see the list box at all. How do i add a scrollbar to this list box or JList component. Please help.

    You need to setBounds() on the JScrollPane, not the JList.
    The JScrollPane is the component that is being added to the panel.

  • How to get a position in a string?

    I need to get a position in a string like the word CHEESE, where the c is position 1, the h is position 2, the e is position 3 etc... Which input stream should i use and how does it work really?

    indexOf(int ch)
    Returns the index within a string of the first occurrence of the specified character.

  • How to get text position in a pdf?

    I need to get text position such has width, height, x, y and base position in a pdf.
    Can one help me to work further.

    i solved PDEForm issue thank you. Now i need to get the text from PDEElement.
    Can you help for this?
      PDEElement pdeElement;
        ASInt32 numElems = PDEContentGetNumElems (pdeContent);
        ASFixedRect bBox;
        for (ASInt32 i = 0; i < numElems; i++) {
            pdeElement = PDEContentGetElem (pdeContent, i);
            if (PDEObjectGetType((PDEObject)pdeElement) == kPDEForm)
                PDEForm form = (PDEForm)pdeElement;
                PDEContent content = PDEFormGetContent(form);
                GetCoOrdinate(content);
            else if(PDEObjectGetType((PDEObject)pdeElement) == kPDEText)
                PDETextState objPDETextState;
                PDEText aotextObject;
                memset(&objPDETextState, 0,sizeof(PDETextState));
                aotextObject = (PDEText)pdeElement;
                PDETextGetTextState(aotextObject,kPDETextRun,0,&objPDETextState,sizeof (PDETextState));
                if(objPDETextState.renderMode == kPDETextInvisible)
                    AVAlertNote("Invisible");
                else
                    PDEElementGetBBox (pdeElement, &bBox);
                    os.str("");
                    os << ASFixedRoundToInt32 (bBox.top) <<":" << ASFixedRoundToInt32 (bBox.bottom) << ":" << ASFixedRoundToInt32 (bBox.left) << ":" << ASFixedRoundToInt32 (bBox.right);
                    AVAlertNote(os.str().c_str());
            else
                os.str("");
                os << "Type: "<< PDEObjectGetType((PDEObject)pdeElement);
               // AVAlertNote(os.str().c_str());
                // Get the bounding box of the PDEElement and fill out the
                // selection structure to highlight the image.
                PDEElementGetBBox (pdeElement, &bBox);
                os.str("");
                os << ASFixedRoundToInt32 (bBox.top) <<":" << ASFixedRoundToInt32 (bBox.bottom) << ":" << ASFixedRoundToInt32 (bBox.left) << ":" << ASFixedRoundToInt32 (bBox.right);
                //AVAlertNote(os.str().c_str());

  • How to get the position of a tag in XML,when i am using the org.xml.sax

    Hi,
    I am able to parse a xml document.I want to get the position of a tag in the document.So that by keeping that as reference, i can access other tags.Plz help me.I am using org.xml.sax API.

    Hello Friends
    After research , I could also find another way to check the existence of a node .We can even use CHOOSE to check the existence.
    <xsl:choose>
          <xsl:when test="(/mynode)">
              your action if the mynode is found
          </xsl:when>
          <xsl:otherwise>
                    action if mynode is not found
          </xsl:otherwise>
    </xsl:choose>
    Thanks.
    Wishes
    Richa

Maybe you are looking for

  • Unable to load data store in a new model

    Hi, I have Win XP Pro SP3. MS SQL 2008 which has adventure works DW2008R2 database. I have oracle data integrator. I have created a physical and logical schema and have established a connection with my MS SQL 2008 and the test connection is successfu

  • How do extract one page from one pdf document and save as a new pdf?

    How do I extract one page from a pdf document and create a new document?

  • Cumulative Key Figure (Running Total) - how to use in formula?

    We have a scenario where I need to use the cumulative value of a Key Figure in a subsequent formula. The “Cumulated” property setting at the Key Figure level in the query is a “Displayed Data Only” setting, however, so the cumulated values are not av

  • Spain VAT ID

    Hi All, user is trying to give the VAT ID for a spain customer as ESJ41725920 and the sytem says the VAT registration number is invalid. When i check the same in T.Code Oy17, the length of the VAT registration number is 11 and checking rule is 3 and

  • Tab setting in JTextPane

    Hi, I am going to develop an simple XML editor which will provide following functionalituies. * Automatic Indentation * Highilight attributes of given schema * Tag Validation. I decided to use JTextPane. 1) Is It right choice for Rich Text Support ?