Stage should respect minimum size of its content

Hi,
I wonder if there was a standardized approach to make the Stage inherits its minimum size from its content.
I tried to bind the Stage's mimimumWidthProperty to StackPane equivalent but without any success.
The only way I found was to 'force' the size by explicitly call stage.setMinWidth(), but this not really dynamic.
For information, the preferred size works fine and is well managed by the Stage.
Thanks.
If the following example, the Stage does not respect the minimum size set on the StackPane:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class TestMinSize extends Application {
    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        StackPane root = new StackPane();
        // set minimum size
        root.setMinWidth(200);
        root.setMinHeight(200);
        root.getChildren().add(btn);
        Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
}

The only thing that springs to mind is binding the properties to substract the decoration size of the stage.
But this wouldn't take into account if a child node of your root node has a minWidth/Height larger than the root's.
And generally this only works if root has a minSizeProperty, but Scene.getRoot() is a Parent.
primaryStage.minHeightProperty().bind(primaryStage.heightProperty().subtract(scene.heightProperty()).add(root.minHeightProperty()));
primaryStage.minWidthProperty().bind(primaryStage.widthProperty().subtract(scene.widthProperty()).add(root.minWidthProperty()));Or slightly more general:
public static void respectMinimumSize(Stage stage) {
     Scene scene = stage.getScene();
     if (scene.getRoot() instanceof Region) {
          Region root = (Region) scene.getRoot();
          stage.minHeightProperty().bind(Bindings.max(0, stage.heightProperty().subtract(scene.heightProperty()).add(root.minHeightProperty())));
          stage.minWidthProperty().bind(Bindings.max(0, stage.widthProperty().subtract(scene.widthProperty()).add(root.minWidthProperty())));
}Edited by: Dejay on Mar 10, 2013 5:56 PM
Edited by: Dejay on Mar 10, 2013 5:57 PM

Similar Messages

  • Folder size is twice that of its contents????

    Startup Disk > Users > Username
    My Username folder shows a folder size that is just about double the size of all of its visible folders.  I can see this when viewed in the Finder in List View with Folder Size Shown as my default View setting.    Any idea how I can figure out what is going on?
    thanks
    Brad

    Topher,
    Before I saw your reply, I emptied my trash and that brought the folder size down to what it should be to match its contents.  I should have remembered that.  None the less, I did what you suggested once I read your message and here it is:
    total 2240
    drwxr-xrwx  34 brad  503       1156 Feb 27 16:13 .
    drwxr-xr-x   7 root  admin      238 Dec  1 08:00 ..
    -r--------   1 brad  503          7 Dec  1 07:48 .CFUserTextEncoding
    -rw-r--r--@  1 brad  503      12292 Mar  1 16:22 .DS_Store
    drwx------   5 brad  503        170 Mar  1 16:42 .Trash
    drwxr-x--x   4 brad  503        136 Apr 19  2011 .adobe
    drwxr-xr-x@  3 brad  503        102 Apr 27  2011 .autodesk
    -rw-------   1 brad  503        546 Feb 15  2012 .bash_history
    drwxr-xr-x   6 brad  503        204 Aug 28  2014 .blurb
    drwx------   3 brad  503        102 Feb 27  2014 .cache
    drwxr-xr-x   4 brad  503        136 Feb 27  2014 .config
    drwx------   3 brad  503        102 Dec  6  2010 .cups
    -rw-r--r--   1 brad  503    1109647 Sep 23  2011 .fonts.cache-1
    drwxr-xr-x   2 brad  503         68 Jun 18  2013 .gs5
    drwxr-xr-x   3 brad  503        102 Sep  6  2011 .local
    -rw-r--r--   1 brad  503        239 Sep  6  2011 .mailcap
    -rw-r--r--   1 brad  503        368 Sep  6  2011 .mime.types
    drwxr-xr-x   3 brad  503        102 Dec 18  2012 .viewcd
    -rw-r--r--   1 brad  503         90 Apr 17  2013 .vuescanrc
    drwxr-xr-x   8 brad  503        272 Jun 26  2014 .wapi
    drwxr-xr-x   4 brad  503        136 Dec  4 12:23 Applications
    drwx------@  3 brad  503        102 Dec 20 11:44 Creative Cloud Files
    drwx---rwx@ 40 brad  503       1360 Mar  1 16:48 Desktop
    drwx---rwx+  7 brad  503        238 Nov 12 18:30 Documents
    drwx------+  3 brad  503        102 Feb 20 16:42 Downloads
    drwx------@  4 brad  503        136 Feb 22 22:43 Google Drive
    drwxrwxr-x   5 brad  admin      170 Dec  7 18:07 Incompatible Software
    drwx------+ 66 brad  503       2244 Mar  1 15:07 Library
    drwx------+  5 brad  503        170 Sep 21 19:42 Movies

  • How can I set the minimum size the location bar should automatically resize to

    I have moved all of my navigation buttons, location bar and tabs to be in line. This has been done to maximise the available space on screen.
    This works perfectly with two or three tabs open, but once more tabs are opened the location bar automatically shrinks to allow for more tabs and becomes unusable. I want to set the minimum size the location bar should shrink to but I do not know how to do this.
    [http://www.mediafire.com/imgbnc.php/eed5749531b3081c43186f59492500e5f089c498c0372fb6fa797b7d697826806g.jpg Screen shot displaying automatically resizing location bar]
    Any help would be appreciated.
    Thanks.

    FBZP seems to be the only way to do the minimum amout setting in standard SAP.
    You can check the BTE (Business transaction event) 00001820 for excluding the low amount items in F110. Please search SDn on how to use the BTEs.
    Regards,
    SDNer

  • Is it possible to have symbol with its contents change in percent  size to adapt to screen changes

    I am trying to make a symbol that can adapt to the changing screen resolution or browser changes. I only need the symbol and its contents to change in percent size while maintaining aspect ratio. 

    Hi there,
      I believe this thread is helpful in making a Symbol's properties to be responsive. To my knowledge there isn't a way to change based on screen resolution. You could always use SVG images to help combat this, but SVG is not currently supported by all browsers.
    Making Symbols Responsive:
    http://forums.adobe.com/message/4757595#4757595
    Also, here is a post on best practices for images in Edge Animate:
    http://helpx.adobe.com/content/help/en/edge-animate/kb/best-practices-graphics-edge-animat e.html

  • Have JFrame respect the minimum size (stop resizing) - Partial solution

    Hi
    I remember I searched for a solution to make JFrame respect the minimum size of itself or it's components, but unfortunately there is no solution, at least not a satisfactory one.
    The force-a-resize-if-it-gets-too-small "solution" looks really bad so I desided to drop the whole thing.
    However I've been testing around with different Look & Feels and changing the layout, and what I discovered is that when setting setDefaultLookAndFeelDecorated(true) the minimum size is respected.
    I haven't seen anyone mentioning this I thought I'd post it here.
    import javax.swing.*;
    import java.awt.*;
    class RespectMinimumSize extends JFrame {
        RespectMinimumSize() {
         setMinimumSize(new Dimension(400, 400));
         setLocationRelativeTo(null);
         pack();
         setVisible(true);
        public static void main(String [] args) {
         JFrame.setDefaultLookAndFeelDecorated(true);
         JDialog.setDefaultLookAndFeelDecorated(true); // Works with JDialog as well
         Toolkit.getDefaultToolkit().setDynamicLayout(true);
         new RespectMinimumSize();
    }

    thanks - initial testing seems to work OK.
    (I had to add a panel, to be able to set minimum size to the panel)

  • Document/Stage size - Sizing to Contents not making sense

    Forgive this basic newbie question, but I have a Flash CS4 document and I am attempting to resize the stage to accomodate its current contents.
    When I do so, the stage becomes *much larger* than the apparent contents, and I am trying to figure out why. I have literally examined every frame of the animation, and selected every individual object to see if the selection bounds indicate a rogue "large object"...but none indicate this...what sort of things about the contents might cause this that I am missing? I don't have any motion paths that seem to account for it either.
    Thanks for any guidance,
    Bob

    Sorry - Again, very new here..I think the document does in fact have "Tweens" because I see dots on some of the layer timelines, and when I right-click on them there is a menu choice available "Remove Tween" (although I didn't explicitly create them - could that have been created as a consequence of applying one of the stock motion paths to an object?)
    Anyhow, are those possibly the culprit?
    I guess I could send you the file privately (I don't think the owner of the file wants it in a public location at this point as it involves a forthcoming product announcement).
    I do appreciate your help,
    Bob

  • Desktop Folders now restrict minimum size

    Desktop folders.
    Apple, and the world's technical press, celebrate, as they should all the great NEW features in Lion, and every OS upgrade,
    for the all the new an innovative great features.
    It is left to a small minority of people who need computers to get a day's work done, and whose voice is seldom heard by Apple,
    to encounter the endless surprises in great features that are put in the trash by Apple for no good reason. Each OS upgrade
    takes away great features, an Lion does this as well.
    The topic at this email is desktop folders.
    You could, until now, drag the folder border to encompass a single file name, whic I sometimes really like to do. NOW there is
    an arbitrary and pointless SIZE LIMITATION to how small you can make an open folder on your desktop. The minimum size
    is rather large, about the space for 10 files in list view.
    Why Apple engineers so gleefully and unapologetically trash great features while celebrating what they call new features
    is incomprehensible to me.
    Folder views in Lion are the sloppiest and most unpredicatble so far.
    For all of its celebrated innovation, Apple engineers also have a really long shadow of destruction and removal
    that is not encouraging, that is in many ways rather offensive, as it flys in the face of common sense
    and is a rotten spot in the endless posturing Apple makes about respect for their customers, in particular
    the long-standing base of users that have stayed with Apple when it was almost down the tubes. I have been
    an Apple user since OS 5 at least.

    Widen the grid spacing; however, if the name is still too long, it will display like that.
    Use List or Column view, or hover over the name and it will popup the full name.

  • Trying to understand  app info size vs package contents info size

    Help needed with a basic question:
    The disk space size shown in the info panel for an app: What is it a measure of?
    Does it represent, and should it be the same as, the size of the app's package contents folder?
    I have several apps whose sizes shown in their info panels are Much less than the sizes of their corresponding package contents folders.
    One example is:
    The info panel for Preview.app shows size: 40.7MB.
    The info panel for its Contents shows size: 70.2MB.
    What's going on?
    Thanks

    Glad to help:
    If you want to compare getinfo in terminal.app use the "du" command:
    du -ch /path/to/file
    example
    du -ch /applications/preview.app
    my readout:
    1.9M /applications/preview.app/Contents/MacOS
    292K /applications/preview.app/Contents/Resources/da.lproj/PDFDocument.nib
    8.0K /applications/preview.app/Contents/Resources/da.lproj/PDFSearchPanel.nib
    136K /applications/preview.app/Contents/Resources/da.lproj/PVImageDocument.nib
    8.0K /applications/preview.app/Contents/Resources/da.lproj/PVPDFPageNumberPanel.nib
    4.0K /applications/preview.app/Contents/Resources/da.lproj/PVPDFPostScriptPanel.nib
    448K /applications/preview.app/Contents/Resources/da.lproj
    292K /applications/preview.app/Contents/Resources/Dutch.lproj/PDFDocument.nib
    8.0K /applications/preview.app/Contents/Resources/Dutch.lproj/PDFSearchPanel.nib
    136K /applications/preview.app/Contents/Resources/Dutch.lproj/PVImageDocument.nib
    8.0K /applications/preview.app/Contents/Resources/Dutch.lproj/PVPDFPageNumberPanel.n ib
    444K /applications/preview.app/Contents/Resources/Dutch.lproj
    260K /applications/preview.app/Contents/Resources/English.lproj/MainMenu.nib
    {~cut 70% to save space~}
    136K /applications/preview.app/Contents/Resources/zh_CN.lproj/PVImageDocument.nib
    8.0K /applications/preview.app/Contents/Resources/zh_CN.lproj/PVPDFPageNumberPanel.n ib
    444K /applications/preview.app/Contents/Resources/zh_CN.lproj
    292K /applications/preview.app/Contents/Resources/zh_TW.lproj/PDFDocument.nib
    8.0K /applications/preview.app/Contents/Resources/zh_TW.lproj/PDFSearchPanel.nib
    136K /applications/preview.app/Contents/Resources/zh_TW.lproj/PVImageDocument.nib
    8.0K /applications/preview.app/Contents/Resources/zh_TW.lproj/PVPDFPageNumberPanel.n ib
    4.0K /applications/preview.app/Contents/Resources/zh_TW.lproj/PVPDFPostScriptPanel.n ib
    448K /applications/preview.app/Contents/Resources/zh_TW.lproj
    16M /applications/preview.app/Contents/Resources
    18M /applications/preview.app/Contents
    18M /applications/preview.app
    18M total
    Betsy7:~ kj$
    Kinda long, but very informative.
    Kj

  • Deleting a directory and its content

    Hi, I'm trying to delete a series of directories like this batch file does
    @echo Removing "%CD%\a"
    @rmdir /s /q "%CD%\a"
    @echo Removing "%CD%\b"
    @rmdir /s /q "%CD%\b"
    @echo Removing "%CD%\c"
    @rmdir /s /q "%CD%\c"looking at the api i found that it doesn't seem to have the option to delete a dir and its content, should i use a function like the one in thread:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=188034
    or would it be better to call the batch script with Runtime.exec()? The system is windows only so i don''t need to have compatibility with *nix shells ect.
    What do you think?

    Try this
    // CLASS:    FileUtil
    // FUNCTION: An extension of File which allows various file manipulations
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class FileUtil
        extends File {
       public FileUtil(File parent, String child) throws NullPointerException {
          super(parent, child);
       public FileUtil(String pathname) throws NullPointerException {
          super(pathname);
       public FileUtil(String parent, String child) throws NullPointerException {
          super(parent, child);
       public FileUtil(URI uri) throws IllegalArgumentException, NullPointerException {
          super(uri);
       public void deleteTree() throws Exception {
          ArrayList contents = new ArrayList();
          listContents(contents);
          File f;
          for (int i = contents.size() - 1; i >= 0; i--) {
          f = new File( (String) contents.get(i));
          f.delete();
       private void listContents(ArrayList files) throws Exception {
          listContents(files, this);
       private void listContents(ArrayList files, File dir) throws Exception {
          System.out.println(dir.getAbsolutePath());
          File[] newFiles = dir.listFiles();
          File newFile;
          if (newFiles != null) {
          for (int i = 0; i < newFiles.length; i++) {
             newFile = new File(newFiles.getAbsolutePath());
         files.add(newFiles[i].getAbsolutePath());
         if (newFile.isDirectory()) {
         listContents(files, newFile);

  • Sizing a TextView to fit its contents (e.g., tooltip, chat bubble, etc.)

    In Flex 3, with a Text component, I can make the component fit its contents (use case: multi-line tooltip, chat-bubble) so that I restrict the max width and the height grows as necessary.<br /><br />To do this in Flex 3, you need to patch the Text component, e.g.<br /><br /><?xml version="1.0" encoding="utf-8"?><br /><mx:Text xmlns:mx="http://www.adobe.com/2006/mxml"><br />     <!--<br />          Text fields do not wrap correctly as reported in this bug:<br />          https://bugs.adobe.com/jira/browse/SDK-12826<br />          <br />          This fix, suggested by Mike Schiff, fixes the issue, so that we can set a minWidth of 0, <br />          maxWidth, and width=100% and have speech bubbles correctly size themselves.<br />          https://bugs.adobe.com/jira/browse/SDK-12826#action_157090<br />     --><br />     <mx:Script><br />          <br />               override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {<br />                    super.updateDisplayList(unscaledWidth, unscaledHeight);<br />                    textField.wordWrap = textField.wordWrap || (Math.floor(measuredWidth) != Math.floor(width)); <br />               }<br />          <br />     </mx:Script><br /></mx:Text><br /><br />Then you can:<br /><br /><naklab:TextWithWrap<br />    htmlText="{someText}"<br />    width="100%"<br />    maxWidth="220"<br />    minWidth="0"<br />    fontWeight="normal"<br />    fontSize="12"<br />    color="#000000"<br />/><br /><br />I cannot find a way to do this with the TextView component in Gumbo. How would you recommend making a TextView component fit its contents and should I file an ECR on this or am I missing something? (Otherwise, how would you handle the use cases above in Gumbo?)<br /><br />Thanks,<br />Aral

    OK, the forum ate my code :(
    Not sure how to get it to display. Feel free to close the topic as it doesn't make sense. I'll ask elsewhere.
    Thanks,
    Aral

  • How to set the minimum size of app window?

    Hi JavaFX experts :)
    Is it possible to limit the minimum size of application window? What would be the JavaFX equivalent of the following SWING code?
            JFrame frame = new JFrame("Application Title");
            frame.setMinimumSize(new Dimension(320, 240));
            frame.setPreferredSize(new Dimension(640, 480));Preferred or initial size was easy (width/height), but what about the minimum size?
    Stage {
        title: "Application Title"
        width: 640
        height: 480
        scene: Scene {
            content: [
                // some content
    }Thanks!

    var stage: Stage;
    var stageWidth = stage.width on replace
        if (stageWidth < 640) stageWidth = 640;
    var stageHeight = stage.height on replace
        if (stageHeight < 400) stageHeight = 400;
    stage = Stage {
        title: "Application Title"
        width: bind stageWidth with inverse
        height: bind stageHeight with inverse
        scene: Scene {
            content: [
                // some content
    }It doesn't prevent resizing to smaller dimensions but it restores to minimal dimension if done.

  • Setting a JLabel's minimum size

    Hello,
    I have a container with a GridBag layout, and when I resize to a size wher everything fits its fine, but on the bottom of the window I have a JLabel, which can be quite large sometimes. When it is large, its minimum size is the length of the string, so when I resize its container i get some big ugly scroll bars and its contents dont get any smaller, although every other component can be much smaller.
    What I would like is for the JLabel to have a minimum size (say 100 pixels) and if the window is resized less than this, introduce scroll bars, otherwise just cut off some of the text, as the label isn't very important!
    I have tried loads of different stuff, the most obvious being JLabel.setMinimumSize(new Dimension(100,16)); but nothing seems to have worked, can anyone help?

             public void updateVideoInfo(){
              String str = " ";
              str = "  " + videoData.getCurrentCameraProperties().getDeviceName()+" at " + videoData.getWidth() + " by " + videoData.getHeight();
              videoInfo.setText(str);
              int width = this.getSize().width - play.getSize().width - stop.getSize().width;
              videoInfo.setPreferredSize(new Dimension(width-15,16));
         public void validate(){
              updateVideoInfo();
         }I did a quick work arround, which I had tried before but didnt work for some reason... but has now
    But this would be awfull to change If i ever add anything in the future so I will look at what you said!

  • Copy its content to show on onother window

    Hello!
    The Problem I'm having is:
    A list of all orders is shown on a view which is defined
    for. Click on a special button opens a new Window
    (external window) and this window should show the same list like the privious view once more.
    With other words it must contain the same content. To do this is
    it necessary to perform the whole program again or can I copy
    its content for showing on the external window. I'm very confused.
    This external window acts as kind of preview of the list.
    Or do you have other suggestions?
    Thanks
    Sas Erdem

    Hi Sas,
              It is better to have 0..n if there is any table or else better to have 0..1;
    Say View1--is your first view
    View2 --is your print view in external window
    your first doubt:Now Copy this node to View2 and map them both.
    How can I map two views to eachother?
    List-- newly created context node 0..n;
    Procedure:
    Select and right click the node List in View1 -> Select Copy
    Open context tab of Controller-> Paste the node (If it is not there already)
    Open data modeler .Map View2 to Controller. Wizard appears. Copy and map the node(just drag and drop from right to left)
    Open context tab of View1
    Do you mean context tab from external window ?
    I guess it is clear now.
    Copy all the values into this node from respective nodes or attributes.
    When I copy all this values from respective nodes or attributes why
    copying this node to View2 again ??
    I mean to say: "What ever values you want to display in print view you need to copy to node List. These values are stored in this List you can display them in print"
    regards,
    Siva
    Edited by: Siva Rama Krushna on Feb 6, 2008 1:57 PM

  • JDialog's minimum size

    How can I set a JDialog's minimumSize and preferredsize? There are no such setXXX() methods.
    I want to achieve that a user can enlarge a dialog but shrinking should be allowed only until the dialog has its minimum dimension.

    Thank you. I found any method handling resizing events neither in the WindowListener nor in the WindowStateListener interface. It seems s if you have to use the ComponentListener interface. This works pretty good although I would prefer that the resizing just stops when the minimum size is reached during resizing and not only when the dialog is released. For the time being the dialog can be shrinked as the user wants but it resizes itself to its default widht and height after the mouse is released.

  • I backed up my old core 2 duo imac and and was trying to transfer files to my new 2011 imac and when i go to oppen a folder from what i transferred it says "The folder "Music" can't be opened because you don't have permission to see its contents."?

    I backed up my old core 2 duo imac and and was trying to transfer files to my new 2011 imac and when i go to oppen a folder from what i transferred it says "The folder “Music” can’t be opened because you don’t have permission to see its contents".  Why cant i access the files from my old mac?  I tried the time machine and that isnt working either.  I have files that I need to use on my new mac, all my old programs and such.  I thought they said it was easy to get your files from one mac to another.  Please help.

    Your account names are probably different on the two Macs. If you know the UNIX command line, open a terminal window and run:
    $ id 
    You should see a line that starts with something like this:
    uid=501(your_user_id_here)
    now check the owner of the folder you copied over:
    $ ls -ld Music
    drwx------+ 8 some_user_id_here  staff  272 May 14 16:08 Music
    Do the IDs match? If not, you could change the ownership. Say your id is "johnsmith"
    $ chown -R johnsmith Music
    Now try and access it with iTunes.

Maybe you are looking for

  • Problem with invoking an Action in a Menu...

    I wanted to make a program that would create a box of rectangles and have each rectangle change color when clicked. I want the user to be able to decide which color you want the rectangle to be. I put choices in a menu. However whenever an option is

  • Poor graphics redraw when scrolling Word documents

    I have a strange blurring effect when scrolling Word documents on my Macbook pro, as if the graphic card had trouble refreshing: the screen is interspersed by horizontal irregular lines that make it impossible to read the text. I have recently replac

  • Special Characters in CONTAINS section of ORACLE TEXT

    Can we have special characters in the CONTAINS Section of the ORACLE TEXT. Ex: Select count(*) from Table_Name where CONTAINS(Column_Name, '%SearchString#%')>1.. If I am introductions characters like @,#,$,^,&,*(, ) --> then I am getting error as giv

  • Exit in java

    Hey I was hoping someone could help me out. i need to write some code so that i give someone the option to either exit the program or rerun the program. I am only new to java and am having difficulty setting this up. thanks.

  • ORA-12514 error while connecting to server

    I am using instantclient to connect to Oracle 9i server. The connection string is given using this format //host:[port][service name]. In our development environment we can successfully connect to the server. But the connection fails in the productio