- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的程序中有一个部分,用户应该能够编辑时间量。已经设置了默认时间量,但用户应该能够根据需要对其进行编辑 (00:00:00)是否可以使用单行 JTextArea 来限制可以输入的字符(显然只能输入数字)和某种不允许编辑冒号的过滤器?或者有更简单的东西吗?
最佳答案
因此,处理持续时间有很大不同,因为许多正常的“验证”过程可以被丢弃(例如,您并不真正关心时间,因为用户可能需要输入 100 小时,因为示例)...
所以,基于这个time field example ,我剥离了 API 并重新构建了它(无论如何它确实需要彻底修改;))
所以我最终得到了这个持续时间字段......
从本质上讲,它只不过是一系列带有 DocumentFilter
、DocumentListener
的字段、一些键绑定(bind)和通用自动化,使其“看起来”像一个单个字段...
import java.awt.Component;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
public class DurationField extends AbstractTimeField {
private HourDocumentFilter hourDocumentFilter;
private JTextField secondField;
private DocumentFilter secondDocumentFilter;
private FocusListener secondFocusHandler;
public DurationField() {
setDuration(0, 0, 0);
}
public void setDuration(int hour, int minute, int seconds) {
setHour(hour);
setMinute(minute);
setSeconds(seconds);
}
public long getDuration() throws NumberFormatException {
int hour = getHour();
int minute = getMinute();
int second = getSecond();
return (hour * 60 * 60 * 1000)
+ (minute * 60 * 1000)
+ (second * 1000);
}
@Override
public void setHour(int hour) {
setFieldValue(getHourField(), hour, 3);
}
public void setSeconds(int seconds) {
setFieldValue(getSecondField(), seconds, 2);
}
public int getSecond() throws NumberFormatException {
return Integer.parseInt(getSecondField().getText());
}
@Override
protected JTextField createHourField() {
JTextField field = super.createHourField();
field.setColumns(4);
return field;
}
@Override
protected int getHourFocusForwardLength() {
return -1;
}
protected int getSecondFocusForwardLength() {
return 2;
}
protected JTextField createSecondField() {
JTextField secondField = new JTextField(2);
((AbstractDocument) secondField.getDocument()).setDocumentFilter(getSecondDocumentFilter());
secondField.addFocusListener(getSecondFocusHandler());
secondField.setHorizontalAlignment(JTextField.RIGHT);
secondField.getDocument().addDocumentListener(new MoveFocusForwardHandler(secondField, getMinuteFocusForwardLength()));
return secondField;
}
@Override
protected JComponent[] getTimeFields() {
return new JComponent[]{
getHourField(),
new JLabel(":"),
getMinuteField(),
new JLabel("."),
getSecondField()
};
}
@Override
protected List<JComponent> initFocusTransveralOrder() {
List<JComponent> order = super.initFocusTransveralOrder();
order.add(getSecondField());
return order;
}
@Override
protected void installKeyBindings() {
super.installKeyBindings();
JTextField minuteField = getMinuteField();
installKeyBinding(
minuteField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, 0),
"toSecondField",
new MoveFocusForward());
installKeyBinding(
minuteField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),
"afterMinuteArrow",
new MoveFieldFocusForward(minuteField, true));
installKeyBinding(
minuteField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD6, 0),
"afterMinuteKeyPad",
new MoveFieldFocusForward(minuteField, false));
JTextField secondField = getMinuteField();
installKeyBinding(
secondField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),
"beforeSecond",
new MoveFieldFocusBackward(minuteField, true));
installKeyBinding(
secondField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD4, 0),
"beforeSecond",
new MoveFieldFocusBackward(secondField, false));
}
public JTextField getSecondField() {
if (secondField == null) {
secondField = createSecondField();
}
return secondField;
}
@Override
protected DocumentFilter getHourDocumentFilter() {
if (hourDocumentFilter == null) {
hourDocumentFilter = new HourDocumentFilter();
}
return hourDocumentFilter;
}
protected DocumentFilter getSecondDocumentFilter() {
if (secondDocumentFilter == null) {
secondDocumentFilter = new SecondDocumentFilter();
}
return secondDocumentFilter;
}
/**
* Returns the focus listener used to monitor the hour field
*
* @return
*/
protected FocusListener getSecondFocusHandler() {
if (secondFocusHandler == null) {
secondFocusHandler = new SecondFocusHandler();
}
return secondFocusHandler;
}
protected void secondFieldLostFocus(FocusEvent evt) {
String text = getSecondField().getText();
if (text.length() < 2) {
text = pad(text, 2);
getSecondField().setText(text);
}
}
/**
* Hour field focus handler. This watches for focus lost events a automatically pads the field with a leading "0" if the field is only 1 character in length
*/
protected class SecondFocusHandler extends AbstractFocusHandler {
@Override
public void focusLost(FocusEvent e) {
secondFieldLostFocus(e);
}
}
protected class HourDocumentFilter extends DocumentFilter {
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
System.out.println("insert: offset = " + offset + "; text = " + text);
super.insertString(fb, offset, text, attr);
}
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
try {
// We convert the value here to make sure it's a number...
int value = Integer.parseInt(text);
super.replace(fb, offset, length, text, attrs);
} catch (NumberFormatException exp) {
}
}
}
protected class SecondDocumentFilter extends DocumentFilter {
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
super.insertString(fb, offset, text, attr);
}
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
try {
boolean isAcceptable = false;
// How long is the text been added
int strLength = text.length();
// Convert the value to an integer now and save us the hassel
int value = Integer.parseInt(text);
// If the length is only 1, probably a new character has been added
if (strLength == 1) {
// The valid range of values we can accept
int upperRange = 9;
int lowerRange = 0;
// Is the value acceptable..
if (value >= lowerRange && value <= upperRange) {
isAcceptable = true;
}
} else {
// Basically, we are going to trim the value down to at max 2 characters
// Need to know at what offest...
// 2 - offset..
// offset == 0, length = 2 - offset = 2
// offset == 1, length = 2 - offset = 1
strLength = 2 - offset;
String timeText = text.substring(offset, strLength);
value = Integer.parseInt(timeText);
if (value >= 0 && value <= 59) {
// Pad out the value as required
text = pad(value, 2);
isAcceptable = true;
}
}
if (isAcceptable) {
super.replace(fb, offset, length, text, attrs);
}
} catch (NumberFormatException exp) {
}
}
}
}
还有抽象父类...
import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.KeyboardFocusManager;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.AbstractDocument;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
import javax.swing.text.JTextComponent;
public abstract class AbstractTimeField extends JPanel {
private DocumentFilter minDocumentFilter;
private FocusListener hourFocusHandler;
private FocusListener minuteFocusHandler;
private JTextField hourField;
private JTextField minuteField;
private JPanel pnlFields;
private List<JComponent> focusOrder;
public AbstractTimeField() {
initUI();
installKeyBindings();
}
protected void initUI() {
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
add(getTimeFieldsPanel(), gbc);
}
protected void installKeyBindings() {
JTextField hourField = getHourField();
installKeyBinding(
hourField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_SEMICOLON, KeyEvent.SHIFT_DOWN_MASK),
"toMinuteField",
new MoveFocusForward());
installKeyBinding(
hourField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),
"afterHourArrow",
new MoveFieldFocusForward(hourField, true));
installKeyBinding(
hourField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD6, 0),
"afterHourKeyPad",
new MoveFieldFocusForward(hourField, false));
JTextField minuteField = getMinuteField();
installKeyBinding(
minuteField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),
"beforeMinuteArrow",
new MoveFieldFocusBackward(minuteField, true));
installKeyBinding(
minuteField,
JComponent.WHEN_FOCUSED,
KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD4, 0),
"beforeMinuteKeyPad",
new MoveFieldFocusBackward(minuteField, false));
}
protected JPanel getTimeFieldsPanel() {
if (pnlFields == null) {
pnlFields = new JPanel(new GridBagLayout());
pnlFields.setBorder(new CompoundBorder(UIManager.getBorder("TextField.border"), new EmptyBorder(0, 2, 0, 2)));
pnlFields.setBackground(UIManager.getColor("TextField.background"));
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
for (JComponent field : getTimeFields()) {
field.setBorder(null);
pnlFields.add(field, gbc);
gbc.gridx++;
}
}
return pnlFields;
}
protected JComponent[] getTimeFields() {
return new JComponent[]{
getHourField(),
new JLabel(":"),
getMinuteField()
};
}
protected List<JComponent> initFocusTransveralOrder() {
List<JComponent> focusOrder = new ArrayList<>(3);
focusOrder.add(getHourField());
focusOrder.add(getMinuteField());
return focusOrder;
}
protected List<JComponent> getFocusTraversalOrder() {
if (focusOrder == null) {
focusOrder = initFocusTransveralOrder();
}
return focusOrder;
}
protected int getHourFocusForwardLength() {
return 2;
}
protected int getMinuteFocusForwardLength() {
return 2;
}
protected JTextField createHourField() {
JTextField hourField = new JTextField(2);
((AbstractDocument) hourField.getDocument()).setDocumentFilter(getHourDocumentFilter());
hourField.addFocusListener(getHourFocusHandler());
hourField.setHorizontalAlignment(JTextField.RIGHT);
hourField.getDocument().addDocumentListener(new MoveFocusForwardHandler(hourField, getHourFocusForwardLength()));
return hourField;
}
public JTextField getHourField() {
if (hourField == null) {
hourField = createHourField();
}
return hourField;
}
protected JTextField createMinuteField() {
JTextField minuteField = new JTextField(2);
((AbstractDocument) minuteField.getDocument()).setDocumentFilter(getMinuteDocumentFilter());
minuteField.addFocusListener(getMinuteFocusHandler());
minuteField.setHorizontalAlignment(JTextField.RIGHT);
minuteField.getDocument().addDocumentListener(new MoveFocusForwardHandler(hourField, getMinuteFocusForwardLength()));
return minuteField;
}
public int getHour() throws NumberFormatException {
return getFieldValue(getHourField());
}
public int getMinute() throws NumberFormatException {
return getFieldValue(getMinuteField());
}
protected int getFieldValue(JTextComponent field) throws NumberFormatException {
return Integer.parseInt(field.getText());
}
public void setHour(int hour) {
setFieldValue(getHourField(), hour, 2);
}
public void setMinute(int minute) {
setFieldValue(getMinuteField(), minute, 2);
}
protected void setFieldValue(JTextComponent field, int value, int padding) {
String text = pad(value, padding);
field.setText(text);
}
public JTextField getMinuteField() {
if (minuteField == null) {
minuteField = createMinuteField();
}
return minuteField;
}
/**
* Returns the document filter used to filter the hour field
*
* @return
*/
protected abstract DocumentFilter getHourDocumentFilter();
/**
* Returns the document filter user to filter the minute field
*
* @return
*/
protected DocumentFilter getMinuteDocumentFilter() {
if (minDocumentFilter == null) {
minDocumentFilter = new MinuteDocumentFilter();
}
return minDocumentFilter;
}
/**
* Returns the focus listener used to monitor the hour field
*
* @return
*/
protected FocusListener getHourFocusHandler() {
if (hourFocusHandler == null) {
hourFocusHandler = new HourFocusHandler();
}
return hourFocusHandler;
}
/**
* Used the focus listener used to monitor the minute field
*
* @return
*/
protected FocusListener getMinuteFocusHandler() {
if (minuteFocusHandler == null) {
minuteFocusHandler = new MinuteFocusHandler();
}
return minuteFocusHandler;
}
public static String pad(long lValue, int iMinLength) {
return pad(Long.toString(lValue), 2);
}
public static String pad(int iValue, int iMinLength) {
return pad(Integer.toString(iValue), iMinLength);
}
public static String pad(String sValue, int iMinLength) {
StringBuilder sb = new StringBuilder(iMinLength);
sb.append(sValue);
while (sb.length() < iMinLength) {
sb.insert(0, "0");
}
return sb.toString();
}
protected void hourFieldLostFocus(FocusEvent evt) {
if (!evt.isTemporary()) {
String text = getHourField().getText();
if (text.length() < 2) {
text = pad(text, 2);
getHourField().setText(text);
}
}
}
protected void minuteFieldLostFocus(FocusEvent evt) {
if (!evt.isTemporary()) {
String text = getMinuteField().getText();
if (text.length() < 2) {
getMinuteField().setText(text + "0");
}
}
}
protected void installKeyBinding(JComponent field, int condition, KeyStroke keyStroke, String name, Action action) {
InputMap im = field.getInputMap(condition);
im.put(keyStroke, name);
ActionMap am = field.getActionMap();
am.put(name, action);
}
protected void moveFocusToNextField(JComponent parent) {
List<JComponent> order = getFocusTraversalOrder();
Component current = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (current == parent) {
int index = order.indexOf(current);
if (index != -1) {
if (index == order.size() - 1) {
transferFocus();
} else {
JComponent next = order.get(index + 1);
next.requestFocusInWindow();
}
} else {
transferFocus();
}
}
}
protected void moveFocusToPreviousField(JComponent parent) {
List<JComponent> order = getFocusTraversalOrder();
Component current = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (current == parent) {
int index = order.indexOf(current);
if (index != -1) {
if (index == 0) {
transferFocusBackward();
} else {
JComponent previous = order.get(index - 1);
previous.requestFocusInWindow();
}
} else {
transferFocusBackward();
}
}
}
protected abstract class AbstractFocusHandler extends FocusAdapter {
@Override
public void focusGained(FocusEvent e) {
if (e.getComponent() instanceof JTextComponent) {
JTextComponent field = (JTextComponent) e.getComponent();
field.selectAll();
}
}
}
/**
* Hour field focus handler. This watches for focus lost events a automatically pads the field with a leading "0" if the field is only 1 character in length
*/
protected class HourFocusHandler extends AbstractFocusHandler {
@Override
public void focusLost(FocusEvent e) {
hourFieldLostFocus(e);
}
}
/**
* Minute field focus handler, watches for focus lost events and automatically adds a "0" to the end of the field if it is only 1 character in length
*/
protected class MinuteFocusHandler extends AbstractFocusHandler {
@Override
public void focusLost(FocusEvent e) {
minuteFieldLostFocus(e);
}
}
protected class MoveFocusForwardHandler implements DocumentListener {
private JTextComponent parent;
private int maxLength;
public MoveFocusForwardHandler(JTextComponent parent, int maxLength) {
this.parent = parent;
this.maxLength = maxLength;
}
public int getMaxLength() {
return maxLength;
}
public JTextComponent getParent() {
return parent;
}
@Override
public void insertUpdate(DocumentEvent e) {
documentChanged(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
documentChanged(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
documentChanged(e);
}
protected void documentChanged(DocumentEvent e) {
if (getMaxLength() > 0) {
if (e.getDocument().getLength() >= getMaxLength()) {
moveFocusToNextField(getParent());
}
}
}
}
/**
* The document filter used to filter the minute field.
*/
protected class MinuteDocumentFilter extends DocumentFilter {
@Override
public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attr) throws BadLocationException {
super.insertString(fb, offset, text, attr);
}
@Override
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
try {
boolean isAcceptable = false;
// How long is the text been added
int strLength = text.length();
// Convert the value to an integer now and save us the hassel
int value = Integer.parseInt(text);
// If the length is only 1, probably a new character has been added
if (strLength == 1) {
// The valid range of values we can accept
int upperRange = 9;
int lowerRange = 0;
if (offset == 0) {
// If we are at the first edit position, we can only accept values
// from 0-5 (50 minutes that is)
upperRange = 5;
}
// Is the value acceptable..
if (value >= lowerRange && value <= upperRange) {
isAcceptable = true;
}
} else {
// Basically, we are going to trim the value down to at max 2 characters
// Need to know at what offest...
// 2 - offset..
// offset == 0, length = 2 - offset = 2
// offset == 1, length = 2 - offset = 1
strLength = 2 - offset;
String timeText = text.substring(offset, strLength);
value = Integer.parseInt(timeText);
if (value >= 0 && value <= 59) {
// Pad out the value as required
text = pad(value, 2);
isAcceptable = true;
}
}
if (isAcceptable) {
super.replace(fb, offset, length, text, attrs);
if (fb.getDocument().getLength() == 2) {
moveFocusToNextField(getMinuteField());
}
}
} catch (NumberFormatException exp) {
}
}
}
public class TimeFocusTraversalPolicy
extends FocusTraversalPolicy {
private List<Component> order;
public TimeFocusTraversalPolicy(List<Component> order) {
this.order = new ArrayList<>(order.size());
this.order.addAll(order);
}
@Override
public Component getComponentAfter(Container focusCycleRoot,
Component aComponent) {
int idx = (order.indexOf(aComponent) + 1) % order.size();
return order.get(idx);
}
@Override
public Component getComponentBefore(Container focusCycleRoot,
Component aComponent) {
int idx = order.indexOf(aComponent) - 1;
if (idx < 0) {
idx = order.size() - 1;
}
return order.get(idx);
}
@Override
public Component getDefaultComponent(Container focusCycleRoot) {
return order.get(0);
}
@Override
public Component getLastComponent(Container focusCycleRoot) {
return order.get(order.size() - 1);
}
@Override
public Component getFirstComponent(Container focusCycleRoot) {
return order.get(0);
}
}
public class MoveFocusForward extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
moveFocusToNextField((JComponent) e.getSource());
}
}
public class MoveFocusBackward extends AbstractAction {
@Override
public void actionPerformed(ActionEvent e) {
moveFocusToPreviousField((JComponent) e.getSource());
}
}
public class MoveFieldFocusForward extends AbstractAction {
private JTextComponent field;
private final boolean ignoreNumLock;
public MoveFieldFocusForward(JTextComponent field, boolean ignoreNumLock) {
this.field = field;
this.ignoreNumLock = ignoreNumLock;
}
@Override
public void actionPerformed(ActionEvent e) {
boolean numLockOff = false;
try {
// Get the state of the nums lock
numLockOff = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
} catch (Exception exp) {
}
if (ignoreNumLock || !numLockOff) {
if (field.getCaretPosition() >= field.getDocument().getLength()) {
moveFocusToNextField((JComponent) e.getSource());
}
}
}
}
public class MoveFieldFocusBackward extends AbstractAction {
private JTextComponent field;
private final boolean ignoreNumLock;
public MoveFieldFocusBackward(JTextComponent field, boolean ignoreNumLock) {
this.field = field;
this.ignoreNumLock = ignoreNumLock;
}
@Override
public void actionPerformed(ActionEvent e) {
boolean numLockOff = false;
try {
// Get the state of the nums lock
numLockOff = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
} catch (Exception exp) {
}
if ((ignoreNumLock || !numLockOff) && field.getCaretPosition() <= 1) {
moveFocusToPreviousField((JComponent) e.getSource());
}
}
}
}
抽象是为了我的利益,从这里我也可以构建一个 TimeField
:)
关于java - JTextArea 过滤器和/或时间输入 (00 :00:00) Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25477999/
我有一个测试即将进行,我想澄清两个有关参数的问题。 在我的笔记中指出,将参数传递给函数的推荐方法是使用“按引用传递” const type& x; // for "in" parameters
当我通过 OMG 2.5(Beta)推广的 UML 规范阅读以下概念时: in: Indicates that Parameter values are passed in by the caller
我试图在用户按下 Enter 时触发一个函数。我将此输入设置为只读的原因是限制用户在填充值后修改输入中的值。 该值来自将在点击属性中触发的弹出窗口。问题是 keyup.enter 没有触发该输入。 代
我在jQuery中使用模式弹出窗口控件,该弹出窗口具有由jQuery Tokenize输入插件提供动力的输入文本。问题是,当我在模式弹出文本框中键入内容时, token 化插件的搜索结果显示为隐藏在弹
我有一个问题。当我选中复选框时,系统工作正常,总值发生变化,但一旦我修改文本输入,它就会变为 0。我需要将此文本框输入排除在更改值之外。 这是 html: $15000 $
我正在努力让它发挥作用,但还是有些不对劲。 我想用 CSS 设置提交按钮的样式以匹配我已有的按钮。 风格: input[type="button"], input[type="submit"], b
import java.util.*;; public class selection { Scanner in=new Scanner(System.in); private
这可能是一个非常菜鸟的问题。假设我有一个带宽限制为 100MB/s 的网卡,那么输入/输出带宽是否有可能达到该限制 同时 ?或者我会在任何时候遇到这个不等式:in bandwidth + out ba
看着这个问题,Fill immutable map with for loop upon creation ,我很好奇是什么this表示在 Map(1 -> this) . scala> Map(1
我有这样的东西 一个 乙 问? 是或否 数字 数字或零 我想做的是: 如果 B1 = “Y”,则让用户在 B2 中输入一个数字。 如果 B1 = “N”,则将 B2 中的值更改为零,并且不允许用户在
我有一个包含许多列的表,我想添加 input标题单元格内的字段,但我希望输入适合根据正文内容的宽度。 这是没有 input 的样子领域: 这就是 input 的样子领域: 可以看出,像“index”和
关于为 FTP 客户端设置传出和传入文件夹,您遵循哪些最佳实践(如果有)?我们通常使用“outgoing”和“incoming”,但无论你如何表述方向,它都可以有两种解释方式,具体取决于名称相对于哪一
我正在尝试“求解”给定 d 的 Pell 方程:x^2 - d * y^2 = 1,或者至少我想得到最小的 x > 0 来求解方程。到目前为止,一切都很好。这是我的 Haskell 代码 minX :
我是VS Code的新手,可以使用Ctrl + Enter将代码运行到python交互式窗口中。我希望光标自动移动到下一行,因此我可以逐行浏览代码。 能做到吗? 最佳答案 如this blog pos
我正在创建一个 bool 值矩阵/二维数组,并且我想为 dategrid 推断一种不仅仅是“ANY”的类型。 let yearRange = [2000,2001,2002,2003,2004]; l
我有两个排序的列表,例如 a = [1, 4, 7, 8] b = [1, 2, 3, 4, 5, 6] 我想知道a中的每个项目是否在b中。对于上面的示例,我想找到 a_in_b = [True, T
菜鸟警报 这很奇怪 - 当我编写以下代码时,尝试在 AngularJS 中创建自定义指令: myModule.directive('myTab', function(){ console.lo
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
假设我正在使用 gdscript 静态类型,并且对于一个函数参数,我事先不知道我会得到什么。这就是 python 中 typing.Any 的作用。如何使用 gdscript 做到这一点? 似乎 Va
我使用 dropzone 上传多个图像,并且工作正常,直到我想为每个图像插入品牌和网址。 我遇到的唯一问题是,当我要从输入字段获取值时,我会从服务器获取来自字段(品牌、网址)的未定义值,但如果我使用静
我是一名优秀的程序员,十分优秀!