Archive for August, 2014

RSyntaxTextArea: Paste from Clipboard History

Friday, August 29th, 2014

Just committed to Git is a new feature:  Clipboard History.  Pressing Ctrl+Shift+V (Cmd+Shift+V on OS X) will cause the “clipboard history” popup to appear below the current caret position:

Clipboard History

Clipboard History

This popup displays the most recent snippets of text added to the clipboard.  This allows you to paste any text that was *recently* on the clipboard, not just what’s *currently* in the clipboard buffer.  This is pretty useful if you’re a frequent copy-paster.

The clipboard history is implemented as a singleton instance of the org.fife.ui.rtextarea.ClipboardHistory class.  You can access it, but currently the only interesting thing you can do is set its maximum size.  By default, it only remembers the 12 most recent entries on the clipboard that can be interpreted as plain text.

RSyntaxTextArea in a JavaFX app

Tuesday, August 5th, 2014

While I’ll certainly not put much time into learning JavaFX, I did poke around at it a little, and it is a nice API.  It’s better designed than Swing, and easier to write clean code in.  In any case, I decided to see how RSyntaxTextArea worked in a JavaFX app, now that JavaFX 8 “fully” supports embedding Swing components into JavaFX apps.

It was pretty easy to do, and at first glance, worked great:

RSTA in JavaFX

RSTA in JavaFX

However, I hit a big snag:  When I resized the window, (what seemed like) every other repaint resulted in everything *but* the Swing content being unpainted!

RSTA in JavaFX - Flicker

RSTA in JavaFX – Flicker

I say every other repaint, because slowly resizing the window you would see constant flicker, between blackness instead of JavaFX rendering, and the JavaFX goodness you were supposed to see.

I took out the RSyntaxTextArea, this does not happen.  So this does not seem to occur in JavaFX apps with no Swing embedded in them.

I added in a JButton instead of the RSyntaxTextArea.  The flicker did not happen.  So it seems to not be all Swing content that does this.

I replaced the JButton with a JTextArea.  The flicker came back.  Okay, so it’s only *certain* Swing components.

Note that there is flicker with stand-alone JTextAreas/RSyntaxTextAreas; JScrollPanes don’t have to be in the equation to see this issue.

So what’s the deal?  Somehow certain Swing content causes the JavaFX rendering pipeline to bug out.