作者arkzon (ArkLiu)
看板java
标题[问题] 用JFrame把多个input转成output
时间Wed Oct 8 16:07:15 2008
我用JFrame先设计出了一个视窗
然後用JTextField 规划出了 4个inputField 4个outField
2个JButton 一个是执行 一个是清除
我的格式大概都写好了
但是我发现我卡住了
因为我的event.getSource()是选择 执行 或者 清除
请问我要怎样 可以读取input 然後全部输出到output里面
input code
label = new JLabel( "Name " );
add( label ); // add label to JFrame
// construct textfield with 15 columns
textField_Name = new JTextField( 15 );
add( textField_Name ); // add textField1 to JFrame
output code
// Create Label "Gross Pay"
label = new JLabel( "Gross Pay " );
add( label ); // add label to JFrame
// construct textfield with default text and 15 columns
textField_GrossPay = new JTextField( 15 );
textField_GrossPay.setEditable( false ); // disable editing
add( textField_GrossPay ); // add textField3 to JFrame
後面的getSource() code
public void actionPerformed( ActionEvent event )
{
if ( event.getSource() == leftButton )
{
ooxxooxxoxxoxoxoxo;
}
请诸君题点一下方向 多谢:)
--
"Ask not what your country can do for you;
ask what you can do for your country."
By John F.Kennedy
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 71.105.240.111
1F:推 stukk:你是希望input fields的内容在按过button後,显示在output? 10/08 21:55
2F:推 linsung:4个 textField 都 getText() 就不就取出资料了?? 10/09 15:20