[中学教育]打字练习软件源代码
1 2
3
4
5
6
7
8
9
10 打字练习软件源代码
11 import javax.swing.*;
12 import java.awt.*;
13
14
15 /**
16 * This code was edited or generated using CloudGarden's Jigloo 17 * SWT/Swing GUI Builder, which is free for non-commercial 18 * use. If Jigloo is being used commercially (ie, by a corporation, 19 * company or business for any purpose whatever) then you 20 * should purchase a license for each developer using Jigloo. 21 * Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.22 23 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR 24 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED 25 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. 26 */
27 public class Chat extends JInternalFrame{
28 MainFrame parent;
private JTextPane jtp;29
30 private JTextField txtData;
31
32 public Chat(MainFrame parent){
this.parent=parent;33
34
35 setLayer(4);
36 setBounds(1,326,0,0);
37 this.setPreferredSize(new java.awt.Dimension(140, 223)); 38 ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
39
this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); 40
41
42 GridBagLayout thisLayout = new GridBagLayout();
43 thisLayout.rowWeights = new double[] {0.1, 0.1, 0.0, 0.0};
44 thisLayout.rowHeights = new int[] {7, 7, 49, 56}; 45 thisLayout.columnWeights = new double[] {0.0, 0.0, 0.0, 0.0}; 46 thisLayout.columnWidths = new int[] {0, 45, 45, 48}; 47 getContentPane().setLayout(thisLayout);
48 setVisible(true);
49 pack();
50 {
51 jtp = new JTextPane();
52 getContentPane().add(jtp, new GridBagConstraints(1, 0, 4, 5, 0.0, 0.0,
53 GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
54
55 jtp.setPreferredSize(new Dimension(140, 160)); 56 jtp.setEditable(false);
57 }
58 {
59 txtData = new JTextField();
60 getContentPane().add(txtData, new GridBagConstraints(1, 7, 3, 1, 0.0, 0.0,
61 GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
62
63 txtData.setColumns(10);
64 }
65 }
}66
67
68 import java.io.*;
69 public class DistillText {
70 public static String getData(String fileName,int segment){71
72 int i=0;
73 if((fileName==null) || (fileName.length()==0)) 74 return "";
75 File f;
76 FileReader in=null;
77 String s="";
78 try{
79 f=new File(fileName);
80 in=new FileReader(f);
81 char[] buffer=new char[312]; 82 int len;
83 if(PublicData.Lang.equals("English")){ 84 if(segment>=(int)(f.length()/312)) 85 PublicData.textTag=0; 86 }
87 if(PublicData.Lang.equals("Chinese")){
88 if(segment>=(int)(f.length()/312-1)+1)
89 PublicData.textTag=0; 90 }
91 while((len=in.read(buffer))!=-1){
92 s=new String(buffer,0,len); 93 i++;
94 if(i==segment){ 95 PublicData.textTag++; 96 break; 97 }
98 }
99 }
100 catch(IOException e){ 101 System.out.println(e); 102 }
103 finally{
104 try{
105 if(in!=null) 106 in.close(); 107 }
108 catch(IOException e){} 109 }
110 return s;
111 }
112 }
113
114 import java.awt.FlowLayout;
115 import java.awt.GridBagConstraints; 116 import java.awt.GridLayout;
import java.awt.Insets;117
118 import java.awt.event.ActionEvent; 119 import java.awt.event.ActionListener; 120 import javax.swing.text.*;
import javax.swing.*;121
122 import java.awt.*;
123
124 import javax.swing.event.*;
125
126 public class Editor extends JInternalFrame implements DocumentListener,Runnable{
127
128
Runtime r=Runtime.getRuntime();129 130 Hint parent;
131
132 Document doc; 133 StyledDocument styledDoc = new DefaultStyledDocument();
134 Thread th;
135
136 private int hour=0;//时 137 private int minute=0;//分 138 private int second=0;//秒 139
140 private JLabel lblTime; 141 private JTextField txtCount; 142 private JLabel lblError; 143 private JCheckBox on_off_Hint; 144 private JButton btnRight; 145 private JButton btnError; 146 private JCheckBox faze; 147 private JCheckBox grade; 148 private JCheckBox on_off_Assistant; 149 private JPanel pCollocate; 150 private JTextPane txtOriginal; 151 private JTextPane txtNewText; 152 private JPanel pShowData; 153 private JButton btnClose;
private JLabel lblWord;154 155 private JTextField txtMW; 156 private JLabel lblM; 157 private JTextField txtError; 158 private JTextField txtRight; 159 private JLabel lblRight; 160 private JLabel lblCount;
private JTextField txtTime;161 162 private JPanel pAttrib; 163
164 //
输入的正确和错误的个数据
private int rightWord=0;165 166 private int errorWord=0; 167 private int rightCount=0; 168 private int errorCount=0; 169 private int wordCount=0; 170 //临时
171 private boolean temp=true; 172
173
174 public Editor(Hint parent){
175
176 this.parent=parent;
177
178 th=new Thread(this);
179
180
181 //组建Editor用户界面....
182 setLayer(4);
183 setBounds(142,0,0,0);
184 this.setPreferredSize(new java.awt.Dimension(657, 325));//内部窗体大小185
186 ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
187
188 this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
189
190 getContentPane().setLayout(null);
191 this.setVisible(true);
192 {
193 pAttrib = new JPanel();
194 getContentPane().add(pAttrib, new GridBagConstraints(1, 0, 12, 3, 0.0, 0.0,
195 GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
196
197 FlowLayout pAttribLayout = new FlowLayout();
pAttrib.setBorder(BorderFactory.createTitledBorder(""));198 199 pAttrib.setLayout(pAttribLayout); 200 pAttrib.setBounds(-2, 33, 658, 42); 201 {
202 lblTime = new JLabel();
203 pAttrib.add(lblTime);
204 lblTime.setText("\u7528\u65f6:");
lblTime.setFont(new java.awt.Font("新宋体", 0, 12));205 206 }
207 {
208 txtTime = new JTextField(8);
pAttrib.add(txtTime);209
210 txtTime.setText("00:00:00"); 211 txtTime.setEditable(false); 212 txtTime.setHorizontalAlignment(SwingConstants.CENTER);
213
214 }
215 {
lblCount = new JLabel();216 217 pAttrib.add(lblCount);
218 lblCount.setText("\u603b\u5b57\u6570:");
219 lblCount.setFont(new java.awt.Font("新宋体", 0, 12));
220 }
221 {
222 txtCount = new JTextField(); 223 pAttrib.add(txtCount); 224 txtCount.setColumns(6); 225 txtCount.setText("0"); 226 txtCount.setEditable(false); 227 txtCount.setHorizontalAlignment(SwingConstants.CENTER);
228
229 }
230 {
231 lblRight = new JLabel(); 232 pAttrib.add(lblRight); 233 lblRight.setText("\u6b63\u786e:"); 234 lblRight.setFont(new java.awt.Font("新宋体", 0, 12));
235 }
236 {
237 txtRight = new JTextField(); 238 pAttrib.add(txtRight); 239 txtRight.setColumns(4); 240 txtRight.setText("0"); 241 txtRight.setEditable(false);
txtRight.setHorizontalAlignment(SwingConstants.CENTER);242
243
244 }
245 {
246 lblError = new JLabel(); 247 pAttrib.add(lblError); 248 lblError.setText("\u9519\u8bef:");
lblError.setFont(new java.awt.Font("新宋体", 0, 12));249
250 }
251 {
252 txtError = new JTextField();
pAttrib.add(txtError);253 254 txtError.setColumns(4); 255 txtError.setText("0"); 256 txtError.setEditable(false); 257 txtError.setHorizontalAlignment(SwingConstants.CENTER);
258
259 }
{260
261 lblM = new JLabel(); 262 pAttrib.add(lblM);
263 lblM.setText("\u6bcf\u5206\u949f");264 lblM.setFont(new java.awt.Font("新宋体", 0, 12)); 265 }
266 {
267 txtMW = new JTextField();
268 pAttrib.add(txtMW);
269 txtMW.setColumns(4);
270 txtMW.setText("0");
271 txtMW.setEditable(false);
272 txtMW.setHorizontalAlignment(SwingConstants.CENTER);
273
274 }
275 {
276 lblWord = new JLabel();
277 pAttrib.add(lblWord);
278 lblWord.setText("\u4e2a\u5b57"); 279 lblWord.setFont(new java.awt.Font("新宋体", 0, 12)); 280 }
281 {
282 btnClose = new JButton();
283 pAttrib.add(btnClose);
284 btnClose.setText("\u79bb\u5f00"); 285 btnClose.setIcon(new ImageIcon(getClass().getClassLoader()
286
287 .getResource("Image/leave.gif"))); 288 btnClose.setFont(new java.awt.Font("新宋体", 0, 12)); 289 btnClose.addActionListener(new ActionListener() { 290 public void actionPerformed(ActionEvent evt) { 291 exitFram();
292 }
});293
294 }
295 }
296 {
pShowData = new JPanel();297
298 getContentPane().add(
299 pShowData,
300 new GridBagConstraints(
301 1,
302 1,
303 12,
10,304
305 0.0,
306 0.0,
307 GridBagConstraints.CENTER,308 GridBagConstraints.BOTH, 309 new Insets(0, 0, 0, 0), 310 0,
311 0));
312 GridLayout pShowDataLayout = new GridLayout(2, 1); 313 pShowDataLayout.setHgap(5); 314 pShowDataLayout.setVgap(5); 315 pShowDataLayout.setColumns(1); 316 pShowDataLayout.setRows(2); 317 pShowData.setLayout(pShowDataLayout); 318 pShowData.setBounds(5, 82, 644, 231); 319 {
320 txtOriginal = new JTextPane(styledDoc); 321 pShowData.add(txtOriginal); 322 txtOriginal.setPreferredSize(new java.awt.Dimension(600, 0));
323
324 txtOriginal.setEditable(false); 325 }
326 {
327 txtNewText = new JTextPane(); 328 pShowData.add(txtNewText); 329 txtNewText.setPreferredSize(new java.awt.Dimension(600, 0));
330
331 Document doc=txtNewText.getDocument(); 332 doc.addDocumentListener(this); 333
334 }
335 }
336 {
pCollocate = new JPanel();337 338 getContentPane().add( 339 pCollocate,
340 new GridBagConstraints(
1,341
342 11,
343 12,
344 2,
345 0.0,
346 0.0,
347 GridBagConstraints.SOUTH,
GridBagConstraints.BOTH,348 349 new Insets(0, 0, 0, 0), 350 0,
351 0));
352 FlowLayout pCollocateLayout = new FlowLayout(); 353 pCollocate.setBorder(BorderFactory.createTitledBorder("")); 354 pCollocate.setLayout(pCollocateLayout); 355 pCollocate.setBounds(-2, -2, 658, 35); 356 {
357 on_off_Hint = new JCheckBox(); 358 pCollocate.add(on_off_Hint); 359 on_off_Hint.setText("\u5173\u95ed\u5b57\u6bcd\u63d0\u793a");
360
361 on_off_Hint.setSelected(true); 362 on_off_Hint.setFont(new java.awt.Font("新宋体",0,12));363
364 }
365 {
366 on_off_Assistant = new JCheckBox(); 367 pCollocate.add(on_off_Assistant); 368 on_off_Assistant.setText("\u5173\u95ed\u6c49\u5b57\u52a9\u624b");
369
370 on_off_Assistant.setSelected(true); 371 on_off_Assistant.setFont(new java.awt.Font("新宋体",0,12));372
373 }
{374
375 grade = new JCheckBox();
376 pCollocate.add(grade);
377
378 grade.setText("\u79bb\u5f00\u65f6\u662f\u5426\u663e\u793a\u6210\u7ee9");
379
380 grade.setSelected(true);
grade.setFont(new java.awt.Font("新宋体",0,12));381 382 }
383 {
384 faze = new JCheckBox();
pCollocate.add(faze);385
386
387 faze.setText("\u804a\u5929\u7cfb\u7edf\u5f00\u542f\u65f6\u663e\u793a\u81ea\u5df1\u768
388 4\u72b6\u6001");
389 faze.setSelected(true);
390 faze.setFont(new java.awt.Font("新宋体",0,12)); 391 }
{392
393 btnError = new JButton();
394 pCollocate.add(btnError);
395 //btnError.setIcon(new
396 ImageIcon(getClass().getClassLoader().getResource("Image/Error.gif"))); 397 btnError.setBackground(new java.awt.Color(255,255,255));
398
399
400 btnError.setToolTipText("\u9519\u8bef\u6587\u5b57\u7528\u7ea2\u8272\u8868\u793a");
401
402 btnError.setText("×");
403 btnError.setPreferredSize(new java.awt.Dimension(47, 17));
404
405 btnError.setFont(new java.awt.Font("新宋体",1,12)); 406 btnError.setForeground(new java.awt.Color(219,32,36)); 407 }
408 {
409 btnRight = new JButton();
410 pCollocate.add(btnRight);
411 //btnRight.setIcon(new
412 ImageIcon(getClass().getClassLoader().getResource("Image/Right.gif"))); 413 btnRight.setBackground(new java.awt.Color(255,255,255));
414
415
416 btnRight.setToolTipText("\u6b63\u786e\u6587\u5b57\u7528\u84dd\u8272\u8868\u793a");
417
btnRight.setText("\u221a");418
419 btnRight.setFont(new java.awt.Font("新宋体",1,12)); 420 btnRight.setPreferredSize(new java.awt.Dimension(47, 17));
421
422 btnRight.setForeground(new java.awt.Color(0,0,255)); 423 }
424
txtOriginal.setText(DistillText.getData(PublicData.Text,PublicData.textTag));425
426
427 //PublicData.key=txtOriginal.getText().substring(0,1); 428 Empty empty=new Empty();
empty.start();429
430 if(txtOriginal.getText().length()!=0)
431 {
432 if(PublicData.Lang.equals("English")){ 433 PublicData.key=txtOriginal.getText().substring(0,1);
434
435 this.parent.repaint();
}436
437 if(PublicData.Lang.equals("Chinese")){ 438 PublicData.key="";
439 }
440 }
441 }
442 this.pack();
443 txtNewText.requestFocus();
444 th.start();
445 }
446
447 //判断正确和错误的字.并改变它们的颜色 448 public void chDocs(int xLen,int yLen,String xStr,String yStr) 449 {
450 SimpleAttributeSet attrSet=new SimpleAttributeSet(); 451 rightWord=0;
452 errorWord=0;
453 for(int i=1;i<=xLen;i++)
454 {
455 if(i<=yLen){//数据验证
456 if(xStr.substring(i-1,i).equals(yStr.substring(i-1,i))){ 457 rightWord++;
458 StyleConstants.setForeground(attrSet,Color.BLUE);
459
460 }
461 else{
errorWord++;462
463 StyleConstants.setForeground(attrSet,Color.RED); 464 }
465 StyleConstants.setUnderline(attrSet,true); 466 }
467 else{
468 StyleConstants.setForeground(attrSet,Color.BLACK);
StyleConstants.setUnderline(attrSet,false);469 470 }
471 styledDoc.setCharacterAttributes(i-1,1,attrSet,true); 472 }
473
txtRight.setText((rightWord+rightCount)+"");474 475 txtError.setText((errorWord+errorCount)+""); 476 int c=0;
477 for(int i=0;i
txtNewText.getText().length()){ 530 if(PublicData.Lang.equals("English")){ 531
532 PublicData.key=txtOriginal.getText().substring(txtNewText.getText().length(),
533
534 txtNewText.getText().length()+1); 535 }
536 if(PublicData.Lang.equals("Chinese")){ 537 PublicData.key="";
538 }
539 txtCount.setText((txtNewText.getText().length()+wordCount)+"");
540
541 }
542 else{
543 wordCount=wordCount+txtOriginal.getText().length(); 544 rightCount=rightCount+rightWord; 545 errorCount=errorCount+errorWord; 546 txtOriginal.setText(DistillText.getData(PublicData.Text,PublicData.textTag));
547
548
549 if(PublicData.Lang.equals("English")){ 550 PublicData.key=txtOriginal.getText().substring(0,1);
this.parent.repaint();551
552 }
553 if(PublicData.Lang.equals("Chinese")){ 554 PublicData.key="";
555 this.parent.repaint();
556 }
557 }
}558
559
560 //退出时所要关闭的窗体
561 private void exitFram(){
PublicData.key="";562
563 PublicData.Text="";
564 this.parent.repaint();
565 this.parent.doDefaultCloseAction(); 566 this.doDefaultCloseAction();
567 PublicData.onChoice=true;
568 PublicData.textTag=1;
r.gc();569
570 System.gc();
571 }
572
573 //计时器
574 public void run(){
575 try{
576 while(true){
577 Thread.sleep(1000); 578 second++; 579 if(second==60){ 580 second=0; 581 minute++; 582 if(minute==60){ 583 minute=0; 584 hour++; 585 if(hour==1000){ 586 second=0; 587 minute=0; 588 hour=0; 589 } 590 }
591 }
592 txtTime.setText(((hour<=9)?"0":"")+hour+":"+((minute<=9)?"0":"")
593
594 +minute+":"+((second<=9)?"0":"")+second);
}595
596 }
597 catch (InterruptedException e){} 598 }
599
600 class Empty extends Thread{ 601 public void run(){
while(true){602
603 try{
604 Thread.sleep(100); 605 dataValidate();
if(txtNewText.getText().length()>=txtOriginal.getText().length()){606
607
608 txtNewText.setText(""); 609 }
610 }
611 catch(InterruptedException e){} 612 }
}613
614 }
615 }
616 import java.awt.event.ActionEvent;617 import java.awt.event.ActionListener;
618 import javax.swing.*;
619
620
621
622 /**
623 * This code was edited or generated using CloudGarden's Jigloo 624 * SWT/Swing GUI Builder, which is free for non-commercial 625 * use. If Jigloo is being used commercially (ie, by a corporation, 626 * company or business for any purpose whatever) then you 627 * should purchase a license for each developer using Jigloo. 628 * Please visit www.cloudgarden.com for details. 629 * Use of Jigloo implies acceptance of these licensing terms. 630 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR 631 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED 632 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. 633 */
634 public class Etymon extends JInternalFrame{ 635
636 private Hint parent;
637 private JButton btnCelean;
638 private JLabel lblword;
private JPanel p4;639
640 private JPanel p3;
641 private JPanel p2;
642 private JTextField txtMSword;
643 private JLabel lblRight;
644 private JTextField txtRight;
645 private JLabel lblM;
private JTextField txtError;646
647 private JLabel lblError;
648 private JTextField txtCountWord;
649 private JLabel countWord;
private JTextField txtTime;650
651 private JLabel lblTime;
652 private JPanel p1;
653 private JLabel lblt;
654
655 private JLabel[] ShowWord;
656 public Etymon(Hint parent){
657
this.parent=parent;658
659
660 setLayer(7);
661 setBounds(142,0,0,0);
662 this.setPreferredSize(new java.awt.Dimension(657, 325));//内部窗体大小663
664 ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
665
666 this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
667
668 getContentPane().setLayout(null);
669 this.setVisible(true);
670 {
671 lblt = new JLabel();
672 getContentPane().add(lblt);
673 lblt.setIcon(new ImageIcon(getClass().getClassLoader().getResource(
674
675 "Image/zgt.gif")));
676 lblt.setBounds(26, 40, 602, 189);
677 }
678 {
679 p1 = new JPanel();
680 getContentPane().add(p1);
681 p1.setBounds(-2, -2, 658, 42);
682 p1.setBorder(BorderFactory.createTitledBorder(""));
{683
684 lblTime = new JLabel();
685 p1.add(lblTime);
686 lblTime.setText("\u7528\u65f6:"); 687 lblTime.setPreferredSize(new java.awt.Dimension(30, 14));
688
689 lblTime.setFont(new java.awt.Font("新宋体",0,12));
}690
691 {
692 txtTime = new JTextField();
693 p1.add(txtTime);
txtTime.setText("00:00:00");694
695 txtTime.setEditable(false);
696 txtTime.setPreferredSize(new java.awt.Dimension(69, 20));
697
698 txtTime.setFont(new java.awt.Font("新宋体",0,12)); 699 txtTime.setHorizontalAlignment(SwingConstants.CENTER);
700
}701
702 {
703 countWord = new JLabel();
704 p1.add(countWord);
705 countWord.setText("\u603b\u5b57\u6570:"); 706 countWord.setFont(new java.awt.Font("新宋体",0,12)); 707 }
708 {
709 txtCountWord = new JTextField(); 710 p1.add(txtCountWord);
711 txtCountWord.setText("0");
712 txtCountWord.setPreferredSize(new java.awt.Dimension(69, 20));
713
714 txtCountWord.setFont(new java.awt.Font("新宋体",0,12));715
716 txtCountWord.setHorizontalAlignment(SwingConstants.CENTER);
717
718 txtCountWord.setEditable(false); 719 }
720 {
721 lblRight = new JLabel();
722 p1.add(lblRight);
723 lblRight.setText("\u6b63\u786e:"); 724 lblRight.setFont(new java.awt.Font("新宋体",0,12)); 725 }
726 {
txtRight = new JTextField();727
728 p1.add(txtRight);
729 txtRight.setText("0");
730 txtRight.setPreferredSize(new java.awt.Dimension(69, 20));
731
732 txtRight.setFont(new java.awt.Font("新宋体",0,12)); 733 txtRight.setEditable(false);
txtRight.setHorizontalAlignment(SwingConstants.CENTER);734
735
736 }
737 {
lblError = new JLabel();738
739 p1.add(lblError);
740 lblError.setText("\u9519\u8bef:"); 741 lblError.setFont(new java.awt.Font("新宋体",0,12)); 742 }
743 {
744 txtError = new JTextField();
p1.add(txtError);745
746 txtError.setText("0");
747 txtError.setPreferredSize(new java.awt.Dimension(69, 20));
748
749 txtError.setFont(new java.awt.Font("新宋体", 0, 12));750 txtError.setEditable(false);
751 txtError.setHorizontalAlignment(SwingConstants.CENTER);
752
753 }
754 {
755 lblM = new JLabel();
756 p1.add(lblM);
757 lblM.setText("\u6bcf\u5206\u949f"); 758 lblM.setFont(new java.awt.Font("新宋体",0,12)); 759 }
760 {
761 txtMSword = new JTextField();
762 p1.add(txtMSword);
763 txtMSword.setText("0");
764 txtMSword.setPreferredSize(new java.awt.Dimension(69, 20));
765
766 txtMSword.setFont(new java.awt.Font("新宋体",0,12)); 767 txtMSword.setEditable(false);
768 txtMSword.setHorizontalAlignment(SwingConstants.CENTER);
769
770 }
771 {
lblword = new JLabel();772
773 p1.add(lblword);
774 lblword.setText("\u5b57");
775 lblword.setFont(new java.awt.Font("新宋体",0,12)); 776 }
777 {
778 btnCelean = new JButton();
p1.add(btnCelean);779
780 btnCelean.setText("\u79bb\u5f00"); 781 btnCelean.setFont(new java.awt.Font("新宋体", 0, 12)); 782 btnCelean.setBounds(579, 236, 63, 21);
btnCelean.setBackground(new java.awt.Color(255, 255, 255));783
784
785 btnCelean.addActionListener(new ActionListener() { 786 public void actionPerformed(ActionEvent evt) { 787 exit();
788 }
789 });
}790
791 }
792 {
793 p2 = new JPanel();
794 getContentPane().add(p2); 795 p2.setBounds(-2, 229, 658, 28); 796 p2.setBorder(BorderFactory.createTitledBorder(""));
797 }
798 {
799 p3 = new JPanel(); 800 getContentPane().add(p3); 801 p3.setBounds(-2, 290, 658, 35); 802 p3.setBorder(BorderFactory.createTitledBorder(""));
803 }
804 {
805 //ShowWord=new JLabel[20]; 806 //for(int i=0;i<20;i++){ 807 //ShowWord[i].setText("熊"); 808 //}
809 p4 = new JPanel(); 810 p4.setLayout(null); 811 getContentPane().add(p4); 812 p4.setBounds(-2, 257, 658, 35); 813 p4.setBorder(BorderFactory.createTitledBorder(""));
814 }
815 this.pack();
}816
817 private void exit(){
818 this.parent.doDefaultCloseAction(); 819 this.doDefaultCloseAction(); 820 PublicData.onChoice=true; 821 PublicData.textTag=1; 822 System.gc();
}823
824 }
825
826 import javax.swing.*;
import javax.swing.event.*;827
828 import javax.swing.text.html.*; 829 import java.awt.*;
830 import java.awt.event.ActionEvent; 831 import java.awt.event.ActionListener; 832 import java.io.*;
833 import java.net.*;
834
835
836 /**
837 * This code was edited or generated using CloudGarden's Jigloo
838 * SWT/Swing GUI Builder, which is free for non-commercial 839 * use. If Jigloo is being used commercially (ie, by a corporation, 840 * company or business for any purpose whatever) then you 841 * should purchase a license for each developer using Jigloo. 842 * Please visit www.cloudgarden.com for details. 843 * Use of Jigloo implies acceptance of these licensing terms. 844 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR 845 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED 846 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. 847 */
848 public class Help extends JInternalFrame{
849
850 JEditorPane html;
851 private JPanel p;
852 private JButton btnCencel;
853
854 public Help(){
855 try {
856 URL url = null;
857 // System.getProperty("user.dir") + 858 // System.getProperty("file.separator"); 859 String path = null;
try { 860
861 path = "/help/index.html"; 862 url = getClass().getResource(path); 863 } catch (Exception e) {
864 System.err.println("Failed to open " + path); 865 url = null;
866 }
867
if(url != null) { 868
869 html = new JEditorPane(url); 870 html.setEditable(false);
html.addHyperlinkListener(createHyperLinkListener()); 871
872
873 JScrollPane scroller = new JScrollPane(); 874 JViewport vp = scroller.getViewport(); 875 vp.add(html);
876 add(scroller, BorderLayout.CENTER); 877 }
{878
879 p = new JPanel();
880 getContentPane().add(p, BorderLayout.NORTH);
881 p.setPreferredSize(new java.awt.Dimension(651, 28));
882 p.setLayout(null);
883 {
884 btnCencel = new JButton(); 885 p.add(btnCencel);
886 btnCencel.setText("\u79bb\u5f00"); 887 btnCencel.setIcon(new
888 ImageIcon(getClass().getClassLoader().getResource("Image/leave.gif"))); 889 btnCencel.setBounds(574, 3, 77, 21); 890 btnCencel.setFont(new java.awt.Font("新宋体",0,12));891
892 btnCencel.addActionListener(new ActionListener() {
893
894 public void actionPerformed(ActionEvent evt) {
895
896 PublicData.onChoice=true; 897 exit();
898 }
899 });
900 }
901 }
902 }catch (MalformedURLException e) {
903 System.out.println("Malformed URL: " + e);
} catch (IOException e) { 904
905 System.out.println("IOException: " + e); 906 }
907
908 setLayer(4);
909 setBounds(142,0,0,0);
910 this.setPreferredSize(new java.awt.Dimension(657, 549));//内部窗体大小911
912 ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
913
914 this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
915
916 this.setVisible(true);
917 this.pack();
918 }
919 public HyperlinkListener createHyperLinkListener() { 920 return new HyperlinkListener() {
921 public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {922
923
924 if (e instanceof HTMLFrameHyperlinkEvent) {
925
926 ((HTMLDocument)html.getDocument()).processHTMLFrameHyperlinkEvent((HTMLFra
927 meHyperlinkEvent)e);
928 }
929 else{
930 try {
931 html.setPage(e.getURL()); 932 } catch (IOException ioe) { 933 System.out.println("IOE: " + ioe); 934 }
935 }
936 }
937 }
938 };
939 }
940
941 private void exit(){
942 PublicData.onChoice=true;
943 System.gc();
944 this.doDefaultCloseAction();
945 }
946 }
947
948 import javax.swing.*;
949
950 public class Hint extends JInternalFrame{ 951 Tool parent;
952 public Hint(Tool parent){
953 this.parent=parent;
954 setLayer(4);
955 setBounds(142,326,0,0); 956 this.setPreferredSize(new java.awt.Dimension(657, 223));
957
958 ((javax.swing.plaf.basic.BasicInternalFrameUI)
959 this.getUI()).setNorthPane(null); 960 this.putClientProperty("JInternalFrame.isPalette", 961 Boolean.TRUE);
962 this.setVisible(true); 963 this.pack();
964 this.add(new Keyset()); 965 if(PublicData.choice!=2){ 966 Editor edit=new Editor(this); 967 this.parent.parent.add(edit,2); 968 edit.requestFocus();
969 }
970 else{
971 Etymon etymon=new Etymon(this); 972 this.parent.parent.add(etymon,7); 973 }
974 }
975 }
976
977 import javax.swing.*;
978 import java.awt.*;
979 /*
980 *------------Keyset.java-------------
981 * 该java文件主要完成编辑键区的字符对照 982 * 该java文件开工日期:2007年3月17日 983 * 该Java文件完工日期:2007年3月20日 984 * 编写人:熊占洲
985 */
986 public class Keyset extends JPanel{
987 public void paintComponent(Graphics g){ 988 super.paintComponent(g);
989 String str=new String(PublicData.key); 990 int keyTop=0;//字符在键盘上的纵坐标 991 int keyLeft=0;//字符在键盘上的横坐标
boolean leftShift=false;//是否是左边的Shift992 993 boolean rightShift=false;//是否是右边的Shift 994 boolean yShift=false;//是否要用Shift 995 boolean ySpace=false;//是否是空格 996 String shift=new
997 String("~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?");
998
String noShift=new String("`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./");999
1000
1001 int LEFT=52;
1002 int TOP=20;
int lTemp=LEFT;1003
1004 int tTemp=TOP;
1005 if(shift.lastIndexOf(str)<=46){//计算是不是要用上Shift 1006 if((shift.lastIndexOf(str)>=0 && shift.lastIndexOf(str)<=5) ||
1007
1008 (shift.lastIndexOf(str)>=13 && shift.lastIndexOf(str)<=17) ||
1009
(shift.lastIndexOf(str)>=26 && shift.lastIndexOf(str)<=30) || 1010
1011
1012 (shift.lastIndexOf(str)>=37 && shift.lastIndexOf(str)<=41)){//计算字符在
1013 不在左手区
1014 yShift=true;
1015 rightShift=true;
1016 if(shift.lastIndexOf(str)>=0 && shift.lastIndexOf(str)<=5){//计算字符在该1017 区的位置
1018 keyTop=1;
1019 for(int i=0;i<=5;i++){ 1020 if(str.equals(shift.substring(i, i+1))){ 1021 keyLeft=i;
1022 System.out.println(shift.substring(i, i+1)); 1023 }
1024 }
1025 }
1026 if(shift.lastIndexOf(str)>=13 && shift.lastIndexOf(str)<=17){//计算字符在1027 该区的位置
1028 keyTop=2;
1029 for(int i=13;i<=17;i++){ 1030 if(str.equals(shift.substring(i, i+1))){ 1031 keyLeft=i;
1032 }
1033 }
1034 }
1035 if(shift.lastIndexOf(str)>=26 && shift.lastIndexOf(str)<=30){//计算字符在
该区的位置1036
1037 keyTop=3;
1038 for(int i=26;i<=30;i++){ 1039 if(str.equals(shift.substring(i, i+1))){ 1040 keyLeft=i;
1041 }
1042 }
}1043
1044 if(shift.lastIndexOf(str)>=37 && shift.lastIndexOf(str)<=41){//计算字符在1045 该区的位置
1046 keyTop=4;
for(int i=37;i<=41;i++){1047 1048 if(str.equals(shift.substring(i, i+1))){ 1049 keyLeft=i;
1050 }
1051 }
1052 }
1053 }
if((shift.lastIndexOf(str)>=6 && shift.lastIndexOf(str)<=12) || 1054
1055
1056 (shift.lastIndexOf(str)>=18 && shift.lastIndexOf(str)<=25) ||
1057
1058 (shift.lastIndexOf(str)>=31 && shift.lastIndexOf(str)<=36) ||
1059
1060 (shift.lastIndexOf(str)>=42 && shift.lastIndexOf(str)<=46)){//计算字符在1061 不在右手区
1062 yShift=true;
1063 leftShift=true;
1064 if(shift.lastIndexOf(str)>=6 && shift.lastIndexOf(str)<=12){
1065
1066 keyTop=1;
1067 for(int i=6;i<=12;i++){ 1068 if(str.equals(shift.substring(i, i+1))){ 1069 keyLeft=i;
1070 }
1071 }
1072 }
1073 if(shift.lastIndexOf(str)>=18 && shift.lastIndexOf(str)<=25){
1074
1075 keyTop=2;
1076 for(int i=18;i<=25;i++){ 1077 if(str.equals(shift.substring(i, i+1))){ 1078 keyLeft=i;
1079 }
1080 }
}1081
1082 if(shift.lastIndexOf(str)>=31 && shift.lastIndexOf(str)<=36){
1083
1084 keyTop=3;
1085 for(int i=31;i<=36;i++){ 1086 if(str.equals(shift.substring(i, i+1))){ 1087 keyLeft=i;
}1088
1089 }
1090 }
1091 if(shift.lastIndexOf(str)>=42 && shift.lastIndexOf(str)<=46){
1092
1093 keyTop=4;
1094 for(int i=42;i<=46;i++){ 1095 if(str.equals(shift.substring(i, i+1))){ 1096 keyLeft=i;
1097 }
1098 }
}1099
1100 }
1101 }
1102 if(noShift.lastIndexOf(str)<=46){1103 if(noShift.lastIndexOf(str)>=0 && noShift.lastIndexOf(str)<=12){
1104
1105 keyTop=1;
1106 for(int i=0;i<=12;i++){
1107 if(str.equals(noShift.substring(i,i+1))){ 1108 keyLeft=i;
1109 }
1110 }
1111 }
1112 if(noShift.lastIndexOf(str)>=13 && noShift.lastIndexOf(str)<=25){
1113
1114 keyTop=2;
1115 for(int i=13;i<=25;i++){
1116 if(str.equals(noShift.substring(i,i+1))){ 1117 keyLeft=i;
1118 }
1119 }
1120 }
1121 if(noShift.lastIndexOf(str)>=26 && noShift.lastIndexOf(str)<=36){
1122
1123 keyTop=3;
1124 for(int i=26;i<=36;i++){
if(str.equals(noShift.substring(i,i+1))){1125 1126 keyLeft=i;
1127 }
1128 }
1129 }
1130 if(noShift.lastIndexOf(str)>=37 && noShift.lastIndexOf(str)<=46){
1131
keyTop=4;1132
1133 for(int i=37;i<=46;i++){
1134 if(str.equals(noShift.substring(i,i+1))){ 1135 keyLeft=i;
}1136
1137 }
1138 }
1139 }
1140 if(str.equals(" ")){
1141 ySpace=true;
1142 }
1143
//绘制编辑键区图形//1144
1145 g.setColor(Color.black);
1146 for(int i=0;i<=12;i++){1147 if(keyTop==1 && keyLeft==i){ 1148 g.setColor(Color.gray); 1149 g.fillRect(LEFT,TOP,35,35); 1150 }
1151 g.setColor(Color.black); 1152 g.draw3DRect(LEFT,TOP,35,35,true); 1153 LEFT=LEFT+37; 1154 }
1155 //?键
1156 g.draw3DRect(LEFT,TOP,70,35,true); 1157
1158 int sum=12;
1159 LEFT=lTemp;
1160 TOP=TOP+37;
1161 //Tab键
1162 g.draw3DRect(LEFT,TOP,54,35,true); 1163 LEFT=LEFT+56;
1164
1165 for(int i=1;i<=12;i++)
1166 {
1167 if(keyTop==2 && keyLeft==i+sum){ 1168 g.setColor(Color.gray);
g.fillRect(LEFT,TOP,35,35);1169 1170 }
1171 g.setColor(Color.black); 1172 g.draw3DRect(LEFT,TOP,35,35,true); 1173 LEFT=LEFT+37; 1174 }
1175 //|\键
sum=sum+12;1176
1177 if(keyTop==2 && keyLeft==sum+1){ 1178 g.setColor(Color.gray); 1179 g.fillRect(LEFT,TOP,51,35);
}1180
1181 g.setColor(Color.black); 1182 g.draw3DRect(LEFT,TOP,51,35,true); 1183
1184 sum=sum+1;
1185 LEFT=lTemp;
1186 TOP=TOP+37;
//Caps Lock键1187
1188 g.draw3DRect(LEFT,TOP,65,35,true); 1189 LEFT=LEFT+67;
1190
1191 for(int i=1;i<=11;i++){ 1192 if(keyTop==3 && keyLeft==sum+i){ 1193 g.setColor(Color.gray); 1194 g.fillRect(LEFT,TOP,35,35); 1195 }
1196 g.setColor(Color.black); 1197 g.draw3DRect(LEFT,TOP,35,35,true); 1198 LEFT=LEFT+37; 1199 }
1200 //Enter键
1201 g.draw3DRect(LEFT,TOP,77,35,true); 1202 sum=sum+11;
1203 LEFT=lTemp;
1204 TOP=TOP+37;
1205 //左Shift键
1206 if(leftShift==true){
1207 g.setColor(Color.gray); 1208 g.fillRect(LEFT,TOP,82,35); 1209 }
1210 g.setColor(Color.black); 1211 g.draw3DRect(LEFT,TOP,82,35,true); 1212
LEFT=LEFT+84;1213
1214 for(int i=1;i<=10;i++){ 1215 if(keyTop==4 && keyLeft==sum+i){ 1216 g.setColor(Color.gray); 1217 g.fillRect(LEFT,TOP,35,35); 1218 }
1219 g.setColor(Color.black);
g.draw3DRect(LEFT,TOP,35,35,true);1220 1221 LEFT=LEFT+37; 1222 }
1223 //右Shift键
if(rightShift==true){1224
1225 g.setColor(Color.gray); 1226 g.fillRect(LEFT,TOP,97,35); 1227 }
1228 g.setColor(Color.black); 1229 g.draw3DRect(LEFT,TOP,97,35,true); 1230
//左Ctrl键1231
1232 LEFT=lTemp;
1233 TOP=TOP+37;
1234 g.draw3DRect(LEFT,TOP,53,35,true);
1235 LEFT=LEFT+55;
1236 //win键
1237 g.draw3DRect(LEFT,TOP,44,35,true); 1238 LEFT=LEFT+46;
1239 //左Alt键
1240 g.draw3DRect(LEFT,TOP,44,35,true); 1241 LEFT=LEFT+46;
1242 //Space键
1243 if(ySpace==true){
1244 g.setColor(Color.gray); 1245 g.fillRect(LEFT,TOP,211,35); 1246 }
1247 g.setColor(Color.black); 1248 g.draw3DRect(LEFT,TOP,211,35,true); 1249 //右Alt键
1250 LEFT=LEFT+213;
1251 g.draw3DRect(LEFT,TOP,44,35,true); 1252 LEFT=LEFT+46;
1253 //win键
1254 g.draw3DRect(LEFT,TOP,46,35,true); 1255 LEFT=LEFT+48;
1256 //快捷键
g.draw3DRect(LEFT,TOP,42,35,true);1257 1258 LEFT=LEFT+44;
1259 //右Ctrl键
1260 g.draw3DRect(LEFT,TOP,53,35,true); 1261 //编辑键区图形绘制完成 1262 //绘制字母、符号------- 1263 LEFT=lTemp;
TOP=tTemp;1264
1265 g.setColor(Color.lightGray); 1266 Font f=new Font("x",Font.BOLD,13); 1267 g.setFont(f);
LEFT=LEFT+7;1268
1269 TOP=TOP+14;
1270 for(int i=1;i<=13;i++){ 1271 g.drawString(shift.substring(i-1,i),LEFT,TOP); 1272 g.drawString(noShift.substring(i-1,i),LEFT,TOP+18);
1273 LEFT=LEFT+37; 1274 }
f=new Font("x",Font.BOLD,12);1275 1276 g.setFont(f);
1277 g.drawString("BackSpace",LEFT-4,TOP+8);
1278 LEFT=lTemp+7;
1279 TOP=TOP+37;
1280 g.drawString("Tab",LEFT,TOP+8); 1281 f=new Font("x",Font.BOLD,14); 1282 g.setFont(f);
1283 LEFT=lTemp+63;
1284 for(int i=13;i<=25;i++){
1285 g.drawString(shift.substring(i,i+1),LEFT,TOP); 1286 if(i>=23)
1287 g.drawString(noShift.substring(i,i+1),LEFT,TOP+16); 1288 LEFT=LEFT+37;
1289 }
1290 f=new Font("x",Font.BOLD,12); 1291 g.setFont(f);
1292 LEFT=lTemp;
1293 TOP=TOP+37;
1294 g.drawString("CapsLock",LEFT+7,TOP+8); 1295 f=new Font("x",Font.BOLD,14); 1296 g.setFont(f);
1297 LEFT=lTemp+74;
1298 for(int i=26;i<=36;i++){
1299 g.drawString(shift.substring(i,i+1),LEFT,TOP); 1300 if(i>=35)
g.drawString(noShift.substring(i,i+1),LEFT,TOP+16);1301 1302 if("F".equals(shift.substring(i,i+1)) || "J".equals(shift.substring(i,i+1)))
1303
1304 g.drawString("_",LEFT+5,TOP+15); 1305 LEFT=LEFT+37;
1306 }
1307 f=new Font("x",Font.BOLD,12);
g.setFont(f);1308
1309 g.drawString("Enter??",LEFT+15,TOP+8); 1310 LEFT=lTemp+7;
1311 TOP=TOP+37;
g.drawString("?Shift",LEFT,TOP+8);1312 1313 f=new Font("x",Font.BOLD,14); 1314 g.setFont(f);
1315 LEFT=lTemp+91;
1316 for(int i=37;i<=46;i++){
1317 g.drawString(shift.substring(i,i+1),LEFT,TOP); 1318 if(i>=44)
g.drawString(noShift.substring(i,i+1),LEFT,TOP+16);1319 1320 LEFT=LEFT+37;
1321 }
1322 f=new Font("x",Font.BOLD,12);1323 g.setFont(f);
1324 g.drawString("?Shift",LEFT,TOP+8); 1325 LEFT=lTemp+7;
1326 TOP=TOP+37;
1327 g.drawString("Ctrl",LEFT,TOP+8); 1328 LEFT=LEFT+55;
1329 g.drawString("Win",LEFT,TOP+8); 1330 LEFT=LEFT+46;
1331 g.drawString("Alt",LEFT,TOP+8); 1332 LEFT=LEFT+46;
1333 g.drawString("Space",LEFT+90,TOP+8); 1334 LEFT=LEFT+213;
1335 g.drawString("Alt",LEFT,TOP+8); 1336 LEFT=LEFT+46;
1337 g.drawString("Win",LEFT,TOP+8); 1338 LEFT=LEFT+50;
1339 g.drawString("SM",LEFT,TOP+8); 1340 LEFT=LEFT+44;
1341 g.drawString("Ctrl",LEFT,TOP+8); 1342 }
1343 }
1344
import java.awt.Dimension;1345
1346 import java.awt.Toolkit;
1347 import java.awt.event.ActionEvent; 1348 import java.awt.event.ActionListener; 1349 import javax.swing.*;
1350 import java.io.*;
1351 import java.util.*;
import Net.*;1352
1353
1354 public class LanConfig extends JDialog { 1355 private JPanel p1;
private JPanel p2;1356
1357 private ButtonGroup grp; 1358 private JRadioButton chatServer; 1359 private JButton btnBrowse; 1360 private JRadioButton testServer; 1361 private JButton btnCancel; 1362 private JButton btnOK;
private JPanel p3;1363
1364 private JTextField txtPort; 1365 private JLabel lblport;
1366 private JRadioButton testClient;
1367 private JLabel msg1; 1368 private JComboBox cmb; 1369 private JLabel lblTestTime; 1370 private JTextField textFile; 1371 private JLabel testText; 1372 private JTextField txtServerPort; 1373 private JLabel serverPort; 1374 private ButtonGroup grp2; 1375 private JTextField txtUserName; 1376 private JLabel userName; 1377 private JRadioButton chatClient; 1378 private JLabel localIP; 1379 private JTextField txtLineIP; 1380 private JLabel LineIP; 1381
1382 private String ChatUserName; 1383 private boolean ChatMode; 1384 private boolean TestMode; 1385 private int ServerPort; 1386 private int LinePort; 1387 private String netTestText; 1388 private int netTestTime;
private String IP;1389
1390
1391 /**
1392 * Auto-generated main method to display this JDialog
1393 */
1394 public LanConfig(){ 1395 readProperty();
initGUI();1396
1397 }
1398 private void readProperty(){ 1399 InputStream is = this.getClass().getResourceAsStream("Config.properties");
1400
1401 Properties properties = new Properties(); 1402 try {
1403 properties.load(is); 1404 is.close(); 1405 ChatMode = (Integer.parseInt(properties.getProperty("ChatMode"))==1) ?
1406 true:false;
ChatUserName = properties.getProperty("ChatUserName"); 1407
1408 TestMode = (Integer.parseInt(properties.getProperty("TestMode"))==1) ?
1409 true:false;
1410 ServerPort = Integer.parseInt(properties.getProperty("ServerPort"));
1411
1412 LinePort = Integer.parseInt(properties.getProperty("LinePort"));
1413
1414 netTestText = properties.getProperty("netTestText"); 1415 netTestTime = Integer.parseInt(properties.getProperty("netTestTime"));
1416
1417 IP=properties.getProperty("LineIP"); 1418 //System.out.println(ChatMode);
1419 }
1420 catch(IOException ex) {}
1421 }
1422
1423 private void writeProperties() {
1424 Properties prop = new Properties();
1425 try {
1426 InputStream fis = new FileInputStream("Config.properties"); 1427
1428 prop.load(fis);
1429
1430 OutputStream fos = new FileOutputStream("Config.properties");
1431
1432 prop.setProperty("ChatMode", (ChatMode==true)?"1":"0");
1433
1434 ChatUserName=txtUserName.getText(); 1435 prop.setProperty("ChatUserName", ChatUserName); 1436 prop.setProperty("TestMode", (TestMode==true)?"1":"0");
1437
1438 ServerPort=Integer.parseInt(txtServerPort.getText()); 1439 prop.setProperty("ServerPort", ServerPort+"");
LinePort=Integer.parseInt(txtPort.getText());1440 1441 prop.setProperty("LinePort", LinePort+""); 1442 netTestText=textFile.getText();
1443 prop.setProperty("netTestText", netTestText);
String time=(String)(cmb.getItemAt(cmb.getSelectedIndex()));1444
1445
1446 time=time.substring(0,time.length()-2); 1447 netTestTime=Integer.parseInt(time); 1448 prop.setProperty("netTestTime",netTestTime+""); 1449 IP=txtLineIP.getText();
1450 prop.setProperty("LineIP",IP);
prop.store(fos,"疯狂打字通v2.1");1451 1452
1453 }
1454 catch (IOException e){}
1455 prop.clear();
1456 prop.clone();
1457 }
1458
1459 private void initGUI() {
1460 Dimension screen=Toolkit.getDefaultToolkit().getScreenSize(); 1461 try {
1462 {
1463 getContentPane().setLayout(null); 1464 this.setTitle("\u7f51\u7edc\u914d\u7f6e"); 1465 setIconImage(Toolkit.getDefaultToolkit().getImage("image/f.gif"));
1466
1467 }
1468 {
1469 this.setSize(344, 315);
1470 setLocation((screen.width-getWidth())/2,(screen.height-getHeight())/2);
1471
1472 this.setVisible(true);
1473 {
1474 {
1475 grp = new ButtonGroup(); 1476 }
{1477
1478 grp2 = new ButtonGroup(); 1479 }
1480 p1 = new JPanel();
1481 getContentPane().add(p1); 1482 p1.setBorder(BorderFactory.createTitledBorder("网络聊天"));1483
p1.setBounds(0, 0, 336, 56);1484 1485 {
1486 userName = new JLabel(); 1487 p1.add(userName);
userName.setText("\u7f51\u7edc\u540d:");1488 1489 userName.setFont(new java.awt.Font("新宋体",0,12));1490
1491 }
1492 {
1493 txtUserName = new JTextField(); 1494 txtUserName.setText(ChatUserName);
p1.add(txtUserName);1495 1496 txtUserName.setPreferredSize(new java.awt.Dimension(87, 20));
1497
1498 }
1499 {
1500 chatServer = new JRadioButton(); 1501 grp.add(chatServer); 1502 p1.add(chatServer); 1503 chatServer.setText("\u670d\u52a1\u5668\u65b9\u5f0f");
1504
1505 chatServer.setFont(new java.awt.Font("新宋体", 0, 12));1506
1507 chatServer.addActionListener(new ActionListener() {
1508
1509 public void actionPerformed(ActionEvent evt) {
1510
1511 ChatMode=true; 1512 }
1513 });
1514 if(ChatMode==true){ 1515 chatServer.setSelected(true); 1516 }
1517 }
1518 {
1519 chatClient = new JRadioButton(); 1520 grp.add(chatClient);
p1.add(chatClient);1521 1522 chatClient.setText("\u5ba2\u6237\u673a\u65b9\u5f0f");
1523
1524 chatClient.setFont(new java.awt.Font("新宋体",0,12));1525
1526 chatClient.addActionListener(new ActionListener() {
1527
public void actionPerformed(ActionEvent evt) {1528
1529
1530 ChatMode=false; 1531 }
});1532
1533 if(ChatMode==false){ 1534 chatClient.setSelected(true); 1535 }
1536 }
1537 }
1538 {
p2 = new JPanel();1539
1540 p2.setLayout(null);
1541 getContentPane().add(p2);
1542 p2.setBorder(BorderFactory.createTitledBorder("网络测试"));1543
1544 p2.setBounds(0, 56, 336, 189); 1545 {
1546 testServer = new JRadioButton(); 1547 grp2.add(testServer); 1548 p2.add(testServer);
1549 testServer.setText("\u670d\u52a1\u5668\u65b9\u5f0f");
1550
1551 testServer.setFont(new java.awt.Font("新宋体",0,12));1552
1553 testServer.setBounds(7, 21, 112, 21); 1554 testServer.addActionListener(new ActionListener() {
1555
1556 public void actionPerformed(ActionEvent evt) {
1557
1558 txtServerPort.setEnabled(true); 1559 textFile.setEnabled(true); 1560 btnBrowse.setEnabled(true); 1561 cmb.setEnabled(true); 1562 txtPort.setEnabled(false); 1563 txtLineIP.setEnabled(false); 1564 TestMode=true;
}1565
1566 });
1567 if(TestMode==true){ 1568 testServer.setSelected(true); 1569 }
1570 }
1571 {
serverPort = new JLabel();1572 1573 p2.add(serverPort);
1574 serverPort.setText("\u670d\u52a1\u5668\u7aef\u53e3:");
1575
serverPort.setFont(new java.awt.Font("新宋体", 0, 12));1576
1577
1578 serverPort.setBounds(24, 49, 70, 14); 1579 }
1580 {
1581 txtServerPort = new JTextField(); 1582 p2.add(txtServerPort);
txtServerPort.setBounds(91, 46, 91, 21);1583 1584 txtServerPort.setText(ServerPort+""); 1585 if(TestMode==false){
1586 txtServerPort.setEnabled(false);1587 }
1588 }
1589 {
1590 testText = new JLabel(); 1591 p2.add(testText);
1592 testText.setText("\u6d4b \u8bd5\u6587 \u672c:");
1593
1594 testText.setBounds(24, 80, 70, 14); 1595 testText.setFont(new java.awt.Font("新宋体",0,12));1596
1597 }
1598 {
1599 textFile = new JTextField(); 1600 p2.add(textFile);
1601 textFile.setBounds(91, 77, 203, 21); 1602 textFile.setText(netTestText); 1603 if(TestMode==false){ 1604 textFile.setEnabled(false); 1605 }
1606 }
1607 {
1608 btnBrowse = new JButton();
p2.add(btnBrowse);1609 1610 btnBrowse.setText("..."); 1611 btnBrowse.setBounds(297, 77, 28, 20); 1612 btnBrowse.setFont(new java.awt.Font("新宋体",0,11));1613
1614 if(TestMode==false){ 1615 btnBrowse.setEnabled(false);
}1616
1617 }
1618 {
1619 lblTestTime = new JLabel();
p2.add(lblTestTime);1620 1621 lblTestTime.setText("\u6d4b \u8bd5\u65f6 \u95f4:");
1622
1623 lblTestTime.setBounds(24, 110, 70, 14); 1624 lblTestTime.setFont(new java.awt.Font("新宋体",0,12));1625
1626 }
{1627
1628 ComboBoxModel cmbModel = new DefaultComboBoxModel();
1629
1630 cmb = new JComboBox();
1631 p2.add(cmb);
1632 cmb.setModel(cmbModel); 1633 cmb.setBounds(91, 107, 203, 21); 1634 cmb.setFont(new java.awt.Font("新宋体",0,12));1635
1636 cmb.addItem(netTestTime+"分钟"); 1637 cmb.setEditable(false); 1638 if(TestMode==false){ 1639 cmb.setEnabled(false); 1640 }
1641 cmb.addItem("1分钟"); 1642 for(int i=5;i<=60;i=i+5){ 1643 cmb.addItem(i+"分钟"); 1644 }
1645 }
1646 {
1647 msg1 = new JLabel(); 1648 p2.add(msg1);
1649 msg1.setText("(\u5927\u4e8e0\u4e14\u5c0f\u4e8e65535)");
1650
1651 msg1.setBounds(182, 42, 119, 28); 1652 msg1.setFont(new java.awt.Font("新宋体",0,12));1653
1654 }
1655 {
1656 testClient = new JRadioButton(); 1657 grp2.add(testClient); 1658 p2.add(testClient);
1659 testClient.setText("\u5ba2\u6237\u673a\u65b9\u5f0f");
1660
1661 testClient.setFont(new java.awt.Font("新宋体",0,12));1662
1663 testClient.setBounds(7, 133, 91, 21);
testClient.addActionListener(new ActionListener() {1664
1665
1666 public void actionPerformed(ActionEvent evt) {
1667
1668 txtServerPort.setEnabled(false); 1669 textFile.setEnabled(false); 1670 btnBrowse.setEnabled(false);
cmb.setEnabled(false);1671 1672 txtPort.setEnabled(true); 1673 txtLineIP.setEnabled(true);
1674 TestMode=false;
1675 }
1676 });
1677 if(TestMode==false){ 1678 testClient.setSelected(true); 1679 }
1680 }
1681 {
1682 lblport = new JLabel(); 1683 p2.add(lblport); 1684 lblport.setText("\u8fde \u63a5\u7aef \u53e3:"); 1685 lblport.setFont(new java.awt.Font("新宋体",0,12));1686
1687 lblport.setBounds(24, 161, 70, 14); 1688 }
1689 {
1690 txtPort = new JTextField(); 1691 p2.add(txtPort); 1692 txtPort.setBounds(91, 158, 56, 21); 1693 txtPort.setText(LinePort+""); 1694 if(TestMode==true){ 1695 txtPort.setEnabled(false); 1696 }
}1697
1698 {
1699 LineIP = new JLabel(); 1700 p2.add(LineIP); 1701 LineIP.setText("\u8fde\u63a5IP:"); 1702 LineIP.setBounds(154, 162, 49, 14); 1703 LineIP.setFont(new java.awt.Font("新宋体",0,12));1704
1705 }
1706 {
1707 txtLineIP = new JTextField();
p2.add(txtLineIP);1708 1709 txtLineIP.setBounds(196, 159, 98, 21); 1710 txtLineIP.setText(IP); 1711 if(TestMode==true){ 1712 txtLineIP.setEnabled(false); 1713 }
1714 }
{1715
1716 localIP = new JLabel(); 1717 p2.add(localIP);
1718 localIP.setBounds(185, 21, 147, 21);1719 localIP.setFont(new java.awt.Font("新宋体",0,12));1720
1721 localIP.setText("本机IP:"+NetTools.getIP()); 1722 }
1723 }
1724 {
1725 p3 = new JPanel();
1726 getContentPane().add(p3);
1727 p3.setLayout(null);
1728 p3.setBounds(0, 245, 336, 35); 1729 {
1730 btnOK = new JButton(); 1731 p3.add(btnOK);
1732 btnOK.setText("\u786e\u5b9a"); 1733 btnOK.setBounds(189, 6, 63, 21); 1734 btnOK.setFont(new java.awt.Font("新宋体",0,12));1735
1736 btnOK.addActionListener(new ActionListener() {
1737
1738 public void actionPerformed(ActionEvent evt) {
1739
1740 writeProperties();
}1741
1742 });
1743 }
1744 {
1745 btnCancel = new JButton(); 1746 p3.add(btnCancel);
1747 btnCancel.setText("\u53d6\u6d88");
btnCancel.setBounds(266, 6, 63, 21);1748 1749 btnCancel.setFont(new java.awt.Font("新宋体",0,12));1750
1751 btnCancel.addActionListener(new ActionListener() {
1752
1753 public void actionPerformed(ActionEvent evt) {
1754
1755 }
1756 });
1757 }
1758 }
}1759
1760 } catch (Exception e) {
1761 e.printStackTrace();
1762 }
1763
1764 }
1765
1766 }
1767
1768 import java.awt.BorderLayout; 1769 import java.awt.Container; 1770 import java.awt.GridBagConstraints; 1771 import java.awt.GridBagLayout; 1772 import java.awt.Insets; 1773 import java.awt.event.ActionEvent; 1774 import java.awt.event.ActionListener; 1775 import java.io.IOException; 1776 import java.io.InputStream; 1777 import java.util.Properties; 1778
1779 import javax.swing.JInternalFrame; 1780 import javax.swing.*; 1781 import javax.swing.table.*; 1782
1783 import java.net.*;
1784 import java.io.*;
1785
1786
1787 public class LanManage extends JInternalFrame{
1788
1789
1790 JTable table = null; 1791 DefaultTableModel defaultModel = null;
private JLabel userCount;1792 1793 private JButton btnCelean; 1794 private JButton saveData; 1795 private JButton beginTest;
private JLabel conUser;1796 1797 private JTextField hintMessage; 1798 private JLabel hint; 1799 private JComboBox time; 1800 private JLabel testTime; 1801 private JButton TextBrowse; 1802 private JTextField txtText;
private JLabel testText;1803 1804 private JPanel p; 1805 JScrollPane s;
1806
1807 //配置属性
1808 private int ServerPort; 1809 private int LinePort; 1810 private String netTestText; 1811 private int netTestTime; 1812
1813 //网络属性
1814 ServerSocket server; 1815 Socket client;
1816 BufferedReader in; 1817 PrintWriter out; 1818
1819 //用户信息
1820 private String estate; 1821 private String userName; 1822 private String ime; 1823 private String remark; 1824 private String clientIP; 1825 private String clientName; 1826 private int countWord; 1827 private int rightWord; 1828 private int errorWord;
private double mWord;1829 1830
1831 private int a=0;
1832
1833 private void startServer(){//启动服务器 1834 try{
1835 server=new ServerSocket(ServerPort);
}catch(IOException e){}1836 1837 }
1838
1839
1840
private void readProperty(){//读取配置文件1841
1842 InputStream is = this.getClass().getResourceAsStream("Config.properties");
1843
1844 Properties properties = new Properties();
1845 try {
1846 properties.load(is);
is.close();1847 1848 ServerPort = Integer.parseInt(properties.getProperty("ServerPort"));
1849
1850 LinePort = Integer.parseInt(properties.getProperty("LinePort"));
1851
1852 netTestText = properties.getProperty("netTestText"); 1853 netTestTime = Integer.parseInt(properties.getProperty("netTestTime"));
1854
1855 }
1856 catch(IOException ex) {}
1857 }
1858
1859 public LanManage(){//组件用户界面
1860 readProperty();
1861 String[] name={"状态","用户","输入法","备注","IP","主机名","总字数","正确","错1862 误","每分钟"};
1863 defaultModel=new DefaultTableModel(new Object[0][0],name); 1864 table=new JTable(defaultModel);
1865
1866 JScrollPane s = new JScrollPane(table);
1867
1868 p=new JPanel();
1869 GridBagLayout pLayout = new GridBagLayout(); 1870 pLayout.rowWeights = new double[] {0.0, 0.1, 0.1, 0.1, 0.1}; 1871 pLayout.rowHeights = new int[] {13, 7, 7, 7, 7}; 1872 pLayout.columnWeights = new double[] {0.0, 0.1, 0.1, 0.1, 0.1, 0.1};
1873
1874 pLayout.columnWidths = new int[] {55, 20, 7, 7, 7, 7}; 1875 p.setLayout(pLayout);
1876 Container contentPane = this.getContentPane(); 1877 contentPane.add(s, BorderLayout.CENTER); 1878 p.setPreferredSize(new java.awt.Dimension(657, 100)); 1879 p.setBorder(BorderFactory.createTitledBorder(""));
contentPane.add(p,BorderLayout.SOUTH);1880 1881 {
1882 testText = new JLabel();
1883 p.add(testText, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));1884
1885
1886 testText.setText("\u6d4b\u8bd5\u6587\u672c:"); 1887 testText.setFont(new java.awt.Font("新宋体",0,12)); 1888 }
1889 {
1890 txtText = new JTextField();
1891 p.add(txtText, new GridBagConstraints(1, 0, 3, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));1892
1893
1894 txtText.setEditable(false);
1895 txtText.setText(netTestText);
1896
1897 }
1898 {
1899 TextBrowse = new JButton();
1900 p.add(TextBrowse, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, 1901 GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
1902
1903 TextBrowse.setText("...");
1904 TextBrowse.setFont(new java.awt.Font("新宋体",0,12));
1905 }
1906 {
1907 testTime = new JLabel();
1908 p.add(testTime, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, 1909 GridBagConstraints.NORTHEAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0,
1910 0));
1911 testTime.setText("\u6d4b\u8bd5\u65f6\u95f4:");
1912 testTime.setFont(new java.awt.Font("新宋体",0,12));
1913 }
1914 {
1915 ComboBoxModel timeModel = new DefaultComboBoxModel();1916
time = new JComboBox();1917
1918 p.add(time, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, 1919 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
1920
1921 time.setModel(timeModel);
1922 time.setFont(new java.awt.Font("新宋体",0,12));
1923 time.addItem(netTestTime+"分钟");
time.addItem("1分钟");1924
1925 for(int i=5;i<=60;i=i+5){
1926 time.addItem(i+"分钟");
1927 }
}1928
1929 {
1930 hint = new JLabel();
1931 p.add(hint, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 1932 GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
1933
1934 hint.setText("\u63d0\u793a\u4fe1\u606f:");
hint.setFont(new java.awt.Font("新宋体",0,12));1935
1936 }
1937 {
1938 hintMessage = new JTextField();
1939 p.add(hintMessage, new GridBagConstraints(1, 2, 5, 1, 0.0, 0.0, 1940 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
1941
1942 }
1943 {
1944 conUser = new JLabel();
1945 p.add(conUser, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0, 1946 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
1947
1948 conUser.setText("\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684\u7528\u6237:");1949
1950 conUser.setFont(new java.awt.Font("新宋体",0,12));
1951 }
1952 {
1953 userCount = new JLabel();
1954 p.add(userCount, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, 1955 GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
1956
1957 userCount.setText("0");
1958 userCount.setFont(new java.awt.Font("新宋体",0,12));
1959 }
1960 {
beginTest = new JButton();1961
1962 p.add(beginTest, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, 1963 GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
1964
1965 beginTest.setText("\u5f00\u59cb\u6d4b\u8bd5");
1966 beginTest.setFont(new java.awt.Font("新宋体",0,12));
1967 }
{1968
1969 saveData = new JButton();
1970 p.add(saveData, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, 1971 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
1972
1973 saveData.setText("\u5b58\u50a8\u6d4b\u8bd5\u7ed3\u679c");1974
1975 saveData.setFont(new java.awt.Font("新宋体",0,12));
1976 }
1977 {
1978 btnCelean = new JButton();
1979 p.add(btnCelean, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0,
GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));1980
1981
1982 btnCelean.setText("\u5173\u95ed");1983 btnCelean.setFont(new java.awt.Font("新宋体",0,12)); 1984 btnCelean.addActionListener(new ActionListener() { 1985 public void actionPerformed(ActionEvent evt) { 1986 exit();
1987 }
1988 });
1989 }
1990
1991 setLayer(4);
1992 setBounds(142,0,0,0);
1993 this.setPreferredSize(new java.awt.Dimension(657, 549));//内部窗体大小1994
1995 ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
1996
1997 this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
1998
1999 this.setVisible(true);
2000 this.pack();
2001 startServer();
2002 }
2003
2004 private void exit(){
this.doDefaultCloseAction();2005
2006 PublicData.onChoice=true;
2007 }
2008
2009 }
2010
2011 import java.awt.*;
import javax.swing.*;2012
2013
2014 public class LoginGraphics extends JPanel{
2015 public void paint(Graphics g){
paintComponent(g);2016
2017
2018 g.setFont(new Font("x",Font.BOLD+Font.ITALIC,20)); 2019 g.setColor(new Color(255,255,255)); 2020 g.drawString("FTYPED",22,32);
2021 g.setColor(new Color(0,0,0));
2022 g.drawString("FTYPED",20,30);
2023
g.setFont(new Font("Dialog",Font.BOLD+Font.ITALIC,45));2024 2025 for(int i=1;i<=5;i++){
2026 g.setColor(new Color(255-(i*50),255-(i*50),255-(i*50)));
2027 g.drawLine(0,36+i,293,36+i); 2028 }
2029
2030 g.setColor(new Color(255,255,255)); 2031 g.drawString("疯狂打字通",62,85); 2032 g.setColor(new Color(0,0,0));
2033 g.drawString("疯狂打字通",60,85); 2034
2035 g.setFont(new Font("x",Font.BOLD,14)); 2036 g.drawString("v2.1",300,90);
2037
2038 g.setFont(new Font("x",Font.PLAIN,12)); 2039 g.setColor(new Color(255,255,255)); 2040 g.drawString("激发你手指的灵感",341,91); 2041 g.setColor(new Color(0,0,0));
2042 g.drawString("激发你手指的灵感",340,90); 2043
2044
2045 for(int i=1;i<=5;i++){
2046 g.setColor(new Color(255-(i*50),255-(i*50),255-(i*50))); 2047 g.drawLine(60,100-i,443,100-i); 2048 }
2049
g.setFont(new Font("x",Font.PLAIN,12));2050 2051 g.setColor(new Color(255,255,255)); 2052 g.drawString("FTYPED工作组版权所有",311,151); 2053 g.drawString("FTYPED工作组成员:熊占洲、廖阳、张浩佳、杨智、李文彪、张佳2054 伟",61,115);
2055 g.drawString("(2007.3.15-2007.4.26)",321,133);
g.drawString("开发工具 Java 编辑工具 Eclipse",61,151);2056 2057 g.setColor(new Color(0,0,0));
2058 g.drawString("FTYPED工作组版权所有",310,150); 2059 g.drawString("FTYPED工作组成员:熊占洲、廖阳、张浩佳、杨智、李文彪、张佳
伟",60,114);2060
2061 g.drawString("(2007.3.15-2007.4.26)",320,132); 2062 g.drawString("开发工具 Java 编辑工具 Eclipse",60,150); 2063 }
2064 }
2065
2066 import java.awt.*;
import java.awt.event.ActionEvent;2067
2068 import java.awt.event.ActionListener;
2069
2070 import javax.swing.*;2071
2072 import Net.NetTools;
2073
2074 public class MainFrame extends JDesktopPane implements ActionListener{
2075
2076 Dimension screen;
2077 Toolkit toolkit=Toolkit.getDefaultToolkit(); 2078 private JMenuBar fMenu; 2079 private JMenu fMenuSys; 2080 private JMenu fMenuLx; 2081 private JMenuItem fMenuS; 2082 private JMenu fMenuChat; 2083 private JMenuItem fMenuLocal; 2084 private JMenuItem fMenuLAN; 2085 private JMenu fMenuHelp; 2086 private JMenuItem fMenuSoft; 2087 private JMenuItem fMenuAbout; 2088 private JMenuItem fMenuShortcutKey; 2089 private JMenuItem fMenuStudy; 2090 private JMenuItem fMenuNet; 2091 private JMenuItem fMenuCollocateLocal; 2092 private JMenu fMenuCollocate;
private JMenuItem fMenuGameWord;2093 2094 private JMenuItem fMenuGameKey; 2095 private JMenu fMenuGame; 2096 private JMenuItem fMenuC; 2097 private JMenu fMenuTest; 2098 private JMenuItem fMenuArticle; 2099 private JMenuItem fMenuCode;
private JMenuItem fMenuEtymon;2100 2101 private JMenuItem fMenuKey; 2102 private JMenuItem fMenuExit; 2103 private JMenuItem fMenuShowPort;
private JMenuItem fMenuBM;2104 2105 private Icon ico;
2106
2107 JFrame frame;
2108 Tool tool;
2109 public MainFrame(){
2110 JFrame.setDefaultLookAndFeelDecorated(true);
frame = new JFrame(); 2111 2112 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
2113 Container container = frame.getContentPane();
2114 container.add(this, BorderLayout.CENTER);
2115 this.setPreferredSize(new java.awt.Dimension(800, 550)); 2116 frame.setTitle("疯狂打字通v2.1");
2117 Image ico=Toolkit.getDefaultToolkit().getImage("Image/f.gif"); 2118 frame.setIconImage(ico);
2119 frame.setResizable(false);
2120 screen=toolkit.getScreenSize();
2121 frame.setLocation((screen.width-800)/2,screen.height/2-600/2);//窗口定位2122
2123 //添加菜单
2124 fMenu = new JMenuBar();
2125 frame.setJMenuBar(fMenu);
2126 fMenu.setPreferredSize(new java.awt.Dimension(392, 23)); 2127 {
2128 fMenuSys = new JMenu();
2129 fMenu.add(fMenuSys);
2130 fMenuSys.setText("系统(S)");
2131 fMenuSys.setFont(new Font("x",Font.PLAIN,12)); 2132 fMenuSys.setMnemonic(java.awt.event.KeyEvent.VK_S); 2133 fMenuSys.setRolloverEnabled(true); 2134 {
2135 fMenuExit = new JMenuItem(); 2136 fMenuSys.add(fMenuExit);
fMenuExit.setText("退出");2137
2138 fMenuExit.addActionListener(this); 2139 fMenuExit.setFont(new Font("x",Font.PLAIN,12)); 2140 fMenuExit.setIcon(new
2141 ImageIcon(getClass().getClassLoader().getResource("Image/leave.gif"))); 2142 }
2143 }
{2144
2145 fMenuLx = new JMenu();
2146 fMenu.add(fMenuLx);
2147 fMenuLx.setText("练习(E)");
fMenuLx.setFont(new Font("x",Font.PLAIN,12));2148 2149 fMenuLx.setMnemonic(java.awt.event.KeyEvent.VK_E); 2150 fMenuLx.setRolloverEnabled(true); 2151 {
2152 fMenuKey = new JMenuItem(); 2153 fMenuLx.add(fMenuKey);
2154 fMenuKey.setText("键盘练习");
fMenuKey.addActionListener(this);2155 2156 fMenuKey.setFont(new Font("x",Font.PLAIN,12)); 2157 fMenuKey.setIcon(new
2158 ImageIcon(getClass().getClassLoader().getResource("Image/lx_1.gif")));
2159 }
2160 {
2161 fMenuEtymon = new JMenuItem(); 2162 fMenuLx.add(fMenuEtymon);
2163 fMenuEtymon.setText("字根练习"); 2164 fMenuEtymon.addActionListener(this); 2165 fMenuEtymon.setFont(new Font("x",Font.PLAIN,12)); 2166 fMenuEtymon.setIcon(new
2167 ImageIcon(getClass().getClassLoader().getResource("Image/lx_2.gif"))); 2168 }
2169 {
2170 fMenuCode = new JMenuItem(); 2171 fMenuLx.add(fMenuCode);
2172 fMenuCode.setText("简码练习"); 2173 fMenuCode.addActionListener(this); 2174 fMenuCode.setFont(new Font("x",Font.PLAIN,12)); 2175 fMenuCode.setIcon(new
2176 ImageIcon(getClass().getClassLoader().getResource("Image/lx_3.gif"))); 2177 }
2178 {
2179 fMenuArticle = new JMenuItem(); 2180 fMenuLx.add(fMenuArticle);
fMenuArticle.setText("文章练习");2181 2182 fMenuArticle.addActionListener(this); 2183 fMenuArticle.setFont(new Font("x",Font.PLAIN,12)); 2184 fMenuArticle.setIcon(new
2185 ImageIcon(getClass().getClassLoader().getResource("Image/lx_4.gif"))); 2186 }
2187 }
{2188
2189 fMenuTest = new JMenu();
2190 fMenu.add(fMenuTest);
2191 fMenuTest.setText("测试(T)");
fMenuTest.setFont(new Font("x",Font.PLAIN,12));2192 2193 fMenuTest.setMnemonic(java.awt.event.KeyEvent.VK_T); 2194 fMenuTest.setRolloverEnabled(true); 2195 {
2196 fMenuLAN = new JMenuItem(); 2197 fMenuTest.add(fMenuLAN);
2198 fMenuLAN.setText("LAN测试");
fMenuLAN.addActionListener(this);2199 2200 fMenuLAN.setFont(new Font("x",Font.PLAIN,12)); 2201 fMenuLAN.setIcon(new
2202 ImageIcon(getClass().getClassLoader().getResource("Image/LAN.gif"))); 2203 }
2204 {
2205 fMenuLocal = new JMenuItem(); 2206 fMenuTest.add(fMenuLocal); 2207 fMenuLocal.setText("本地测试"); 2208 fMenuLocal.addActionListener(this); 2209 fMenuLocal.setFont(new Font("x",Font.PLAIN,12)); 2210 fMenuLocal.setIcon(new
2211 ImageIcon(getClass().getClassLoader().getResource("Image/Local.gif"))); 2212 }
2213 }
2214 {
2215 fMenuChat = new JMenu();
2216 fMenu.add(fMenuChat);
2217 fMenuChat.setText("聊天(L)");
2218 fMenuChat.setFont(new Font("x",Font.PLAIN,12)); 2219 fMenuChat.setMnemonic(java.awt.event.KeyEvent.VK_L); 2220 fMenuChat.setRolloverEnabled(true); 2221 {
2222 fMenuS = new JMenuItem(); 2223 fMenuChat.add(fMenuS);
2224 fMenuS.setText("服务器方式");
fMenuS.addActionListener(this);2225 2226 fMenuS.setFont(new Font("x",Font.PLAIN,12)); 2227 fMenuS.setIcon(new
2228 ImageIcon(getClass().getClassLoader().getResource("Image/pin_1.gif"))); 2229 }
2230 {
2231 fMenuC = new JMenuItem();
fMenuChat.add(fMenuC);2232
2233 fMenuC.setText("客户端方式"); 2234 fMenuC.addActionListener(this); 2235 fMenuC.setFont(new Font("x",Font.PLAIN,12)); 2236 fMenuC.setIcon(new
ImageIcon(getClass().getClassLoader().getResource("Image/pin_2.gif")));2237 2238 }
2239 {
2240 fMenuShowPort = new JMenuItem(); 2241 fMenuChat.add(fMenuShowPort); 2242 fMenuShowPort.setText("示显网络属性");
fMenuShowPort.addActionListener(this);2243 2244 fMenuShowPort.setFont(new Font("x",Font.PLAIN,12));
2245
2246 fMenuShowPort.setIcon(new 2247 ImageIcon(getClass().getClassLoader().getResource("Image/pin_3.gif"))); 2248 }
2249 }
2250 {
2251 fMenuGame = new JMenu();
2252 fMenu.add(fMenuGame);
2253 fMenuGame.setText("游戏(G)");
2254 fMenuGame.setFont(new Font("x",Font.PLAIN,12)); 2255 fMenuGame.setMnemonic(java.awt.event.KeyEvent.VK_G); 2256 fMenuGame.setRolloverEnabled(true); 2257 {
2258 fMenuGameKey = new JMenuItem(); 2259 fMenuGame.add(fMenuGameKey); 2260 fMenuGameKey.setText("字符空降兵"); 2261 fMenuGameKey.addActionListener(this); 2262 fMenuGameKey.setFont(new Font("x",Font.PLAIN,12));
2263
2264 fMenuGameKey.setIcon(new
2265 ImageIcon(getClass().getClassLoader().getResource("Image/game.gif"))); 2266 }
2267 {
2268 fMenuGameWord = new JMenuItem();
fMenuGame.add(fMenuGameWord);2269 2270 fMenuGameWord.setText("汉字护卫艇"); 2271 fMenuGameWord.addActionListener(this); 2272 fMenuGameWord.setFont(new Font("x",Font.PLAIN,12));
2273
2274 fMenuGameWord.setIcon(new 2275 ImageIcon(getClass().getClassLoader().getResource("Image/game.gif")));
}2276
2277 }
2278 {
2279 fMenuCollocate = new JMenu();
fMenu.add(fMenuCollocate);2280
2281 fMenuCollocate.setText("配置(C)"); 2282 fMenuCollocate.setFont(new Font("x",Font.PLAIN,12)); 2283 fMenuCollocate.setMnemonic(java.awt.event.KeyEvent.VK_C);
2284
2285 fMenuCollocate.setRolloverEnabled(true); 2286 {
fMenuCollocateLocal = new JMenuItem();2287 2288 fMenuCollocate.add(fMenuCollocateLocal); 2289 fMenuCollocateLocal.setText("本地");
2290 fMenuCollocateLocal.addActionListener(this);
2291 fMenuCollocateLocal.setFont(new Font("x",Font.PLAIN,12));
2292
2293 fMenuCollocateLocal.setIcon(new 2294 ImageIcon(getClass().getClassLoader().getResource("Image/s_1.gif"))); 2295 }
2296 {
2297 fMenuNet = new JMenuItem(); 2298 fMenuCollocate.add(fMenuNet); 2299 fMenuNet.setText("网络");
2300 fMenuNet.addActionListener(this); 2301 fMenuNet.setFont(new Font("x",Font.PLAIN,12)); 2302 fMenuNet.setIcon(new
2303 ImageIcon(getClass().getClassLoader().getResource("Image/s_2.gif"))); 2304 }
2305 }
2306 {
2307 fMenuHelp = new JMenu();
2308 fMenu.add(fMenuHelp);
2309 fMenuHelp.setText("帮助(H)");
2310 fMenuHelp.setFont(new Font("x",Font.PLAIN,12)); 2311 fMenuHelp.setMnemonic(java.awt.event.KeyEvent.VK_H); 2312 fMenuHelp.setRolloverEnabled(true);
{2313
2314 fMenuBM = new JMenuItem(); 2315 fMenuHelp.add(fMenuBM);
2316 fMenuBM.setText("编码查询"); 2317 fMenuBM.addActionListener(this); 2318 fMenuBM.setFont(new Font("x",Font.PLAIN,12)); 2319 fMenuBM.setIcon(new
ImageIcon(getClass().getClassLoader().getResource("Image/q.gif")));2320 2321 }
2322 {
2323 fMenuStudy = new JMenuItem();
fMenuHelp.add(fMenuStudy);2324
2325 fMenuStudy.setText("学习");
2326 fMenuStudy.addActionListener(this); 2327 fMenuStudy.setFont(new Font("x",Font.PLAIN,12)); 2328 fMenuStudy.setIcon(new
2329 ImageIcon(getClass().getClassLoader().getResource("Image/xx.gif"))); 2330 }
{2331
2332 fMenuSoft = new JMenuItem(); 2333 fMenuHelp.add(fMenuSoft);
2334 fMenuSoft.setText("帮助");
2335 fMenuSoft.addActionListener(this); 2336 fMenuSoft.setFont(new Font("x",Font.PLAIN,12)); 2337 fMenuSoft.setIcon(new
2338 ImageIcon(getClass().getClassLoader().getResource("Image/h.gif"))); 2339 }
2340 {
2341 fMenuShortcutKey = new JMenuItem(); 2342 fMenuHelp.add(fMenuShortcutKey); 2343 fMenuShortcutKey.setText("快捷键"); 2344 fMenuShortcutKey.addActionListener(this); 2345 fMenuShortcutKey.setFont(new Font("x",Font.PLAIN,12));
2346
2347 fMenuShortcutKey.setIcon(new 2348 ImageIcon(getClass().getClassLoader().getResource("Image/key.gif"))); 2349 }
2350 {
2351 fMenuAbout = new JMenuItem(); 2352 fMenuHelp.add(fMenuAbout); 2353 fMenuAbout.setText("关于我们"); 2354 fMenuAbout.addActionListener(this); 2355 fMenuAbout.setFont(new Font("x",Font.PLAIN,12)); 2356 fMenuAbout.setIcon(new
ImageIcon(getClass().getClassLoader().getResource("Image/about.gif")));2357 2358 }
2359 }
2360
2361 //添加工具条.
2362 tool=new Tool(this);
2363 this.add(tool,1);
//添加聊天工具条2364
2365 Chat chat=new Chat(this);
2366 this.add(chat,2);
2367
frame.pack(); 2368
2369 frame.setVisible(true);
2370 }
2371 // 实现ActionListener接口的方法
2372 public void actionPerformed(ActionEvent e){ 2373 if(PublicData.onChoice==true){
2374 if(e.getSource()==fMenuExit){ 2375 int i=JOptionPane.showConfirmDialog(this,"你真的要退出吗?","疯狂打字
",2376
2377
2378 JOptionPane.YES_OPTION,JOptionPane.QUESTION_MESSAGE);
2379 if(i==0){
2380 System.exit(0); 2381 }
2382 }
2383 if(e.getSource()==fMenuKey){ 2384 PublicData.onChoice=false; 2385 PublicData.Lang="English"; 2386 PublicData.Text="Text/English_"+(int)(Math.random()*5+1)+".txt";
2387
2388 PublicData.choice=1; 2389 showFrame(); 2390 }
2391 if(e.getSource()==fMenuEtymon){ 2392 PublicData.onChoice=false; 2393 PublicData.Lang="Chinese"; 2394 PublicData.choice=2; 2395 showFrame(); 2396 }
2397 if(e.getSource()==fMenuCode){ 2398 PublicData.onChoice=false; 2399 PublicData.Lang="Chinese"; 2400 PublicData.Text="Text/TwoCode.txt";
PublicData.choice=3;2401 2402 showFrame(); 2403 }
2404 if(e.getSource()==fMenuArticle){ 2405 PublicData.onChoice=false; 2406 PublicData.Lang="Chinese"; 2407 PublicData.Text="Text/Chinese_"+(int)(Math.random()*5+1)+".txt";
2408
2409 PublicData.choice=3; 2410 showFrame(); 2411 }
if(e.getSource()==fMenuLAN){2412 2413
2414 }
2415 if(e.getSource()==fMenuLocal){ 2416 PublicData.onChoice=false; 2417 PublicData.Lang="Chinese"; 2418 PublicData.Text="Text/Chinese_"+(int)(Math.random()*5+1)+".txt";
2419
2420 PublicData.choice=3; 2421 showFrame();
2422 }
2423 if(e.getSource()==fMenuS){ 2424
2425 }
2426 if(e.getSource()==fMenuC){ 2427
2428 }
2429 if(e.getSource()==fMenuShowPort){ 2430 JOptionPane.showConfirmDialog(this,"本机IP:"+NetTools.getIP()+"\n主机
2431 名:"+
2432 NetTools.getName()+"\n聊天端口2433 号:"+(NetTools.getIpSect()+55555),"疯狂打字", 2434
2435 JOptionPane.YES_OPTION,JOptionPane.INFORMATION_MESSAGE);
2436
2437 }
2438 if(e.getSource()==fMenuGameKey){ 2439
2440 }
2441 if(e.getSource()==fMenuGameWord){ 2442
2443 }
2444 if(e.getSource()==fMenuCollocateLocal){ 2445
}2446
2447 if(e.getSource()==fMenuNet){ 2448 new LanConfig(); 2449 }
2450 if(e.getSource()==fMenuBM){ 2451 PublicData.onChoice=false;
QueryCoding coding=new QueryCoding();2452 2453 this.add(coding,6); 2454 }
2455 if(e.getSource()==fMenuStudy){ 2456
}2457
2458 if(e.getSource()==fMenuSoft){ 2459
2460 }
2461 if(e.getSource()==fMenuShortcutKey){ 2462
}2463
2464 if(e.getSource()==fMenuAbout){ 2465
2466 }
2467 }
2468 }
2469 private void showFrame(){ 2470 Hint hint =new Hint(tool); 2471 this.add(hint,2);
2472 }
2473 }
2474
2475 public class PublicData { 2476 public static int choice=0; 2477 public static boolean onChoice=true; 2478 public static String key=" "; 2479 public static int textTag=1; 2480 public static String Lang; 2481 public static String Text; 2482 public static String SplitMapName="null.gif";
2483 }
2484 import java.awt.event.ActionEvent; 2485 import java.awt.event.ActionListener; 2486 import java.awt.event.KeyListener; 2487 import java.awt.event.KeyEvent; 2488 import java.io.*;
import javax.swing.*;2489
2490
2491 public class QueryCoding extends JInternalFrame{ 2492 private JTextField txtWord; 2493 private JButton btnExit; 2494 private JButton btnHelp; 2495 private JPanel p2;
private JTextField txtCode2;2496 2497 private JLabel lbl2;
2498 private JTextField txtCode1; 2499 private JLabel lbl1;
private JPanel p1;2500
2501 private JButton btnQuery; 2502 private JLabel lblQword; 2503 public QueryCoding(){ 2504 setLayer(5);
2505 ///setBounds(142,326,0,0); 2506 this.setPreferredSize(new java.awt.Dimension(231, 203));
//((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);2507
2508
2509 this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
2510
2511 this.setVisible(true);2512 getContentPane().setLayout(null); 2513 this.setBounds((800-231)/2+140/2, (550-203)/2, 231, 203); 2514 {
2515 txtWord = new JTextField(); 2516 getContentPane().add(txtWord); 2517 txtWord.setBounds(85, 5, 28, 21); 2518 txtWord.addKeyListener(new KeyListener() { 2519 public void keyPressed(KeyEvent e) {} 2520 public void keyReleased(KeyEvent e){} 2521 public void keyTyped(KeyEvent e){ 2522 if(txtWord.getText().length()!=0 &&
2523 e.getKeyChar()==java.awt.event.KeyEvent.VK_ENTER){ 2524 queryWord(); 2525 }
2526 }
2527 });
2528 }
2529 {
2530 lblQword = new JLabel();
2531 getContentPane().add(lblQword); 2532 lblQword.setText("查询的汉字:"); 2533 lblQword.setBounds(11, 10, 77, 14);
lblQword.setFont(new java.awt.Font("新宋体",0,12));2534 2535 }
2536 {
2537 btnQuery = new JButton(); 2538 getContentPane().add(btnQuery); 2539 btnQuery.setText("查询=回车"); 2540 btnQuery.setBounds(122, 5, 98, 21);
btnQuery.setMnemonic(java.awt.event.KeyEvent.VK_ENTER);2541
2542
2543 btnQuery.setFont(new java.awt.Font("新宋体",0,12)); 2544 btnQuery.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {2545 2546 if(txtWord.getText().length()!=0){ 2547 queryWord(); 2548 txtWord.setFocusable(true); 2549 }
2550 }
2551 });
}2552
2553 {
2554 p1 = new JPanel();
2555 getContentPane().add(p1);2556 p1.setBounds(10, 33, 210, 42); 2557 p1.setBorder(BorderFactory.createTitledBorder(""));
2558 {
2559 lbl1 = new JLabel(); 2560 p1.add(lbl1);
2561 lbl1.setText("\u4e94\u7b14:"); 2562 lbl1.setFont(new java.awt.Font("新宋体",0,12));
2563 }
2564 {
2565 txtCode1 = new JTextField(); 2566 p1.add(txtCode1); 2567 txtCode1.setPreferredSize(new java.awt.Dimension(57, 20));
2568
2569 txtCode1.setEditable(false); 2570 }
2571 {
2572 lbl2 = new JLabel(); 2573 p1.add(lbl2);
2574 lbl2.setText("\u62fc\u97f3:"); 2575 lbl2.setFont(new java.awt.Font("新宋体",0,12));
2576 }
2577 {
txtCode2 = new JTextField();2578 2579 p1.add(txtCode2); 2580 txtCode2.setPreferredSize(new java.awt.Dimension(61, 20));
2581
2582 txtCode2.setEditable(false); 2583 }
2584 }
{2585
2586 p2 = new SplitMap(); 2587 getContentPane().add(p2); 2588 p2.setBounds(6, 82, 217, 70);
p2.setFont(new java.awt.Font("新宋体",0,12));2589 2590 }
2591 {
2592 btnHelp = new JButton(); 2593 getContentPane().add(btnHelp); 2594 btnHelp.setText("\u5e2e\u52a9"); 2595 btnHelp.setBounds(8, 159, 91, 21);
btnHelp.setFont(new java.awt.Font("新宋体",0,12));2596
2597 }
2598 {
2599 btnExit = new JButton();2600 getContentPane().add(btnExit); 2601 btnExit.setText("\u9000\u51fa"); 2602 btnExit.setBounds(122, 159, 98, 21); 2603 btnExit.setFont(new java.awt.Font("新宋体",0,12)); 2604 btnExit.addActionListener(new ActionListener() { 2605 public void actionPerformed(ActionEvent evt) { 2606 Exit();
2607 }
2608 });
2609 }
2610 this.pack();
2611 }
2612
2613 private void queryWord(){
2614 System.gc();
2615 PublicData.SplitMapName=txtWord.getText().substring(0,1)+".gif";
2616
2617 this.p2.repaint();
2618 System.gc();
2619 if((("code/wb.db"==null) || ("code/wb.db".length()==0)) || (("code/py.db"==null) ||
2620 ("code/py.db".length()==0)))
2621 return;
File f;2622
2623 FileReader in=null;
2624 int len;
2625 String s="";
2626 String string=txtWord.getText().substring(0,1); 2627 try{
2628 f=new File("code/wb.db");
in=new FileReader(f);2629
2630 char[] buffer=new char[1100]; 2631 while((len=in.read(buffer))!=-1){ 2632 s=new String(buffer,0,len);
if(s.indexOf(string)!=-1){2633 2634 String
2635 str=s.substring(s.indexOf(string),s.indexOf(string)+string.length()+4); 2636 txtCode1.setText(str.substring(1,str.length())); 2637 break;
2638 }
2639 }
}2640
2641 catch(IOException e){
2642 System.out.println(e);
2643 }
2644 finally{
2645 try{
2646 if(in!=null) 2647 in.close(); 2648 }
2649 catch(IOException e){} 2650 }
2651 in=null;
2652 len=0;
2653 s="";
2654 try{
2655 f=new File("code/py.db"); 2656 in=new FileReader(f); 2657 char[] buffer=new char[7000]; 2658 while((len=in.read(buffer))!=-1){ 2659 s=new String(buffer,0,len); 2660 if(s.indexOf(string)!=-1){ 2661 String
2662 str=s.substring(s.indexOf(string),s.indexOf(string)+string.length()+6);
2663 txtCode2.setText(str.substring(1,str.length()));
2664 break; 2665 }
}2666
2667 }
2668 catch(IOException e){ 2669 System.out.println(e); 2670 }
2671 finally{
2672 try{
if(in!=null)2673 2674 in.close(); 2675 }
2676 catch(IOException e){}
}2677
2678 System.gc();
2679 }
2680
2681 private void Exit(){
2682 PublicData.onChoice=true; 2683 PublicData.SplitMapName="null.gif";
this.doDefaultCloseAction();2684 2685 System.gc();
2686 }
2687 }
2688
2689 import java.awt.*;
2690 import javax.swing.*;
2691
2692 public class SplitMap extends JPanel{ 2693
2694 public void paint(Graphics g){ 2695 paintComponent(g); 2696 setBorder(BorderFactory.createLineBorder(Color.RED));
2697 g.drawString("正在加载图片......",65,40);
2698 g.drawImage(Toolkit.getDefaultToolkit().getImage(
2699
2700 (PublicData.SplitMapName==null)?"splitmap/null.gif":("splitmap/"+PublicData.SplitMapN
2701 ame)),0,0,this);
2702 }
2703 }
2704
2705 import javax.swing.*;
2706 import java.awt.*;
2707 import java.awt.event.*; 2708 import java.io.*;
2709 import java.util.*;
import LanClient.*;2710
2711
2712
2713 public class Tool extends JInternalFrame implements ActionListener{
2714
2715 MainFrame parent; 2716
private JButton btnJP;2717 2718 private JButton btnZG; 2719 private JButton btnJM; 2720 private JButton btnWZ;
private JButton btnLocalTest;2721 2722 private JButton btnLANTest; 2723 private JButton btnBMCX; 2724 private JButton btnExit; 2725 private JButton btnHelp; 2726 private JPanel p;
2727 private ImageIcon image; 2728
public Tool(MainFrame parent){2729 2730 this.parent=parent;
2731
2732 //添加按钮
2733 p=new JPanel();
2734 image=new ImageIcon("Image/JP.gif"); 2735 btnJP=new JButton("键盘练习(1)",image); 2736 btnJP.setFont(new Font("x",Font.PLAIN,12)); 2737 btnJP.setMnemonic('1');
2738 btnJP.addActionListener(this); 2739
2740 image=new ImageIcon("Image/ZG.gif"); 2741 btnZG=new JButton("字根练习(2)",image); 2742 btnZG.setFont(new Font("x",Font.PLAIN,12)); 2743 btnZG.setMnemonic('2');
2744 btnZG.addActionListener(this); 2745
2746 image=new ImageIcon("Image/JM.gif"); 2747 btnJM=new JButton("简码练习(3)",image); 2748 btnJM.setFont(new Font("x",Font.PLAIN,12)); 2749 btnJM.setMnemonic('3');
2750 btnJM.addActionListener(this); 2751
2752 image=new ImageIcon("Image/WZ.gif"); 2753 btnWZ=new JButton("文章练习(4)",image);
btnWZ.setFont(new Font("x",Font.PLAIN,12));2754 2755 btnWZ.setMnemonic('4');
2756 btnWZ.addActionListener(this); 2757
2758 image=new ImageIcon("Image/LocalTest.gif"); 2759 btnLocalTest=new JButton("本地测试(5)",image); 2760 btnLocalTest.setFont(new Font("x",Font.PLAIN,12));
btnLocalTest.setMnemonic('5');2761 2762 btnLocalTest.addActionListener(this); 2763
2764 image=new ImageIcon("Image/LANTest.gif");
btnLANTest=new JButton("网络测试(6)",image);2765 2766 btnLANTest.setFont(new Font("x",Font.PLAIN,12)); 2767 btnLANTest.setMnemonic('6'); 2768 btnLANTest.addActionListener(this); 2769
2770 image=new ImageIcon("Image/BMCX.gif"); 2771 btnBMCX=new JButton("编码查询(7)",image);
btnBMCX.setFont(new Font("x",Font.PLAIN,12));2772 2773 btnBMCX.setMnemonic('7');
2774 btnBMCX.addActionListener(this);
2775
2776 image=new ImageIcon("Image/help.gif"); 2777 btnHelp=new JButton("帮 助(8)",image); 2778 btnHelp.setFont(new Font("x",Font.PLAIN,12)); 2779 btnHelp.setMnemonic('8');
2780 btnHelp.addActionListener(this); 2781
2782 image=new ImageIcon("Image/Exit.gif"); 2783 btnExit=new JButton("退出系统(Q)",image); 2784 btnExit.setFont(new Font("x",Font.PLAIN,12)); 2785 btnExit.setMnemonic('Q');
2786 btnExit.addActionListener(this); 2787
2788 p.setLayout(new FlowLayout()); 2789 p.add(btnJP);
2790 p.add(btnZG);
2791 p.add(btnJM);
2792 p.add(btnWZ);
2793 p.add(btnLocalTest);
2794 p.add(btnLANTest);
2795 p.add(btnBMCX);
2796 p.add(btnHelp);
2797 p.add(btnExit);
add(this.p);2798
2799
2800
2801 setLayer(1);
2802 setBounds(1,0,0,0);
2803 setPreferredSize(new Dimension(140,325)); 2804 ((javax.swing.plaf.basic.BasicInternalFrameUI) this.getUI()).setNorthPane(null);
2805
2806 this.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
2807
2808 pack();
setVisible(true); 2809
2810 }
2811 //实现ActionListener接口的方法 2812 public void actionPerformed(ActionEvent e){ 2813 if(PublicData.onChoice==true){ 2814 if(e.getSource()==btnJP){ 2815 PublicData.onChoice=false;
PublicData.Lang="English";2816 2817 PublicData.Text="Text/English_"+(int)(Math.random()*5+1)+".txt";
2818
2819 PublicData.choice=1;
2820 showFrame();
2821 }
2822 if(e.getSource()==btnZG){ 2823 PublicData.onChoice=false; 2824 PublicData.Lang="Chinese"; 2825 PublicData.choice=2; 2826 showFrame();
2827 }
2828 if(e.getSource()==btnJM){ 2829 PublicData.onChoice=false; 2830 PublicData.Lang="Chinese"; 2831 PublicData.Text="Text/TwoCode.txt"; 2832 PublicData.choice=3; 2833 showFrame();
2834 }
2835 if(e.getSource()==btnWZ){ 2836 PublicData.onChoice=false; 2837 PublicData.Lang="Chinese"; 2838 PublicData.Text="Text/Chinese_"+(int)(Math.random()*5+1)+".txt";
2839
2840 PublicData.choice=3; 2841 showFrame();
}2842
2843 if(e.getSource()==btnLocalTest){ 2844 PublicData.onChoice=false; 2845 PublicData.Lang="Chinese"; 2846 PublicData.Text="Text/Chinese_"+(int)(Math.random()*5+1)+".txt";
2847
2848 PublicData.choice=3;
showFrame();2849
2850 }
2851 if(e.getSource()==btnLANTest){ 2852 InputStream is = this.getClass().getResourceAsStream("Config.properties");
2853
2854 Properties properties = new Properties(); 2855 try{
2856 properties.load(is); 2857 is.close();
2858 if((Integer.parseInt(properties.getProperty("TestMode"))==1) ?
2859 true:false){
PublicData.onChoice=false;2860 2861 LanManage lanmanage=new LanManage(); 2862 parent.add(lanmanage,4);
2863 }
2864 else{
2865 new Client(); 2866 }
2867
2868 }catch(IOException ex){} 2869 }
2870 if(e.getSource()==btnBMCX){ 2871 PublicData.onChoice=false; 2872 QueryCoding coding=new QueryCoding(); 2873 parent.add(coding,6); 2874 }
2875 if(e.getSource()==btnHelp){ 2876 PublicData.onChoice=false; 2877 Help help=new Help(); 2878 parent.add(help,4); 2879 }
2880 if(e.getSource()==btnExit){ 2881 int i=JOptionPane.showConfirmDialog(this.parent,"你真的要退出吗?","疯
2882 狂打字",
2883
2884 JOptionPane.YES_OPTION,JOptionPane.QUESTION_MESSAGE);
2885 if(i==0){
System.exit(0);2886 2887 }
2888 }
2889 }
2890
2891 }
2892
private void showFrame(){2893 2894 Hint hint =new Hint(this); 2895 parent.add(hint,2);
2896 }
}2897
2898
2899 import java.awt.*;
2900 import javax.swing.*;
2901
2902
2903 /**
* This code was edited or generated using CloudGarden's Jigloo2904
2905 * SWT/Swing GUI Builder, which is free for non-commercial 2906 * use. If Jigloo is being used commercially (ie, by a corporation,
2907 * company or business for any purpose whatever) then you
2908 * should purchase a license for each developer using Jigloo. 2909 * Please visit www.cloudgarden.com for details.
2910 * Use of Jigloo implies acceptance of these licensing terms. 2911 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR 2912 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED 2913 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. 2914 */
2915 public class Welcome extends JFrame implements Runnable{ 2916 Thread t;
2917 private LoginGraphics loginGraphics_IL;
2918
2919 public static void main(String[] args) {
2920 Welcome inst = new Welcome();
2921 inst.setVisible(true);
2922 }
2923
2924 public Welcome() {
2925 super();
2926 t=new Thread(this);
2927 initGUI();
2928 }
2929
private void initGUI() {2930
2931 try {
2932 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
2933
2934 setUndecorated(true);
2935 // 计算屏幕大小
2936 Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
2937
2938 //添加图标
2939 setIconImage(Toolkit.getDefaultToolkit().getImage("image/f.gif"));
2940
setTitle("疯狂打字通v2.1");2941
2942 //setLayout(new FlowLayout());
2943 //添加图形
2944 setSize(443, 155);
2945 //将窗口居中
2946 setLocation((screen.width-getWidth())/2,(screen.height-getHeight())/2);
2947
{2948
2949 loginGraphics_IL = new LoginGraphics(); 2950 add(loginGraphics_IL);
2951 loginGraphics_IL.setBorder(BorderFactory.createCompoundBorder(
2952
2953 null,
2954 null));
2955 loginGraphics_IL.setBackground(new java.awt.Color(192,192,192));
2956
2957 }
2958 t.start();
2959 } catch (Exception e) {
2960 e.printStackTrace();
2961 }
2962 }
2963 public void run(){
2964 try{
2965 Thread.sleep(3000);
2966 new MainFrame();
2967 this.setVisible(false);
2968 t.interrupt();
2969 }catch(InterruptedException e){}
2970 }
2971 }
2972
2973 /*
*/2974
2975 package com.cloudgarden.layout;
2976
2977 /**
2978 * Used by both AnchorLayout (SWT) and AnchorLayoutManager (Swing) 2979 */
2980 public class AnchorConstraint {
2981
/**2982
2983 * Meaning: This side is not anchored.
2984 */
public static final int ANCHOR_NONE = 0;2985 2986
2987 /**
2988 * (Relative anchor) Meaning: This side is anchored so that it always 2989 * occurs a fixed fraction of
2990 * the distance along it's parent's side. The position is calculated by 2991 * the formula " position = (parent side)*(value)/1000 " so for
* instance if top=100 and topType == ANCHOR_REL then the2992 2993 * value of y for this side would be (parent height)*top/1000. 2994 */
2995 public static final int ANCHOR_REL = 1;2996
2997 /**
2998 * (Absolute anchor) Meaning: This side is anchored a fixed distance 2999 * in pixels (given by the value for this side) from it's parent's respective side.
3000
3001 * For instance, if bottomType == ANCHOR_ABS and bottom = 100 then the
3002
3003 * bottom side of this component will remain fixed 100 pixels from 3004 * the bottom side of it's parent container.
3005 */
3006 public static final int ANCHOR_ABS = 2;
3007
3008 public int top;
3009 public int bottom;
3010 public int left;
3011 public int right;
3012 public int topType;
3013 public int bottomType;
3014 public int rightType;
3015 public int leftType;
3016
3017 public AnchorConstraint() {
3018 this(0, 0, 0, 0, ANCHOR_NONE, ANCHOR_NONE, ANCHOR_NONE,
ANCHOR_NONE);3019
3020 }
3021
3022 /**
3023 * Creates an AnchorConstraint.
3024 * @param top - value (relative or absolute) for top side
* @param right - like 'top' but for right side3025
3026 * @param bottom - like 'top' but for bottom side 3027 * @param left - like 'top' but for left side
3028 * @param topType - either ANCHOR_ABS, ANCHOR_REL or ANCHOR_NONE
3029
3030 * to indicate whether the 'top' parameter is an absolute value (in pixels) or
3031
3032 * a fractional value (in 1/1000 ths) of the height of this component's parent,
3033
3034 * denoting where the anchor will be applied (if at all). 3035 * @param rightType - like 'topType' but for right side
* @param bottomType - like 'topType' but for bottom side3036 3037 * @param leftType - like 'topType' but for left side 3038 */
3039 public AnchorConstraint(
3040 int top,
3041 int right,
3042 int bottom,
3043 int left,
3044 int topType,
3045 int rightType,
3046 int bottomType,
3047 int leftType) {
3048 this.top = top;
3049 this.bottom = bottom;
3050 this.left = left;
3051 this.right = right;
3052 this.topType = topType;
3053 this.rightType = rightType;
3054 this.bottomType = bottomType;
3055 this.leftType = leftType;
3056 }
3057
3058 }
3059
3060 /*
3061 */
package com.cloudgarden.layout;3062
3063
3064 import java.awt.Component;
3065 import java.awt.Container;
3066 import java.awt.Dimension;
3067 import java.awt.LayoutManager2;
3068 import java.awt.Rectangle;
import java.util.HashMap;3069
3070
3071 /**
3072 * Lays out components, using a combination of their "bounds" property
* and their AnchorConstraints layout constraint objects. 3073 3074 *
3075 * Sides of the components can be anchored either absolutely (eg, if the 3076 * right side is anchored absolutely then it will always be a fixed number 3077 * of pixels from the right side of it's parent container) or relatively (ie, 3078 * if any side is anchored relatively then it will always occur a fixed 3079 * fraction of the way along it's parent's side). Or they can be not anchored,
* at all in which case they will occur at places determined by their 3080 3081 * component's "bounds" property and the anchoring of the component's 3082 * other sides.
3083 */
3084 public class AnchorLayout implements LayoutManager2 { 3085
3086 private int preferredWidth, preferredHeight, minHeight, minWidth; 3087 private HashMap constraintMap = new HashMap(); 3088 private boolean sizesCalculated = false; 3089 private Container container;
3090
3091 public AnchorLayout() {
3092 super();
3093 }
3094
3095 void initialize(Container parent) {
3096 if (sizesCalculated)
3097 return;
3098 Component[] children = parent.getComponents(); 3099 preferredWidth = 10000;
3100 preferredHeight = 10000;
3101 minWidth = 0;
3102 minHeight = 0;
3103 Rectangle pb = parent.getBounds(); 3104 for (int i = 0; i < children.length; i++) { 3105 Component child = children[i];
if (child != null) {3106
3107 Object ld = constraintMap.get(child); 3108 Rectangle b = child.getBounds(); 3109 Dimension pref = child.getPreferredSize(); 3110 Dimension min = child.getMaximumSize(); 3111 if (pref == null)
3112 pref = child.getSize();
if (min == null)3113
3114 min = child.getSize(); 3115 int minX = b.x + b.width; 3116 int minY = b.y + b.height;
int maxX = b.x + b.width;3117 3118 int maxY = b.y + b.height; 3119 if (ld instanceof AnchorConstraint) { 3120 AnchorConstraint ac = (AnchorConstraint) ld; 3121 int acl = ac.left; 3122 int acr = ac.right; 3123 int aclt = ac.leftType;
int acrt = ac.rightType;3124 3125
3126 if (aclt == AnchorConstraint.ANCHOR_REL)
3127 acl = acl * pb.width / 1000;3128 if (acrt == AnchorConstraint.ANCHOR_REL) 3129 acr = pb.width - acr * pb.width / 1000; 3130
3131 if (aclt != AnchorConstraint.ANCHOR_NONE 3132 && acrt != AnchorConstraint.ANCHOR_NONE)3133
3134 maxX = acl + pref.width + acr; 3135 if (aclt == AnchorConstraint.ANCHOR_NONE) 3136 acl = 0;
3137 if (acrt == AnchorConstraint.ANCHOR_NONE) 3138 acr = 0;
3139 minX = acl + min.width + acr; 3140
3141 int act = ac.top;
3142 int acb = ac.bottom;
3143 int actt = ac.topType;
3144 int acbt = ac.bottomType;
3145 if (actt == AnchorConstraint.ANCHOR_REL) 3146 act = act * pb.height / 1000; 3147 if (acbt == AnchorConstraint.ANCHOR_REL) 3148 acb = pb.height - acb * pb.height / 1000; 3149
if (actt != AnchorConstraint.ANCHOR_NONE3150 3151 && acbt != AnchorConstraint.ANCHOR_NONE)3152
3153 maxY = act + pref.height + acb; 3154 if (actt == AnchorConstraint.ANCHOR_NONE) 3155 act = 0;
3156 if (acbt == AnchorConstraint.ANCHOR_NONE)
acb = 0;3157
3158 minY = act + min.height + acb; 3159 }
3160 if (minX > minWidth)
minWidth = minX;3161
3162 if (maxX > minWidth)
3163 preferredWidth = maxX;
3164 if (minY > minHeight)
3165 minHeight = minY;
3166 if (maxY > preferredHeight)
3167 preferredHeight = maxY;
}3168
3169 }
3170
3171 }
3172
3173 /* (non-Javadoc)
3174 * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
3175 boolean)
3176 */
3177 public void layoutContainer(Container container) { 3178 this.container = container;
3179 Component children[] = container.getComponents(); 3180 Rectangle rect = container.getBounds(); 3181 int width = rect.width;
3182 int height = rect.height;
3183 for (int i = 0; i < children.length; i++) { 3184 Component child = children[i]; 3185 if (child != null) {
3186 Object ld = constraintMap.get(child); 3187 Rectangle b = child.getBounds(); 3188 Dimension pref = child.getPreferredSize(); 3189 if (pref == null)
3190 pref = child.getSize(); 3191 if (ld instanceof AnchorConstraint) { 3192 AnchorConstraint ac = (AnchorConstraint) ld; 3193 int acl = ac.left;
int acr = ac.right;3194
3195 int aclt = ac.leftType; 3196 int acrt = ac.rightType; 3197 if (aclt == AnchorConstraint.ANCHOR_REL) 3198 acl = acl * width / 1000; 3199 if (acrt == AnchorConstraint.ANCHOR_REL) 3200 acr = width - acr * width / 1000; 3201
if (aclt != AnchorConstraint.ANCHOR_NONE) {3202 3203 if (acrt != AnchorConstraint.ANCHOR_NONE) {
3204
b.width = width - acr - acl;3205 3206 b.x = acl; 3207 } else {
3208 b.width = pref.width; 3209 if (b.width + acl > width) 3210 b.width = width - acl; 3211 b.x = acl;
}3212
3213 } else {
3214 if (acrt != AnchorConstraint.ANCHOR_NONE) {
3215
3216 b.x = width - acr - pref.width;3217 }
3218 b.width = pref.width; 3219 if (b.width + b.x > width) 3220 b.width = width - b.x; 3221 }
3222
3223 int act = ac.top;
3224 int acb = ac.bottom;
3225 int actt = ac.topType;
3226 int acbt = ac.bottomType; 3227 if (actt == AnchorConstraint.ANCHOR_REL) 3228 act = act * height / 1000; 3229 if (acbt == AnchorConstraint.ANCHOR_REL) 3230 acb = height - acb * height / 1000; 3231
3232 if (actt != AnchorConstraint.ANCHOR_NONE) { 3233 if (acbt != AnchorConstraint.ANCHOR_NONE) {
3234
3235 b.height = height - acb - act; 3236 b.y = act;
3237 } else {
3238 b.height = pref.height;
if (b.height + act > height)3239 3240 b.height = height - act; 3241 b.y = act;
3242 }
3243 } else {
3244 if (acbt != AnchorConstraint.ANCHOR_NONE) {
3245
b.y = height - acb - pref.height;3246 3247 }
3248 b.height = pref.height; 3249 if (b.height + b.y > height)
b.height = height - b.y;3250 3251 }
3252 child.setBounds(b);
3253 }
3254 }
3255 }
3256 }
3257
/* (non-Javadoc)3258
3259 * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String,
3260 java.awt.Component)
3261 */
3262 public void addLayoutComponent(String name, Component comp) {} 3263
3264 /* (non-Javadoc)
3265 * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
3266
3267 */
3268 public void removeLayoutComponent(Component comp) { 3269 constraintMap.remove(comp);
3270 }
3271
3272 /* (non-Javadoc)
3273 * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
3274
3275 */
3276 public Dimension preferredLayoutSize(Container parent) { 3277 initialize(parent);
3278 return new Dimension(preferredWidth, preferredHeight); 3279 }
3280
3281 /* (non-Javadoc)
3282 * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
3283
3284 */
3285 public Dimension minimumLayoutSize(Container parent) { 3286 initialize(parent);
3287 return new Dimension(minWidth, minHeight); 3288 }
3289
/* (non-Javadoc)3290
3291 * @see java.awt.LayoutManager2#addLayoutComponent(java.awt.Component,
3292 java.lang.Object)
3293 */
public void addLayoutComponent(Component comp, Object constraints) {3294
3295
3296 constraintMap.put(comp, constraints); 3297 }
3298
3299 /* (non-Javadoc)
3300 * @see java.awt.LayoutManager2#maximumLayoutSize(java.awt.Container)
3301
3302 */
3303 public Dimension maximumLayoutSize(Container target) {
3304 return preferredLayoutSize(target);3305 }
3306
3307 /* (non-Javadoc)
3308 * @see java.awt.LayoutManager2#getLayoutAlignmentX(java.awt.Container)
3309
3310 */
3311 public float getLayoutAlignmentX(Container target) { 3312 return 0;
3313 }
3314
3315 /* (non-Javadoc)
3316 * @see java.awt.LayoutManager2#getLayoutAlignmentY(java.awt.Container)
3317
3318 */
3319 public float getLayoutAlignmentY(Container target) { 3320 return 0;
3321 }
3322
3323 /* (non-Javadoc)
3324 * @see java.awt.LayoutManager2#invalidateLayout(java.awt.Container)
3325
3326 */
public void invalidateLayout(Container target) {3327 3328 sizesCalculated = false;
3329 }
3330
3331 }
3332
3333
3334
3335 3336
3337 疯狂打字同v2.0
3338
3339
3340 五笔基本使用方法
3341 1.基本字根及其优选
3342 字根,是由若干笔划交叉连接而形成的相对3343 不变的结构叫字根。
3344 五笔字型中优选了130种基本字根,分五大区,每区又分五个位。 3345 一区?横起笔类 27种,分“王土大木工”五个位;
3346
3347 二区?竖起笔类 23种,分“目日口田山”五个位;
3348 三区?撇起笔类 29种,分“禾白月人金”五个位;
3349 四区?捺起笔类 23种,分“言立水火之”五个位;
3350 五区?折起笔类 28种,分“已子女又纟”四个位;
3351
3352 所有字根及其在键盘上的分部如下3353 图
3354
3355
3356
3357 口诀 3359
3360
3361 3363 口诀就是将每个键上的主要字根串联成一句话,只要你记熟这句口诀,那么这个键上的主要字根3364 你便能够想起来。例如口诀“土士二干十寸雨”就是字根“土”、“士”、“二”、“干”等F键上。其3365 它类似(对照口诀和键盘图便可理解)。熟3366 悉口诀对于记住字根有重要的作用。
3367 口诀如下:
3369
3370 3371
3372
3373 区 |
3375 键 |
3377 口诀 |
3379
3380
3381 一区 |
3383 11-G |
3386 王旁青头戋(兼)五一,(“兼”与“戋”同音) | 3388
3389
3390
3391 12-F | 3394 土士二干十寸雨。 | 3395
3396
3397
3398 13-D | 3401 大犬三羊古石厂, (“羊”指羊字底) | 3403
3404
3405 14-S | 3408 木丁西, | 3409
3410
3411
3412 15-A | 3414
3415 工戈草头右框七。 (“右框”即“匚”) | 3417
3418
3419
3420 | 3421 | 3422 | 3423
3424
3425 二区 |
3427 21-H | 3430 目具上止卜虎皮,(“具上”指具字的上部,"虎皮"指的是"虍3432 ") |
3433
3434
3435 22-J | 3438 日早两竖与虫依。 | 3439
3440
3441
3442 23-K | 3445 口与川,字根稀, | 3446
3447
3448
3449 24-L | 3452 田甲方框四车力。 (“方框”即“囗”) | 3454
3455
3456 25-M<3463 /td>
3464 | 山由贝,3469 下框几。 |
3470
3471
3472 | 3473 | 3474 |
3475
3476
3477 三区 |
3479 31-T<3486 /td>
3487 | 禾竹一撇3492 双人立, (“双人立”即“彳”) | 3498
3499
3500 | 3501 反文条头3506 共三一。 (“条头”即“夂”) | 3512
3513
3514 32-R<3521 /td>
3522 | 白手看头3527 三二斤, |
3528
3529
3530 33-E<3537 /td>
3538 | 月彡3543 (衫)乃用家衣底。 (“家衣底”即“豕、,”) | 3550
3551
3552 34-W<3559 /td>
3560 | 人和八,3565 三四里,
3569 (“人”和“八”在第3区第4个键里边) | 3576
3577
3578
3579 35-Q<3586 /td>
3587 | 金勺缺点3592 无尾鱼, 3597
3598 犬旁留叉儿一点夕,
3599 氏无七(妻)。 (“氏”去掉“七”) | 3606
3607
3608
3609 | 3610 | 3611 |
3612
3613
3614 四区 |
3616 41-Y<3623 /td>
3624 | 言文方广3629 在四一,
3630 高头一捺谁人去。(高头3635 “ ”,“谁”去“亻”
3636 为“讠、”) | 3637
3638
3639 42-U<3646 /td>
3647 | 立辛两点3652 六门疒, | 3653
3654
3655 43-I<3662 /td>
3663 | 水旁兴头3668 小倒立。 (指“氵”等) |
3674
3675
3676 44-O<3683 /td>
3684 | 火业头,3689 四点米, |
3690
3691
3692 45-P<3699 /td>
3700 | 之字军盖3705 建道底,
3706 (即“之、宀、冖、廴、3710 辶”)
3716 摘礻(示)衤(衣)。 | 3717
3718
3719 |
3720 | 3721 |
3722
3723
3724 3725 五区3726 |
3727 51-N<3734 /td>
3735 | 已半巳满3740 不出己,
3741 左框折尸心和羽。 (“左框”即
3745 “,”) |
3746
3747
3748 52-B<3755 /td>
3756 | 子耳了也3761 框向上。
3762 (“框向上”即
3766 “凵”) |
3767
3768
3769 53-V<3776 /td>
3777 | 女刀九臼3782 山朝西。
3783 (“山朝西”即
3787 “彐”) |
3788
3789
3790 54-C<3797 /td>
3798 | 又巴马,3803 丢矢矣,
3804 (“矣”去“矢”为3808 “厶”) |
3814
3815
3816 55-X<3823 /td>
3824 | 慈母无心3829 弓和匕,
3830 (“母无心”即3834 “,”)
3840 幼无力。 (“幼”去“力”3844 为“幺”) |
3845
3846
3847 2.指 法
3848 一、手指放在键盘上
3849
3850
3851 3852 如下图,手指放在八个基本键上,两个拇指轻放在空格键上。
3853
3854 3855 二、击3856 键要领
3857 1.手指弯曲要自然,3858 手臂不可张开太大
3859 2.手指击键要正确,击键有适当力度,击键之后要立即回到基准键上
3860
3861 3.空格键用大拇指负责击打
3862 4.击键有节奏,速度均匀,初学时尽量慢一点,关键是要用正确的指法
3863
3864 基准键的打法:3866 例如要击D键,方法是:1、提起3867 左手约离键盘两厘米;2、向下击键时中指向下弹击D键,其它手指同时稍向上弹开。其它键的3868 击法与此类似,请多体会。形成正确的习惯很重要,而错误的习惯则很难改。
3869
3870
3871 非基准键的打法:例如要打E键,方法是:1、提起左手约离键盘两厘米;2、整个左手稍向前3872 移,同时用中指向下弹击E键,同一时间其它手指稍向上弹开,击键后四个手指迅速回位如上图,3873 注意右手不要动,其它键类似打法,注意体会。
3874 三、手指分工(如下图)
3876 3877 练习英文指法最好花上两三天时间(每天不少于3878 六小时,若少于此数则练习时间要增加)。
3879 请下决心一定要练到盲打的水平,并且每分钟正3880 确地击键不下150次。
3881
3882 3.汉字的三种字型
3883 根据构成汉字的各字根之间的位置关系,可3884 以把成千上万的方块汉字分三种类型?左右型,上下型,杂合型。根据汉字的字型,我们也用1?33885 给出其型状代号,如下表所示?
3886
3887 3888
3889
3890 字型代号 | 3891 字型 | 3892 字 例 | 3893
3894
3895 1 |
3896 左右 | 3897
3898 汉湘结封 | 3899
3900
3901 2 |
3902 上下 | 3903
3904 字莫花华 | 3905
3906
3907 3 |
3908 杂合 | 3909
3910 困凶道乘 3911 太重天且 |
3912
3913
3914 表中最后3915 一种又叫独体字,前二种又统称合体字,两部份合并一起的汉字又叫双合字,三部分合并在一起3916 的又叫三合字。
3917 因为在3918 汉字编取代码时,由于某些汉字字根较少,“信息量不足”,离散不开,所以有必要再补加一个3919 字型信息,而对于由四个部份以上组成或者可以分作四部分的汉字,其信息已够丰富,则不必要
3920 再考虑字型信息了,这就是我们今后要取“一二三末”四个字根,且不足四码要追加末笔交叉识3921 别码的原因。
3922 1.3923 一型??左右型
3924
3925 左右型汉字,包括两种情况?
3926 (1) 在双合字中,两个部分分列左右,其间有一定的矩离如?肚,胡,理,胆,拥等
3927
3928 (2) 三合字中,整字的三个部分从左至右并列?或者单独占据一边的部分与另外两个部分呈3929 左、右排列,如?侧、别、谈等
3930
3931
3932
3933 2.二型??上下型
3934
3935 上下型汉字也包括两种情况?
3936 (1) 双合字中,两个部分分列上下,其间有一定距离,如字,节,旦,看等
3937
3938 (2) 三合字中,三个部分上下排列,或者单占一层的部分与另外两部分作上下排列,如?意,3939 想,花等
3940 3941 3.三型??杂合型
3942 (外内型汉字和单体型汉字)
3943
3944 三型是指组成整字的各部分之间没有明确的左右或上下型关系者,如?困,同,这,斗,头等3945
3946 4.词组输入方法
3947 p style="line-height: 150%">二字词3948
3949 分别取两个字的单字全码中的前面个字根代码,共3950 四码组成,
3951 3952
3953 如: | 3954
3955 机器?木几口口 3956 (SMKK) |
3957
3958
3959 |
3960 汉字?氵又宀子 3961 (ICPB) |
3962
3963
3964 三字词3965
3966 前两个字各取其第一码,最后一个字取其二码,共为四码3967
3968 如: 计算机?言竹木几 (YTSM)
3969
3970 四字词
3971
3972 每字各取其第一码,共为四码
3973
3974 3975
3976 如: | 3977
3978 汉字编码?氵宀纟石 3979 (IPXD) |
3980
3981
3982 |
3983 光明日报?小日日扌 3984 (IJJR) |
3985
3986
3987 多字词3988
3989 按“一、二、三、末”的规则,取第一、二、三3990 及最末一个字的第一码,共为四码
3991 3992
3993 如: | 3994
3995 电子计算机?日子言木 3996 (JBYS) |
3997
3998
3999 |
4000 中华人民共和国?口人人囗 4001 (KWWL) |
4002
4003
4004 5.单字输入方法
4005 4006
4007 这里的单字是指除键名汉字和字根字之外的汉字。如果一个字可以取够四个字根,就全部用字根
4008 键入,只有在不足四个字根的情况下,才有必要追加识别码。
4009
4010 例?给:纟 人 一 口 (55 34 4011 11 23 XWGK)
4012 驭:马 又 (54 54 41 CCY )
4013
4014 汉:氵 又 (43 54 41 ICY )
4015
4016
4017 对识别的末笔,这里有二点规定,规定取被包围的那一部分笔划结构的末笔
4018
4019 ,(所有包围型汉字中的末笔,规定取被包围的那一部4020 分笔划结构的末笔,如?
4021 国?其末笔应取“丶”,识别码为43(I)
4022 远?其末笔应取“乙”,识别码为53(V)
4023
4024 ,(对于字根“刀、九、力、七”,虽然只有两笔,但一4025 般人的笔顺却常有不同,为了保持一致和照顾直观,规定,凡是这 四种字根当作“末”而又4026 需要识别时,一律用它们向右下角伸得最长最远的笔划“折”来识别,如?
4027
4028 仇?34 54 51 ( WVN )
4029 化?34 55 51 ( WXN )
4030 6.简码输入方法
4031 为了提高输入速度,将常用汉字只取前边一4032 个,两个或三个字根构成简码。
4033 一级简码
4034 一 11(G) 地 12(F) 在 13(D) 要 4035 14(S) 工 15(A)
4036 上 21(H) 是 22(J) 中 23(K) 国 24(L) 同 25(M)
4037
4038 和 31(T) 的 32(R) 有 33(E) 人 34(W) 我 35(Q)
4039
4040 主 41(Y) 产 42(V) 不 43(I) 为 44(O) 这 45(P)
4041
4042 民 51(N) 了 52(B) 发 53(V) 以 54(C) 经 55(X)
4043
4044
4045 二级简码
4046 二级简码只要击其前两个字根4047 加空格键即可
4048 如:
4049 吧?口巴 (23, 54, KC)
4050 昌:日日 (21, 21, JJ)
4051
4052 三级简码
4053 三级简码由单字的前4054 三个根字码组成,只要击一个字的前三个字根加空格即可。如?
4055 重?全码?丿一日土 (31 11 22 12, TGJF)
4056 简码?丿一日 (31 11 22 TGJ)4057
4058 7.汉字折分成字根的原则
4059 折分原则可归纳为四个要点?取大优先,兼4060 顾直观,能连不交,能散不连
4061 4063
4064 l 、取大优先:“取大优先”。按书写顺序拆分汉4065 字时,每次都拆取一个“尽可能大”的,即尽可能笔画多的字根。例1:校:第一种拆法:木、亠、八、X(误);第二种拆法:木、六、X,显然,前者是错误的,因为亠、八完全“凑”成“六”,形成一个“更大”的字根。至于什么才算“大”,“大”4076 到什么程度,这就需要您熟悉所有的字根了。
4077 4079
4080 2、 兼顾直观:在拆分汉字时,为了照顾汉字4081 字根的完整性,4082 有时不得不暂且牺牲一下“书写顺序”和“取大优先”的原则,形成个别例外的情况。例1:困:按4083 “书写顺序”应拆成:“冂、木、一”,但直观的原则,应该折分为“囗、木”了。4084
4085 4087
4088 3、 能连不交:请看以下拆分4089 实例:于:一十(二者是相连的)、二丨(二者是相交的)丑:乙土(二者是相连的)、刀二(二4090 者是相交的)。当一个字既可拆成相连的几个部分,也可拆成相交的几个部分时,“相连”的拆4091 法是正确的。
4092 4、 能散不连:4093 笔画和字根之间,字根与字根之间的关系,可以分4094 为“散”、“连”和“交”的三种关系。如:倡:三个字根之间是“散”的关系;自:首笔“丿”与“目”4095 之间是“连”的关系;夷:“一”、“弓”与“人”是“交”的关系。字根之间的关系,决定了汉字的字
4096 型(上下、左右、杂合)。
4097 4099
4100 (a)几个字根都“交”“连”在一起的,如“夷”、“丙”等,是“杂合型”。而散结构是“左右”型或4101 “上下”型字。
4102 4104
4105 (b)值得注意的是,有时候一个汉字被拆成的几个部分都是复笔字根(不是单笔画),它们之间4106 的关系,在“散”和“连”之间模棱两可。如:占:卜口两者按“散”处理,是上下型。只要不是单4107 笔画,一律按“能散不连”判别。因此,上例中的“占”被认为是“上下型”字。
4108
4109 4111
4112 (c)作为以上这些规定,是为了保证编码体系的严整性。实际上,用得上后三条规定的字只是4113 极少数。
4114 返回
4115
4116
4117
4118
4119
4120
4122 疯狂打字同v2.0
4123
4124
4125 Windows快捷键
4126 4127 巧妙地利用快捷键,可以大大加快我们操作电脑的速度。 4128 因此,研究并有针对性地记忆Windows下的快捷键对自己很有好4129 处!
4130 1.Win键
4131 4132 在现在的键盘的两边有一个标着Windows图标Windows键,简称为Win键。4133
4134 配合它能够快速打开一些非常实用的系统功能。 4135 供大家参考:
4136
Win F1 打开Windows的帮助文件 4137 Win F 打开Windows的查找文件窗口 4138 Win E 打开Windows的资源管理器 4139 Win Break 打开Windows的系统属性窗口
4140 Win M 最小化所有打开的Windows的窗口 4141 Win Shift M 恢复所有最小化的Windows的窗口 4142 Win U 打开Windows工具管理器 4143 Win Ctrl F 打开Windows查找计算机窗口 4144 Win D 快速显示/隐藏桌面
4145 Win R 打开运行对话框,重新开始一个Windows任务 4146 Win Tab 在目前打开的多个任务之间切换,按下回车键即变成当前任务4147
4148 Win Break 打开“系统属性”窗口 4149 注意:
4150
以上不包括被其它第三方软件重新定义了的Win键的功能。4151
4152 右边的Windows键的右侧的那个键叫Application键,它的作用很鲜为人4153 知,我们可以通过按下它来打开某一项目的快捷菜单,即相当于右击鼠标。4154
4155
4156 2.Windows中通用键
4157 按键操作
4158 Ctrl C 复制 4159 Delete 删除
4160
Ctrl Z 撤消
4161
Ctrl V 粘贴
4162
Ctrl X 剪切
4163
Shift Delete 永久删除所选项,而不将它放到“回收站”中4164
4165
拖动某一项时按 Ctrl 复制所选项。 4166
拖动某一项时按 Ctrl Shift 创建所选项目的快捷方式。4167
4168
F2 重新命名所选项目。
4169
Ctrl 向右键 将插入点移动到下一个单词的起始处。 4170
Ctrl 向左键 将插入点移动到前一个单词的起始处。 4171
Ctrl 向下键 将插入点移动到下一段落的起始处。 4172
Ctrl 向上键 将插入点移动到前一段落的起始处。 4173
Ctrl Shift 任何箭头键 突出显示一块文本。 4174
Shift 任何箭头键 在窗口或桌面上选择多项,或者选中文档中的文本。4175
4176
Ctrl A 选中全部内容。
4177
F3 搜索文件或文件夹。
4178
Ctrl O 打开某一项。
4179
Alt Enter 查看所选项目的属性。 4180
Aal F4 关闭当前项目或者退出当前程序。 4181
Ctrl F4 在允许同时打开多个文档的程序中关闭当前文档。4182
4183
Alt Tab 在打开的项目之间切换。
4184
Alt Esc 以项目打开的顺序循环切换。 4185
F6 在窗口或桌面上循环切换屏幕元素。 4186
F4 显示“我的电脑”和“Windows 资源管理器”中的“地址”栏列表。4187
4188
Shift F10 显示所选项目的快捷菜单 4189
ALT 空格键 显示当前窗口的“系统”菜单。 4190
Ctrl Esc 显示“开始”菜单。 4191
ALT 菜单名中带下划线的字母 显示相应的菜单 4192
在打开的菜单上显示的命令名称中带有下划线的字母 执行相应的命令。4193
4194
F10 激活当前程序中的菜单条。 4195
向右键 打开右边的下一菜单或者打开子菜单。 4196
向左键 打开左边的下一菜单或者关闭子菜单。 4197
F5 刷新当前窗口。
4198
退格键 在“我的电脑”或“Windows 资源管理器”中查看上一层文件夹。4199
4200
Esc 取消当前任务。
4201
将光盘插入到 CD-ROM 驱动器时按 Shift 键 阻止光盘自动播放。4202
4203
Ctrl Home 快速到达文件头或所在窗口头部 4204
Ctrl End 快速到达文件尾或所在窗口尾部 4205
Alt Enter 切换DOS窗口最大化和最小化 4206
4207
3.对话框快捷键
4208 按键操作
4209 Ctrl Tab 在选项卡之间向前移动4210
4211 Ctrl Shift Tab 在选项卡之间向后移动 4212
Tab 在选项之间向前移动
4213
Shift Tab 在选项之间向后移动 4214
Aal 带下划线的字母 执行相应的命令或选中相应的选项。4215
4216
Enter 执行活选项动或按钮所对应的命令。 4217
Spacebar 如果活选项动是复选框,则选中或清除该复选框。4218
4219
箭头键 活选项动是一组选项按钮时,请选中某个按钮。 4220
F1 显示帮助
4221
F4 显示当前列表中的项目。 4222
退格键 如果在“另存为”或“打开”对话框中选中了某个文件夹,则打开上一级4223 文件夹。
4224
4225
4.“资源管理器”快捷键
4226 按键操作
4227 END 显示当前窗口的底端。4228
4229 HOME 显示当前窗口的顶端。 4230
Num Lock 数字键盘的星号 (*) 显示所选文件夹的所有子文件夹。4231
4232
Num Lock 数字键盘的加号 ( ) 显示所选文件夹的内容。4233
4234
Num Lock 数字键盘的减号 (-) 折叠所选的文件夹 4235
向左键 当前所选项处于展开状态时折叠该项,或选定其父文件夹。4236
4237
向右键 当前所选项处于折叠状态时展开该项,或选定第一个子文件夹。4238
4239
4240
4244
4245
4246
4247
4248
4249
4250 4251
4252 疯狂打字同v2.0
4253
4254
4255 智能abc基本使用方法
4256 1.u―强制记忆词条输入
4257 强制记忆,一般用来定义那些较长或较常用4258 的词组。
4259 利用该功能,可以直接把新词加到用户库中。 4260
方法如下:
4261
打开智能ABC(如版本4.0),出现了智能ABC的输入法状态。4262
4263
鼠标移至输入法状态的框上,单击右键,出现一个菜单,选中“定义新词”。4264
4265
举例来讲,在“定义新词”对话框中的“新词”处输入“软件世界杂志社”,4266
4267 在外码处输入rj,按“添加”键,如果成功,新词就会出现在“新词一览表”中,最后按4268 “关闭”键。
4269
注意:外码最好简单一些,容易记忆。如本文中的rj,就是“软件世界杂志4270 社”ruanjian的拼音简称。
4271
在以后的使用过程中,只要键入urj,就会出现“软件世界杂志社”这几个字。4272
4273
注意:
4274 u是控制强制记忆的开关,实际中并不会显示出来。 4275
定义新词时,必须输入词条内容和外码两部分。 4276
新词处输入词条的内容,可以是汉字、词组或短语,也可以由汉字和其它的字符组4277 成;
4278
外码处输入可以是汉语拼音、外来语原文或者是使用者所喜欢的任意标记。4279
4280
允许定义的非
词最大长度为15字,输入码最大长度为九个字符;最大词条容4281 量为400条。
4282 你可以一次加入多个词条。特别是一些地名或是你的同学、同事的名字或是你家的4283 地址甚至电话号码,
4284 用强制记忆的方法将大大加快这些字的输入速度。 4285
不过,笔者发现如果输入的词条中有中文和数字混用的话,有可能顺序会变化。4286
4287
例如:在“定义新词”对话框中,“新词”处输入“北京3844信箱”,外码处输入xx,4288
4289 但当要用时,输入uxx,却出现了“北京市信箱3844”。 4290
要删除所定义的词的方法:把光标移动到“新词一览表”中,选中需要删除的词条4291 后,按下“删除”按钮。再按“关闭”。
4292
2.v―中文输入过程中的英文输入
4293 输入中文文章时,最怕其中有英文单词,新宋体
4294
4295 如果是一段文章也就算了,一个一个的单词最麻烦。 4296 实际上,你完全可以不必切换到英文方式。键入“v”作为标志符,后面跟随要输入4297 的英文,
4298 按空格键即可,英文字母就会出现,“v”本身并不会出现。 4299
例如:在输入过程中希望输入英文“sun”则只要输入:“vsun”,再按空格键即可。4300
4301
在这种方法中,直接输入大写字母无效,如果输入“vSun”,则还是显示sun。4302
4303
这个方法适合单个英文较多时用。
4304
3.i、I―中文数字的简化输入法
4305 智能ABC提供阿拉伯数字和中文大小写数字4306 的转换能力:
4307 “,”为输入小写中文数字的前导字符。 4308
“,”为输入大写中文数字的前导字符(注意此时的,用[Shift]+[I_键来控制)。4309
4310
输入“i1”,按空格(或回车键),将显示“一”; 4311
依次类推输入“i2000”,按空格,将显示“二???”。 4312
输入“I1”,按空格(或回车键),将显示“壹”; 4313
依次类推“I2000”,按空格,将显示“贰零零零”。 4314
对一些常用量词也可简化输入,输入“ig”,按空格(或回车键),将显示“个”;4315
4316
系统规定数字输入中字母的含义为:
4317
4318 g[个]、s [十,拾]、b[百,佰]、q[千,仟]、w[万]、e[亿]、z[兆]、d[第]、4319
4320
n[年]、y[月]、r[日]、t[吨]、k[克]、$[元]、h[时]、f[分]、l[里]、4321
4322
m[米]、j[斤]、o[度]、p[磅]、u[微]、i[毫]、a[秒]、c[厘]、x[升]4323
4324
26个英文字母中,输入“i”+除“v”字母外的其余字母,都有相应的中文量词可以4325 得到。
4326
4.把握按词输入的大体规律
4327 以下的27个单音节词,可以只输入声母(或4328 声母的最前的一个字母)就显示出来。
4329 如直接输入“a”,则显示“啊”。
4330
a b c d e f g 4331
4332
啊 不 才 的 饿 发 个
4333
h i j k l m n 4334
4335
和 一 就 可 了 没 年
4336
o p q r s t 4337
4338
哦 批 去 日 是 他
4339
w x y z 4340
我 小 有 在
4341
zh sh ch
4342
这 上 出
4343
5.[、]―以词定字
4344 无论是标准库中的词,还是用户自己定义的4345 词,都可以用来定字。
4346 用“[”取第一个字,“]”取最后一个字。 4347
例如:键入“shijie”,若直接按空格键,则可得到“世界”; 4348
键入“shijie”,若按“[”,再按空格键则得到“世”; 4349
键入“shijie”,若按“]”,再按空格键则得到“界”。 4350
6.《 》号的转变
4351 在输入过程中经常发现,要用《 》,时却4352 出现了〈 〉,要用〈 〉,
4353 却又出现了《 》,有时甚至不得不用“插入”菜单中的符号。 4354 实际上,书名号的输入键为[Shift]+[〈 ]和[ 〉]键。 4355
第一次按[Shift]+[〈 ]键时,对应的输出字符为《 ,再按[Shift]+[〈 ]时,4356 则出现〈 。
4357
此后如果输入的〈 与 〉能够匹配上,则再次输入 〉时,则出现 》。4358
4359
总之《 》、〈 〉一定是一对一对出现的。 4360
4364
4365
4366
4367
4368 疯狂打字通2.1 激4369 发你手指的灵感
4370
4371
4372
4417
4418
4419
4420
4421
4422
4423 指法
4424 4425
4426
4427
4428 4429 指 法
4430
4431 一、手指放在键盘上
4432
4433
4434 4435 如下图,手指放在八个基本键上,两个拇指轻放在空格键上。
4436
4437 4438 二、击4439 键要领
4440 1.手指弯曲要自然,4441 手臂不可张开太大
4442 2.手指击键要正确,击键有适当力度,击键之后要立即回到基准键上
4443
4444 3.空格键用大拇指负责击打
4445 4.击键有节奏,速度均匀,初学时尽量慢一点,关键是要用正确的指法
4446
4447 基准键的打法:4449 例如要击D键,方法是:1、提起4450 左手约离键盘两厘米;2、向下击键时中指向下弹击D键,其它手指同时稍向上弹开。其它键的
4451 击法与此类似,请多体会。形成正确的习惯很重要,而错误的习惯则很难改。
4452
4453
4454 非基准键的打法:例如要打E键,方法是:1、提起左手约离键盘两厘米;2、整个左手稍向前4455 移,同时用中指向下弹击E键,同一时间其它手指稍向上弹开,击键后四个手指迅速回位如上图,4456 注意右手不要动,其它键类似打法,注意体会。
4457 三、手指分工(如下图)
4459 4460 练习英文指法最好花上两三天时间(每天不少于4461 六小时,若少于此数则练习时间要增加)。
4462 请下决心一定要练到盲打的水平,并且每分钟正4463 确地击键不下150次。
4464
4465
4466
4467 /*
4468 * 创建日期 2007-4-19
4469 *
4470 * TODO 要更改此生成的文件的模板,请转至 4471 * 窗口 , 首选项 , Java , 代码样式 , 代码模板 4472 */
4473 package LanClient;
4474
import java.awt.Dimension;4475
4476 import java.awt.Toolkit;
4477
4478 import javax.swing.*;
4479 /**
4480 * @author Administrator
*4481
4482 * TODO 要更改此生成的类型注释的模板,请转至 4483 * 窗口 , 首选项 , Java , 代码样式 , 代码模板 4484 */
public class Client extends JFrame{4485
4486 public Client(){
4487 try {
4488 setUndecorated(true);
4489 setResizable(false);
4490
4491 //计算屏幕大小
Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();4492
4493
4494 //添加图标
4495 setIconImage(Toolkit.getDefaultToolkit().getImage("image/f.gif"));
4496
4497 setTitle("疯狂打字通v2.1--网络测试客户端"); 4498 setSize(screen.width,screen.height); 4499 setLocation((screen.width-getWidth())/2,(screen.height-getHeight())/2);
4500
4501 setVisible(true);
4502 } catch (Exception e) {
4503 e.printStackTrace();
4504 }
4505 }
4506 }
4507
4508 package Net;
4509
4510 import java.net.InetAddress;
4511
4512 public class NetTools {
4513
4514 public static String getLocalHostIP(){ 4515 String ip;
4516 try{
4517 InetAddress addr = InetAddress.getLocalHost();4518
4519 ip = addr.getHostAddress(); 4520 }catch(Exception ex){
4521 ip = "";
4522 }
4523 return ip;
4524 }
4525
4526 public static String getLocalHostName(){ 4527 String hostName;
4528 try{
4529 InetAddress addr = InetAddress.getLocalHost();4530
4531 hostName = addr.getHostName(); 4532 }catch(Exception ex){
4533 hostName = "";
4534 }
4535 return hostName;
4536 }
4537
4538 public static String[] getAllLocalHostIP(){
4539 String[] ret = null;
4540 try{
4541 String hostName = getLocalHostName(); 4542 if(hostName.length()>0){ 4543 InetAddress[] addrs = InetAddress.getAllByName(hostName);4544
4545 if(addrs.length>0){
4546 ret = new String[addrs.length]; 4547 for(int i=0 ; i< addrs.length ; i++){ 4548 ret[i] = addrs[i].getHostAddress();4549
4550 }
4551 }
4552 }
4553 }catch(Exception ex){
4554 ret = null;
4555 }
4556 return ret;
4557 }
4558
4559 public static String[] getAllHostIPByName(String hostName){
4560
4561 String[] ret = null;
4562 try{
4563 if(hostName.length()>0){ 4564 InetAddress[] addrs = InetAddress.getAllByName(hostName);4565
4566 if(addrs.length>0){
4567 ret = new String[addrs.length]; 4568 for(int i=0 ; i< addrs.length ; i++){ 4569 ret[i] = addrs[i].getHostAddress();4570
4571 }
4572 }
4573 }
4574 }catch(Exception ex){
4575 ret = null;
4576 }
4577 return ret;
4578 }
4579
4580 public static String getIP(){
4581 String[] localIP = getAllLocalHostIP(); 4582 String ip="";
4583 for(int i=0 ; i