2013-01-19
I have got the different result on Mac
I just want to share two results I have got on My Mac. I transcribed all of this article. Creating Visual Effects in JavaFX: About This Document | JavaFX 2 Tutorials and Documentation Also the article is written by @skrb using InvalidationListener.
The result that I saw was different from what I had expected. The one is blend mode and another is InvalidationListener.
- The environment is Mac OS X 10.7.4 with JDK7
- Figure 1(Blend Mode)
- Code 1
This code shows using 3 type of blend mode. But Figure 1 shows the same result...
It seems like BlendMode.SRC_ATOP does not work on Mac?
(see Creating Visual Effects in JavaFX: Blending Objects | JavaFX 2 Tutorials and Documentation)
public class BlendSample extends Application { @Override public void start(Stage stage) throws Exception { HBox root = new HBox(); root.setPadding(new Insets(10)); root.setSpacing(8); // Blending Node node1 = getBlendMode(BlendMode.MULTIPLY, Color.BLUE); Node node2 = getBlendMode(BlendMode.SRC_ATOP, Color.ORANGE); // This has the different result Node node3 = getBlendMode(BlendMode.SRC_OVER, Color.AQUA); root.getChildren().addAll(node1, node2, node3); stage.setScene(new Scene(root, 500, 300)); stage.show(); } static Node getBlendMode(BlendMode mode, Color color) { Rectangle r = new Rectangle(); r.setX(590); r.setY(50); r.setWidth(50); r.setHeight(50); r.setFill(color); Circle c = new Circle(); c.setFill(Color.rgb(255, 0, 0, 0.5f)); c.setCenterX(590); c.setCenterY(50); c.setRadius(25); Group g = new Group(); g.setBlendMode(mode); g.getChildren().add(r); g.getChildren().add(c); return g; }
- Figure 2(InvalidationListener)
InvalidationListener called only once but it should be twice.
- Code 2
package javaapplication22; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.property.SimpleIntegerProperty; public class BindDemo { public static void main(String[] args) { SimpleIntegerProperty x = new SimpleIntegerProperty(0); SimpleIntegerProperty y = new SimpleIntegerProperty(); y.bind(x); y.addListener(new InvalidationListener() { @Override public void invalidated(Observable o) { System.out.println("Invalidate:" + o); } }); System.out.println(y.get()); // This code works without invalidationListener? x.set(10); x.set(20); System.out.println(y.get()); } }
When I run any JavaFX programs and maximize the screen then quit the application, the error message as follows appears on NetBeans.
- The Error message
Glass detected outstanding Java exception at -[GlassApplication runLoop:]:src/com/sun/mat/ui/GlassApplication.m:566
Exception in thread "JavaFX Application Thread" java.util.concurrent.RejectedExecutionException: Task com.sun.prism.render.RenderJob@343d0d2b rejected from com.sun.javafx.tk.quantum.QuantumRenderer@142b9cd8[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 53]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2013)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:816)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1337)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:110)
at com.sun.javafx.tk.quantum.QuantumRenderer.disposePresentable(QuantumRenderer.java:176)
at com.sun.javafx.tk.quantum.WindowStage.setScene(WindowStage.java:186)
at javafx.stage.Window$10.invalidated(Window.java:751)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
at javafx.stage.Window.setShowing(Window.java:782)
at javafx.stage.Window.hide(Window.java:807)
at com.sun.javafx.stage.WindowCloseRequestHandler.dispatchBubblingEvent(WindowCloseRequestHandler.java:45)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at com.sun.javafx.stage.WindowPeerListener.closing(WindowPeerListener.java:82)
at com.sun.javafx.tk.quantum.GlassStage.requestClosingAllWindows(GlassStage.java:203)
at com.sun.javafx.tk.quantum.QuantumToolkit$11.handleQuitAction(QuantumToolkit.java:347)
at com.sun.glass.ui.mac.MacApplication$4.action(MacApplication.java:104)
I would appreciate any advice since I am very beginner of JavaFX.
keep coding....
- 95 https://www.google.co.jp/
- 26 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CDAQFjAA&url=http://d.hatena.ne.jp/tomoTaka/20130119/1358580757&ei=cqv7UMXgG4PEkgXp_oHQDA&usg=AFQjCNHQIYShpJDmbPQKQ4Ptuu3LWMyP0w&bvm=bv.41248874,d.dGI
- 18 http://twitter.com/tomo_taka01
- 16 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CEAQFjAB&url=http://d.hatena.ne.jp/tomoTaka/20120311/1331446628&ei=QvX6UPC6FafjmAXO5IGACw&usg=AFQjCNGdiwhg27rBpZY3fV4KYN_hM6WdTw&sig2=vM8qgkmdyIGb-OSff_r9vg&bvm=bv.41248874,
- 15 http://www.google.co.jp/url?sa=f&rct=j&url=http://d.hatena.ne.jp/tomoTaka/20121220/1356013679&q=javafxで&ei=D2_6UKqmJ8OikAWdn4GgCA&usg=AFQjCNHCYWKZlygbK2l680Xfv9M6Sx2tAw
- 14 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=1&ved=0CDIQFjAA&url=http://d.hatena.ne.jp/tomoTaka/20120211/1328913605&ei=Hin-UMW_MaHImQXHzIDIAw&usg=AFQjCNH6oP23fivTH0kHAMW3ktQyNcMvzQ&sig2=NggbcZnaApkkDZ-5ymrg3A
- 13 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CD8QFjAC&url=http://d.hatena.ne.jp/tomoTaka/20121027/1351342145&ei=dDf9UIfXBKb6mgXXn4DYBg&usg=AFQjCNHyp7QGl7gGB778M500R4W-Lv9u1A&bvm=bv.41248874,d.dGY&cad=rja
- 13 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=0CD4QFjAD&url=http://d.hatena.ne.jp/tomoTaka/20120428/1335615310&ei=LemmUN2MDarJmQXXuoDgDw&usg=AFQjCNGPJtDFG-dNXm6RfKQVwWpTU8GTrw
- 13 https://www.google.com/
- 12 http://community.java.net/community/javafx


