How do I simulate a buffered peripheral device with SwingWorker?

It may help to know that SwingWorker uses an ExecutorService internally; it adds the interim EDT processing mechanism for convenience. As long as you update your GUI on the EDT and synchronize access to any shared data, the latter is equivalent to the former. Assuming you are using the Model–View–Controller pattern, suggested here, your model … Read more

Setting smaller buffer size for sys.stdin?

You can completely remove buffering from stdin/stdout by using python’s -u flag: -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) see man page for details on internal buffering relating to ‘-u’ and the man page clarifies: -u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, … Read more

An algorithm for inflating/deflating (offsetting, buffering) polygons

I thought I might briefly mention my own polygon clipping and offsetting library – Clipper. While Clipper is primarily designed for polygon clipping operations, it does polygon offsetting too. The library is open source freeware written in Delphi, C++ and C#. It has a very unencumbered Boost license allowing it to be used in both … Read more

JTextFields on top of active drawing on JPanel, threading problems

NewTest extends JPanel; but because you’re not painting every pixel on each call to paintComponent(), you need to invoke the super-class’s method and erase the old drawing: @Override protected void paintComponent(Graphics g) { super.paintComponent(g); int width = this.getWidth(); int height = this.getHeight(); g.setColor(Color.black); g.fillRect(0, 0, width, height); … } Addendum: As you note, setting the … Read more