JAVA記事本報(bào)告及代碼_第1頁(yè)
JAVA記事本報(bào)告及代碼_第2頁(yè)
JAVA記事本報(bào)告及代碼_第3頁(yè)
JAVA記事本報(bào)告及代碼_第4頁(yè)
JAVA記事本報(bào)告及代碼_第5頁(yè)
已閱讀5頁(yè),還剩16頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、文檔來(lái)源為:從網(wǎng)絡(luò)收集整理.word版本可編輯.歡迎下載支持華北科技學(xué)院計(jì)算機(jī)系綜合性實(shí)驗(yàn)實(shí)驗(yàn)報(bào)告課程名稱(chēng) Java程序設(shè)計(jì)B實(shí)驗(yàn)學(xué)期2011 至 2012 學(xué)年第 1 學(xué)期學(xué)生所在系部計(jì)算機(jī)學(xué)院年級(jí) 2009專(zhuān)業(yè)班級(jí)網(wǎng)絡(luò)學(xué)生姓名 學(xué)號(hào)任課教師李芙玲實(shí)驗(yàn)成績(jī)計(jì)算機(jī)系制Java程序設(shè)計(jì)B課程綜合性實(shí)驗(yàn)報(bào)告開(kāi)課實(shí)驗(yàn)室: 基礎(chǔ)實(shí)驗(yàn)室2011年11月16日實(shí)驗(yàn)題目簡(jiǎn)易寫(xiě)字板軟件設(shè)計(jì)一、實(shí)驗(yàn)?zāi)康耐ㄟ^(guò)編寫(xiě)Java的應(yīng)用系統(tǒng)綜合實(shí)例一一簡(jiǎn)易寫(xiě)字板軟件,總結(jié)、回顧和實(shí)踐面向?qū)ο蟮木幊趟枷胍约熬幊谭椒?,并通過(guò)編寫(xiě)程序來(lái)掌握J(rèn)ava語(yǔ)言編程技巧,將學(xué)習(xí)到的知識(shí)融會(huì)貫通,同時(shí)提高調(diào)試程序的能力,養(yǎng)成良好的編程習(xí)慣,

2、并增強(qiáng)對(duì)程序設(shè)計(jì)整體思路的把握。熟悉在集成開(kāi)發(fā)環(huán)境下編寫(xiě) Java程序。二、設(shè)備與環(huán)境硬件:多媒體計(jì)算機(jī)軟件:Windows 2000以上的操作系統(tǒng)、JDK開(kāi)發(fā)包、集成開(kāi)發(fā)環(huán)境三、實(shí)驗(yàn)內(nèi)容總體要求:程序功能基本完成,用戶(hù)界面友好,代碼的可維護(hù)性和可擴(kuò)展性較好,最好包括 必要的注釋和相應(yīng)的文檔。具體要求:基本的文本錄入, 字符修改,刪除,換行,粘貼,復(fù)制,剪切等功能,主要包括:.菜單欄設(shè)計(jì)及功能實(shí)現(xiàn):菜單欄主要包括文件、編輯、格式、幫助等常見(jiàn)菜單。其中文件菜單有新建、打開(kāi)、保存、另存為、退出等功能;編輯菜單有剪切、復(fù)制、粘貼、 等功能;格式菜單含有對(duì)文字字體、字型、字號(hào)及顏色等的設(shè)置功能,根據(jù)情

3、況可在編輯菜 單添加查找和查找替換功能。.編輯區(qū)設(shè)計(jì):對(duì)文本的編輯處理區(qū)。.工具欄設(shè)計(jì):可根據(jù)需要增加該項(xiàng)功能。.其他功能設(shè)計(jì)。四、實(shí)驗(yàn)結(jié)果及分析1.主界面的設(shè)計(jì)與實(shí)現(xiàn)整個(gè)界面包括菜單條,菜單項(xiàng)(文件,編輯,格式,查看,幫助)和菜單條,滾動(dòng)條菜單的設(shè)計(jì)本程序共設(shè)計(jì)了五個(gè)菜單,分別是文件菜單(新建,打開(kāi),保存,另存為,退出);編輯菜單(撤銷(xiāo),剪切,復(fù)制,粘貼,刪除,全選,時(shí)間)格式菜單(自動(dòng)換行,字體)查看菜單(狀態(tài)欄)幫助(查看幫助,關(guān)于記事本)文件菜單功能編輯菜單功能格式菜單的功能幫助菜單的功能編輯區(qū)設(shè)計(jì)編輯區(qū)添加了文本區(qū),并在文本區(qū)內(nèi)添加了滾動(dòng)條,在文本區(qū)內(nèi)添加了鼠標(biāo)操作,即鼠標(biāo)右鍵進(jìn)行復(fù)

4、制,粘貼,剪切2.各項(xiàng)功能的實(shí)現(xiàn)(1)窗體設(shè)計(jì):設(shè)計(jì)了一個(gè)大小可變,名為記事本的窗體,并添加了窗體關(guān)閉事件,即關(guān)閉窗體時(shí)會(huì)提示是否保存menu1=new JMenu(文件);menu1.addActionListener(menu2=new JMenu(編輯);menu3=new JMenu(格式);menu4=new JMenu(查看);menu5=new JMenu(幫助); menubar.add( menu1);menubar.add( menu?;menubar.add( menu3);menubar.add( menu4);menubar.add( menu5);this );添加

5、窗體上的菜單addWindowListener( public if變。想保存文件嗎?new WindowAdapter()void windowClosing(WindowEvent event)(save_status =0)int check=JOptionPane. showConfirmDialog (null ,文件的文字已經(jīng)改,警告,JOptionPane. YES_NO_CANCEL_OP)T IONif(check=0)saveFile( status ); if(check=1)System. exit (0); if(check=2) dispose。;);(2)文件菜單

6、各項(xiàng)功能.新建功能設(shè)計(jì):item1 本區(qū)為空item1 .addActionListener(是新建菜單,在iteml上添加監(jiān)聽(tīng)器,當(dāng)執(zhí)行新建操作時(shí),自動(dòng)設(shè)置文publicifnew ActionListener()void actionPerformed(ActionEvent e)(e.getSource(尸 text .setText( this .setTitle(item1 );無(wú)標(biāo)題-記事本);.打開(kāi)功能設(shè)計(jì):item2上添加監(jiān)聽(tīng)器,JfileChooser jfc1=new JfileChooser( FileReader fr = newFileReader(f1);當(dāng)執(zhí)行打開(kāi)

7、操作時(shí)運(yùn)用文件的輸入流進(jìn)行打開(kāi)“ D:/ )BufferedReader br = new BufferedReader(fr);調(diào)用showOpenDialog()方法返回初始目錄為本地系統(tǒng)的默認(rèn)目錄的對(duì)話(huà)框null )while (str = br.readLine()!=文檔來(lái)源為:從網(wǎng)絡(luò)收集整理.word版本可編輯.歡迎下載支持 text .setText(str); fr.close(); br.close(); 調(diào)用readLine()順序讀取文件的一行 運(yùn)行結(jié)果如圖.保存功能,和打開(kāi)功能相反,iten3添加監(jiān)聽(tīng)器,當(dāng)執(zhí)行保存操作時(shí)運(yùn)用文件輸出流把文件保存到指定目錄中JfileCh

8、ooser jfc1=new JfileChooser() FileWriter fw =new FileWriter(f2);BufferedWriter bw =new BufferedWriter(fw);將BufferedReader 和FileReader連接在一起,然后使用BufferedReader流將數(shù)據(jù)寫(xiě)入到目的地。.編輯中的復(fù)制,粘貼,剪切功能item* .addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) text .*(); );添力口 ActionList

9、ener 監(jiān)聽(tīng)器,調(diào)用 API 中的 copy(),cut(),prase() 方法復(fù)制粘貼剪切可從鼠標(biāo)右鍵使用,構(gòu)造一個(gè)彈出式菜單menu= new JpopupMenu()為text添加鼠標(biāo)監(jiān)聽(tīng)器text .addMouseListener( new MouseAdapter() / 鼠標(biāo)右鍵實(shí)現(xiàn)復(fù)制,粘貼,剪切功能 public void mousePressed(MouseEvent e) if (e.getModifiers()=InputEvent. BUTTON3_MASK menushow( text ,e.getX(),e.getY(); );.顯示時(shí)間,為日期添加日歷 te

10、m27.addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) if (e.getSource()= item27 ) Calendar c1 =Calendar. getInstance (); inty = c1.get(Calendar.YEARintm = c1.get(Calendar.MONTHintd = c1.get(Calendar.DATE;inth = c1.get(Calendar.HOURint m1 = c1.get(Calendar. MINUTE int

11、m2 = m+1;text .setText(y+ 年”+m2+月+d+日+h+: +m1); );6自動(dòng)換行功能item31 .addActionListener( new ActionListener() public void actionPerformed(ActionEvent e) if (item31 .getLabel().equals( 自動(dòng)換行) item31 .setLabel(,自動(dòng)換行”); text .setLineWrap( true ); else item31 .setLabel( 自動(dòng)換行); text .setLineWrap( false ););7.字

12、體功能定義了另外一個(gè)類(lèi),用對(duì)話(huà)框功能實(shí)現(xiàn)一個(gè)能選擇字體,字形,大小的對(duì)話(huà)框。myziti=new JtextField()定義文本框 顯示所選擇的字體,字形,大小JScrollPane scroll=new JScrollPane( zitiList );scroll.setBounds(10, 60,100 ,100);設(shè)置圖中所示的滾動(dòng)條public void valueChanged(ListSelectionEvent event)myzixing .setText( myxingzhuang zixingList.getSelectedIndex();ziti_check= myzi

13、ti .getText();style_check =myzixing .getText();daxiao_check = mydaxiao .getText();int zitidaxiao=Integer.parseInt(daxiao_check );int zitistyle=Font.PLAIN ;if( style_check.equals(常規(guī))zitistyle=Font.PLAIN;if( style_check.equals(斜體)zitistyle=Font.ITALIC;if( style_check.equals(粗體)zitistyle=Font.BOLD;if(

14、style_check.equals(粗斜體)zitistyle=Font. -BOLD+Font. ITALIC;shili .setFont( new Font( ziti_check,zitistyle,zitidaxiao););添加監(jiān)聽(tīng)器,調(diào)用 equal() 按鈕添加監(jiān)聽(tīng)器方法,選擇所需的字形cancel .addActionListener(public voiddispose。;);ok .addActionListener( public voidnew ActionListener()actionPerformed(ActionEvent e) new ActionList

15、ener()actionPerformed(ActionEvent e)四、心得體會(huì)實(shí)驗(yàn)完成了基本功能,能進(jìn)行基本的操作。做完實(shí)驗(yàn)的第一感受是亂,在實(shí)驗(yàn) 中按照系統(tǒng)提示添加了很多東西,如添加菜單條,菜單項(xiàng),菜單,文本區(qū)等覺(jué)得都比 較熟練,在查閱了網(wǎng)上和書(shū)上別人代碼后, 也根據(jù)自己的理解實(shí)現(xiàn)了打開(kāi),新建和保 存功能,但是對(duì)于字體的設(shè)計(jì)我確實(shí)沒(méi)有自己完成,在運(yùn)用別人的代碼后因?yàn)槎x, 結(jié)構(gòu)等不匹配也很苦惱,自己修改了好久,找了很多同學(xué)幫忙才運(yùn)行成功。這次實(shí)驗(yàn)讓我對(duì)所學(xué)的知識(shí)運(yùn)用更加熟練,也讓我對(duì)JAVA有了更深的喜愛(ài),雖然我能掌握的知識(shí)很少,但是在以后的時(shí)間我會(huì)更加認(rèn)真的學(xué)習(xí)JAVA ,我覺(jué)得在所

16、學(xué)的專(zhuān)業(yè)課中,終于找到一個(gè)自己感興趣的,雖然學(xué)的沒(méi)有別人好,我相信我會(huì)學(xué) 好的。平教評(píng)定項(xiàng)目ABCD評(píng)定項(xiàng)目ABCD介師算法正確界囿美觀,布局合理程序結(jié)構(gòu)合理操作熟練語(yǔ)法、語(yǔ)義正確解析完整實(shí)驗(yàn)結(jié)果正確義字流暢報(bào)告規(guī)范題解正確其他:評(píng)價(jià)教師簽名:2011年11月26日package me;import java.awt.*;import javax.swing.*;import ;import ;import ;import java.io.*;import ;public class FirstWindow public static void main(String args口兒new FW

17、indow(記事本);class FWindow extends JFrame implements ActionListener,WindowListener,ItemListener public static Frame frame;JMenuBar menubar;JPopupMenu menu;JMenu menu1,menu2,menu3,menu4,menu5;JMenuItemitem1,item2,item3,item4,item5,item21,item22,item23,item24,item25,item26,item27,item31,item32,ite m41,i

18、tem51,item52;JMenuItem itemCopy,itemCut,itemPaste;JTextArea text;JScrollPane scrollPane;JComboBox listFont,listFSize;int save_status = 0,status=0,huanhang_count=0;FWindow(String s)addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent event)if(save_status=0)int check=JOptionPane.

19、showConfirmDialog(null, 文件的文字已經(jīng)改變。想保存文件嗎? ,警告 ,JOptionPane.YES_NO_CANCEL_OPTION);if(check=0)saveFile(status);if(check=1)System.exit(0);if(check=2)dispose(););setTitle( 記事本 );setSize(700,400);setLocation(120,120);menubar=new JMenuBar();setJMenuBar(menubar);text=new JTextArea();scrollPane=new JScrollP

20、ane(text);/ 滾動(dòng)條add(scrollPane);scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);menu=new JPopupMenu();menu1=new JMenu( 文件 );menu1.addActionListener(this);menu2=new JMenu( 編輯 );menu3=new JMenu

21、( 格式 );menu4=new JMenu( 查看 );menu5=new JMenu( 幫助 );menubar.add(menu1);menubar.add(menu2);menubar.add(menu3);menubar.add(menu4);menubar.add(menu5);item1=new JMenuItem( 新建 ); / 文件菜單下菜單項(xiàng)的創(chuàng)建item1.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)if(e.getSource()=item1)text.

22、setText();this.setTitle( 無(wú)標(biāo)題 - 記事本 );private void setTitle(String string) / TODO Auto-generated method stub);item2=new JMenuItem( 打開(kāi) .);item2.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)if(e.getSource()=item2)File f1;JFileChooser jfc1 = new JFileChooser(D:/);int n

23、um1 = jfc1.showOpenDialog(null);if(num1=JFileChooser.APPROVE_OPTION)tryf1 = jfc1.getSelectedFile();this.setTitle(f1.getName();FileReader fr = new FileReader(f1);BufferedReader br = new BufferedReader(fr);String str;while(str = br.readLine()!=null)text.setText(str);fr.close();br.close();catch(FileNot

24、FoundException e1)e1.printStackTrace();catch(IOException e2)e2.printStackTrace();private void setTitle(String name) );item3=new JMenuItem( 保存 );item3.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)if(e.getSource()=item3)File f2 = null;JFileChooser jfc2 = new JFileCho

25、oser();int num2 = jfc2.showSaveDialog(null);if(num2=JFileChooser.APPROVE_OPTION)f2=jfc2.getSelectedFile();this.setTitle(f2.getName();tryFileWriter fw = new FileWriter(f2);BufferedWriter bw = new BufferedWriter(fw);bw.write(text.getText();bw.close();fw.close();catch(IOException e2)e2.printStackTrace(

26、);private void setTitle(String name) / TODO Auto-generated method stub);item4=new JMenuItem( 另存為 .);item5=new JMenuItem( 退出 );item5.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)if(e.getSource()=item4)int a = JOptionPane.showConfirmDialog(null, 文件已被改變, 是否要保存?,提示 ,JO

27、ptionPane.YES_NO_CANCEL_OPTION);if(a=1)this.dispose();else if(a=0)File f2 = null;JFileChooser jfc2 = new JFileChooser();int num2 = jfc2.showSaveDialog(null);if(num2=JFileChooser.APPROVE_OPTION)f2=jfc2.getSelectedFile();this.setTitle(f2.getName();tryFileWriter fw = new FileWriter(f2);BufferedWriter b

28、w = new BufferedWriter(fw);bw.write(text.getText();bw.close();fw.close();catch(IOException e2)e2.printStackTrace();this.dispose();private void setTitle(String name) / TODO Auto-generated method stubprivate void dispose() / TODO Auto-generated method stub);item1.setAccelerator(KeyStroke.getKeyStroke(

29、KeyEvent.VK_N,InputEvent.CTRL_MASK);item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_MASK);item3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK);menu1.add(item1);menu1.add(item2);menu1.add(item3);menu1.add(item4);menu1.add(item5);item21=new JMenuIte

30、m( 撤銷(xiāo) );/編輯菜單下菜單項(xiàng)的創(chuàng)建item22=new JMenuItem( 剪切 );item23=new JMenuItem( 復(fù)制 );item24=new JMenuItem( 粘貼 );item25=new JMenuItem( 刪除 );item26=new JMenuItem( 全選 );item27=new JMenuItem( 時(shí)間 / 日期 );item27.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)if(e.getSource()=item27)Ca

31、lendar c1 =Calendar.getInstance();int y = c1.get(Calendar.YEAR);int m = c1.get(Calendar.MONTH);int d = c1.get(Calendar.DATE);int h = c1.get(Calendar.HOUR);int m1 = c1.get(Calendar.MINUTE);int m2 = m+1;text.setText(y+年+m2+月+d+日+h+:+m1););item21.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,Inpu

32、tEvent.CTRL_MASK);item22.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK);item23.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK);item24.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V ,InputEvent.CTRL_MASK);/item1.setAccelerator(KeyStroke.getKey

33、Stroke(KeyEvent.VK_Del);item26.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,InputEvent.CTRL_MASK);/item1.setAccelerator(new MenuShortcut(KeyEvent.VK_F5);menu2.add(item21);menu2.add(item22);menu2.add(item23);menu2.add(item24);menu2.add(item25);menu2.add(item26);menu2.add(item27);item31=new JMe

34、nuItem(,自動(dòng)換行力item32=new JMenuItem( 字體 );item32.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) StyleDialog aa=new StyleDialog(text););item31.setAccelerator(KeyStroke.getKeyStroke(W);item32.setAccelerator(KeyStroke.getKeyStroke(F);menu3.add(item31);menu3.add(item32);i

35、tem31.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) if(item31.getLabel().equals( 自動(dòng)換行 )item31.setLabel(,自動(dòng)換行”);text.setLineWrap(true);else item31.setLabel( 自動(dòng)換行 );text.setLineWrap(false););item41=new JMenuItem( 狀態(tài)欄 );/查看菜單下菜單項(xiàng)的創(chuàng)建item41.setAccelerator(KeyStroke.getK

36、eyStroke(S);menu4.add(item41);item51=new JMenuItem( 查看幫助 );/幫助菜單下菜單項(xiàng)的創(chuàng)建item52=new JMenuItem( 關(guān)于記事本);item52.setAccelerator(KeyStroke.getKeyStroke(A);menu5.add(item51);menu5.add(item52);item22.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) text.cut(););item23.addActio

37、nListener(new ActionListener() public void actionPerformed(ActionEvent e) text.copy(););item24.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) text.paste(););text.addMouseListener(new MouseAdapter() /鼠標(biāo)右鍵實(shí)現(xiàn)復(fù)制,粘貼,剪切功能public void mousePressed(MouseEvent e)if(e.getModi

38、fiers()=InputEvent.BUTTON3_MASK)menu.show(text,e.getX(),e.getY(););JMenuItem cut = new JMenuItem( 剪切 (T);/添加右鍵菜單JMenuItem copy = new JMenuItem( 復(fù)制 (C);JMenuItem paste = new JMenuItem( 粘貼 (P);menu.add(copy);menu.add(cut);menu.add(paste);/* 按鈕事件 */cut.addActionListener(new ActionListener() public void

39、 actionPerformed(ActionEvent e) text.cut(););copy.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) text.copy(););paste.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) text.paste(););setVisible(true); / FWindow() 方法結(jié)束protected void sa

40、veFile(int status2) / TODO Auto-generated method stubclass StyleDialog extends JDialogJLabel ziti,zixing,daxiao;JPanel style,myshili;JTextArea shili;JButton ok,cancel;JList zitiList,zixingList,daxiaoList;JTextField myziti,myzixing,mydaxiao;String mystyle=Arial,Elephant,Forte, 宋體 ,華文行楷 ,黑體 ,華文彩云 ,華文

41、仿宋 , 楷書(shū) _GB2312, 隸書(shū) ,華文中宋 ;String myxingzhuang= 常規(guī) ,斜體 , 粗體 , 粗斜體 ;String mypounds=9,10,11,12,13,14,15,16,17,18;String daxiao_check,style_check,ziti_check;StyleDialog(JTextArea text)super(frame, 字體 ,false);/setTitle( 字體 );this.setResizable(false);this.setBackground(Color.white);Container container=g

42、etContentPane();container.setLayout(null);ziti=new JLabel( 字體 );ziti.setFont(new Font(Monospaced,Font.PLAIN,12);ziti.setBounds(10,10,50,20);myziti=new JTextField( 宋體 );myziti.setEditable(false);myziti.setBackground(Color.white);myziti.setBounds(10, 35, 100, 20);zitiList=new JList(mystyle);zitiList.s

43、etSelectedIndex(3);zitiList.setFont(new Font(Monospaced,Font.PLAIN,12);zitiList.setVisibleRowCount(5);zitiList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);zitiList.addListSelectionListener(new ListSelectionListener()public void valueChanged(ListSelectionEvent event)myziti.setText(mystylezi

44、tiList.getSelectedIndex();ziti_check=myziti.getText();style_check=myzixing.getText();daxiao_check=mydaxiao.getText();int zitidaxiao=Integer.parseInt(daxiao_check);int zitistyle=Font.PLAIN;if(style_check.equals( 常規(guī) )zitistyle=Font.PLAIN;if(style_check.equals( 斜體 )zitistyle=Font.ITALIC;if(style_check.

45、equals( 粗體 )zitistyle=Font.BOLD;if(style_check.equals( 粗斜體 )zitistyle=Font.BOLD+Font.ITALIC;shili.setFont(new Font(ziti_check,zitistyle,zitidaxiao););JScrollPane scroll=new JScrollPane(zitiList);scroll.setBounds(10, 60,100 ,100);zixing=new JLabel( 字形 );zixing.setFont(new Font(Monospaced,Font.PLAIN,1

46、2);zixing.setBounds(120, 10, 50, 20);myzixing=new JTextField( 常規(guī) );myzixing.setEditable(false);myzixing.setBackground(Color.white);myzixing.setBounds(120, 35, 100, 20);zixingList=new JList(myxingzhuang);zixingList.setSelectedIndex(0);zixingList.setFont(new Font(Monospaced,Font.PLAIN,12);zixingList.s

47、etVisibleRowCount(5);zixingList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);zixingList.addListSelectionListener(new ListSelectionListener()public void valueChanged(ListSelectionEvent event)myzixing.setText(myxingzhuangzixingList.getSelectedIndex();ziti_check=myziti.getText();style_check=my

48、zixing.getText();daxiao_check=mydaxiao.getText();int zitidaxiao=Integer.parseInt(daxiao_check);int zitistyle=Font.PLAIN;if(style_check.equals( 常規(guī) )zitistyle=Font.PLAIN;if(style_check.equals( 斜體 )zitistyle=Font.ITALIC;if(style_check.equals( 粗體 )zitistyle=Font.BOLD;if(style_check.equals( 粗斜體 )zitistyl

49、e=Font.BOLD+Font.ITALIC;shili.setFont(new Font(ziti_check,zitistyle,zitidaxiao););JScrollPane scroll2=new JScrollPane(zixingList);scroll2.setBounds(120, 60,100 ,80);daxiao=new JLabel( 大小 );daxiao.setFont(new Font(Monospaced,Font.PLAIN,12);daxiao.setBounds(230, 10, 50, 20);mydaxiao=new JTextField(12)

50、;mydaxiao.setEditable(false);mydaxiao.setBackground(Color.white);mydaxiao.setBounds(230, 35, 50, 20);daxiaoList=new JList(mypounds);daxiaoList.setSelectedIndex(3);daxiaoList.setFont(new Font(Monospaced,Font.PLAIN,12);daxiaoList.setVisibleRowCount(5);daxiaoList.setSelectionMode(ListSelectionModel.SIN

51、GLE_SELECTION);daxiaoList.addListSelectionListener(new ListSelectionListener()public void valueChanged(ListSelectionEvent event)mydaxiao.setText(mypoundsdaxiaoList.getSelectedIndex();ziti_check=myziti.getText();style_check=myzixing.getText();daxiao_check=mydaxiao.getText();int zitidaxiao=Integer.parseInt(daxiao_check);int zitistyle=Font.PLAIN;if(style_check.equals( 常規(guī) )zitistyle=Font.PLAIN;if(style_check.equals( 斜體 )zitistyle=Font.ITALIC;if(style_ch

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論