Skip to main content

Textfield loses functionality when reloaded in Stage

1 reply [Last post]
riepi
Offline
Joined: 2008-03-27
Points: 0

I want to build a small application, one frame, one stage. With functions i load and delete my content into my stage(fading in, fading out) so that there are many different views. But i have a problem: When i load a new Group{} into my Stage which contains Textfields{} i cant enter those Textfields but the first time.

I wrote this short example too demonstrate my Problem. There is a black Rectangle to load content. In the content there is a red rectangle next to my Textfield to delete the content. The second time i load the content i cant change the text in my textfield. Perhaps i have to bring it into focus or there is some other fault?

<br />
package core;</p>
<p>import javafx.application.*;<br />
import javafx.scene.*;<br />
import javafx.ext.swing.*;<br />
import javafx.scene.geometry.*;<br />
import javafx.scene.paint.Color;<br />
import javafx.input.MouseEvent;</p>
<p>var someText:String;<br />
var someContent:Group = Group{<br />
    content: [<br />
        Rectangle {<br />
            x: 40, y: 10<br />
            width: 20, height: 20<br />
            fill: Color.RED<br />
            onMouseClicked: function( e: MouseEvent ):Void {<br />
                deleteContent();<br />
            }<br />
        },<br />
        ComponentView{<br />
            translateX: 30<br />
            translateY: 70<br />
            component: Label{<br />
                font: Font{<br />
                    size: 12<br />
                }<br />
                text:"type some text"<br />
            }<br />
        },<br />
        ComponentView{<br />
            translateX: 30<br />
            translateY: 90<br />
            component:<br />
            TextField {<br />
                columns: 10<br />
                text: bind someText with inverse<br />
                editable: true<br />
            }<br />
        },<br />
    ]<br />
}; // Group</p>
<p>var stage:Stage = Stage {<br />
    content: [<br />
        Rectangle {<br />
            x: 10, y: 10<br />
            width: 20, height: 20<br />
            fill: Color.BLACK<br />
            onMouseClicked: function( e: MouseEvent ):Void {<br />
                getContent();<br />
            }<br />
        }<br />
    ]<br />
}//Stage</p>
<p>Frame {<br />
    title: "MyApplication"<br />
    width: 200<br />
    height: 200<br />
    closeAction: function() {<br />
        java.lang.System.exit( 0 );<br />
    }<br />
    visible: true</p>
<p>    stage: bind stage<br />
};</p>
<p>function getContent():Void{<br />
    insert someContent into stage.content;<br />
}</p>
<p>function deleteContent():Void{<br />
    delete someContent from stage.content<br />
}</p>
<p>

Hope someone can help me.
riepi

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
riepi
Offline
Joined: 2008-03-27
Points: 0

hmmm, same effect when i bind content to stage:

[code]
package bindContentOnStage;

import javafx.application.*;
import javafx.scene.*;
import javafx.ext.swing.*;
import javafx.scene.geometry.*;
import javafx.scene.paint.Color;
import javafx.input.MouseEvent;

var someText:String;
var otherText1:String;
var otherText2:String;

var someContent:Group = Group{
content: [
ComponentView{
translateX: 30
translateY: 70
component: Label{
font: Font{
size: 12
}
text:"type some text"
}
},
ComponentView{
translateX: 30
translateY: 90
component:
TextField {
columns: 10
text: bind someText with inverse
editable: true
selectOnFocus: true
}
},
]
}; // Group

var otherContent:Group = Group{
content: [

ComponentView{
translateX: 30
translateY: 70
component: Label{
font: Font{
size: 12
}
text:"type some other text"
}
},
ComponentView{
translateX: 30
translateY: 90
component:
TextField {
columns: 10
text: bind otherText1 with inverse
editable: true
selectOnFocus: true
}
},
ComponentView{
translateX: 30
translateY: 110
component:
TextField {
columns: 10
text: bind otherText2 with inverse
editable: true
selectOnFocus: true
}
},
]
}; // Group

var actContent:Group;

var stage:Stage = Stage {

content: [
Rectangle {
x: 10, y: 10
width: 20, height: 20
fill: Color.BLACK
onMouseClicked: function( e: MouseEvent ):Void {
bindContent(someContent);
}
},
Rectangle {
x: 40, y: 10
width: 20, height: 20
fill: Color.RED
onMouseClicked: function( e: MouseEvent ):Void {
bindContent(otherContent);
}
},
Group{content: bind actContent}
//bind aktuellerContent
]
}//Stage

Frame {
title: "MyApplication"
width: 200
height: 200
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
stage: bind stage
};

function bindContent(content:Group):Void{
actContent = content
}
[/code]