how to drag the Web Start app

7 views
Skip to first unread message

navdeep singh

unread,
Jan 20, 2009, 1:56:16 PM1/20/09
to jav...@googlegroups.com

hi frnds... i have made one app but dont know how to drag it on web start...

i givin the code...



import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.scene.shape.ArcTo;
import javafx.scene.shape.Path;
import javafx.scene.shape.MoveTo;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.Scene;


var face = Circle{ centerX: 103 centerY: 102
radius: 100
fill: Color.YELLOW};

var left_eyes = Circle{ centerX: 50 centerY: 80
radius: 13
fill: Color.BLACK};

var right_eyes = Circle{ centerX: 150 centerY: 80
radius: 13
fill: Color.BLACK};

var nose = Line{startX: 100 startY: 90
endX: 100 endY: 130
strokeWidth: 5};

var smile = Path{
elements:[MoveTo{ x: 50 y: 155},
ArcTo{ x: 150 y: 155 radiusX: 80 radiusY: 80 } ]
strokeWidth: 5
};

var smile_face:Group = Group{
content:[face, left_eyes, right_eyes, nose, smile ]
};

Stage{
title: "Smily Emotion"
style: StageStyle.TRANSPARENT
width: 215
height: 238
resizable: false
scene: Scene{
content:[smile_face,
Rectangle { x: 200 y: 2 width: 
10 height: 10 fill: 
Color.RED
onMouseClicked: function(e: MouseEvent): Void {
java.lang.System.exit(1);
]
fill: Color.TRANSPARENT 
}
}



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 : navd...@gmail.com

Mauro

unread,
Feb 5, 2009, 2:36:43 AM2/5/09
to javafx
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
Reply all
Reply to author
Forward
0 new messages