我有 JTextField。 txtPickANick.setText("选择昵称"); 我需要在显示带有此文本的 JFrame 时选择文本。我尝试 selectAll() 但它不起作用。
private JTextField getTxtPickANick() {
if (txtPickANick == null) {
txtPickANick = new JTextField();
txtPickANick.setFont(new Font("Bookman Old Style", Font.PLAIN, 15));
txtPickANick.setHorizontalAlignment(SwingConstants.CENTER);
txtPickANick.setBounds(44, 74, 185, 21);
txtPickANick.setColumns(10);
txtPickANick.setDocument(new LimitDlzka(17));
txtPickANick.setText("Pick a nick name");
txtPickANick.selectAll();
}
return txtPickANick;
}