fix: focus is set to the URL field in the scraper dialog and the URL is selected when opened
This commit is contained in:
parent
dae1e997b3
commit
66186a342d
|
@ -8,6 +8,8 @@ import java.awt.GridBagLayout;
|
|||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.IOException;
|
||||
|
@ -136,6 +138,19 @@ public class MobyGamesOptionsPanel extends JPanel
|
|||
if (urlTextField == null)
|
||||
{
|
||||
urlTextField = new JTextField();
|
||||
urlTextField.addFocusListener(new FocusListener() {
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
urlTextField.select(0, urlTextField.getText().length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
urlTextField.select(0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
urlTextField.setText("https://www.mobygames.com/game/");
|
||||
urlTextField.addKeyListener(new KeyAdapter()
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.awt.event.ActionListener;
|
|||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import se.lantz.gui.BaseDialog;
|
||||
import se.lantz.manager.ScraperManager;
|
||||
|
@ -106,7 +107,7 @@ public class ScraperDialog extends BaseDialog
|
|||
getMobyGamesPanel().preSelectFields();
|
||||
getC64comPanel().preSelectFields();
|
||||
getGb64comPanel().preSelectFields();
|
||||
getMobyGamesPanel().getUrlTextField().requestFocusInWindow();
|
||||
SwingUtilities.invokeLater(() -> getMobyGamesPanel().getUrlTextField().requestFocusInWindow());
|
||||
this.getRootPane().setDefaultButton(getMobyGamesPanel().getConnectButton());
|
||||
|
||||
return super.showDialog();
|
||||
|
|
Loading…
Reference in New Issue