Animating dashed-line with java.awt.BasicStroke

Use a dashed line, a Thread (or a Swing Timer) & combine them with repaint() and some tweaking of where the dashes start and end – and there you have it. Example package test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import … Read more

Character display/search for Unicode characters

Sure. Give this a run. import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.*; import javax.swing.table.*; import javax.swing.plaf.basic.BasicComboBoxEditor; import javax.swing.text.Document; import java.util.*; import java.util.logging.*; public class UnicodeExplorer { public static final int codePointColumnWidth = 16; public static final int numberUnicodes = 256 * 256; private final ArrayList<Font> fontList = new ArrayList<Font>(); private final SpinnerNumberModel startPage = … Read more

JavaFX screencapture headless exception on OSX

JavaFX doesn’t use AWT stack, so it’s not being started in pure JavaFX application. Due to threads handling specifics AWT is being run in headless mode on Mac then requested from JavaFX. There are next options to solve that: Use some voodoo magic to initialize AWT — in static initialization run java.awt.Toolkit.getDefaultToolkit(); EDIT this worked … Read more

JavaFX app in System Tray

Wrap the code in the actionListener which calls back to JavaFX in Platform.runLater. This will execute the code which interfaces with the JavaFX system on the JavaFX application thread rather than trying to do it on the Swing event thread (which is what is causing you issues). For example: ActionListener listenerTray = new ActionListener() { … Read more

How can I make this JButton visible? When I have progressive scan background JWindow()?

It’s not clear how your video source works, but it appears to be incompatible with Swing due to Mixing Heavyweight and Lightweight Components. Although awt components aren’t transparent, you can always draw your own translucent text on the Frame and do manual hit testing, as suggested below. You might also check to see if your … Read more

JComponents disappearing after calling mouseClicked()

Consider using a JList for the right panel to take advantage of the flexible layout options and selection handling, as shown here and below. import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.Icon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import … Read more