Here... this one allows you to drag the applet from any area into the
desktop... or to drag the app around the desktop.
package draggableapplet;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.*;
import javafx.scene.text.Font;
import javafx.scene.input.MouseEvent;
import javafx.animation.Timeline;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.stage.AppletStageExtension;
var x:Number;
Timeline {
repeatCount: Timeline.INDEFINITE
autoReverse: true
keyFrames: [
at(0.0s) { x => 40}
at(1.0s) { x => 224}
]
}.play();
Stage {
title: "Application title"
width: 270
height: 116
extensions: AppletStageExtension {
shouldDragStart: function(e: MouseEvent): Boolean {
e.primaryButtonDown;
}
}
scene: Scene {
fill:Color.YELLOW
content: [
Circle {
centerX: bind x,
centerY: 40
radius: 40
fill: Color.RED
},
Text {
font: Font {
size: 24
}
x: 10,
y: 28
textOrigin:TextOrigin.TOP
content: "Arrastrame / Drag me"
}
]
}
}
The following code creates a limited area from where you can drag the
applet or app.... the previous one allows you to drag the applet/app
from any place, which will disable the ability to use drag and drop
inside the applet/app....
package advdragapplet;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.text.TextOrigin;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.input.MouseEvent;
import javafx.animation.Timeline;
import javafx.stage.AppletStageExtension;
// area to drag the applet/app
var dragArea:Group;
dragArea = Group {
opacity: 0.5
// THE DRAGGABLE AREA APPEARS ONLY IF IT IS AN APPLET AND IT CAN BE
DRAGGED
// YOU CAN MAKE IT VISIBLE ALL THE TIME BY REPLACING THE LINE
WITH .... VISIBLE:TRUE
visible: bind AppletStageExtension.appletDragSupported
onMouseDragged:function(e:MouseEvent):Void {
stage.x += e.dragX;
stage.y += e.dragY;
}
content: [
Rectangle {
x: 0
y: 0
width: 140
height: 20
fill: Color.YELLOW
},
Text {
font: Font {
size: 12
}
x: 10,
y: 5
textOrigin:TextOrigin.TOP
content: "Arrastrame / Drag me"
}
]
};
var x:Number;
Timeline {
repeatCount: Timeline.INDEFINITE
autoReverse: true
keyFrames: [
at(0.0s) { x => 40}
at(0.5s) { x => 224}
]
}.play();
var stage=Stage {
title: "Draggable Applet"
width: 280
height: 116
scene: Scene {
fill:Color.PURPLE
content: [
Circle {
centerX: bind x,
centerY: 40
radius: 40
fill: Color.CYAN
},
dragArea,
]
}
extensions: [
AppletStageExtension {
shouldDragStart: function(e): Boolean {
e.primaryButtonDown and dragArea.hover;
}
}
]
}
VISIT MY BLOG.... IT'S IN SPANISH, BUT YOU CAN GET SOME CODE FROM
THERE....
http://aprendiendo-javafx.blogspot.com
On Jan 20, 3:56 pm, "navdeep singh" <
navdee...@gmail.com> wrote:
> hi frnds... i have made one app but dont know how to drag it on web start...
>
> i givin the code...
>
> *
> *
> after running this, it see at the center of screen....
> but cant drag.......
>
> plz help me...
>
> --
> Keep smiling…
> It's one of the best advertisements for God…
> it makes people wonder what you've got…
>
> With Regards
> Navdeep Singh
> Let me know what you think about me :
navdee...@gmail.com