forked from fanruan/design
plough
7 years ago
17 changed files with 128 additions and 42 deletions
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 388 B |
@ -0,0 +1,48 @@
|
||||
package com.fr.design.widget.ui.designer.component; |
||||
|
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
|
||||
import java.awt.event.FocusAdapter; |
||||
import java.awt.event.FocusEvent; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
|
||||
/** |
||||
* Created by kerry on 2017/11/7. |
||||
*/ |
||||
public class UIBoundSpinner extends UISpinner{ |
||||
|
||||
public UIBoundSpinner(double minValue, double maxValue, double dierta) { |
||||
super(minValue, maxValue, dierta); |
||||
} |
||||
|
||||
public UIBoundSpinner(double minValue, double maxValue, double dierta, double defaultValue) { |
||||
super(minValue, maxValue, dierta, defaultValue); |
||||
} |
||||
|
||||
@Override |
||||
protected void initTextFiledListeners(){ |
||||
this.getTextField().addFocusListener(new FocusAdapter() { |
||||
@Override |
||||
public void focusLost(FocusEvent e) { |
||||
setTextFieldValue(getTextField().getValue()); |
||||
setTextField(value); |
||||
} |
||||
}); |
||||
|
||||
this.getTextField().addKeyListener(new KeyAdapter() { |
||||
@Override |
||||
public void keyPressed(KeyEvent e) { |
||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
||||
setTextFieldValue(getTextField().getValue()); |
||||
setTextField(value); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
protected void setTextField(double value){ |
||||
this.getTextField().setValue(value); |
||||
} |
||||
} |
Loading…
Reference in new issue