Java JTextField create not focusable text field
import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JTextField; class NoFocusJTextField extends JTextField { public NoFocusJTextField(String s) { super(s);//from w w w.j a v a 2 s . com } public boolean isRequestFocusEnabled() { return false; } public boolean isFocusTraversable() { return false; } } public class Main { public static void main(String[] argv) throws Exception { JTextField component = new NoFocusJTextField("www.demo2s.com"); JFrame f = new JFrame(); f.add(component, BorderLayout.NORTH); f.add(new JTextField(20), BorderLayout.SOUTH); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(300, 300); f.setVisible(true); } }