javaSwing中在文本框TextField中输入值,然后点击按钮获取文本框中的值并进行相应的计算,怎么实现啊

javaSwing中在文本框TextField中输入值,然后点击按钮获取文本框中的值并进行相应的计算,怎么实现啊,第1张

1、监听按钮

EventAction ea;eagetSource()equals("你的按钮对象名称");//--即表示按钮被点击了

2、获取输入框值

TextField tf;tfgetText();//--即可获得输入框文本

必填为:allowBlank : false(这个不能控制用户填不填,但是用户不填会报红,可以联系到form不让用户这次 *** 作有效)

alert( ExtgetCmp("flen")getValue()) 是undefinde,应该是你没有给组件设置初始值。

可以配置一个value属性,比如 value : 123

试试[textfield becomeFirstResponder],取消焦点的方法 resignFirstResponder 在于tableview关联的NSarray中设置一个控制字段,例如bool值flag,button点击,则flag=!flag,然后table reloadData,在-(UITableViewCell )

这个是很简单的事件触发机制的例子,稍等,我弄给你!!

你需要的是awt的做的?还是用swing做的?

下面是awt的

import javaawt;

import javaawtevent;

public class Demo implements ActionListener

{

TextField txtf;

TextArea txta;

public Demo()

{

Frame f = new Frame("实例");

fsetSize(500,300);

txtf = new TextField(10);

txta = new TextArea(10,8);

fadd(txtf,BorderLayoutNORTH);

fadd(txta,BorderLayoutCENTER);

txtfaddActionListener(this);

fsetVisible(true);

}

public static void main(String args[])

{

new Demo();

}

public void actionPerformed(ActionEvent e)

{

txtaappend(txtfgetText());

}

}

你好。

你试下:

sizeWithFont: constrainedToSize: lineBreakMode:

NSString 的方法 可以获取size

- (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath )indexPath

{

static NSString CellIdentifier = @"LabelTextFieldCell";

LabelTextFieldCell cell = (LabelTextFieldCell )[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

//根据nib,实例化cell

NSArray nib = [[UINib nibWithNibName:@"LabelTextFieldCell" bundle:nil] instantiateWithOwner:self options:nil];

cell= (LabelTextFieldCell )[nib objectAtIndex:0];

}

// Configure the cell

//设置text的值

cellinputTexttext = [selfdata objectAtIndex:indexPathrow];

//弱类型才可以再块中进行改变

__weak NSMutableArray dataWeak = selfdata;

//具体声明块方法,将text修改后的值,传递回Data中

cellonTextEntered = ^(NSString enteredString){

[dataWeak setObject:enteredString atIndexedSubscript:indexPathrow];

};

return cell;

}

首先创建一个UIAlertView并且在上面添加一个UITextField

在UIAlertView上添加一个UITextField

Objective-C

UIAlertView pwdAlert = [[UIAlertView alloc] initWithTitle:message

message:@"\n\n"

delegate:self

cancelButtonTitle:@"取消"

otherButtonTitles:@"确定", nil];

[pwdAlert setTag:kAlertTagOfJoinForumPassword];

[pwdAlert setDelegate:self];

UITextField textFieldPwd = [[UITextField alloc] initWithFrame:CGRectMake(270, 600, 2300, 250)];

[textFieldPwd setBackgroundColor:[UIColor whiteColor]];

[textFieldPwd setTag:kTextFieldTagOfForumPassword];

[textFieldPwd setPlaceholder:@"请输入密码"];

[pwdAlert addSubview:textFieldPwd;

[textFieldPwd release];

[pwdAlert show];

[pwdAlert release];

接下来获取UITextField里面输入的值,这里首先要实现UIAlertView的delegate的方法:alertView:(UIAlertView )alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

Objective-C

- (void)alertView:(UIAlertView )alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

{

NSInteger aTag = [alertView tag];

//输入的密码

if(aTag == kAlertTagOfJoinForumPassword){

if (buttonIndex == 1) {

//选择确定

UITextField pwdTextField = (UITextField )[alertView viewWithTag:kTextFieldTagOfForumPassword];

NSString pwd = [pwdTextFieldtext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

//

}else{

//选择取消

}

}

}

Categorized under: iphone/ipad, UIAlertView

Tagged with: UIAlertView, UITextField, 输入

Comments are closed

action接收jsp传来的值,主要的方式是将数据放在request对象中,然后在另一个页面拿到这个数据即可,代码如下:

Ajsp :通过post 和get、连接都可以传

a标签连接的:

<a herf='Bjspname=<%=name%>'>传递到B页面</a>

Bjsp :

B页面通过如下代码接收

<%

String name=requestgetParameter("name");

outprintln("接收到:"+name);

%>

以上就是关于javaSwing中在文本框TextField中输入值,然后点击按钮获取文本框中的值并进行相应的计算,怎么实现啊全部的内容,包括:javaSwing中在文本框TextField中输入值,然后点击按钮获取文本框中的值并进行相应的计算,怎么实现啊、ext textfield 的值怎么获取、ExtJS textfield怎样自动获得焦点等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9470254.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存