My eyesite is getting a lot worse, so I am using Window Magnifier (on Windows 11) to make things easier to read on my computer screen. Using my keyboard, I simply press the Windows button and (+) or (-) to zoom in or out.
When I use Notepad++, WordPad, or even Firefox, the Magnifier will follow the text as I type. This is very convenient, as it enables me to not have to keep manually moving the magnifier as I type.
Whenever I make Java GUI’s using Swing, I notice that this behaviour is not present. Is there anyway to get the same thing for Java Swing GUI’s? Considering the vast majority of my applications have the ability to do this, I strongly suspect that Java can too, and I am just missing a flag or something.
Here is an example code. When I type, the magnifier does not follow the text, and the text I am typing is eventually off-screen, forcing me to relocate the magnifier to see what I am typing.
import javax.swing.text.*;
import javax.swing.*;
public final class Daily
{
public static void main(final String[] args) throws Exception {final Daily daily = new Daily();}
public Daily() throws Exception
{
_20241214_text_box();
}
public static void _20241214_text_box()
{
SwingUtilities
.invokeLater
(
() ->
{
final JFrame frame = new JFrame();
frame.setSize(800, 800);
frame.setLocationByPlatform(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JTextComponent textBox =
// new JTextField()
new JTextArea()
;
frame.add(textBox);
frame.setVisible(true);
}
)
;
}
}
14