views:

62

answers:

2

I'm creating a pretty simple form, and I'm running into an issue with Controls/components shifting position (textboxes and checkboxes in particular) by a few pixels upon selection. It's by no means breaking my interface, but you can imagine it's a bit of an irritant. I have a feeling it's an issue with the custom node(s) I've created... though I can't determine where the problem would be.

I did something similar before without any trouble, but ever since I tried "modularizing" my code (created a custom node with label and texbox opposed to separately declaring each in the main) I've come across this (along with a few other subtle issues). Here is my custom node... in case this gives way to figuring out my problem.

public class NumberWithLabelNode extends CustomNode {

public var width: Number;
public var height: Number;
public var x: Number;
public var y: Number;
public var labelText: String = "Generic Label:  ";
public var text: String = "0.0";
public var columns: Integer = 5;
public var error: Boolean = false;
public var errorText: String = "  Invalid input.";

public override function create(): Node {
    return HBox {
                width: bind width
                height: bind height
                content: [
                    Text {
                                content: bind labelText
                            },
                    TextBox {
                        layoutInfo: LayoutInfo { hgrow: Priority.NEVER }
                        columns: bind columns
                        text: bind text with inverse
                    },
                    Text {
                        visible: bind error
                        fill: Color.RED
                        content: bind errorText;
                    }
                ]
            }
}

}

If you see anything I've done incorrectly/doesn't follow standards, please let me know. To re-iterate, I want this custom node to behave exactly as if I created a label and textbox in an hbox.

I'm hoping somebody can at least guide me in the direction of where my issue could be without having to look at the rest of my source (may be a long shot... I'm hoping to not have to strip down code to post here).

Thanks in advance!

A: 

This might not fix the issue, but will help:

You are not supposed to set width/height of any Resizable yourself. The parent container sets them for you. If you wish an object to be specifically sized use LayoutInfo object instead.

Honza
You're right... doesn't fix the particular problem, but I appreciate it nonetheless!To make sure we're on the same page... you're referring to the following:"width: bind width height: bind height"??I tried removing those lines, and the textboxes did not behave the way I wanted (changed my mind... desired behavior is to fill space now). I changed layoutInfo: LayoutInfo { hgrow: Priority.NEVER } to ALWAYS, too.
Greg
I ended up getting things working more to my liking. I ended up extending both CustomNode and Resizable (and implementing the needed methods for Resizable... see API). I found this helpful -> http://blog.cedarsoft.com/2010/05/javafx-template-for-resizable-customnode/
Greg
A: 

I ended up getting things working more to my liking. I ended up extending both CustomNode and Resizable (and implementing the needed methods for Resizable... see API). I found this helpful -> http://blog.cedarsoft.com/2010/05/javafx-template-for-resizable-customnode/.

Something to note: CustomNode is not a Resizable. JFXtras adds a Node called XCustomNode that adds the (missing) Resizable feature(s). The JFXtras libraries can be found at code.google.com/p/jfxtras/downloads/list (sorry... can only post 1 link right now). Stick to the 0.7 builds if you're using JavaFX 1.3. The 0.6 versions work with JavaFX 1.2.

Greg