How To Keep Track of Component Location Within JTextPane

I'm inserting JComboBox's into a JTextPane (to allow the user to construct paragraphs), and using the insertComponent(Component) method. After the user selects the JComboBox's, I can't find any way to find the JComboBox's current location. I need to be able to convert the current text plus the selected strings within the JComboBox plus store the last configuration so I can pull it up in the future.
The JComboBox's can easily be shifted around by additional text added or deleted via the keyboard. I know I can at least use a ComponentListener to find out if the user deleted the JComboBox. The only thing I can think of is to use a KeyListener on the JTextPane to keep track of all the Component locations. This seems a bit tedious as they'd all (could be 10 or more in one JTextPane) need to be updated with each keystroke rather than just getting their location at the end.
Does anyone have any ideas on a better way to track the location?
Thanks

So that's exactly what I did but Position has a problem when the component is located at an index of 0. I created a test program and posted it here: http://forums.sun.com/thread.jspa?threadID=5444569 . If you have any advice camickr (or anyone else), I'd greatly appreciate it. I started capturing all the exceptions to write special cases to track when the component is moved to 0 but there's a ton of possibilities (backspace, cut, delete, etc).

Similar Messages

  • How to keep track of what I've previously draw

    They said:
    Everytime the paint method is called, everything that was drawn before must be redrawn. The paint method has no way to keep track of what you've previously drawn, it is your responsibility as the programmer to keep track of such things.
    Is this right?
    How can keep track of my random shades of random amounts?
    Is there a simple way to do that?
    In a example, I must use getGraphics to get JPanel's graphics, then I use it to random draw something in the JPanel.
    I just want to keep them in my JPanel when it resizes.I haven't get the answer yet.
    Can you help me?

    Ok I haven't got time to write the code for you, but here's the idea:
    //User drags mouse around to draw on screen
    //use mouseActionListener to catch MouseDragged event
    int x = mouseEvent.getX();
    int y = mouseEvent.getY();
    Point p = new Point(x,y);
    arrayListOfPoints.add(p);
    // end mouse action capture
    //override paint method of component
    public void paint(Graphics g){
        super(g);
        Iterator it = arrayListOfPoints.iterator();
        while(it.hasNext()){
            Point p = (Point)it.next();
            g.drawLine(p.getX(),p.getY(),p.getX(),p.getY())   

  • How to keep track of how many times a link has been clicked?

    How to keep track of how many times a link has been clicked or accessed? Do I need to use database for this?

    Hi
    Proably something like this can work,
    1> Have a servlet/bean invoked when the link is linked
    2> have a static variable in that servlet/bean wich gets incremented before the control is passed to another desired page..
    The problem with this approach is that care has to be taken that the servlet/bean is not re-instalised, in case of which the static variable will also be instalised and the data would be lost.
    The best thing is to store the count in the database.
    Regards
    Arathi.

  • How to keep track of the users who are all currently logged in

    Hi All,
    I have basic knowledge of Session and Servlets. I am wondering how to keep track of the users who are all currently logged in. There should be some way of achieving it.
    I thought of it and come up with having an Application variable that hold it when ever a user successfully logged in.
    Thanks in advance for any reply.

    You can do this by keeping data in a static veriable in a some class of yours. The variable will need to be a collection.
    Whenever a user loogs in to the site a servlet/jsp should put the users information in to the collection and when logs off or when the session expires the entry should be take off.
    You can achive this by storing the velues in a some sort of a week collection where the entries are automaticaly removed when all the other refferences to the entry goes out of scope.
    You might need to read bit about java.lang.ref package and WeekReference
    Or you can make the entry in the collection contain the last time that the user visited any of the pages and a thread can run time to time and clean up the older entries which have timed out

  • How to keep track of the changes done in ALV GRID Report

    Hi Experts,
    how to keep track of the changed record in ALV GRID Report. how to set the field to be editable even for the entire row also. Can anybody guide along with code also?...
    Valuable answers will be rewarded.
    Thanks,
    Satish.

    Hi,
    Access the table through SM30. It comes blank as standard. Click "New Entries" and make entries for changes to be tracked. For example, whenever an org. unit changes 002 and 003 relationship, you will make entries like:
    01 O 1001 B002 Activate box checked
    01 O 1001 B003 Activate box checked
    Here, 01 is your active plan version, O is org. unit, 1001 is infotype and B002 and B003 are the subtypes. You can also use * for infotype and subtype which means every change will be logged.
    If you then run the report RHCDOC_DISPLAY through SA38, it will pick up all the changes pertaining to B002 and B003 relationship for org. units (in the above example).
    Similarly, you can set up this table for other object types.
    For more information, follow SPRO>Personnel Management>OM>Basic Settings>Activate change documents and go through the documentation for that node. Also, read up the documentation for the report.
    Hope this helps.
    Donnie

  • How to keep Track of the wagetype Changes

    Hi Experts,
    How to keep Track of the Changes after changing the wagetype values.If any body has made changes to the existing wagetype, how do we keep a track of what changes has done, is there any standard Tcode through  which we can get the information.
    Thanks in advance,
    Regards,
    Magesh.S

    Hi,
    Access the table through SM30. It comes blank as standard. Click "New Entries" and make entries for changes to be tracked. For example, whenever an org. unit changes 002 and 003 relationship, you will make entries like:
    01 O 1001 B002 Activate box checked
    01 O 1001 B003 Activate box checked
    Here, 01 is your active plan version, O is org. unit, 1001 is infotype and B002 and B003 are the subtypes. You can also use * for infotype and subtype which means every change will be logged.
    If you then run the report RHCDOC_DISPLAY through SA38, it will pick up all the changes pertaining to B002 and B003 relationship for org. units (in the above example).
    Similarly, you can set up this table for other object types.
    For more information, follow SPRO>Personnel Management>OM>Basic Settings>Activate change documents and go through the documentation for that node. Also, read up the documentation for the report.
    Hope this helps.
    Donnie

  • How to keep track of changes made for a particular Inq Doc number.

    hi all,
    my senario is as follows :
    the requirement is to send mail every time we take print for a sapscript for inquiry ..however the header and the body of the mail will change depending whether the user created a new inquiry doc or changes an existing doc. how to keep track of the changes.
    please give me some suggestion.
    thanks in advance
    Srinivas

    its time cosuming process :
    check table CDHRD/CDPOS tables to keep track of changes.
    Regards
    Prabhu

  • How to keep track of the sequence of the BSP Pages being invoked.

    Hi,
    How to keep track of the sequence of the BSP Pages being invoked.
    I have a BSP Page A.htm. There are two other pages B.HTM and C.HTM in the same BSP Application.
    The page B.HTM has a link A.HTM. The page C.HTM also has a link A.HTM. On clicking  these links the Page A.HTM would be invoked. Is there any way to keep track which BSP Page  (i.e B.HTM or C.HTM) invoked the page A.HTM.
    Any input on this Regard would be of great help.
    Thanks and Regards,
    Pavithra

    Hi Pavithra,
    Declare in page attributes:
    appl_url type string
    In the onClick event of the link that calls the A.htm page , use:
    call method runtime->get_url
    receiving
    URL = appl_url.
    Now appl_url contains the url (also name) of the page that invoked A.htm .
    Hope it helps.
    Anubhav.

  • How to keep track of emails btn Blackberry & Outlook???

    Hi,
    I'm considering buying a Blackberry Curve (Sprint).  My hangup thus far is that I want to have all of my sent emails in my Outlook on my home computer.  My solution thus far has been to use GoToMyPC so that I can connect to my home PC from any computer and take care of my emails.  Also, I work mostly from home, so this isn't a huge problem in terms of convenience and efficiency. 
    Most people tell me that they CC themselves when they send an important email from their Blackberry.  This is how they keep track of important emails sent from their Blackberry.  IS THERE ANOTHER WAY?  A MORE RELIABLE WAY?  IS THERE A WAY TO HAVE ALL EMAILS SYNC'D WITH OUTLOOK WHEN (THEORETICALLY) SYNCING MY BLACKBERRY WITH MY HOME COMPUTER?  IF NOT, WHAT IS THE BEST WAY?
    Thanks in advance,
    Gary 
    Solved!
    Go to Solution.

    I have two (2) EMails addresses; on is my blackberry address, and the other is my Outlook.  I mostly give out my Outlook address so I could have it on my PC at home, and when Isync it is there,. Or, in the field if I inadvertantly delete a message, I know it will still  be on my PC at Home. I think your friend is correct. If she has the Blackberry
    Enterprise System through her IT Dept. at work. I have the BIS (Blackberry Internet Service).
    I hope this helps. It is quite confusing
    Writer~
    Thanks,
    Writer~

  • How to keep track of last song played?

    Hi!
    Does anyone know how to keep track of which song played last time before itunes was closed? I have a big list of songs in my playlist and I play it everyday while I'm working. If I shut down my computer and start it again the next day, I have to manually look for the song I played the previous evening. Is there a way where it will keep track of the last song and play it from that?
    Thanks
    JB

    Subwaygirl, welcome to the Mac family! I'm not sure whether you're asking about beginning to play from the last song played on your iPod or iTunes so I'll answer both.
    From the iPod, simply hit Play and it will begin at the next song. It cannot go back to the last song played.
    From iTunes, use my answer to Chris to add the Last Played column, sort by that and select the song at the top of the list. That is your most recently played song. If you hit the >> or Next button you will then go to the next song in the randomly-sorted list.
    Powerbook G3 Mac OS X (10.3.9)

  • How to keep track of which checkboxes are checked

    I have 21 checkboxes on a scene and want a user to have to
    pick at least four of them, i will then use the ticked checkboxes
    to bring data back from a database. My question is how do i keep
    track of which checkboxes are clicked so i can put them in to a sql
    statement like this?
    select * from table where title in (checkbox1, checkbox2,
    checbox13);
    And how do i make sure the user has picked four boxes before
    being allowed to leave the current frame?
    EDIT: sorry this is probably in the wrong forum it should go
    under basics, but instead of posting the thread there can someone
    please reply to it here, thank you.

    i am using flash component checkboxes, i tried to come up
    with my own way to do this i am doing different:
    on CheckBoxState -- name of custom handler
    TickedBoxes = [] -- a empty list will be filled where ever a
    checkbox is ticked
    CheckBoxNames = ["dr no", "from russia","goldfinger",
    "thunderball", "you only live" ]
    -- the above is a list containing the names of all my
    checkboxes
    repeat with i = 1 to 5 - repeat for each checkbox
    CurrentCheckbox = CheckBoxNames
    -- used to keep track of which box is checked this sets
    currentcheckbox to value of i, i is a checkbox from checkboxname
    list
    if the hilite of member(CurrentCheckbox) then -- if
    currentcheckbox hilite is true (checked)...
    append(TickedBoxes, CurrentCheckbox) -- ... add
    currentcheckbox to the tickedboxes list
    end if
    end repeat -- end repeat
    return TickedBoxes -- return the list of checked boxes
    end
    on mouseUp me -- on mouse click
    choosenBoxes = me.CheckBoxState() -- chosenboxes is a
    variable calls the handler on it
    -- will put sql here
    end
    this is the only script i have which is attahced to my
    submit button, but for some reason when i try to trace the results
    in the message window it always return void can anybody tell me
    what i am doing wrong?

  • How to keep track of an iterator?

    Hi everyone.
    I'm having an issue trying to keep track of an interator in a tree map.
    Basically my application is an address book, and it has the following button:
    First Prev Next Last
    So if they press the first button it will run the following code:
      Collection c = treeMap.values();
            //obtain iterator for tree map
            Iterator iter = c.iterator();
            //get first item in the list
            Contact temp = (Contact)iter.next();This works fine.
    But now I'm trying to get the Last element in the tree and then assign a "global" iterator to it, infact all the buttons should have an iterator that will keep track of where the current element is...and thats where I'm having problems with.
    So if I get the first element when someone presses the first button, I would like to now assign an iterator to that position, so if someone presses the Next button, I would just do iter.next(); and then display the information .
    The problem is though, I also need to go back 1 element if the user presses the Previous button...is there a way to go forward and backward with an iterator?
    I have an internal iterator keeping track of things but I get an error, like for example:
      Collection c = treeMap.values();
             int count = 0;
            //obtain iterator for tree map
            Iterator iter = c.iterator();
            while(iter.hasNext() && count < treeMap.size()-1)
                count++;
                iter.next();
            trackIter = iter.next();trackIter = iter.next();
    I want trackIter to point to whatever iter.next() is pointing at, which in this case, is the last element in the list but I get an error here saying:
    found : java.lang.Object
    required: java.util.Iterator
    trackIter = iter.next();
    Any ideas?
    Thanks

    First of all your bug.
    Iterators return Objects.
    What kind of object it returns depends on what you were shoving into the Map. If you shoved a Dog into the map, then the iterator returns the Dog, but the Iterator and the Collection only knows that it is an Object, not that it is a Dog. Your code that needed to get a Dog back, needs to cast the result returned by the iterator as a Dog
    trackItem = (Dog) iter.next();
    However, before you haul off and fix your code, twould be best to fix your design. Your question, "is there a way to go forward and backward with an iterator?" is a good question. Before I tell you the answer, let me ask you a question? What are you going to do if the answer is "NO - you can't go forward and backward"
    I mean, it's OK to hack and slash around, trying this and that, but generally it would be good to know the answer to that question BEFORE you write a bunch of code involving iterators, because when you find out that you CAN'T go both forward and backwards with an iterator, what are you gonna do. Are you going to leave part of the design working one way, using iterators for going next and then some totally different mechanism to go the other way? Of course you could do that, but that is not really how one arrives at good design, by first hacking out one feature until you can get it working and then turning you attention to the next and hacking out a different bunch of code.
    Observe that Collections can be converted to Arrays and that Arrays have indicies and moving forward and backward in an array is a simple matter of incrementing or decrementing an integer and testing if you fell of the end. Also arrays, having no particular order restrictions can be sorted, or re-ordered any way that you like. How much easier your problem would be if only you had an array instead of a Collection.
    Don't take the criticism of your design the wrong way. I actually like the idea of using something like an iterator for your buttons, but the thing you are using is not really an iterator. As you said it must go both ways. It is really more like a text cursor where you can advance forward and backwards over a list. So build a Cursor class that you can hand an array. Give it routines like, first(), last(), mid(), stepForward(), stepBack(), getCurrent(), getIndex(), setIndex().
    And then you ask yourself, "before I write this code - let me see if someone has already written it." you look up Cursor in the API. Nope, there is a cursor class, but it is for crossHair cursors and the like. Then you ask yourself, "What else could they have called this?" How about ListIterator. Bingo - there you are, an interface class that has hasNext, hasPrevious, ... But it is only an interface. It doesn't do anything. What kind of class would implement this interface? Maybe List, so you look up List. Drat, it is some disgusting awt component. Oh wait, there's another interface, List, and there on the "All known Implementing Classes" you see LinkedList, ArrayList and others.
    Cool. You can reduce a collection to an array, if you could get an array into one of these list types, you could have your interface all built for you and everything, or if it isn't exactly what you want, no big deal, you already know the interface you need, you can just build it, whatever reduces your effort.
    See how it works? And just for the record, I didn't know about ListIterators, when I started typing this. But I know a design principle that helped me find it. I don't grab a component that I know and see if I can make the system work with the thing that I know. Instead I think of what I want it to do, try to design the interface for what I want it to do and then, once I know what I want from a structural standpoint, I start groveling around to see if that thing already exists.
    You were almost there. When you asked if an Iterator goes both forwards and backwards. And the answer is, "No"
    I see that others have posted before I finished writing this tome. Reversing the array and creating an iterator for that list will not get you the behavior that you are in some state, at some place in the list, from which you can go either forward or backwards. It just gets you a way to go backwards through the list.
    On the assumption that you are a student attempting to learn something, I would suggest that you actually do both approaches. Using the ListIterator approach is what you would do in a production environment (I just need this one behavior and it already exists over here) but you will probably learn more if you implement your own cursor class as I described above. The point is that you have a chunk of functionality, knowing where you are in a list and being able to step either forward or backward, that you want to achieve. The way that you get some chunk of functionality is that you design and build a class that lets you get that functionality. Iterator is NOT that class.

  • How to keep an image "in place" within a document using Pages?

    Here's what I want solved. When I position an image (like a jPeg photo) within a document I take a great amount of care as to how it looks in the layout. BUT, if I add a new line of text ABOVE the image, all the text moves, but the image stays in place. When the text above moves down, any kind of "art direction" is lost.
    Yes, I know there is a way to "LOCK" the image, but that doesn't solve this issue. The formatting still moves all the text and the image is stuck, LOCKED or UN-LOCKED.
    I want to know if there is a way to KEEP THE IMAGE in place within the text. I want to be able to edit above the image and not have the headache of needing to move the image every single time I change something above it.
    Does this make sense?
    I have to assume there is a way to do this, I just haven't figured it out.
    I am using Pages 09.
    thanks,
    Mike C

    (a little bit more)
    This text below is from the Pages help menu, but (sadly) This does NOT solve my problems.
    Locking and Unlocking Floating Objects
    You can lock floating objects to avoid inadvertently moving them as you work. Inline objects cannot be grouped or locked.
    After you lock individual or grouped objects, you can’t move, delete, or modify them in any way until you unlock them. However, a locked object can be selected, copied, or duplicated; when you copy or duplicate a locked object, the new object is also locked.
    To lock a floating object:
    Select the objects you want to lock, and then choose Arrange > Lock.
    To unlock a floating object:
    Select the objects you want to unlock, and then choose Arrange > Unlock.

  • Can I keep track of the location of my lost iPhone using the lost mode in Find My iPhone even after the sim is removed?

    My iPhone 5 is stolen, but luckily I had Find My iPhone enabled on iOS 7. The device is currently online(cellular is on) but location services are off. Is there any way to track its location.
    Furthermore, if I turn on the lost mode and the thief turns off cellular data, would I be able to keep track its location?

    Unless you enabled Find My iPad on it before it was stolen then there isn't any way to locate it. If you did enable it then you could try locating it either via http://icloud.com on a computer or Find My iPhone on another device - but that will only work if it's connected to a network and the device hasn't already been wiped and/or Find My iPad disabled on it.
    If it was stolen then you should report it to the police. You should also change your iTunes account password, your email account passwords, and any passwords that you'd stored on websites/emails/notes etc.
    If it was never registered to your account then it won't appear on your support profile : https://supportprofile.apple.com/
    The only other ways to find it that I know of (apart from on the actual device) are via the packaging, the backup on a computer's iTunes : http://support.apple.com/kb/HT4061

  • How to keep track of how many records to display in a page.

    Hi All:
    I am using Weblogic 9.2, Web Services Client, and Struts.
    I have a java client in struts that calls a web services.
    The "ID" field contains a Java integer.
    The "First_Name" is a Java String.
    The "Effective_Date" field is a Java date field.
    The web service returns an arrayList of a class called Result.
    Code for Result.java:
    >
    public class Result
    int id;
    String first_Name;
    Date effective_Date;
    public int getId
    return id;
    public void setId(int id)
    this.id=id;
    public String getFirst_Name()
    return first_Name;
    public void setFirst_Name(String first_Name)
    this.first_Name = first_Name;
    public Date getEffective_Date()
         return effective_Date;
    public void setEffective_Date(Date effective_Date)
         this.effective_Date=effective_Date;
    From the arrayList, I displayed the result as the following:
    ID FIRST_NAME EFFECTIVE_DATE
    3 John 9/10/2007
    2 Andrew 1/11/2006
    5 Peter 3/4/2006
    The "ID" header is a link.
    The "First Name" header is a link.
    The "EFFECTIVE_Date" is a link.
    If I clicked on the link "ID", the first time, it will sort the rows in ascending
    order like the following:
    ID FIRST_NAME EFFECTIVE_DATE
    2 Andrew 1/11/2006
    3 John 9/10/2007
    5 Peter 3/4/2006
    If I clicked on the link "ID", the second time, it will sort the rows in descending
    order like the following:
    ID FIRST_NAME EFFECTIVE_DATE
    5 Peter 3/4/2006
    3 John 9/10/2007
    2 Andrew 1/11/2006
    If I clicked on the "First_Name" field the first time, it will sort the rows in
    desceding order.
    If I clicked on the "First_Name" field the second time, it will sort the rows in
    ascending order.
    This applies the same for the "EFFECTIVE_DATE".
    If the arrayList returns 80 records of class Results.java.
    I needed to displayed only the first 50 records for the first page and 30 records for the second page.
    How do I keep track of that so that when I am in the second page, I know to display only record 51 to 80?
    If I have a arrayList that returns 120 records of class Results.java.
    In the first page, it displayed only 50 records.
    In the second page, it displayed only 50 records.
    In the third page, it displayed only 20 records.
    Assuming I am able to sort the rows by ID, FirstName and Effective_Date by using Results.java implementing the
    Java Comparator class. Is it still possible to keep track of how many records displayed in the first page and how many records should
    be dispalyed in the second page?
    Any hint would be greatly appreciate.
    Yours,
    Frustrated.

    Hi,
    Access the table through SM30. It comes blank as standard. Click "New Entries" and make entries for changes to be tracked. For example, whenever an org. unit changes 002 and 003 relationship, you will make entries like:
    01 O 1001 B002 Activate box checked
    01 O 1001 B003 Activate box checked
    Here, 01 is your active plan version, O is org. unit, 1001 is infotype and B002 and B003 are the subtypes. You can also use * for infotype and subtype which means every change will be logged.
    If you then run the report RHCDOC_DISPLAY through SA38, it will pick up all the changes pertaining to B002 and B003 relationship for org. units (in the above example).
    Similarly, you can set up this table for other object types.
    For more information, follow SPRO>Personnel Management>OM>Basic Settings>Activate change documents and go through the documentation for that node. Also, read up the documentation for the report.
    Hope this helps.
    Donnie

Maybe you are looking for

  • Animated GIFs are ridiculously large - why?

    Hi all, I cannot figure out why the animated GIFs I am exporting are so massive in file size. For example, I import a small 5-frame 650Byte GIF. I edit the size of the canvas to pad it to a square (from 54x40 to 54x54, or something like that), then I

  • Document page numbers in pages palette?

    I just jumped from CS to CS5. I work in magazine spreads most of the time and would like the pages palette to reflect my document page numbering. All I can get it to show is 1, 2, 3, etc. with 1 starting on the LEFT page of the thumbnail spread, wher

  • Error in SM58 on r/3 side in idoc to jdbc scenario

    Hi Experts, I am sending the idoc from R3 to XI, in r3 side idoc successfully created and status is 03, but when check in sm58 it is complaining about user name and password. but the problem in rfc destination to xi system, when i click on remote log

  • Itunes 11.1 upgrade from itunes version 10.6.3, OS v. 10.6.8, will not work

    Please help if you can.  Bought a iphone 5s.  Need itunes 11.1 to activate and backup.  Needed to upgrade the OS to 10.6.8 from 10.5.8 on older macbook pro.  Installed sucessfully.  Downloaded itunes 11.1 from apple site.  Installed it.  Installer sa

  • Transaction Launcher to open an ECC transaction

    Hi Experts, My requirement is to launch an ECC transaction VA01 from CRM Interaction center. 1. It should open the VA01 screen with the Order Type populated, say for example 'OR'. 2. When I click on Continue, it should show the creation screen with t