/*
 * Copyright 2000-2016 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.ui;

import javax.swing.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class PortField extends JSpinner {
  public PortField() {
    this(0);
  }

  public PortField(int value) {
    this(value, 0);
  }

  public void setMin(int value) {
    ((SpinnerNumberModel)getModel()).setMinimum(value);
  }

  public PortField(int value, int min) {
    setModel(new SpinnerNumberModel(value, min, 65535, 1));
    final NumberEditor editor = new NumberEditor(this, "#");
    setEditor(editor);
    final MyListener listener = new MyListener();
    final JFormattedTextField field = editor.getTextField();
    field.addFocusListener(listener);
    field.addMouseListener(listener);
  }

  public void setEditable(boolean value) {
    ((NumberEditor)getEditor()).getTextField().setEditable(value);
  }

  public void setNumber(int value) {
    setValue(value);
  }

  public int getNumber() {
    return ((SpinnerNumberModel)getModel()).getNumber().intValue();
  }

  public boolean isSpecified() {
    return getNumber() != 0;
  }

  private static class MyListener extends MouseAdapter implements FocusListener {

    private boolean select = true;

    @Override
    public void mousePressed(MouseEvent e) {
      select = false;
    }

    @Override
    public void focusGained(FocusEvent e) {
      if (!select) {
        select = true;
        return;
      }
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(() -> {
        final Object source = e.getSource();
        if (source instanceof JFormattedTextField) {
          final JFormattedTextField textField = (JFormattedTextField)source;
          textField.selectAll();
        }
      });
    }


    @Override
    public void focusLost(FocusEvent e) {}

  }
}
@@ -631,128 +631,64 @@
 ort 
-javax.swing.*;%0Aimport java.awt.event.FocusEvent;%0Aimport java.awt.event.FocusListener;%0Aimport java.awt.event.MouseAdapter
+org.jetbrains.annotations.NotNull;%0A%0Aimport javax.swing.*
 ;%0Aim
@@ -707,26 +707,17 @@
 t.event.
-MouseEvent
+*
 ;%0A%0Apubli
@@ -1177,24 +1177,61 @@
 Listener();%0A
+    addMouseWheelListener(listener);%0A
     final JF
@@ -2412,13 +2412,1971 @@
  e) %7B%7D%0A%0A
+    @Override%0A    public void mouseWheelMoved(MouseWheelEvent e) %7B%0A      final Object source = e.getSource();%0A      if (source instanceof JSpinner) %7B%0A        final JSpinner spinner = (JSpinner)source;%0A        final SpinnerModel model = spinner.getModel();%0A        if (model instanceof SpinnerNumberModel) %7B%0A          final SpinnerNumberModel numberModel = (SpinnerNumberModel)model;%0A          final Number value = (Number)numberModel.getValue();%0A          final Number stepSize = numberModel.getStepSize();%0A          final Comparable minimum = numberModel.getMinimum();%0A          final Comparable maximum = numberModel.getMaximum();%0A          final Number newValue = calculateNewValue(value, stepSize, minimum, maximum, e.getUnitsToScroll());%0A          if (newValue != null) %7B%0A            numberModel.setValue(newValue);%0A          %7D%0A        %7D%0A      %7D%0A    %7D%0A%0A    private static Number calculateNewValue(@NotNull Number value, @NotNull Number stepSize,%0A                                            Comparable minimum, Comparable maximum, int steps) %7B%0A      final Number newValue;%0A      if ((value instanceof Float) %7C%7C (value instanceof Double)) %7B%0A        final double v = value.doubleValue() + (stepSize.doubleValue() * (double)steps);%0A        newValue = value instanceof Double ? new Double(v) : new Float(v);%0A      %7D%0A      else %7B%0A        final long v = value.longValue() + (stepSize.longValue() * (long)steps);%0A%0A        if (value instanceof Long) %7B%0A          newValue = Long.valueOf(v);%0A        %7D%0A        else if (value instanceof Integer) %7B%0A          newValue = Integer.valueOf((int)v);%0A        %7D%0A        else if (value instanceof Short) %7B%0A          newValue = Short.valueOf((short)v);%0A        %7D%0A        else %7B%0A          newValue = Byte.valueOf((byte)v);%0A        %7D%0A      %7D%0A%0A      if ((maximum != null) && (maximum.compareTo(newValue) %3C 0) %7C%7C (minimum != null) && (minimum.compareTo(newValue) %3E 0)) %7B%0A        return null;%0A      %7D%0A      return newValue;%0A    %7D%0A
   %7D%0A%7D

allow to modify proxy port with mouse wheel