How to get JToolBar location

How can I find the current location of a JToolBar (NORTH, SOUTH, EAST, WEST or FLOATING) ?
I've searched the forums for an answer to this question and seen the question asked before but no answer given.
In short I have a situation where the contents of the toolbar need to change based on some application specific context. Currently I have a routine that returns the appropriate JToolbar. I'd like to be able to move the current toolbar and put the new one in the same place the old one was.
I could change the code to empty the existing toolbar and the repopulate it with the items required in the current context but I'd like to avoid that if possible because in the future I might want to cache toolbars. (It could still be done but you can't avoid the extra steps of having to clear and repopulate from cached specs rather than just using a cached toolbar).
Thanks !

Now for the question of the floating toolbar:
* This class is licensed under GNU public license.
* Original author: Marco Lopes ([email protected])
import java.awt.Component;
import java.awt.event.HierarchyListener;
import java.awt.event.HierarchyEvent;
import javax.swing.JToolBar;
* <p>Provides a JToolBar extension where it's possible to check wether the tool bar is
* floating or docked. Also, it provides a new property that can be listened by a
* PropertyChangeListener {@link #FLOATING}.</p>
* <p>In every HierarchyEvent where the parent is changed, a new property change event will be fired.
* Note that one event is fired in the begining telling that the tool bar is floating. </p>
* <p>This event is fired before the toolbar is processed and added to the parent and should be ignored.</p>
* @see java.beans.PropertyChangeListener
* @author Last modified by $Author: MLopes $
* @version $Revision: 1.4 $
public class ExtendedToolBar extends JToolBar
     /** the property fired to indicate a change in the status: floating(true) or docked(false) */
     public static final String FLOATING = "Floating";
     /** keeps the original parent reference */
     private Component originalParent;
     /** indicates whether the component is floating or not */
     private boolean floating = false;
     /** @see javax.swing.JToolBar#JToolBar() */
     public ExtendedToolBar()
          super();
          initComponents();
     /** @see javax.swing.JToolBar#JToolBar(int) */
     public ExtendedToolBar(final int orientation)
          super(orientation);
          initComponents();
     /** @see javax.swing.JToolBar#JToolBar(String) */
     public ExtendedToolBar(final String name)
          super(name);
          initComponents();
     /** @see javax.swing.JToolBar#JToolBar(String, int) */
     public ExtendedToolBar(final String name, final int orientation)
          super(name, orientation);
          initComponents();
     * returns true if this tool bar is floating.
     * @return true if this tool bar is floating.
     public boolean isFloating()
          return floating;
     /** adds a HierarchyListener to listen to changes in its parent */
     private void initComponents()
          this.addHierarchyListener(new HierarchyListener() {
               public void hierarchyChanged(HierarchyEvent e) {
                    checkParent(e);
     * checks if the parent has changed, means that the tool bar has been detached and
     * it's now floating.
     * The first event is used to get the original parent.
     * In every event, a new property change event will be fired. Note that one event
     * is fired in the begining telling that the tool bar is floating. This event is fired
     * before the toolbar is processed and added to the parent and should be ignored.
     * @param he the trigered hierarchy event
     private void checkParent(final HierarchyEvent he)
          if (originalParent == null) {
               originalParent = he.getChangedParent();
               return;
          if ( he.getChangeFlags() == HierarchyEvent.PARENT_CHANGED ) {
               if (originalParent == he.getChangedParent()) {
                    final boolean oldValue = floating;
                    floating = false;
                    firePropertyChange(FLOATING, oldValue, floating);
               } else {
                    final boolean oldValue = floating;
                    floating = true;
                    firePropertyChange(FLOATING, oldValue, floating);

Similar Messages

  • How to get the location of the browser?(pt_BR, en_US, es_ES...)

    How to get the location of the browser?
    example: pt_BR, en_US, es_ES...

    Hi Eduardo Cordeiro,
    Sorry in reaching you late...I was out on a trip...
    You need to put the javascript in your Flex application html wrapper file ...in which your  Flex application SWF is embedded.
    Write the Javascript function in your html file as below :
    function getBrowserLanguage()
      var browserLanguage = navigator.browserLanguage;
      return browserLanguage;
    //In your mxml File you can access the JavaScript function in your MXML as below:
    var browserLang:String  = ExternalInterface.call('getBrowserType');
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • How to get the location of a jarfile in the java 1.6 cache

    In 1.5 i am using getResource() to get the location of the jarfile i need, but in 1.6 this does not work anymore. I found a webpage with a workaround for this, but unfortunately i did not bookmark it and i can't find it again. Does anybody know how to get a file url instead of an http url to the jar file?
    I need the location to this jarfile. There is no other workaround and please DO NOT respond and tell me, that i don't need the location in the cache! I read all threads on the java forums to this issue and i didn't find a good answer.

    java.io.File class can be used.
    File f = new File("filename");
    S.O.P(f.canRead());
    S.O.P(f.canWrite());You can set the attribute using Runtime class.
    Runtime r = Runtime.getRuntime();
    Process p =r.exec("attrib -r file");If you are working with unix,
    r.exec("chmod -permissionoptions file");

  • How to get the location of a pageitem when there are pageitems with same UID?

    There are two text frames with same UID but on different pages( also defferent spreads ). What I want to know is how I can get the location of them both.
    The following code can only get the location of the first frame because the second frame has the same UIDRef with the first one(because they are in one document with same UID) .
        InterfacePtr<IGeometry> splineGeo(ItemRef, IID_IGEOMETRY);
        PMMatrix itemPMMatrix = ::InnerToPasteboardMatrix( splineGeo );
        PMRect  itemPMRect = itemGeo->GetStrokeBoundingBox( itemPMMatrix );
    Is there any way I can get the second frame location?
    Thanks a lot.

    No.
    Just copy the pageitems from master page to document page.

  • How to get the location of the last click.

    What I can't seem to figure out how to do is get the location of the last click. I'm not setting anything by using the click im using the click to test boundaries. Basically if I click within this area this happens if i click within this other area something
    happens, etc. Thanks for your help! Also feel free to say an easier way to do this if you know one.

    Your description about your issue is very vague but you could for example handle the MouseLeftButtonDown event for the "area" and then use the MouseEventArgs.GetPosition method to determine the coordinates of the mouse click relative to some element,
    e.g.:
    private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    Canvas canvas = sender as Canvas;
    Point p = e.GetPosition(canvas);
    double x = p.X;
    double y = p.Y;
    <Canvas Height="100" Width="100" Background="Red" MouseLeftButtonDown="Canvas_MouseLeftButtonDown">
    </Canvas>
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • How to get the location of the JMenuItem on the screen in actionPerformed

    How can I get the location of the JMenuItem on the screen in actionPerformed.
    When I use the function getLocationOnScreen() on JMenuItem or the object retruned by getComponent() I get IllegalComponentStateException.
    I have figured out that inside actionPerformed the parent of the JMenuItem which is JPopupMenu (that contains the JMenuItem) is not visible anymore (its isVisble() function returns false).
    Then how can I get the location on the screen of the JMenuItem or it�s popup menu such that I can use it in subsequent call to SwingUtilities.convertPoint(JMenuItem, int x, int y,frame), as I need to display a modal dialog box relative to the position of the popup menu in it�s frame.
    Regards,
    Janusz

    Thanks for reply.
    Unfortunately I have to figure out the location of the menu from within actionPerformed handler. At that point of time it is too late to overwrite JMenuItem. I probably could do some severe surgery in the code to implement my own JMenuItem derived class & overwrite processMouseEvent and pass the location attribute somehow to actionPerformed handler � but I am looking for some solution that would not require changes to the code outside actionPerformed handler.

  • How to get the location of the caret?

    Hello
    I want to get the location of the caret. Not the offset of the document.
    I have tried the Caret.getMagicCaretPosition(), but I think it gives me a point in viewport.
    How can I get the absoult location of the caret(the location on screen ,not in viewport)?
    Thank you very much.
    Best wishes

    Thankyou ,You reply seems to help me ,but I am still confused that this method returns void ,how can I get the result of the point on screen?
    When I want the caret location (the caret belongs to a JTextPane) on screen, I invoke :
    SwingUtilities.convertPointToScreen(textPane.getCaret().getMagicCaretPositon(),textPane);
    but how can I get the result of the convertion?
    Thank you!

  • How to get Functional Location of a Workcenter?

    Hi there,
    I am looking for a function that brings me the functional location to a given workcenter of an operation (production order).
    In our case this is a one-to-one relation. In transaction IL03 I can see the workcenter on Location-tab. But how to get this functional location only with a work center that I know?
    How is this possible?
    Kind regards
    JetGum

    check if this [works>>>|http://www.sap-img.com/abap/customized-work-center-list.htm]

  • How to get Folder Location by just providing folder name ?

    Hi,
    I want to get folder location by providing its name.
    I created one folder on "E:\" drive and when I used following code in netbeans it giving me the current loaction of java file.
    File directory = new File("SVN");
            boolean isDirectory = directory.isDirectory();
            if (isDirectory) {
                // It returns true if directory is a directory.
                System.out.println("the name you have entered is a directory  : "  +    directory); 
                //It returns the absolutepath of a directory.
                System.out.println("the path is "  + directory.getAbsolutePath());
            else {
                // It returns false if directory is a file.
                System.out.println("the name you have entered is a file  : " +   directory);
                //It returns the absolute path of a file.
                System.out.println("the path is "  +  directory.getAbsolutePath());
        }And i got following output
    the name you have entered is a file  : SVN
    the path is C:\Users\AjayS\Documents\NetBeansProjects\TestCodes\SVNBut my folder is located on "E:\" drive.
    Regards,
    Ajay

    You will have to search for them. But that indicates something seriously wrong with the requirement. In effect you're using the local filename as a secondary key but there is no index on it. You should consider a database.

  • How to get the Location of the Device

    hi all,
    I want to find out the Location of the MObile device.
    I am trying to find out with the help of the Location API which was available in the CLDC 1.1.I am using the following code to get the Location
    try{
         Criteria cr = new Criteria();
         cr.setHorizontalAccuracy(500);
         LocationProvider lp = LocationProvider.getInstance(cr);
         Location l = lp.getLocation(60);
         Coordinates c = l.getQualifiedCoordinates();
         if(c!=null)
         double lat = c.getLatitude();
         double alt = c.getAltitude();
         double lon = c.getLongitude();
         locate = c.convert(alt,1);
    }catch(Exception e){System.out.println(e);}
    I used a seperate thread to get the Location.The thread was running it was not diaplying any value(in the Emulator).Can anybody tell me the possible output when we use the Emulator.
    Please help me,Thanks in advance
    Lakshman

    hi,
    Even though the Nokia was the leaders of the JSR 179.but the Specification were developed by the sun.So to my knowledge the device which will support CLDC 1.1 will support my code.
    at present i had a Blackberry 7100t,I have to check whether the device support the CLDC 1.1
    can anybody please tell me what are the mobile devices that support the CLDC1.1?
    lakshman

  • How to get Current Location in a Android Emulator using Flex

    Hi
    In the following code I am able to plot the Location using Latitude and Longitude but the requirement is
    in an Android Emulator on launch of the application I need google map to display the users current location,
    How can this be achieved ??? I tried to get the Latitude and Longitude of the current position using
    geoLocation class by I am not able to get that working,
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark" title="Home">
        <s:layout>
            <s:VerticalLayout />
        </s:layout>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import com.google.maps.LatLng;
                import com.google.maps.MapEvent;
                import com.google.maps.MapType;
                import com.google.maps.controls.PositionControl;
                import com.google.maps.controls.ZoomControl;
                import flash.sensors.Geolocation;
                private var myGeo:Geolocation;
                protected function showBtn_clickHandler(event:MouseEvent):void
                    if(Geolocation.isSupported == 'true')
                        myGeo = new Geolocation();
                        myGeo.setRequestedUpdateInterval(100);
                        myGeo.addEventListener(GeolocationEvent.UPDATE, onUpdate);
                    else
                        myTextArea.text = "Device Not Supported";
                private function onUpdate(event:GeolocationEvent):void
                    myTextArea.text += "Hi"+ "/n"+ event.latitude.toString() + "/n" +
                        event.longitude.toString();
                protected function myMap_mapevent_mapreadyHandler(event:MapEvent):void
                    myMap.setCenter(new LatLng(24,58),9,MapType.NORMAL_MAP_TYPE);
                    myMap.addControl(new ZoomControl);
                    myMap.addControl(new PositionControl);
            ]]>
        </fx:Script>
        <s:Button id="showBtn" label="Show" click="showBtn_clickHandler(event)"/>
        <s:TextArea id="myTextArea" width="100%" height="50%" />
        <maps:Map id="myMap" width="100%" height="50%"
                  xmlns:maps="com.google.maps.*"
                  sensor="true"
                  key="ABQIAAAA2Fwy6HLBheYSAWRBEZKwEhRLum8XdHegG17d4EymNgK0o7h2qRRWVBVQywiGHEiGtKahjfGW8xxc RA"
                  mapevent_mapready="myMap_mapevent_mapreadyHandler(event)"
                  url="http://www.xyz.com"/>
    </s:View>

    Geolocation isn't supported in the Emulator. You'll have to set up a test case that gives the geolocation without relying on the Emulator.

  • How to get Storage Location and Vendor details in MD03 automatically

    Hi folks,
        We want to create automatic PR and PO from Planned Order.
    But when PR gets created in MD03, the values for Purchase organization, Storage Location and fixed vendor are blank, even after maintaining source list with fixed vendor .
    How to populate these values automatically ?
    I am also attaching screenshot of MD03 screen

    Hello
    If you are creating the orders using MRP, you should make sure that the field MRP is set to 1 on the source list. The field 'fixed vendor' is not relevant to MRP. When the vendor is selected from the source list, the purchasing organization should be also copied to the purchase requisition.
    The storage location will be copied from the respective field on the material master tab MRP2.
    Also take a look on the following document:
    MRP: Vendor is not selected and general problems on source determination
    BR
    Caetano

  • How to get caret location

    Hello reader,
    I think you are also enjoying java programming in summer. My problem is this i want to get the caret position in JTextPane so how can i get it. Plz tell me in detail.
    Thankyou very much.

    JTextPane p = new JTextPane();
    // The below line gives the current caret position
    p.getCaretPosition();

  • How to get location of 3D object in a hierarchy?

    It's easy enough to get the location of a 3D object at the root, but how do I get the location of a 3d object that is in a hierarchy?
    For instance, if I have a baseball player (biped - 3dsmax), grouped as "player" and exported to Director, how do I then get the location of the biped's hand?  (or the glove that is linked to the biped's hand).
    I tried just doing the basic...
    put member("BBplayer").model("glove").transform.position
    but director can't find the glove.
    It can find the root model "BBplayer", but not any child object.
    Anyone know how to get the location of a child object?
    Thanks!!

    I downloaded and installed that xtra and it really just shows the same info that I get in my object inspector.
    Ok, so for a biped and related skin/mesh/objects to export correctly to the .w3d file type, one has to select all the biped parts and related
    meshes into one Group.  This group then becomes the object in Director that all things are based from.  My charcter looks and animates
    fine in Director.  However, I still can't get coordinate information from anything inside this group or inside the hierarchy of this group, only
    the group itself.
    If I look at the group, either in the object inspector or the xtra you suggested, none of the child models appear under modelResources, model or group.  They simply don't show up as being in this group or the children to the group.  Nothing does except a few things that are useless, like "group("Bip01 Footsteps"), or some of the nubs, like headnub, fingernub and a couple of toenubs.  Why some nubs show up and some don't is yet another mystery.
    Anyhow, none of this makes logical sense.
    I simply want to "get" location information for any 3d model in the scene, regardless of what group it's in or the structure.  Anybody?  It has to be possible, this is a fundamental need of any 3D programming.
    Thanks!!!

  • How to get and use mouse information?

    I want to write a simple program for getting mouse location, and if the location of the mouse is within an area, then a red dot show on the screen.
    Could anyone please teach me how to get mouse location?
    Thanks

    http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html
    http://java.sun.com/docs/books/tutorial/uiswing/events/mousemotionlistener.html
    http://java.sun.com/docs/books/tutorial/uiswing/events/mousewheellistener.html
    Doh! Too slow!
    Message was edited by:
    DrLaszloJamf

Maybe you are looking for

  • [JS CS3] Setting the default layer

    I've been through the ID JS DOM, and I can't seem to find a reference for this...I think I'm missing something basic here. I've created two new layers via JavaScript: myDoc.layers.add ({name: 'manufacturers index', layerColor: UIColors.green}); myDoc

  • Using multiple vendors of raidus servers for backup

    is it possible to use ISA server as a primary radius server and steel belt as a backup. if so is there some documentation to use them together

  • How do I open up a form based on a query/parameter

    Can someone please tell me how can I open the form based on a query and the query is based on a pre-set value. Thanks. I am new to Oracle Form. Please treat me like a newbie. Thanks.

  • Kernel Panic During Time Machine Backups

    I get a kernel panic each time I try and backup using Time Machine.  It works fine for the initial backup, but after that each backup causes a kernel panic.  I thought the drive was going out, so I got a new one.  It still happens.  I have done disk

  • How do I get started with my new Mac and and Iphone?

    I had my Iphone synced with a PC that literally burned up unexpectedly. I replaced it with a Mac and want to sync my phone, however, when I click to manage content manually, a message pops up telling me that my phone will be erased (!!). Because I ha