Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 各位大侠请帮忙看看我这个小程序
babyone

学会思考,学会做人



发贴: 49
积分: 0
于 2004-09-22 21:34 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
呵呵 。。。 好久没上网了,主要是我的显示器坏了 ,现向各位大侠报个到!

import java.awt.*;
import java.awt.event.*;

public class FormatMonth implements TextListener,ActionListener extends MouseAdapter
{
  Frame f;
  Label lb;
  TextField tf;
  Button b1,b2,b3;
  String sInput;
  
  public static void main(String[] args){
    new FormatMonth();
  }
  
  public FormatMonth(){
    f=new Frame("年月日转换小程序");
    lb=new Label("输入简写的年月日如(07/12/2004),(按enter键清除)");
    
    b1=new Button("开始");
    b1.setActionCommand("b1");
    b1.addActionListener(this);
    
    b2=new Button("转换");
    b2.setActionCommand("b2");
    b2.addActionListener(this);
    
    b3=new Button("退出");
    b3.setActionCommand("b3");
    b3.addActionListener(this);
    
    tf=new TextField("",20);
    tf.addTextListener(this);
    tf.addActionListener(this);
    
    f.add(tf,BorderLayout.NORTH);
    f.add(b1,BorderLayout.WEST);
    f.add(b2,BorderLayout.CENTER);
    f.add(b3,BorderLayout.EAST);
    f.add(lb,BorderLayout.SOUTH);
    
    f.pack();
    f.setVisible(true);
  }
  
  public void textValueChanged(TextEvent e){
    la.setText(change(tf.getText()));
  }
    
  public void actionPerformed(ActionEvent e){
    String cmd=e.getActionCommand();
    
    b1.setEnabled(true);
    b2.setEnabled(true);
    b3.setEnabled(true);
    
    if(cmd.equals("b1")){
        tf.setText("");
        b2.setEnabled(false);
        b3.setEnabled(false);
    }
    else
      if(cmd.equals("b2")){
        lb.setText(change(tf.getText()));
        b1.setEnabled(false);
        b3.setEnabled(false);
     }
      else(cmd.equals("b3")){
        System.exit(0);
      }
      
    tf.setText("");
}
  
public String change(sInput){
    int x,y;
    String str1,str2;
    
    x=sInput.indexof("/");
    
    str1=sInput.subString(0,x);
    
    switch(str1){
    case "01":str2="January"; break;
    case "02":str2="February"; break;
    case "03":str2="March"; break;
    case "04":str2="April"; break;
    case "05":str2="May"; break;
    case "06":str2="june"; break;
    case "07":str2="july"; break;
    case "08":str2="August"; break;
    case "09":str2="September"; break;
    case "10":str2="Octorber"; break;
    case "11":str2="November"; break;
    case "12":str2="December"; break;
    default: break;
    }
    y=sInput.lastIndexof("/");
    
    str3=sInput.subString(s,y);
    
    str4=sInput.subSring(y);
    
    return str2+str3+sr4;
  }
}

程序调试的时候显示:

---------------- JDK Debug Build ------------------
Compiling C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\FormatMonth.java
Command line: "C:\j2sdk1.4.1\bin\javac.exe" -deprecation -g -classpath C:\DOCUME~1\user\MYDOCU~1\MODELW~1\MYPROJ~1 "C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\FormatMonth.java"
The current directory is: C:\Documents and Settings\user\My Documents\Modelworks\MyProjects
C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\FormatMonth.java:4: '{' expected
public class FormatMonth implements TextListener,ActionListener extends MouseAdapter
^
C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\FormatMonth.java:106: '}' expected
}
^
C:\Documents and Settings\user\My Documents\Modelworks\MyProjects\FormatMonth.java:4: FormatMonth should be declared abstract; it does not define actionPerformed(java.awt.event.ActionEvent) in FormatMonth
public class FormatMonth implements TextListener,ActionListener extends MouseAdapter
^
3 errors
Finished

小虾我不怎么明白 ,请教!


babyone edited on 2004-09-22 21:36


Java开发规范

话题树型展开
人气 标题 作者 字数 发贴时间
7094 各位大侠请帮忙看看我这个小程序 babyone 5709 2004-09-22 21:34
5641 Re:各位大侠请帮忙看看我这个小程序 ghuang 133 2004-09-23 00:08
5661 Re:各位大侠请帮忙看看我这个小程序 babyone 19 2004-09-23 09:57
5671 Re:各位大侠请帮忙看看我这个小程序 babyone 221 2004-09-26 17:13
5579 Re:各位大侠请帮忙看看我这个小程序 littledeer1974 77 2004-09-28 09:28
5662 Re:各位大侠请帮忙看看我这个小程序 babyone 61 2004-09-29 00:09
5664 Re:各位大侠请帮忙看看我这个小程序 babyone 28 2004-09-28 23:59
5639 Re:各位大侠请帮忙看看我这个小程序 karsking 489 2004-09-29 10:37
5698 Re:各位大侠请帮忙看看我这个小程序 babyone 2534 2004-10-21 16:35
5509 Re:各位大侠请帮忙看看我这个小程序 kavinwang 866 2004-10-21 17:13
5814 Re:各位大侠请帮忙看看我这个小程序 babyone 856 2004-10-21 21:15

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923