Ssd4實(shí)驗(yàn)二之實(shí)驗(yàn)報(bào)告_第1頁
Ssd4實(shí)驗(yàn)二之實(shí)驗(yàn)報(bào)告_第2頁
Ssd4實(shí)驗(yàn)二之實(shí)驗(yàn)報(bào)告_第3頁
Ssd4實(shí)驗(yàn)二之實(shí)驗(yàn)報(bào)告_第4頁
Ssd4實(shí)驗(yàn)二之實(shí)驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩20頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論