Source:
<code>public Spinner (SpinnerStyle style, SpinnerModel model) { this.style = style; this.model = model; currentBackground = style.background; setSize(getPrefWidth(), getPrefHeight()); this.addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { setCurrentBackground(getBackgroundForClick(x, y)); invalidate(); return true; } @Override public void touchUp (InputEvent event, float x, float y, int pointer, int button) { if (getCurrentBackground() == getStyle().backgroundNext) { if (getModel().next()) Spinner.this.fire(new ChangeListener.ChangeEvent()); } else if (getCurrentBackground() == getStyle().backgroundPrev) { if (getModel().previous()) Spinner.this.fire(new ChangeListener.ChangeEvent()); } setCurrentBackground(getStyle().background); invalidate(); } @Override public void touchDragged (InputEvent event, float x, float y, int pointer) { setCurrentBackground(getBackgroundForClick(x, y)); invalidate(); } @Override public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) { if (getStage() != null) getStage().setScrollFocus(Spinner.this); } @Override public boolean scrolled (InputEvent event, float x, float y, int amount) { if (x >= 0 && x <= getWidth() && y >= 0 && y <= getHeight()) { if (amount > 0) { if (getModel().previous()) Spinner.this.fire(new ChangeListener.ChangeEvent()); } else if (amount < 0) { <START> if (getModel().next()) Spinner.this.fire(new ChangeListener.ChangeEvent()); <END> } invalidate(); } return false; } }); }</code><technical_language>pools for events. For example other widgets, Button:123. done in a method anyway, is duplicated multiple methods called programatically easily</technical_language>

Target:
public Spinner (SpinnerStyle style, SpinnerModel model) { this.style = style; this.model = model; currentBackground = style.background; layout = new GlyphLayout(style.font, model.getDisplayValue()); setSize(getPrefWidth(), getPrefHeight()); this.addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { updateBackgroundForCoords(x, y); return true; } @Override public void touchUp (InputEvent event, float x, float y, int pointer, int button) { if (getState() == SpinnerState.NEXT) updateValue(true); else if (getState() == SpinnerState.PREVIOUS) updateValue(false); updateBackgroundForCoords(x, y); } @Override public void touchDragged (InputEvent event, float x, float y, int pointer) { updateBackgroundForCoords(x, y); } @Override public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) { if (getStage() != null) { getStage().setScrollFocus(Spinner.this); getStage().setKeyboardFocus(Spinner.this); } updateBackgroundForCoords(x, y); } @Override public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) { updateBackgroundForCoords(x, y); } @Override public boolean scrolled (InputEvent event, float x, float y, int amount) { if (getState() != SpinnerState.IDLE) updateValue(amount < 0); return false; } @Override public boolean keyDown (InputEvent event, int keycode) { if (getState() != SpinnerState.IDLE) { if (keycode == Input.Keys.UP) updateValue(true); else if (keycode == Input.Keys.DOWN) updateValue(false); } return false; } }); }