FocusListener « JTextField « Java Swing Q&A





1. FocusListener on custom JTextField    coderanch.com

This seems to work okay with J2SE 1.4.2 import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; public class FocusTest { public static void main(String[] args) { SK sk = new SK(16); JPanel north = new JPanel(); north.add(sk); JTextField tf = new JTextField(16); JPanel south = new JPanel(); south.add(tf); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(north, "North"); f.getContentPane().add(south, "South"); f.setSize(300,200); f.setLocation(200,200); f.setVisible(true); ...