getWidth() and getHeight() bizarre behavior?

Good guy, what I'm doing wrong here.
Group myGroup;
Label CompassLabel;
//  doing new for all.

//add label to the group.
myGroup.getChildren().add(CompassLabel);
CompassLabel.setText("360");
So I have a label and add it to a group.

Then I do the following:
 System.out.println(CompassLabel.getWidth() + CompassLabel.getHeight());
they return both the value 0.0

If I do this:
Node nodeN = myGroup.getChildren().get(0); //The Label
if (nodeN instanceof Label)
{
                        Label label = (Label) nodeN;
                        System.out.println(label.getWidth() + label.getHeight());
}
This gives:
26.27734375 // Returned Value for width
32.27734375 // returned Value for height
Why is this? Thank you, best regards.

MiPa is correct.

After you have created the label and before question you its dimensions, you don't give up control to run JavaFX so that he can make a pulse of rendering on the label that defines the height and width properties. The impulse of rendering is necessary because the dimensions of the label will depend on the stuff as if it were inherited css attributes which are calculated during the processing of the pulse.

You can use a binding - quick and easy declaration for one a small number of relationships.

CompassLabel.layoutXProperty.bind(new SimpleDoubleProperty(xStart).subtract(CompassLabel.widthProperty().divide(2)));  // not compiled code you might need to tweak it for syntax errors.

Or subclass group, override layoutChildren and make your layout code in there, making use of things like the prefWidth calculations. It's good if you want to create your own control as components
http://docs.Oracle.com/JavaFX/2/API/JavaFX/scene/group.html#layoutChildren)
http://docs.Oracle.com/JavaFX/2/API/JavaFX/scene/group.html#prefWidth (double)

Or you can make your layout so that it depends on the width.

Or, instead of a group of deaf, you can use a layout manager as a VBox that automatically manages the layout resizing and placement for you questions after that you put up with content and relevant constraints. It's the solution of choice in many cases

Or you can delay questioning the width until you are sure that this node has been rendered. For example, to create the first scene - after a stage.show () method is called. Or perhaps listening to the impulse to occur or on a timeline for finishing late (although I would not recommend the listener or pulse timeline approach if it can be avoided).

Tags: Java

Similar Questions

  • Clones of Windows 2008 r2 with bizarre behavior

    Hello

    We just wanted to share a bizarre situation that we came up with a scenario of several clones of Windows 2008 x 64 r2 web edition.

    Here it goes:

    First, we use the ESX 3.5 U5/VC with the latest updates.

    We get 4 clones (parent 1/3 of them created using VCenter/1 of them created manually) divided into different ESXs. Following the recommendation of the brand, we have not changed the SID again.

    Now the bizarre behavior:

    Whatever actions you do on the last clone of (5), it will change the content of its parent. It's like having a fill. disk, the cluster or real time shared between them.

    For example:

    If you go to Manager services IIS and make all the changes on a Site, these changes appear thoughtful on the parent in real time.

    If you put two users, one on each clone, the tasks as one of those users do on his clone automatically replace what has changed the other user.

    Any of you could offer us a reasonable way to the way to understand.

    For us, it makes no sense and break the logic of good sense.

    Thanks in advance.

    Hello

    My intuition was wrong - you have not linked clones.

    Virtual machines must be independent of VMware side of things.

    You have this IIS home directory on a network share? -C' is the only other idea I might explain such behavior

    _________________________

    VMX-settings- WS FAQ -[MOAcd | http://sanbarrow.com/moa241.html]- VMDK-manual

  • Target and trigger a behavior strange reversal

    I searched around forums but you have not found this problem or resolution.

    I was hoping to use a reversal on the ToolTip widget event to have balloons pop up explaining certain elements of a chart. I followed the example of Rufus in the video. I created originally the ToolTip so that everything was visible, organized correctly, then tried to make the points of reversal with no fill.  More specifically some of the things that happened (and none of them systematically):

    • The first access point has been defined "no fill" and then verified in preview - seems good
    • The second hotspot has been set to "no fill" then checked preview - now known th it returned to gray and the second was gray too.  However, when I saw and turning spots, the reactive truns of transparent grey and the ball appears.  So if I overthrow the next spot, the first goes back to opaque gray and the other is now transparent.
    • I tried to simply change the color in green on a third hotspot just to see if there was a problem of transparency.  Nope.  When you preview, the spot is still gray, but when I place turning it turns green, and the ball is triggered.
    • Even in design mode, the new color will not be displayed, it remains just gray.  I can change the colour, say green, and it will display properly, until I click on an another hot spot to change its color.  The hotspot previous poster then as gray.  If I then click back to this place, it lights up new green.  So Muse knows it is supposed to be green but it will not display.
    • Finally, I have five points in a row.  When the mouse above left to right one of the hot spots will be transparent turns and stay, when I smile and then from right to left it grey turns again.  If it wasn't weird enough, then when I roll from left to right and left, then right again, it will remain transparent.

    I tried to set a color and the opacity to 1% as suggested in another thread, but it has not yet changed the color of the hot spot.

    Could someone please help with this problem.  I see other problems with viewers etc., but this one is quite perplexed because of the random appearance.

    I tried to try another on a blank page just for confirmation and the same behavior that's happened.

    All I want is for the hot spots of trigger transparent and stay like that.

    Thanks in advance.

    Jeff

    Hey,.

    Please take a look here: http://aad6a8dasda7das9d.businesscatalyst.com/default1.html and let me know if the behavior for the first hotspot is what you need in your case. This is controlled from the "Status" window: http://screencasteu.worldsecuresystems.com/Cristi/2012-05-07_1815.png
    If you have a test site where I can see that the hotspot in question please let me know. I think my explanation above should fix this problem.

    If there is something different that you are after, and I missed that informed me.

    Kind regards

  • Insert and update server behaviors in the same form

    I have a php form that is inserted into a table and then update another table. I have the form of inserting the record first and then I want to update the other table. I'm starting to learn and understand PHP, but I don't know how to have the update function to run after that it inserts the records. I guess that's something like if you insert this disc, then update this record and then go to the redirect page. I know this goes to redirect page after it inserts the record, but I don't know how to tell him not to go to the $insertGoTo. I want him to run the following update function and then go to the $insertGoTo and not the $updateGoTo. Thanks in advance for any help.

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['CompId'], "int"),
                           GetSQLValueString($_POST['empfirstname'], "text"),
                           GetSQLValueString($_POST['empmiddleint'], "text"),
                           GetSQLValueString($_POST['emplastname'], "text"),
                           GetSQLValueString($_POST['EmpType'], "text"),
                           GetSQLValueString($_POST['EmpStatus'], "text"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error());
      $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . "";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s",
                           GetSQLValueString($_POST['CompanyType'], "text"),
                           GetSQLValueString($_POST['CompId'], "int"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error());
      $updateGoTo = "purchases.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
      
    }
    
    

    PHP code is executed from top down and is controlled by the conditional statements ('if' blocks). To achieve what you want, you need to combine the conditional statements that control the insert and update server behaviors and to move the redirect to the end of the code. Amend as follows:

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['CompId'], "int"),
                           GetSQLValueString($_POST['empfirstname'], "text"),
                           GetSQLValueString($_POST['empmiddleint'], "text"),
                           GetSQLValueString($_POST['emplastname'], "text"),
                           GetSQLValueString($_POST['EmpType'], "text"),
                           GetSQLValueString($_POST['EmpStatus'], "text"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error());
    
      $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s",
                           GetSQLValueString($_POST['CompanyType'], "text"),
                           GetSQLValueString($_POST['CompId'], "int"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error());  
    
      $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . "";
    
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    
  • Find and replace using behaviors

    I used search and replace in CS3 to add HTML code that includes a behavior of DW. The behavior opens a popup message when clicked.

    Find and replace works and adding the behavior code correctly. However, when I save the page and then click on the link to test the behavior, the popup does not appear.

    The only way I can get the behavior to work properly must complete the find and replace, double-click to open the behavior of the Tag group, close the behavior and then save the page again.

    Is this a problem of DW or I do something wrong?



    have you also added all necessary css or javascript on pages so files?

  • Display.getWidth () and Display.getHeight () does not

    I have added two variables public static int in the main class (large public static Sub and I initialize these variables in the class as Main() constructor):

    w = Display.GetWidth ();

    h = Display.GetHeight ();

    I have no error, but when I try to use these variables of a class of the screen, it returns 0 (the original values are - 1). I don't know what is happening.

    Thanks for your help.

    I'm going to do some experiments to see if I can reproduce this. I don't think that this should happen. But I would recommend this place anyway:

    Add (new LabelField ("w =" + Display.getWidth () + "h =" + Display.getHeight ()));

    Who should have the desired behavior.

  • Quizzing bizarre behavior and by killing the preference folder

    I asked this before...

    I have a machine that when I try to import questions quiz it keep the bottom of the first quiz question and post it on all the remaining slides.  It does this to empty slides as a result of the questions on the quiz too.  I have disabled all circles and I tried to put a different master slide on the quiz questions, nothing worked.  I erased the cach and I think it was Rod Ward, who suggested killing the preference folder, but when I wrote asking how to do that I don't have an answer.

    I would like suggestions.

    Susan

    Try the instructions in this thread:

    http://forums.Adobe.com/message/3490686#3490686

    Also try disabling all the Compression options in the preferences and if it still does not respond, try the optimized quality of all slides or high quality.

  • How to make the Java panel.getWidth () and panel.getHeight () in JavaFX?

    What is the equivalent syntatically?

    Thank you!
    var panel = Panel {
         content: []
    }
    
    println(panel.width);
    println(panel.height);
    
  • Firefox crashes (and other strange behaviors) due to gifs

    From a recent update Firefox displayed a strange behavior that surrounds the gifs. Sometimes, after viewing pages with a large number of gifs or several very large gifs, Firefox will do things like not animate gifs, or even do not load the images at all, an and will not stop until I have restart Firefox. What's more concerning is that sometimes in these situations, Firefox will simply hang and stop responding, forcing me to kill the process.
    This page shows the behavior of hanging fairly regularly: http://www.neogaf.com/forum/showthread.php?t=1021843 & page = 21
    It seems more likely to happen when I scroll the page quickly. The behavior persists when I restart Firefox mode without failure.

    39 of Firefox seems to have solved the problem.

  • Recent bizarre behavior of Firefox, safe mode doesn't help not, any help is welcome

    I have used Firefox for a while now, since Firefox 3, but my browser has recently ben having a very odd behavior. While browsing, Firefox suddenly crashes (work in the background or cursor busy", then"continuous normal navigation". It also has problems with playing youtube video. Video load properly, start playing, but suddenly the spirits of reading 'on the fly' and fills the bar of progress at a glance, returning the message "an error has occurred" or behaves like the video had finished playing (although she never finished reading).
    Tried to uninstall flas player, cleaning the registry errors and errors in program after uninstalling, restarting, reinstalling the adobe Web site. It did not work. I tried Safe Mode (without pluginns) doesn't work anymore. same weird behavior.
    It's a brand new installation of Firefox (I had problems with the other 4 months ago).
    I'm naïve at the moment on which resides the problem causing this strangeness.
    I ask for your knowledgeable help.
    Thanks, if more details are required, I will be happy to write them.

    -> Cache and delete Cookies

    -> Clear Cache network

    -> Firefox crashes or does not - how to fix

    Check and tell if its working.

  • After Windows Update, is now silent erratic speaker (flickers power button) and sometimes erratic behavior of the mouse

    I noticed a few days after the restart after an update of Windows (a few weeks of updates at the same time evidence) on my old laptop Dell M60 when I hit the mute button would begin just flashing power continuously, but there is ore that turned off.  I restarted and it has always given this behavior, so I turned off the laptop and decided to watch it later.  Today, I had a friend send me an email on their desktop PC indicating that they have the same problem.

    Does anyone else know this? Identified/fixed?

    Hello

    Download the latest sound/audio driver and if not more recent re - install the same. Please use the instruction manual
    as we explain.

    Control Panel - device - SOUNDS - look for HD Audio Manager - Mine said RealTek High Definition Audio

    Make sure you write down the description and model double click top - tab drivers - write version. Now
    Click on update drivers who cannot do anything like MS is far behind the certification of drivers. Then RIGHT
    CLICK above and UNINSTALL - REBOOT - this will rebuild the driver stack.

    1. go to the system manufacturer's website and search for the driver the newest download - SAVE - will click with the button straight on and RUN AS ADMIN
    (This is your rescue.) REBOOT after each installation of driver.

    NOTE: Driver Sound often rollback so check the version after installation and reboot to see if the version you
    installed is there, if not repeat - restart until it is. It may take several tries depending on the recommitments how he
    the fact.

    Then do the same for the site of the manufacturer of the device.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    How to install a device driver in Vista Device Manager
    http://www.Vistax64.com/tutorials/193584-Device-Manager-install-driver.html

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • Why the edges of the layer of a text layer bizarre behavior?

    I'm stuck on this. When I create a text layer in Photoshop CS5 and then finds the edges of the layer, and I can't understand why the edges of the layer are actually in the text itself. It is not extending the edges of the layer out to the real edges. This caused enormous problems in trying to align text layers before the rasterize the layer.

    Can someone explain to me why Photoshop behaves in this way? And there at - it a way to make it stop? For reasons too go in, I can not rasterize the layer at this point. I need to be able to snap everything first.

    I was able to force a similar look by choosing bizarre settings in my character Panel.

    You have the type of Point or area?

    If you can't find the correct settings, either reset the text tool or reset all tools. Go to your control panel (top panel). Right click on the text tool. Select the reset tool and all the weird stuff will disappear for the tool. Reset all the tools to put them all back to their default values.

    What is fix?

  • The Add links and add server behaviors are grayed out and not usable.

    Good evening everyone,

    As indicated in the title, I am trying to add a record set to my project, and it is not giving me the option.  First of all, let me tell you what I use:

    Dreamweaver CS6

    XAMPP server running PHP and MYSQL

    Shows connection to the database and can be used in Dreamweaver.

    Site is built in PHP, and a .php page is currently being developed.

    Everything I have read during the last hours 3 research that said I should have links to a + link, unfortunately I do not have.

    No idea where the problem fixed so that I can continue on with the design of the site?

    Thanks in advance,

    James

    Well, I'm not sure if this is a permanent problem or not, but if other people with this problem can't seem to find an answer, try this one and let me know if it works for you.  I got antsy waiting for a response and just start playing with everything I possibly could, and that's what I did.

    When I clicked on the links, the + is grayed out, but gave me some options on how to do.

    Said one of these options to set up the test server with the words "test server" sites in blue.

    I never clicked this option, because my test server has already been put in place, and showing as connected, but I clicked on it in any case.

    He opened my server that was already there in, I hit then save... and voila!  All of a sudden, my bindings and behavior of server + worked!

  • Bizarre behavior "alignment".

    When I move a text box with the arrow, in that there's room for about 4 or 5 clicks then suddenly snaps a big jump to another position.

    Same thing when I'm setting attack with a keyboard command - the main value indicates that it is changing in increments of 2 but there is no movement until after that 4 or 5 click then it fits as a factor of 10.

    I disabled "Snap to grid of document", but this did not remedy the problem. There is no baseline shift or any other attribute type which should cause this jerky behavior. The only feature that I have on is "Snap to guides" but it is something different entirely and more turning power off does not alter behavior problems, I'll have.

    InDesign as magically update and activate some hidden snap functionality that was not found? Oddly enough, I noticed this problem just today on two different computers. My home desktop computer, then a computer in an office where I get it. Documents on the two totally different systems do the same crazy thing!

    Please notify.

    Sounds to me like the text is printed to line up on the starting grid.

    Bob

  • ViewStack and Transitions or behaviors?

    Hello

    I'm trying to find out how can I implement a form of transition or behavior when I work with a Viewstack. I now change the viewstack using the selectedChild = home; or selectedChild = username; and when I do that I want to apply a transition or behavior if possible. I've seen examples of this using view States, but ask yourself what can I do if I do not use view States

    Thank you

    -Westside

    You can configure the effects and use them on every child, give each child his own effect as it is in sight:




    ...

    Whenever the ViewStack changes a child it will use the child show and hide effects.

Maybe you are looking for

  • Impossible to listen to music using Windows Media Player 12.

    Original title: Media Player 12 After the extraction of a lot of lp to media player. All he's trying to do is rip music. Even when I put it just plays the cd.  When you try to view pictures in Windows Media Player. It plays all my music. And some how

  • Update KB976902 now the mouse doesn't work does not correctly

    I had the KB976902 recently updated on 2 of the 3 computers and 2 who got now have a mouse that does not correctly.  The computer number 3 does not have the update and still works fine.  All three are almost identical hardware and software and have l

  • Some web pages redirects to the Questscan search engine.

    Original title: Scan of quest How can I get rid of Questscan? It does not appear to be installed on my computer. He was not in the list of programs, when I tried to use execute with C:\Program Files\Q =uestScan\uninstall.exe a box came it's nowhere t

  • Book order button is gone in sales, purchase order

    Hi Experts,I'm working on EBS R12, as a command, order book button is missing, can someone help me is it profile or what could be the reason.Kindly help as soon as possible.Thank youRambeau

  • What version of android Adobe form CC will install on?

    I have a lot of android devices, but Google Play Store says that none of my devices are compatible. What is the minimum version required? Do you intend to release a compatible version more or I'll get to the root of my Tablet for that to happen?