|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#22 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
OK, aspetto notizie! Grazie!
|
|
|
|
|
|
#23 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Nel frattempo ho provato anche il codice riportato a questo indirizzo. Peccato che nemmeno questo funzioni.
Non capisco come facciano altre persone a dire che il codice funziona benissimo. A me non trova la classe FX, eppure è tutto come scritto nell'articolo. Provata anche questa soluzione, ma niente. Non trova la classe FX. Comincio a perdere le speranze sinceramente. Mi sa che è una gran bufala sto javafx... Tanto fico quanto inutilizzabile. Ultima modifica di fbcyborg : 13-04-2010 alle 10:21. |
|
|
|
|
|
#24 | |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
Buondì
![]() Quote:
http://www.youtube.com/watch?v=jmKINcGY9dw Allora, JavaFX SDK 1.2.3, Java 1.6._19. Netbeans, ovviamente, ma non vedo perchè non dovrebbe andare su Eclipse, è tutto manuale. Questo è il componente javafx: Codice:
package test;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
public class FXWidget extends Scene {
init {
content = [
Rectangle { width: 200 height: 200 fill: Color.BLUE }
Text { x: 20 y: 20 content: "Hello World!" fill: Color.WHITE }
]
}
}
Codice:
package fxswingtest;
import com.sun.javafx.tk.swing.SwingScene;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.scene.Scene;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
start();
}
});
}
private static void start() {
JComponent fxComponent = sceneClassToJComponent("test.FXWidget");
JFrame window = new JFrame("Test");
window.add(fxComponent);
window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
window.setSize(640, 640);
window.setVisible(true);
}
private static JComponent sceneClassToJComponent(String fxSceneClassName) {
try {
Scene scene = (Scene) Class.forName(fxSceneClassName).newInstance();
return ((SwingScene) scene.get$javafx$scene$Scene$impl_peer()).scenePanel;
} catch(Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "", ex);
return new JLabel("ERR");
}
}
}
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
|
#25 | ||
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Quote:
Quote:
Parto con la prima domanda. Hai creato un nuovo progetto javafx o java? Così provo anche io. Grazie! |
||
|
|
|
|
|
#26 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
ho creato un progetto javafx vuoto con quell'unica classe e l'ho compilato e impacchettato in un jar.
Poi ho scaricato l'sdk di javafx (1.2.3), ho creato un nuovo progetto Java e aggiunto le librerie dell'sdk javafx più il jar del progetto javafx. Dopodichè ho aggiunto al progetto java quella classe Main. Eseguendo il progetto java, salta fuori una finestra con un rettangolo blu e la scritta hello world.
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#27 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Ok...
a te te lo esegue il file javafx, se lo fai partire da solo da Netbeans? |
|
|
|
|
|
#28 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
No perchè manca il metodo "main" (che sarebbe il function run(args: String[])). Ma non serve che sia eseguibile ai fini dell'integrazione in Swing (o così pare).
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#29 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Ok, perfetto.
No perché a me da sempre questo errore: Codice:
java.lang.NoSuchMethodException: test.FXWidget.javafx$run$(com.sun.javafx.runtime.sequence.Sequence) at java.lang.Class.getMethod(Class.java:1605) at com.sun.javafx.runtime.Entry.start(Entry.java:63) at com.sun.javafx.runtime.Main.main(Main.java:80) at com.sun.javafx.runtime.main.Main.main(Main.java:35) Procedo... |
|
|
|
|
|
#30 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Fico!
Funziona anche a me. Alleluja!!! Ora vorrei poter usare questa classe fx al posto di quella hello world che hai messo tu: Codice:
package test;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
var radius = 15;
Timeline {
repeatCount: Timeline.INDEFINITE,
keyFrames: [
KeyFrame {
time: 0.5s,
canSkip: true
values : [
radius => 5 tween Interpolator.EASEBOTH
]
} // KeyFrame
KeyFrame {
time: 1.0s,
canSkip: true
values : [
radius => 15 tween Interpolator.EASEBOTH
]
} // KeyFrame
] // keyFrames
}.play(); // Timeline
Stage {
title : "Alert"
scene: Scene {
width: 30
height: 30
content: [
Circle {
centerX: 15,
centerY: 15,
radius: bind radius
fill: Color.RED
} // Circle
] // content
} // Scene
} // Stage
|
|
|
|
|
|
#31 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
Non ne ho la più pallida idea
Uno stage può essere contenuto in uno Scene? Boh. Bisogna anche far partire l'animazione. Si potrà fare nell'init? Mah. Insomma, bisogna fare qualche esperimento. Se ficchi tutto nell'init cosa dice?
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#32 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Tutto sottolineato in rosso!!!!!!
Che poi se ci fai caso, nell'init che hai usato tu, ci mette solo il content, mentre nel mio caso ci sarebbe un sacco di roba. Però non saprei dove piazzare tutto il resto. Pare che ficcando tutto nell'init, si incazzi!
|
|
|
|
|
|
#33 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
Vabbè, non intendevo proprio un buttar lì tutto alla "valàchelavàben'"
Codice:
package test;
import javafx.scene.Scene;
import javafx.animation.Timeline;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
public class FXWidget extends Scene {
init {
var radius = 15;
content = [
Circle {
centerX: 15,
centerY: 15,
radius: bind radius
fill: Color.RED
}
];
Timeline {
repeatCount: Timeline.INDEFINITE,
keyFrames: [
KeyFrame {
time: 0.5s,
canSkip: true
values: [
radius => 5 tween Interpolator.EASEBOTH
]
} // KeyFrame
KeyFrame {
time: 1.0s,
canSkip: true
values: [
radius => 15 tween Interpolator.EASEBOTH
]
} // KeyFrame
] // keyFrames
}.play();
}
}
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#34 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
Una nota: pare che il thread dell'animazione resti in vita anche dopo la morte della finestra Swing. Al posto di DISPOSE_ON_CLOSE ci va un EXIT_ON_CLOSE. In alternativa si dovrebbe trovare un modo per terminare i thread di javax (magari Timeline ha un stop). Ma sono questioni minori.
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#35 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
A me non lo carica...
Il file si chiama Luce.fx e la classe si chiama Luce, ma quando tento di caricarla dalla gui, mi esce: Codice:
Apr 13, 2010 7:19:06 PM fxswingtest.Main sceneClassToJComponent SEVERE: java.lang.ClassCastException: test.Luce cannot be cast to javafx.scene.Scene |
|
|
|
|
|
#36 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
Luce estende Scene? Puoi incollare il codice che provo direttamente qui?
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#37 |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Certo, ecco il codice di Luce.fx:
Codice:
package test;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
public class Luce extends Scene {
init {
var radius = 15;
content = [
Circle {
centerX: 15,
centerY: 15,
radius: bind radius
fill: Color.RED
}
];
Timeline {
repeatCount: Timeline.INDEFINITE,
keyFrames: [
KeyFrame {
time: 0.5s,
canSkip: true
values: [
radius => 5 tween Interpolator.EASEBOTH
]
} // KeyFrame
KeyFrame {
time: 1.0s,
canSkip: true
values: [
radius => 15 tween Interpolator.EASEBOTH
]
} // KeyFrame
] // keyFrames
}.play();
}
}
|
|
|
|
|
|
#38 |
|
Senior Member
Iscritto dal: Nov 2004
Città: Tra Verona e Mantova
Messaggi: 4553
|
Qui me la prende. In effetti non vedo perchè non dovrebbe, Scene lo estende.
Prova a fare un po' di "clean and build" o a riavviare Eclipse.
__________________
Uilliam Scecspir ti fa un baffo? Gioffri Cioser era uno straccione? E allora blogga anche tu, in inglese come me! |
|
|
|
|
|
#39 | |
|
Senior Member
Iscritto dal: Jan 2004
Città: ROMA
Messaggi: 2055
|
Perfetto ha funzionato.. Ho cancellato il jar e l'ha ricreato. Ora va bene.
Quote:
A dire il vero però non ho notato che l'animazione rimane in vita. Tu cosa hai notato? |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 03:23.






















