ITPUB??ì3
ITPUB论坛 » Java入门与认证版 » 大家好啊帮帮忙看看啊

新一届的微软MVP评选已经开始,欢迎各位推荐!

标题: 大家好啊帮帮忙看看啊
离线 guicaijunjun


来自 山东
精华贴数 0
个人空间 0
技术积分 28 (44389)
社区积分 0 (1780164)
注册日期 2008-5-10
论坛徽章:0
      
      

发表于 2008-5-25 23:07 
大家好啊帮帮忙看看啊

import java.awt.*;
import javax.swing.*;
public class TypeIndicator {
        //类常量
        private final int WINDOW_WIDTH=400;
        private final int WINDOW_HEIGHT=375;
        private final int AREA_WIDTH=50;
        private final String LEGEND="a series of priferences are asked.the responses are"+"" +
                        "used to setermine a personality type progile. the tool"+"is primitive and is meant for fun.you shoule not make"
                        +"any decisions based on its anslysis.";
        //GUI实例变量
        private JFrame window=new JFrame("Type Indicator";
        //显示工具使用和局限性的文本信息
        private JTextArea legendArea=new JTextArea(LEGEND,6,AREA_WIDTH);
    //性格类型测试概要
        private JTextArea resultArea=new JTextArea();       
      //当前喜好文本
        private JTextArea statementPad=new JTextArea(LEGEND,1,AREA_WIDTH);
        private JRadioButton trueButton=new JRadioButton("true ";
        private JRadioButton falseButton=new JRadioButton("false";
        //隐藏的按钮肯定与不肯定的替换
        private JRadioButton hiddenButton=new JRadioButton(" ";
        private ButtonGroup buttonGroup=new ButtonGroup();
        //测试实例变量
        private boolean introvert;
        private boolean senser;
        private boolean thinker;
        private boolean judger;
        //程序入口
        public static void main(String args){
                TypeIndicator testinstrument =new TypeIndicator ();
               
        }//默认构造方法
        public TypeIndicator ()
        {   //设置GUI
                configureAndDisplayGUI();
                introvert=isIntroversionDominant();
                senser=isSendingDominant();
                thinker=isThinkingDominant();
                judger=isJudgingDominant();
                presentResults();
               
        }
        //设置GUI
        private void configureAndDisplayGUI(){
        //配置元素
                window.setSize(WINDOW_WIDTH,WINDOW_HEIGHT);
                window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                legendArea.setEnabled(false);
                legendArea.setLineWrap(true);
                legendArea.setWrapStyleWord(true);
                legendArea.setBackground(window.getBackground());
               
                statementPad.setVisible(false);
                statementPad.setEditable(false);
                statementPad.setBackground(window.getBackground());
               
                trueButton.setVisible(false);
                falseButton.setVisible(false);
        buttonGroup.add(trueButton);
        buttonGroup.add(falseButton);
        buttonGroup.add(hiddenButton);
        
        resultArea.setEditable(false);
        resultArea.setBackground(window.getBackground());
        //向窗口面板中增加元素
        Container c=window.getContentPane();
        c.setLayout(new FlowLayout());
        c.add(legendArea);
        c.add(statementPad);
        c.add(trueButton);
        c.add(falseButton);
        c.add(resultArea);
        //准备好GUI
        window.setVisible(true);
        
        }
               
//内向型比外向型主导
        private boolean isIntroversionDominant(){
                String s1="i prefer renting a video to going toparty";
                String s2="i an happy when house guest leave";
                String s3="meetnig new people makes me tense";
                String s4="i enjoy being alone";
                String s5="Crowds suck the life out of me";
                return doTraitTest(s1,s2,s3,s4,s5);
               
        }
       
        private boolean isSendingDominant(){
                String s1="facts are more intereste than ideas";
                String s2=" i need the details more than the big pictrue";
                String s3="i always measure,i never estimate";
                String s4="seeing ts believing";
                String s5="if you cannot touch it.it id not real ";
                return doTraitTest(s1,s2,s3,s4,s5);
               
        }
        private boolean isThinkingDominant(){
                String s1="i prefer page i to the comics in a newspaper";
                String s2="i think therefore i am";
                String s3="i am not an emotional person";
                String s4="tears will not cause me to change my mind";
                String s5="i rather be data  than troi";
                return doTraitTest(s1,s2,s3,s4,s5);
        }
                private boolean  isJudgingDominant(){
                        String s1="it is easy to male a deision";
                        String s2="i an happy when house guest leave";
                        String s3="meetnig new people makes me tense";
                        String s4="i enjoy being alone";
                        String s5="Crowds suck the life out of me";
                        return doTraitTest(s1,s2,s3,s4,s5);}
                //测试某个类型分类的主要反映
                private boolean doTraitTest(String s1,String s2,String s3,String s4,String s5){
                int choiceTrue=0;
                int choiceFalse=0;
                if(getTrueorFalseResponse(s1)){
                        ++choiceTrue;
                }else {++choiceFalse;}
                if(getTrueorFalseResponse(s2)){
                        ++choiceTrue;
                }else {++choiceFalse;}
                if(getTrueorFalseResponse(s3)){
                        ++choiceTrue;
                }else {++choiceFalse;}
                if(getTrueorFalseResponse(s4)){
                        ++choiceTrue;
                }else {++choiceFalse;}
               
                if(getTrueorFalseResponse(s5)){
                        ++choiceTrue;
                }else {++choiceFalse;}
               
                        //
                return choiceTrue >choiceFalse;
                }
                private boolean getTrueorFalseResponse(String statement){
                {statementPad.setText(statement);
                hiddenButton.setSelected(true);
                statementPad.setVisible(true);
                trueButton.setVisible(true);
                falseButton.setVisible(true);
                for(; {
                if(trueButton.isSelected()||falseButton.isSelected()){
                        break;}
               
                       
                }
                statementPad.setVisible(false);
                trueButton.setVisible(false);
                falseButton.setVisible(false);

               
               
                return trueButton.isSelected();}
                }
                //显示
                private void presentResults(){
                        String result ="your type is
"+"  "+((introvert)? "i" : "e"
                        +((senser)? "s" : "n"+((thinker)? "y" : "f"
                        +((judger)? "j" : "p"+"
"+"where
"
                        +"*E=extroversion
"+"*I=introversion
"
                        +"*S=sensing
"+"*N=intuitive
"+"*T=thinking
"
                        +"*F=felling
"+"*J=judgment
"+"*P=perception
"
                        +"
"+"thank you for trying the tool";
                        resultArea.setText(result);
                        window.show();
                }
               
                }
为什么不能运行啊说是MAIN里没有TypeIndicator呢


只看该作者    顶部
离线 马甲走江湖
江湖任我行


精华贴数 4
个人空间 70
技术积分 19727 (48)
社区积分 26310 (43)
注册日期 2006-10-26
论坛徽章:154
现任管理团队成员金牌徽章银牌徽章铜牌徽章2008欧洲杯之星欧洲冠军杯纪念徽章
2008北京奥运纪念徽章:排球2008北京奥运纪念徽章:举重生肖徽章2007版:猪2008北京奥运纪念徽章:皮划艇激流回旋2008北京奥运纪念徽章:乒乓球2008北京奥运纪念徽章:蹦床

发表于 2008-5-26 13:01 
lz没有main()啊?


__________________
The following programme is not suitable for children

香车圈子,欢迎您的加入
只看该作者    顶部
离线 guicaijunjun


来自 山东
精华贴数 0
个人空间 0
技术积分 28 (44389)
社区积分 0 (1780164)
注册日期 2008-5-10
论坛徽章:0
      
      

发表于 2008-5-26 15:55 
恩?


只看该作者    顶部
离线 greenflute


精华贴数 0
个人空间 0
技术积分 7238 (183)
社区积分 162 (2729)
注册日期 2001-10-26
论坛徽章:16
现任管理团队成员ITPUB元老管理团队2007贡献徽章会员2007贡献徽章2008北京奥运纪念徽章:沙滩排球2008年新春纪念徽章
      

发表于 2008-6-1 00:43 
Main定义错误




greenflute 上传了这个附件:
2008-6-1 00:43
Error.png (4.18 KB)
 

只看该作者    顶部
离线 sinkeler
SCJP | SCWCD
Specialist


来自 北京
精华贴数 3
个人空间 0
技术积分 1029 (1832)
社区积分 1 (38124)
注册日期 2005-3-2
论坛徽章:1
生肖徽章2007版:牛     
      

发表于 2008-6-2 09:07 
呵呵。

最近帮帮忙的代码都这么长,其实可以换成IDE来编辑,实在不行还有log和debug。


__________________
只看该作者    顶部
离线 guicaijunjun


来自 山东
精华贴数 0
个人空间 0
技术积分 28 (44389)
社区积分 0 (1780164)
注册日期 2008-5-10
论坛徽章:0
      
      

发表于 2008-6-4 20:57 
呵呵我知道了谢谢各位喽


只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问