纠结的Flex TextField...

以下是本人写TextField垂直居中的时候遇见的闹心事!

var textField:TextField = new TextField();
textField.autoSize = "center";
textField.multiline = true;
textField.wordWrap = true;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
textField.y = 100;
textField.x = 200;
this.addChild(textField);

如果textField属性书写顺序为以上排列, 运行效果如下:


var textField:TextField = new TextField();
textField.autoSize = "center";
textField.y = 100;
textField.x = 200;
textField.multiline = true;
textField.wordWrap = true;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
this.addChild(textField);

如果textField属性书写顺序为以上排列, 运行效果如下:
var textField:TextField = new TextField();
textField.autoSize = "center";
textField.multiline = true;
textField.wordWrap = true;
textField.y = 100;
textField.x = 200;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
this.addChild(textField);

如果textField属性书写顺序为以上排列, 运行效果如下:

var textField:TextField = new TextField();
//textField.autoSize = "center";
textField.multiline = true;
textField.wordWrap = true;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
textField.y = 100;
textField.x = 200;
this.addChild(textField);

如果textField属性把autoSize属性去掉, 运行效果如下:

这个东西浪费了我好几个小时, 真是不知该如何表达我的心情了!!!
@Override public void actionPerformed(ActionEvent e) {//触发此动作时执行 for (int i = 0; i < 10; i++) { if (e.getSource() == numberButtons[i]) {//返回最初发生 Event 的对象,那个对象被触发,就返回这个对象 textField.setText(textField.getText().concat(String.valueOf(i))); } } if (e.getSource() == decButton) { textField.setText(textField.getText().concat(".")); } if (e.getSource() == addButton) { num1 = Double.parseDouble(textField.getText()); operator = '+'; textField.setText(""); } if (e.getSource() == subButton) { num1 = Double.parseDouble(textField.getText()); operator = '-'; textField.setText(""); } if (e.getSource() == mulButton) { num1 = Double.parseDouble(textField.getText()); operator = '*'; textField.setText(""); } if (e.getSource() == divButton) { num1 = Double.parseDouble(textField.getText()); operator = '/'; textField.setText(""); } if (e.getSource() == equButton) { num2 = Double.parseDouble(textField.getText()); switch (operator) { case '+': result = num1 + num2; break; case '-': result = num1 - num2; break; case '*': result = num1 * num2; break; case '/': result = num1 / num2; break; } textField.setText(String.valueOf(result)); num1 = result; } if (e.getSource() == clrButton) { textField.setText(""); } if (e.getSource() == delButton) { String string = textField.getText(); textField.setText(""); for (int i = 0; i < string.length() - 1; i++) { textField.setText(textField.getText() + string.charAt(i)); } } } }请注释出每一步在做什么
最新发布
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值