|
|
|
@ -3,6 +3,7 @@ package com.fr.design.gui.ispinner;
|
|
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
|
import com.fine.theme.light.ui.FineInputUI; |
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
import com.fine.theme.utils.FineUIUtils; |
|
|
|
|
import com.fr.design.event.GlobalNameListener; |
|
|
|
|
import com.fr.design.event.GlobalNameObserver; |
|
|
|
|
import com.fr.design.event.HoverAware; |
|
|
|
@ -44,6 +45,8 @@ import java.awt.event.MouseWheelListener;
|
|
|
|
|
*/ |
|
|
|
|
public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver, HoverAware { |
|
|
|
|
|
|
|
|
|
private final Insets defaultInsets = new Insets(0, 6, 0, 6); |
|
|
|
|
private final int defaultButtonSize = 24; |
|
|
|
|
protected double value; |
|
|
|
|
private static final int DEFAULT_NUMBERFIELD_COLUMNS = 2; |
|
|
|
|
private UINumberField textField; |
|
|
|
@ -64,6 +67,13 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
|
|
|
|
|
|
|
|
|
|
private boolean hover; |
|
|
|
|
|
|
|
|
|
private static final String UI_CLASS_ID = "InputUI"; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getUIClassID() { |
|
|
|
|
return UI_CLASS_ID; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public UISpinner() { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -89,7 +99,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
|
|
|
|
|
this.dierta = dierta; |
|
|
|
|
initComponents(); |
|
|
|
|
iniListener(); |
|
|
|
|
setUI(FineInputUI.createUI(this)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void iniListener() { |
|
|
|
@ -272,6 +281,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
|
|
|
|
|
textField = initNumberField(); |
|
|
|
|
textField.setMaxValue(maxValue); |
|
|
|
|
textField.setMinValue(minValue); |
|
|
|
|
Insets insets = FineUIUtils.getAndScaleUIInsets("InputTextField.borderInsets", defaultInsets); |
|
|
|
|
textField.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); |
|
|
|
|
textField.setOpaque(false); |
|
|
|
|
|
|
|
|
|
setValue(value); |
|
|
|
|
preButton = createArrowButton(new LazyIcon("up_arrow_12")); |
|
|
|
|
nextButton = createArrowButton(new LazyIcon("down_arrow_12")); |
|
|
|
@ -283,9 +296,9 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
|
|
|
|
|
arrowPane.add(nextButton); |
|
|
|
|
arrowPane.setOpaque(false); |
|
|
|
|
|
|
|
|
|
int buttonWidth = UIManager.getInt("InputButton.width"); |
|
|
|
|
int buttonHeight = UIManager.getInt("InputButton.height"); |
|
|
|
|
arrowPane.setPreferredSize(FineUIScale.scale(new Dimension(buttonWidth, buttonHeight))); |
|
|
|
|
int buttonWidth = FineUIUtils.getAndScaleInt("InputButton.width", defaultButtonSize); |
|
|
|
|
int buttonHeight = FineUIUtils.getAndScaleInt("InputButton.height", defaultButtonSize); |
|
|
|
|
arrowPane.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); |
|
|
|
|
add(arrowPane, BorderLayout.EAST); |
|
|
|
|
componentInitListeners(); |
|
|
|
|
} |
|
|
|
@ -370,10 +383,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Insets insets = UIManager.getInsets("InputTextField.borderInsets"); |
|
|
|
|
Insets scaledInsets = FineUIScale.scale(insets); |
|
|
|
|
numberField.setBorder(BorderFactory.createEmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right)); |
|
|
|
|
numberField.setOpaque(false); |
|
|
|
|
return numberField; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|