From c655df1ccb49fb2263715eb3bd3e2629949334dd Mon Sep 17 00:00:00 2001 From: MoMeak Date: Wed, 23 Aug 2017 14:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=BA=A4=E4=BA=92=E8=A6=81?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=BC=A9=E6=94=BE=E6=9D=A1?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E6=9D=A1=E4=BB=B6=E9=99=90=E5=88=B6?= =?UTF-8?q?0-400=E7=9A=84=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JFormSliderPane.java | 13 ++++++++++++- .../src/com/fr/design/mainframe/JSliderPane.java | 8 ++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java index 3a9e5e6dd..9509e23b6 100644 --- a/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JFormSliderPane.java @@ -16,6 +16,8 @@ import com.fr.general.Inter; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.text.DefaultFormatterFactory; +import javax.swing.text.NumberFormatter; import java.awt.*; import java.awt.event.*; import java.math.BigDecimal; @@ -75,6 +77,15 @@ public class JFormSliderPane extends JPanel { this.setLayout(new BorderLayout()); initSlider(); initShowValSpinner(); + //MoMeak:控制只能输入10-400 + JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); + showValSpinner.setEditor(editor); + JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); + textField.setEditable(true); + DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory(); + NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); + formatter.setAllowsInvalid(false); + initDownUpButton(); initShowValButton(); initUIRadioButton(); @@ -111,7 +122,7 @@ public class JFormSliderPane extends JPanel { } private void initShowValSpinner() { - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1)){ + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)){ public Point getToolTipLocation(MouseEvent event){ return new Point(event.getX(), event.getY() - TOOLTIP_Y); } diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 9d23ecf5e..7de271d6e 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -79,7 +79,7 @@ public class JSliderPane extends JPanel { this.setLayout(new BorderLayout()); initSlider(); initShowValSpinner(); - //MoMeak:控制只能输入10-400,但是用起来感觉不舒服,先注释掉吧 + //MoMeak:控制只能输入10-400 JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0"); showValSpinner.setEditor(editor); JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); @@ -125,7 +125,7 @@ public class JSliderPane extends JPanel { } private void initShowValSpinner() { - showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 10, FOUR_HUNDRED, 1)) { + showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) { public Point getToolTipLocation(MouseEvent event) { return new Point(event.getX(), event.getY() - TOOLTIP_Y); } @@ -232,7 +232,7 @@ public class JSliderPane extends JPanel { new Component[]{fiveTenButton, null}, new Component[]{twoFiveButton, null}, new Component[]{selfAdaptButton, null}, - new Component[]{createSpinnerPanel(), customButton} + new Component[]{customButton, createSpinnerPanel()} }; dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0); dialogContentPanel.setBackground(BACK_COLOR); @@ -475,7 +475,7 @@ class JSliderPaneUI extends BasicSliderUI { class PopupPane extends JPopupMenu { private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 292; + private static final int DIALOG_HEIGHT = 192; PopupPane(JButton b, JPanel dialogContentPanel) { this.add(dialogContentPanel, BorderLayout.CENTER);