events

Flutter: Override widgets/components to get access to events

As a brief “note to self,” when you need to get access to Flutter widget events that you normally can’t access, override the widget to access lifecycle-related events like initState() and dispose() so you can access them. For example, this image (that comes from this URL) shows how to gain access to those lifecycle methods for a Flutter Drawer. You can do this with any component/widget — and you can also make the code more generic by passing in child widgets — and you can also mix in WidgetsBindingObserver and then use didChangeAppLifecycleState to gain access to more events.

Dart futures are NOT run in a separate thread (they are run in the event loop)

I’ve been working with Flutter and Dart for several weeks now, and I was surprised to read several times that Dart is single-threaded, knowing that it has a concept of a Future (or futures) and async methods. Last night I read this excellent article about Dart’s event loop, which sums up Dart futures very nicely in that statement:

“the code of these Futures will be run as soon as the Event Loop has some time. This will give the user the feeling that things are being processed in parallel (while we now know it is not the case).”

Earlier in the article the author also states:

“An async method is NOT executed in parallel but following the regular sequence of events, handled by the Event Loop, too.”

So, in summary, Dart has a single-threaded event loop, and futures and async methods aren’t handled by a separate thread; they’re handled by the single-threaded event loop whenever it has nothing else to do.

I just wanted to note this here for myself today, but for many more details, please see that article, which also discusses Dart isolates, which are like a more primitive form of Akka actors.

Java repaint() may call (or skip) paintComponent (events coalesce) alvin May 9, 2015 - 3:43pm

I was just reminded while reading The Beginner’s Guide to Android Game Development that the Java Component repaint() method may called paintComponent(), but it can also skip it as events coalesce.

Java xeyes - Follow the mouse cursor location outside a JFrame

A Java xeyes solution - I started working on my Java speech recognition app again today, and in the process I saw some source code I thought I should post here. When I was developing this app, I thought it would fun to put a GUI on it, and when I thought about what sort of GUI it should have, I thought of the old X-Windows xeyes app. I looked around to see if anyone had written a "Java xeyes" application, but from what I've seen, nobody has.

Setting Mac iCal event reminders

Mac iCal event reminders FAQ: How do I configure a Mac iCal reminder to remind me of birthdays, due dates for bills, and so on?

If you're new to the Mac world, and want to be able to set up reminders for various things like birthdays, pay bills, or attend events, the good news is that you can do this with the free software already installed on your Mac. The iCal Mac calendar application is just what you need.

Mac task scheduling with iCal

Mac task scheduling FAQ: Is there a simple way to schedule a task/job on a Mac OS X system to run on a certain date and time? (For Linux/Unix users: Like running a Unix job with the crontab facility, but in a GUI?)

In an earlier article I detailed how to run Unix jobs on a Mac system in this Mac OS X crontab (launchd) tutorial. But today I was looking for an easier way to run Mac programs at certain times, or to schedule email reminders to be sent to myself, preferably using a Mac GUI client.

A Java Robot class mouse and keyboard/keystroke example

Java Robot class FAQ: Can you show me an example of how to use the Java Robot class?

Answer: Um, yeah, sure ... I say that a little jokingly. Okay, what really happened is that while developing this Java Robot example code on my Mac, I had to reboot it about 10 times. When you use the Java Robot class, you're poking your head out into the native operating system, and if you mess up with your GUI events -- at least on a Mac OS X system -- a lot of bad things can happen.

The Java on Mac OS X About, Quit and Preferences menu items and events

When writing Java GUI code for the Mac OS X platform, you'll want to properly handle the Mac About, Quit, and Preferences menu items and events. Fortunately doing this is very simple, and I'll demonstrate that in this "Java on Mac OS X" tutorial.