MCPcopy Create free account
hub / github.com/RipMeApp/ripme / configField

Method configField

src/main/java/com/rarchives/ripme/ui/MainWindow.java:648–679  ·  view source on GitHub ↗
(String key, int defaultValue)

Source from the content-addressed store, hash-verified

646 }
647
648 private JTextField configField(String key, int defaultValue) {
649 final var field = new JTextField(Integer.toString(Utils.getConfigInteger(key, defaultValue)));
650 field.getDocument().addDocumentListener(new DocumentListener() {
651 @Override
652 public void insertUpdate(DocumentEvent e) {
653 checkAndUpdate();
654 }
655
656 @Override
657 public void removeUpdate(DocumentEvent e) {
658 checkAndUpdate();
659 }
660
661 @Override
662 public void changedUpdate(DocumentEvent e) {
663 checkAndUpdate();
664 }
665
666 private void checkAndUpdate() {
667 final var txt = field.getText();
668 try {
669 final var newValue = Integer.parseInt(txt);
670 if (newValue > 0) {
671 Utils.setConfigInteger(key, newValue);
672 }
673 } catch (final Exception e) {
674 LOGGER.warn(e.getMessage());
675 }
676 }
677 });
678 return field;
679 }
680
681 private void addItemToConfigGridBagConstraints(GridBagConstraints gbc, int gbcYValue, JLabel thing1ToAdd,
682 JButton thing2ToAdd) {

Callers 1

createUIMethod · 0.95

Calls 3

getConfigIntegerMethod · 0.95
toStringMethod · 0.45
getDocumentMethod · 0.45

Tested by

no test coverage detected