When location of component changed on screen?

Hi,
I have Code that brings up a message in a JDialog under a JTextComponent. I calculate the bottom - left point of the TextComponent and set my Dialog to show up there. However I have a problem keeping it there when the window moves, the TextComponent moves or One of it's parents moves.
I need something that will tell me when the location on screen of the TextComponent changes.
Thanks,
Shaul

AncestorListener#ancestorMoved seems to work just fine.import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
public class TestGUI {
   public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
            new TestGUI().makeUI();
   public void makeUI() {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(400, 200);
      frame.setLayout(new FlowLayout());
      frame.add(new TextFieldWithPopup(10));
      frame.add(new TextFieldWithPopup(20));
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
class TextFieldWithPopup extends JTextField {
   JWindow message = new JWindow();
   private JLabel label;
   public TextFieldWithPopup(int columns) {
      super(columns);
      addFocusListener(new FocusListener() {
         @Override
         public void focusGained(FocusEvent e) {
            message.setVisible(true);
         @Override
         public void focusLost(FocusEvent e) {
            message.setVisible(false);
      label = new JLabel("This is the popup");
      label.setOpaque(true);
      label.setBackground(UIManager.getColor("ToolTip.background"));
      label.setBorder(new LineBorder(Color.BLACK));
      message.add(label);
      message.setAlwaysOnTop(true);
      addAncestorListener(new AncestorListener() {
         @Override
         public void ancestorAdded(AncestorEvent event) {
         @Override
         public void ancestorRemoved(AncestorEvent event) {
         @Override
         public void ancestorMoved(AncestorEvent event) {
            Point p = getLocationOnScreen();
            message.setSize(getSize());
            message.setLocation(p.x + getWidth(), p.y + getHeight());
}db

Similar Messages

  • When i try to change my screen saver on my Mac 10.7.2 Lion, i hear a clicking noise on my computer and then it gets hung. Please help

    When i try to change my screen saver on my Mac 10.7.2, i hear a clicking noise on my computer and then it gets hung. Please help. Off late my computer is taking too long to open documents etc.

    If you hear a clicking noise, as in mechanical I'd be thinking along the lines of failing hard drive. Especially as you mention other problems.
    Boot from another disk if you have one and do a verify disk or use somethinglike Disk Warrior or Tech Tool.

  • How do I quickly update the ActiveX automation references in my VIs when the ActiveX interface changes?

    Hello all,
    I joined a test automation team in the middle of a large project and
    inherited a huge set of VIs (over 700) and associated architecture for
    this automation (not to mention the several thousand TestStand
    sequences).  Another part of the project is being developed by our
    customer, who is using VB 6.0 to create ActiveX components which we
    need to use in LabView to access their hardware.  They've already
    invested a large amount of time developing these ActiveX components,
    and they are not finished -- meaning the ActiveX interfaces will be
    changing.  Every time they send updated ActiveX components, I have to
    re-write many, many VIs including updating a couple strict typdefs. 
    This process takes way too much time and is mind-numbing and prone to
    error or omission.
    Unfortunately I can't post any of the VIs because of a NDA.  But
    perhaps a bit more detailed explanation would help.  TestStand calls a
    VI to open and get an ActiveX reference for automation (which it stores
    in a variant).  It will pass this reference into any VI it calls to
    perform specific functions through this ActiveX interface.  For
    example, one VI that may be called passes this automation refnum into
    another, which passes it to another, which passes it into another to
    get the actual ActiveX reference stored in that variant (through a
    Variant To Data call with a strict typedef of the ActiveX component
    wired to the type input).  [See the attached image of this sample VI
    hierarchy: the far left icon would represent TestStand, and the far
    right is the strict typedef.]  Any of the VIs in the chain might use
    ActiveX Property or Invoke nodes, and it can break at any one of those
    when the ActiveX component changes.  It's easy to fix each one, but
    since there are so many VIs it takes a very long time.
    Is there any way at all to do a massive search/replace or something to
    make the ActiveX references update?  I realise that even though
    property or method names stay the same from one version to the next,
    they are different references.  Is there a way to update these based on
    name if you give it the base ActiveX reference?
    Thanks in advance for any help!
    Tom Williams
    Attachments:
    hierarchy.GIF ‏6 KB

    Ben,
    Unfortunately I can't post any VIs that would demonstrate the problem
    because the ActiveX components are confidential.  I'll try to develop
    my own ActiveX dll that will demonstrate it, but in the meantime, in
    hopes that another picture will help, I've attached an image of a block
    diagram (with some names changed to protect confidential information)
    of one of the lower level VIs from the hierarchy I posted.  In this
    example, the "Automation Refnum IN" is an input with a type definition
    linked to the strict typedef based on the ActiveX automation dll that
    has changed.  I updated that typedef, but as you can see the output to
    the "Class1" indicator is broken.  If I delete the "Class1" indicator
    and select Create->Indicator from the Class1 property node, and then
    wire the new "Class1" indicator to the connector pane, the VI is fixed
    -- at least at compile time.  In most cases there is also a runtime
    problem where the reference obtained by one of the intermediate
    property nodes is null, so the property or method node that uses it
    fails (e.g. "_VNManager.Networks" property returned is 0, so the
    "_Networks.Network1" property node fails).  To fix this problem, I have
    to delete the wires between the property nodes, and one by one select a
    different property/method, then select the correct property/method and
    re-wire.  There seems to be a bit of "jiggling the handle" to get it to
    work though.
    I don't know if the ActiveX developer changed anything in this class,
    but if he did, he didn't change the name of this class.  I would like
    to have to modify the VI only if a class, property or method has
    changed name or been removed.
    Does that all make sense?  Thanks for any pointers or help!
    Tom
    Attachments:
    Class1_Path.GIF ‏7 KB

  • I have the same case with you an iPad Air in dead pixel or speckle silver dust on screen.  It is been 3 months I bought in Avant Abenson in Greenbelt Makati Philippines. Today I decided to change my screen protector film but the speckle dust on the screen

    Speckles dust on the screen and it cannot be removed today when I decided to change the screen protector film and noticed is not my fault it is a factory defect on screen it is either dead pixel or speckle dust on screen they are so many said and experience I have read.  So I need the replacement a new one for that dismayed screen on my iPad Air. I bought this 3 months ago in Avant Abenson at Greenbelt Makati Philippines.  I need the replacement for tomorrow I will go to the store I bought.  I love apple products but they need to replace and make go round to improve some defects and cannot be more escalate with this issue of the many of patronizing your products.  It is sometimes irritating to the eyes and seen dirt on the screen.  Thank you apple customer service to bringing up my complaints and a replacement for tomorrow's to inform the store I bought and advise them here in the Philippines to facilitate in regards to this matter. 

    I wanted to buy an ipad air to replace my ipad 2 but the one I wanted was (luckily) sold out.
    Yesterday I tested the air from a collegue and I noticed the screen was SUBSTANTIALLY less sensitive than the screen of my ipad 2 when using my stylus.
    I use Stylus R US especially for I annotate and with the air this did not work well at all... Half of the time there was no contact registered so underying certain parts of the text was a disaster...
    Just working with the finger all whent OK... Just fear that another app I use a lot (notes +) will have same problem.
    On the Ipad 4 also retina all goes *** smooth as on my ipad 2...
    Is this a fault of a specific ipad air series? Or is this normal?? If it is I think this is truelly a huge flaw and I cannot see how not manny people using the ipad for notetaking etc did not notice this...

  • New computer at work and all my song are on the server-when I try to change the folder location under preferences to the server, it still won't show my songs in Itunes?? please help!

    I have a new computer at work and all my song are on the server-when I try to change the folder location under preferences to the server, it still won't show my songs in Itunes?? please help!

    Howdy carpetjim,
    When you change the folder location like that, it changes where new songs and media are stored. To actually load the library you need to do this:
    Steps to create or choose a different iTunes Library file
    If iTunes is running, quit iTunes.
    If you are using Windows, hold down the Shift key and from the Start menu and choose All Programs > iTunes > iTunes.
    If you are using the Mac, open iTunes and immediately hold down the Option key.
    You should see one of the following screens:
    Additional information
    If you do not see one of the screens above, then you did not hold the correct key at the correct time. You may want to try again. Note that if you pinned iTunes to the Start menu programs, and open it that way, it may not work.
    From: iTunes: How to open an alternate iTunes Library file or create a new one
         http://support.apple.com/kb/ht1589
    Take care,
    Sterling

  • I updated to iTunes 11 on my Windows PC. Since the update, when I open iTunes its window is too large for my screen. Resizing is a pain, because I have to change my screen resolution. And when I restart iTunes,it has reverted back to being too large.Help!

    I recently updated to iTunes 11 on my Windows PC. Since the update, each time I open iTunes its window is too large for my screen. Resizing it is a pain, because I have to change my screen resolution. And then when I restart iTunes, it has reverted back to being too large. Please help!

    Having the same issue here....a quick fix is to just minimize the window, and immediately maximize it.  It will now fit the screen.  Trouble is, after you close it, you'll have to do it again when you re-start itunes.  The good news is it takes all of about 2 seconds.  Apple should fix this.  Should.

  • I dropped my iphone vertically on the ground. The screen is normal when it is locked. but when unlocked, it is broken down from the clock. Can it be fixed and is it under the warranty conditions? If not how much is the price to change the screen?Thanks

    I dropped my iphone vertically on the ground.The screen works when it is locked.When unlocked, it's broken down from the clock.Can it be fixed and is it under warranty conditions?If not how much is the price to change the screen?Thanks

    User damage is not covered by warranty unless you have Applecare +
    assuming you do not,  the out of warranty exchange price for an iPhone 4 is $149,exchange at an Apple Store genius bar
    iPhone 4 are not repaired they are exchanged

  • I can't change video resolution on youtube. When I try to change it, it goes to 240p and the screen is black and the vid doesnt play.

    Hello, I have this problem.
    Recently I noticed, that when I try to change the quality of the video from the default 360p to whatever one, the quality will jump to 240p and the video wont run. There will be just black screen.
    I tried resetting the browser and it did not fix my problem.
    I tried the same video in internet explorer and the quality change worked normally.
    How could I fix this?
    Thanks

    Clear the cache and cookies only from websites that cause problems.
    "Clear the Cache":
    *Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox/Tools > Options > Privacy > Cookies: "Show Cookies"

  • My lock screen picture is zoomed in. When I try to change it, I can't scale it, or try to zoom out to a position I like. It is permanently stuck in one position. I asked a friend that had ios7 and he can't relate, and has never seen it before

    My lock screen picture is zoomed in. When I try to change it, I can't scale it, or try to zoom out to a position I like. It is permanently stuck in one position. I asked a friend that had ios7 and he can't relate, and has never seen it before. Any help will do

    To back to the normal scale you have to disable the parallax.
    Settings -> General -> Accessibility -> Reduce Motion (turn off)
    You won't be able to put the wallpepr out of frame as ios 6 (earlier), but it stop to putting the annoying zoom.

  • Agentry: Trigger action when changing main screen tab

    Hi,
    I'm adapting Work Manager for iPad and in my main screen I have 4 tab screens: Work Orders, Notifications, Time Sheets and Crew Manager.
    I would like to trigger a List Selection action step when the user navigates to the Time Sheets tab in order to select the current day of the week automatically. I already created and tested the action with a button and it's working fine but I don't find a way to trigger an action when changing main screen tabs.
    Here my main screen:
    In the screen definition there is not much I can define... just the icon, size and styling...

    Ok, thank you both, the question has been answered
    Regarding Bill suggestions I think there are too many possible actions in the main screen where to apply the selection step.
    And to apply Jason's workaround I need to do a major UI change and user's are too familiar now with the solution that has been in production for a while...
    I think I will set the date after transmit. It won't work on the initial load and when user manually selects a different day and comes back to the tab, but I think it will cover more than 90% of application uses since they are supposed to synchronise every morning and register time for the current date usually.
    @Jason: I hope you can tell the idea to the engineering team

  • BOM Component changes when changes done in VC

    Hi All,
    When ever we are changing the characteristic values in Variant configuration, it result the component changes in the BOM.
    Please any body let us know how to find the what are the component changes in the BOM when we change any characteristic value in VC. Is there any FM or it will store in any table?
    Regards,
    Vasu.

    Sure Vasu,
    Find explanation on  this as below :
    BOM components are selected by making use of a special type of dependency called SELCETION CONDITIONS.
    If you want to find which BOM components will be selected on selecting which characteristic value, then follow the below given procedure :
    1. goto T.Code CS03.
    2.enter BOM header name , plant etc. and press enter.
    3. now you are in inside BOM.
    4. Select any BOM component for which you want to check when will it be selected during configuration.
    5. then, in top menu , choose  Extra --> Object Dependencies --> Assignments
    6. It will display all Object Dependencies assigned to that BOM component.
    7. Select the Dependency with type Selection Condition.
    8. Click on Dependency editor.
    9. It will show you the Dependency code
    10. when the condition as per this code is satisfied, the component is selected during configuration.
    Please revert back if you have any doubt.
    Reward Points.
    Regards,
    Gaurav Raghav.

  • Windows 7 Screen Resolution not changing at all when I try to change settings. I ve lost my ToolBar on internet for settings ( deletion of cache) Please help me to reset screen.

    Windows 7 Screen Resolution not changing at all when I try to change settings. I ve lost my ToolBar on internet for settings ( deletion of cache) Please help me to reset screen. The screen seems to have slipped or moved to the right. Only icons on left of
    screen showing. I Need to regain The right side of the scree
    I have tried everything I know to sort this out. Thankyou you in advance. Katy Nanna x

    Hi,
    When you set your monitor to a screen resolution that it won't support, the screen will go black for a few seconds while the monitor reverts back to the original resolution.
    Regarding screen resolution, we may follow the below two articles to change it:
    Change your screen resolution
    Getting the best display on your monitor
    Follow the steps below:
    1. Open Screen Resolution by clicking the Start button, clicking
    Control Panel, and then, under Appearance and Personalization, clicking Adjust screen resolution.
    2.Click the drop-down list next to Resolution. Check for the resolution marked (recommended). This is your LCD monitor's native resolution—usually the highest resolution your monitor can support.
    And if the monitor is LCD monitor, The monitor's  manufacturer or reseller should also be able to tell you the native resolution for your LCD monitor.  Or we may check the monitor's manual to adjust.
    Best regards
    Michael Shao
    TechNet Community Support

  • IMac freezes when changing the screen saver

    Hi all:
    I originally posted this in the "Using Mac OS X" forum (iMac freezes when changing the screen saver, but thought I'd post here as well since the issue arises on a freshly installed OS.
    We've got three 350MHz slot-loading G3 iMacs (with 512MB RAM) which we're planning to use for basic word processing. The install of Panther (10.3.5 from black retail cds with 10-seat volume license) went fine on the first two. Ran the updates to 10.3.9, installed MS Office 2004, everything working great (they're a little slow, but after all, they are only 350 MHz).
    On the third, the first problem we noticed was the computer would lock up whenever we changed the screen saver from the default (Flurry; Computer Name also works). It continues to do so even after: repair permissions; repair disk; Disk Warrior; reset pram; reset nvram; reset pmu; change RAM; change hard drive; erase hard drive; write zeros to hard drive; reinstall with different set of retail CDs; trash preferences, and delete cache files. (If there's anything I've left out, it's in the other thread).
    Now we've noticed that we can't create any new user accounts. We've thought about putting this one in production, just warning the user that they can't change the screen saver, but god only knows what will turn up next.
    I'm starting to think it's a logic board issue, but could it be that selective? And would you see the same problem with another hard drive and different install discs? Am I missing something?
    BTW, there's a crash log with the other thread.
    Andrew
    Dual 2.0 GHz G5   Mac OS X (10.3.9)  

    I'm going to mark this one as answered.
    I removed the hard drive from the iMac, and put it into another 350 MHz iMac, and everything works great. I can select any screen saver without having it freeze, create new accounts, whatever my little heart desires.
    In checking the history of the problem iMac, there was an assortment of problems with booting (both from the hard drive and from the CD-ROM drive) which were never satisfactorily resolved. The problems just seemed to go away after sitting unplugged for a few days, as much as for anything we actually did to it.
    Now we just have to decide whether it's worth fixing, or using it somewhere in a non-critical role with OS 9 installed.
    Cheers,
    Andrew

  • TS2755 Azerbaijan (+994) missed as location (??!!) for imessage and FaceTime? When you enter to "change location", no Azerbaijan amongs the region?!!

    IOS7...Azerbaijan (+994) missed as location (??!!) for imessage and FaceTime? When you enter to "change location", no Azerbaijan amongs the region?!!
    +994 phone number is disappeared !!!

    Why no one from Apple support team still didn't replied to this question? It is really problem for Apple Azerbaijan users which I'm pretty sure are more than above mentioned two countries.
    I hope Apple support team will investigate and find the solution for this problem and satisfy Apple users in Azerbaijan.

  • Component changes when changes done in VC

    Hi All,
    When ever we are changing the characteristic values in Variant configuration, it result the component changes in the BOM.
    Please any body let us know how to find the what are the component changes in the BOM when we change any characteristic value in VC. Is there any FM or it will store in any table?
    Regards,
    Vasu.

    Hi Anji,
    Thanks for your reply.
    The above FMs are returning only the characteristic changes. But i need to to find the Changed Components in BOM if the characteristic value changes. Plese give any other FM if you are having.
    Regards,
    Vasu.

Maybe you are looking for

  • How do you change your apple I d on an iPhone 5s

    When my husband got his new iPhone 5 S, he used my Apple ID just to get on so they could show him how to do something's on the phone that required a Apple ID. They told him how to change it to his when he got home, and yea you guessed it.  He forgot.

  • Mac Pro won't be put to sleep

    Hi, My mid 2010 mac pro refuses to sleep.  It may be to do with some universal audio drivers installed with a recent hardware interface I've added, but maybe not. I'm running 10.6.8 on a 2x 2.4 GHz Quad core Intel xeon with 32 GB RAM. Whilst I don't

  • Facetime is missing once i restored from backup.

    I just got my new iphone4, when i don't restored backup from my old iphone3g, it will have the facetime settings but once i restored the old backup into the phone, there will not have the facetime settings at all in the settings.. KIndly help me.. Th

  • ZCM DLU Policy Not Applying To Win7 Computer

    I am running ZCM v10.3 and am preparing to migrate over to Active Directory. When I first setup ZCM, I created a DLU policy for my Windows 7 computers and its been working fine. However, its time to join my Windows 7 computers (running ZCM v10.3) to

  • Batch Sequences missing

    Why is Batch Sequences missing from my Acrobat > Advanced > Document Processing menu?