java


Fire only the last event in a series of events in JavaFX


I have a PackingCanvas that draws elements on the screen, which is an extension of the JavaFX Canvas control. I want my elements to be drawn on resize, but only when the resize is done, as redrawing the entire canvas on every resize event might be too costly in some situations.
What I have now is the following:
widthProperty().addListener(evt -> draw());
heightProperty().addListener(evt -> draw());
I have tried doing this with threads; add a small delay, see if new a new thread is created, if not; draw(), else abort current thread.
However, this doesn't seem like an elegant solution to me. Is there an idiom to deal with these problems?
you can cache width & height inside draw() function.
void draw()
{
cacheHeight = getHeight();
cacheWidth = getWidth();
}
then
heightProperty().addListener(evt -> {if(getHeight()!=cacheHeight) draw();});

Related Links

Spring #ModelAttribute and translating request parameter binding names
How do you find the sum of all the numbers in an array in Java?
Android SDK installation doesn't find JDK
What is “convertView” parameter in ArrayAdapter getView() method
What is a good security framework or API? [closed]
List all possible combinations
Getting style from any offset in JTextPane
implementing Public Suffix extraction using java
java web app cannot create log files on glassfish v3(using log4j)
Storing View ID in JSF
Spring custom converter for all Enums
32-bit or 64-bit application on 64-bit OS?
calling a perl script from a java code in a interactive way
Question about generic method
Socket input stream doesn't read fragment by fragment
jsf Invoking Arbitrary Methods via EL

Categories

HOME
gerrit
appx
stock
session
relayjs
alfresco
rsync
setup-deployment
amazon-ecs
dxl
acquia
wamp
amazon-cloudformation
session-variables
kibana-4
u-sql
resize
quartz-scheduler
foselasticabundle
finite-automata
undefined
shared-hosting
predix
autoconf
jasonette
physics-engine
fish
facet
linkerd
neo4j-spatial
objectanimator
instant-messaging
fabric8
iframe-resizer
http-status-code-503
oracle-fusion-middleware
webtest
caret
stringtemplate
rotational-matrices
jmonkeyengine
suricata
jquery-bootgrid
swift3.0.2
ssjs
lumberjack
node-gyp
nand2tetris
nomethoderror
keydown
galleria
winscp-net
idisposable
nstextview
worker-thread
knockout-components
composite-key
spring-mongodb
lync-client-sdk
google-cdn
url-pattern
log4c
google-web-starter-kit
superstack
nessus
spim
teamcity-8.0
iis-arr
emailrelay
event-bubbling
p2
system.reflection
python-green
pick
qpainter
winddk
relocation
gulp-less
openexr
sgen
starcluster
cloud-connect
mbr
inbox
dataservice
interface-orientation
rdoc
errai
appconkit
nsmanagedobject
zpt
hirefire
xtype
pyinotify
android-sdk-2.1
w3wp.exe
cxxtest
createwindow

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile