java 文本框输出语句_求大神 为什么文本框没有输出

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

package homework;

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class week {

private JFrame ftame;

private JButton b1[];

private JPanel panel,panel2;

private JTextField text1,text2,text3;

private JLabel label1,label2,label3;

week(){

int i;

String str[]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日","1","2","3","4","5","6","7","8","9","0","="};

ftame=new JFrame("week");

ftame.setLayout(new GridLayout(2,1));

panel = new JPanel(new GridLayout(5,4));

label1=new JLabel(" 请输入星期数");

text1=new JTextField();

text1.setHorizontalAlignment(JTextField.RIGHT);

text1.setEnabled(false);

text1.setText("");

label2=new JLabel(" 请输入天数");

text2=new JTextField();

label3=new JLabel(" 结果");

text3=new JTextField();

JButton b1[]=new JButton[18];

for(i=0;i

{

b1[i]=new JButton(str[i]);

panel.add(b1[i]);

b1[i].addActionListener(new a());

}

ftame.setVisible(true);

ftame.setSize(400,400);

ftame.add(panel);

panel2=new JPanel(new GridLayout(3,1));

panel2.add(label1);

panel2.add(text1);

panel2.add(label2);

panel2.add(text2);

panel2.add(label3);

panel2.add(text3);

ftame.add(panel2);

}

class a implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

if(e.getSource()==b1)

{

String str=b1[0].getText();

text1.setText(str+"ll");

}

}

}

/**

* @param args

*/

public static void main(String[] args) {

new week();

// TODO Auto-generated method stub

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值