winder / Universal-G-Code-Sender

A cross-platform G-Code sender for GRBL, Smoothieware, TinyG and G2core.
http://winder.github.io/ugs_website/
GNU General Public License v3.0
1.85k stars 758 forks source link

fix: Set focus to first field in macro popup #2474

Closed warmans closed 4 months ago

warmans commented 4 months ago

Resolves: https://github.com/winder/Universal-G-Code-Sender/issues/2473

I've not touched Java in many years so this solution is taken mostly from here:

https://tips4java.wordpress.com/2010/03/14/dialog-focus/

It seems to behave differently on different platforms. HierarchyListener was the only listener that worked on Linux.

breiler commented 4 months ago

Nice, thanks!

Can you move the RequestFocusListener to the package com.willwinder.universalgcodesender.uielements.components and also add a comment that credits the original source, something like:

/**
 * Used for focusing the field in an JOptionDialog. 
 * Source from: https://tips4java.wordpress.com/2010/03/14/dialog-focus/
 */
public class RequestFocusListener implements HierarchyListener {
...