i have question.
my question
how make rectangle hide under button when slides. not want come out of other side of button.
package javafxapplication24; import javafx.animation.translatetransition; import javafx.application.application; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.fxml.fxmlloader; import javafx.geometry.pos; import javafx.scene.group; import javafx.scene.parent; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.layout.borderpane; import javafx.scene.layout.flowpane; import javafx.scene.layout.gridpane; import javafx.scene.paint.color; import javafx.scene.shape.rectangle; import javafx.stage.stage; import javafx.util.duration; /** * * @author phili_000 */ public class javafxapplication24 extends application { public button by; @override public void start(stage stage) throws exception { flowpane root = new flowpane( ); root.setalignment(pos.center); button butt = new button("play"); rectangle rect = new rectangle(200,40); rect.setfill(color.violet); translatetransition transition = new translatetransition(duration.millis(6000),rect); scene scene = new scene(root,700,700); transition.settox(-300); root.getchildren().addall(butt,rect); butt.setonaction((event) -> { transition.play(); }); stage.setscene(scene); stage.show(); } public static void main(string[] args) { launch(args); } }
i tried best explaining, if have questions. or comment on how can improve questions. please, don't hesitate click 'add comment' button , give me ideas.
add rectangle first, button:
root.getchildren().addall(text, butt);
Comments
Post a Comment