




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
Ssd4試驗(yàn)二之試驗(yàn)匯報(bào)試驗(yàn)?zāi)繕?biāo):為了深入了解布局作用,及主要性學(xué)習(xí)分析軟件功效,及布局實(shí)現(xiàn)加強(qiáng)對java了解試驗(yàn)要求:模擬出界面實(shí)現(xiàn)其全部功效焦點(diǎn)設(shè)置事件監(jiān)聽設(shè)置,文本框內(nèi)容改變監(jiān)聽,按鈕監(jiān)聽字體設(shè)置對話框信息提醒設(shè)置試驗(yàn)步驟:研究布局,模擬布局,測繪組件屬性設(shè)置功效分析實(shí)現(xiàn)功效試驗(yàn)結(jié)果:源代碼:package.gui;importjavax.swing.*;importjavax.swing.event.CaretEvent;importjavax.swing.event.CaretListener;importjavax.swing.event.ChangeEvent;importjavax.swing.event.ChangeListener;importjava.awt.event.ActionEvent;importjava.awt.event.TextListener;importjava.awt.event.TextEvent;importjava.awt.*;importjava.awt.event.ActionListener;import.util.*;publicclassMainFrameextendsJFrame{ privateJLabellabComponentNames; privateJLabellabComponentDescription; privateJLabellabFirstName;privateJLabellabSecondName;privateJLabellabThirdName;privateJLabellabForthName;privateJLabellabFifthName;privateJLabellabSixName;privateJLabellabSevenName;privateJLabellabEnterNumber;privateJLabellabEnterString;privateJLabellabFound;privateJLabellabFirstOccurrence;privateJLabellabLastOccurrence;privateTextFieldtextDisplay;privateTextFieldtextSearch;privateJTextAreatextComponentDescription;privateJButtonbutDisplay;privateJButtonbutSearch;privateJButtonbutExit;privateJPanelpaneMain;privateJPanelpaneComponent;privateJPanelpaneComponentNames;privateJPanelpaneComponentDescription;privateJPanelpaneEnter;privateJPanelpaneFound;privateJPanelpaneExit;privateJScrollPanescrollPane;privateintcount; publicMainFrame() { labComponentNames=newJLabel("UARcomponentsnames:"); //將字體設(shè)置為粗體 //labComponentName.setFont(); // labFirstName=newJLabel("1.UARIdentifier"); labSecondName=newJLabel("2.SuccinctDescripitionoftheUsabilityAspect"); labThirdName=newJLabel("3.EvidencefortheAspect"); labForthName=newJLabel("4.ExplanationoftheAspect"); labFifthName=newJLabel("5.severityoftheProblemortheBenefitoftheGoodFeature"); labSixName=newJLabel("6.PossibleSolutionsandPotentialTrade-offs"); labSevenName=newJLabel("7.RelationshiptoOtherUsabilityAspects"); labEnterNumber=newJLabel("Enteranumber:"); labEnterString=newJLabel("Enterasearchstring:"); butDisplay=newJButton("Display"); butSearch=newJButton("Search"); butExit=newJButton("Exit"); labComponentDescription=newJLabel("UARcomponentdescription:"); labFound=newJLabel("Foundat:"); labFirstOccurrence=newJLabel(); labLastOccurrence=newJLabel(); textDisplay=newTextField(); textSearch=newTextField(); textComponentDescription=newJTextArea(); paneMain=newJPanel(); paneComponent=newJPanel(); paneComponentNames=newJPanel(); paneComponentDescription=newJPanel(); paneEnter=newJPanel(); paneFound=newJPanel(); paneExit=newJPanel(); scrollPane=newJScrollPane(); init(); //必須在窗口顯示后才能取得焦點(diǎn) textDisplay.requestFocusInWindow(); } privatevoidinit(){ //textDisplay.set //textSearch.setBorder(BorderFactory.createLoweredBevelBorder()); paneComponentNames.setLayout(newGridLayout(9,1)); paneComponentNames.add(labComponentNames); Fontfont=newFont(null,Font.BOLD,15); //FontbutFont=newFont(null,Font.ROMAN_BASELINE,12); labComponentNames.setFont(font); labComponentDescription.setFont(font); paneComponentNames.add(labFirstName); paneComponentNames.add(labSecondName); paneComponentNames.add(labThirdName); paneComponentNames.add(labForthName); paneComponentNames.add(labFifthName); paneComponentNames.add(labSixName); paneComponentNames.add(labSevenName); //布局 scrollPane.setViewportView(textComponentDescription); scrollPane.setVerticalScrollBarPolicy(scrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setBorder(BorderFactory.createLoweredBevelBorder()); JPanelmyPane=newJPanel(); myPane.setLayout(newBorderLayout()); myPane.add(newJPanel(),BorderLayout.NORTH); myPane.add(scrollPane,BorderLayout.CENTER); myPane.add(newJPanel(),BorderLayout.SOUTH); myPane.add(newJPanel(),BorderLayout.EAST); paneComponentDescription.setLayout(newBorderLayout()); paneComponentDescription.add(labComponentDescription,BorderLayout.NORTH); paneComponentDescription.add(myPane,BorderLayout.CENTER); paneComponentDescription.add(labFound,BorderLayout.SOUTH); //paneEnter面板布局 JPanelthirdPane=newJPanel(); JPanelthirdPane2=newJPanel(); JPanelthirdPane3=newJPanel(); JPanelthirdPane4=newJPanel(); JPanelthirdPane5=newJPanel(); thirdPane.setLayout(newBorderLayout()); thirdPane.add(newJPanel(),BorderLayout.NORTH); thirdPane.add(thirdPane2,BorderLayout.CENTER); thirdPane2.setLayout(newBorderLayout()); thirdPane2.add(thirdPane3,BorderLayout.NORTH); thirdPane3.setLayout(newBorderLayout()); thirdPane3.add(paneEnter,BorderLayout.CENTER); thirdPane3.add(thirdPane4,BorderLayout.EAST); thirdPane4.setLayout(newBorderLayout()); thirdPane4.add(newJPanel(),BorderLayout.WEST); thirdPane4.add(thirdPane5,BorderLayout.CENTER); thirdPane4.add(newJPanel(),BorderLayout.EAST); thirdPane5.setLayout(newGridLayout(2,1)); paneEnter.setLayout(newGridLayout(2,2)); paneEnter.add(labEnterNumber); paneEnter.add(textDisplay); paneEnter.add(labEnterString); paneEnter.add(textSearch); thirdPane5.add(butDisplay); thirdPane5.add(butSearch); //paneFound面板布局 JPanelforthPane=newJPanel(); JPanelforthPane2=newJPanel(); JPanelforthPane3=newJPanel(); forthPane.setLayout(newFlowLayout(FlowLayout.RIGHT)); forthPane2.setLayout(newBorderLayout()); forthPane3.setLayout(newGridLayout(3,1)); forthPane3.add(labFirstOccurrence); forthPane3.add(newJPanel()); forthPane3.add(labLastOccurrence); forthPane.add(butExit); paneFound.setLayout(newBorderLayout()); paneFound.add(newJPanel(),BorderLayout.NORTH); paneFound.add(forthPane2,BorderLayout.CENTER); forthPane2.add(forthPane3,BorderLayout.NORTH); paneFound.add(forthPane,BorderLayout.SOUTH); //paneEnterAndFound.add(comp); //paneEnterAndFound.add(comp); //paneEnterAndFound.add(comp); //paneEnterAndFound.add(comp); paneComponent.setLayout(newGridLayout(2,2)); paneComponent.add(paneComponentNames); paneComponent.add(paneComponentDescription); paneComponent.add(thirdPane); paneComponent.add(paneFound); paneMain.setLayout(newBorderLayout()); paneMain.add(paneComponent,BorderLayout.CENTER); this.add(newJPanel(),BorderLayout.NORTH); this.add(newJPanel(),BorderLayout.SOUTH); this.add(paneMain,BorderLayout.CENTER); this.add(newJPanel(),BorderLayout.WEST); this.add(newJPanel(),BorderLayout.EAST); //butDisplay.setFont(butFont); butDisplay.addActionListener(newMyListener()); butSearch.addActionListener(newMyListener()); butExit.addActionListener(newMyListener()); textDisplay.addTextListener(newMyTextListener()); textSearch.addTextListener(newMyTextListener()); //TODOAuto-generatedmethodstub this.setSize(880,500); //將顯示出來大小作為最小尺寸 this.setMinimumSize(getSize()); this.setTitle("URAComponents"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); this.setVisible(true); } publicintgetStringCount(Stringstr1,Stringstr2) { Strings=str1; count=0; if(str2.length()!=1) { for(inti=0;i<s.length();i++) { if(s.indexOf(str2)!=-1) { s=s.substring(s.indexOf(str2)+1); count++; } } } else { inti=0,j=0; i=s.length(); s=s.replaceAll(str2,"");//反串中字符a替換成"",使其長度減一. s=s.replaceAll(str2.toUpperCase(),""); //System.out.println(s); j=s.length(); count=i-j; } returncount; } classMyListenerimplementsActionListener { publicvoidactionPerformed(ActionEvente) { Texttext=newText(); JButtonbut=(JButton)e.getSource(); if(but==butDisplay) { try { //傳遞焦點(diǎn) textDisplay.transferFocus(); textComponentDescription.setText(""); textComponentDescription.setText(text.text[Integer.parseInt(textDisplay.getText().trim())-1]); textComponentDescription.setLineWrap(true); } catch(Exceptionex) { JOptionPane.showMessageDialog(null,"Pleaseentervaluesbetween1and7","SearchString",JOptionPane.WARNING_MESSAGE); } } elseif(but==butSearch) { if(textComponentDescription.getText().equals("")||textSearch.getText().equals("")) { JOptionPane.showMessageDialog(null,"Pleaseselecttext","SearchString",JOptionPane.WARNING_MESSAGE); return; } try { textSearch.transferFocusBackward(); intncount=getStringCount(textComponentDescription.getText(),textSearch.getText()); labFirstOccurrence.setText(""); labLastOccurrence.setText(""); if(ncount!=0) { labFirstOccurrence.setText("Occurrence"+"1:"+"Position:"+(textComponentDescription.getText().indexOf(textSearch.getText())+1)); labLastOccurrence.setText("Occurrence"+ncount+":"+"Position:"+(textComponentDescription.getText().lastIndexOf(textSearch.getText())+1)); Object[]options={"是","否"}; intresponse=JOptionPane.showOptionDialog(null,"Thenumberofoccurrencesof"+"'"+textSearch.getText()+"'"+"is:"+ncount+"\n\nSearchsametext?","SearchString",JOptionPane.YES_OPTION,JOptionPane.WARNING_MESSAGE,null,options,options[0]); if(response==1) { textDisplay.setText(""); textSearch.setText(""); labFirstOccurrence.setText(""); labLastOccurrence.setText(""); textComponentDescription.setText(""); } } else { //intoptionType Object[]options={"是","否"}; intresponse=JOptionPane.showOptionDialog(null,"String"+"'"+textSearch.getText()+"'"+"notfound\nSearchsametextagain?","SearchString",JOptionPane.YES_OPTION,JOptionPane.WARNING_MESSAGE,null,options,options[0]); if(response==1) { textDisplay.setText(""); textSearch.setText(""); textComponentDescription.setText(""); } } } catch(Exceptionex) { } //butExit.setBorder(BorderFactory.createRaisedBevelBorder()); } else { //butExit.setBorder(BorderFactory.createRaisedBevelBorder()); System.exit(0); } } } classMyTextListenerimplementsTextListener { @Override publicvoidtextValueChanged(TextEvente){ //TODOAuto-generatedmethodstub TextFieldtext=(TextField)e.getSource(); if(text==textDisplay) { textComponentDescription.setText(""); labFirstOccurrence.setText(""); labLastOccurrence.setText(""); textSearch.setText(""); } else { labFirstOccurrence.setText(""); labLastOccurrence.setText(""); } } } }package.util;publicclassText{ publicStringtext[]=newString[7]; publicText() { text[0]="Thisshouldbeauniqueidentifierforthepurposesoffiling."+ "Ifmorethanonepersonisworkingontheprojectormorethanoneanalysistechniqueisbeingused,"+ "thisidentifiercouldcontainlettersandnumbers.Forexample,ifChrisSmithandJanKooarebothdoingananalysis,"+ "theidentifiermightbeCS1orJK75.Ifbothaheuristicevaluationandathink-aloudusabilitystudywereused,theidentifiersmightbeHE6orTA89."+ "Followtheuniqueidentifierwiththeword'Problem,'ifthereportpertainstoausabilityproblemoftheinterface,orthewords'GoodFeature,'"+ "ifitdescribesanaspectoftheinterfaceyoufeelshouldbepreservedinanyredesign."; text[1]="Thisdescriptionwillbeusedasthe'name'ofthisUARwhenyoutalkaboutitsrelationtootherUARs."+ "Makethenameasshortaspossible(aboutthreetofivewords)butstilldescriptiveanddistinguishablefromotheraspectsofthesystem."+ "IfthisUARisaboutaproblem(asopposedtoagoodfeature),"+ "makesureyouhaveanamethatdescribestheproblem,ratherthanasolution."; text[2]="Thisistheobjectivesupportingmaterialthatjustifiesyouridentifyingtheaspectasworthyofreport."+ "ThissectionneedstocontainenoughinformationforareaderofthisUARtounderstandwhattriggeredthereport.ForanHEreport,forinstance,"+ "thiscouldbeanimageofaclutteredscreenandtheheuristicaboutaestheticsandminimalistdesign."+ "Inathink-aloudstudythisisusuallywhatwasonthescreen(ascreenshotordescription),whattheuserdid(keystrokes,mousemovements),"+ "whatthesystemdidinresponsetoanyuseractions,andwhattheusersaid."+ "Youneedtoincludeenoughpertinentinformationabouttheidentificationofanaspectforthereadertounderstandwhattheanalystwas"+ "thinkingwhentheaspectwasidentified(forHE)orwhattheuserwastryingtodo"+ "whentheaspecteitherhinderedorfacilitatedhisorherprogress."; text[3]="Thisisyourinterpretationoftheevidence.Thatis,forathink-aloudusabilitytest,"+ "whyyouthinkwhathappenedhappened,or,foranHE,whyyouthinktheaspectwasdesignedthewayitwas."+ "Youneedtoprovideenoughcontentinthisexplanationforthereadertounderstandtheproblem-eveniftheydonotknowthe"+ "systemordomainaswell
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二年級下冊數(shù)學(xué)教案-8.1評選吉祥物∣北師大版
- 六年級上冊數(shù)學(xué)教案-數(shù)學(xué)好玩 3 比賽場次|北師大版
- 六年級上數(shù)學(xué)教案-列方程解稍復(fù)雜的百分?jǐn)?shù)實(shí)際問題-蘇教版
- (??家族e(cuò)題)2022-2023學(xué)年三年級上冊期末高頻考點(diǎn)數(shù)學(xué)試卷(北師大版)
- 2025年云南省建筑安全員《A證》考試題庫
- 2024年氯氟氰菊酯項(xiàng)目資金申請報(bào)告代可行性研究報(bào)告
- 2024年電氣機(jī)械及器材項(xiàng)目投資申請報(bào)告
- 2025年濟(jì)南工程職業(yè)技術(shù)學(xué)院單招職業(yè)適應(yīng)性測試題庫帶答案
- 2025年福州職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫一套
- 2025年桂林師范高等專科學(xué)校單招職業(yè)技能測試題庫完美版
- DeepSeek從入門到精通培訓(xùn)課件
- 俄羅斯進(jìn)口凍肉合同范例
- 2025年湖北省技能高考(建筑技術(shù)類)《建設(shè)法規(guī)》模擬練習(xí)試題庫(含答案)
- 急性呼衰院前急救流程
- 部編版七年級語文下冊《第2課說和做》課件
- 養(yǎng)老服務(wù)信息化發(fā)展-深度研究
- 2024-2025學(xué)年第二學(xué)期學(xué)??倓?wù)工作計(jì)劃(附2月-6月安排表行事歷)
- 夫妻離婚協(xié)議書范本2024
- 23G409先張法預(yù)應(yīng)力混凝土管樁
- 《幼兒教育政策與法規(guī)》教案-單元5 幼兒的權(quán)利與保護(hù)
評論
0/150
提交評論