public void focusGained(FocusEvent e) { Component c = e.getComponent(); if (c instanceof TextField) ((TextField) c).selectAll(); }