JavaSwing-CarnegieMellonSchoolofComputerScience.ppt

上传人:ga****84 文档编号:316503 上传时间:2018-09-21 格式:PPT 页数:20 大小:846.50KB
下载 相关 举报
JavaSwing-CarnegieMellonSchoolofComputerScience.ppt_第1页
第1页 / 共20页
JavaSwing-CarnegieMellonSchoolofComputerScience.ppt_第2页
第2页 / 共20页
JavaSwing-CarnegieMellonSchoolofComputerScience.ppt_第3页
第3页 / 共20页
JavaSwing-CarnegieMellonSchoolofComputerScience.ppt_第4页
第4页 / 共20页
JavaSwing-CarnegieMellonSchoolofComputerScience.ppt_第5页
第5页 / 共20页
点击查看更多>>
资源描述

1、Java Swing,Joon Ho Cho,What is Java Swing?,Part of the Java Foundation Classes (JFC)Provides a rich set of GUI componentsUsed to create a Java program with a graphical user interface (GUI)table controls, list controls, tree controls, buttons, and labels, and so on,What features are available?,GUI co

2、mponents like button, checkbox, and so onJava 2D API: images, figures, animation Pluggable look and feel: use samples or create your ownData Transfer: cut, copy, paste, drag & dropInternationalization: supports different input language, right to left readingAccessibility API: for people with disabil

3、itiesUndo Framework API: supports unlimited numbers of actions to undo and redoFlexible Deployment: run within a browser as an applet or Java Web Start,How does HelloWorld look like?,import javax.swing.*; public class HelloWorldSwing private static void createAndShowGUI() /Create and set up the wind

4、ow. JFrame frame = new JFrame(HelloWorldSwing); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /Add the ubiquitous Hello World label. JLabel label = new JLabel(Hello World); frame.getContentPane().add(label); /Display the window. frame.pack(); frame.setVisible(true); public static void main(S

5、tring args) /Schedule a job for the event-dispatching thread: /creating and showing this applications GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() public void run() createAndShowGUI(); ); ,Who are users?,Since we are evaluating user interface toolkit itself, in this case Java Swing, us

6、ers will be software developers, not software usersI believe that most Java developers use Eclipse as their developing platform so we will evaluate Java Swing with Eclipse based on ten usability heuristics by Jakob Nielson,1. Visibility of system status,This may be a strong advantage of Java Swing o

7、ver other UI toolkits, not because of Java Swing itself is great, but because Eclipse provides such sophisticated checking on what is going on nowConstantly checks for syntax errorsLists available methods or variables when press . (dot)However, you dont have synchronous result viewYou will have to r

8、un it in order to see the status of your program,2. Match between system and the real world,First of all, it is JavaIt follows Java conventionIt consists of 18 public packages of Java classesIts classes and methods are reasonably namedUnless you are the first time programmer, you dont have to worry

9、about its syntax or conventionJLabel developerNameLabel = new javax.swing.JLabel();developerNameLabel.setFont(new java.awt.Font(Arial, 0, 14);developerNameLabel.setForeground(new java.awt.Color(255, 255, 255);,3. User control and freedom,Eclipse supports strong undo and redo featuresYou cant possibl

10、y go wrong and have to rewrite every codeYou can always fix it even though it may take you some effort and timeJava Swing also provides undo and redo packagejavax.swing.event.UndoableEditEvent;javax.swing.event.UndoableEditListener;javax.swing.undo.UndoableEdit;,4. Consistency and standards,Similar

11、to #2Java Swing follows Java conventionPackages, classes, methods, parameters, variablesMainly constructor, getter, setter,5. Error prevention,First of all, Java is a strongly typed language: primitives and objectsEclipse checks for syntax and type errors continuouslyIt gives red underline to errors

12、 and small red box to let you know which line in document it is locatedIf you move your mouse over the error, then it suggests possible solutions to the errorIf you think one of the suggestions is a solution, then simply click on it to apply itOf course, it wont compile and run until you fix all the

13、 syntax errorsHowever, you dont have any idea about runtime errors except that you will have to run it and find out,6. Recognition rather than recall,Its a programming language, so its better and faster for you if you memorize names and their functions of classes or methodsHowever, whenever you pres

14、s dot after name of package, class, or object, then eclipse provides you a list of all possible subclasses, functions and variablesIf you move your mouse over almost anything, then eclipse provides you with a text document associated with it, usually javadoc, or you can click on it and it directs yo

15、u to online javadoc pageYou dont have a help of graphical interface to develop a graphical interface, so it maybe a disadvantage of Java Swing with eclipse.By the way, you can have a graphical interface if you use NetBeans IDE instead of eclipse,7. Flexibility and efficiency of use,Swing includes ma

16、ny basic components as a package, so it is efficient to use themAt the same time, you can create almost anything you want as combination of those components and some pure coding in JavaJava have had a reputation for being slower and requiring more memory than those written in natively compiled langu

17、ages such as C or C+However, the performance heavily depends on how you optimize your codes and which components of UI you use the most frequentlyIt may be subsequently slower or faster,8. Aesthetic and minimalist design,Swing is designed in a way that it provides a set of lightweight (all-Java lang

18、uage) components that, to the maximum degree possible, work the same on all platformsIt includes almost only and all components we could find around any software with user interfaceYet, it gives developers varieties to customize those components,9. Help users recognize, diagnose, and recover from er

19、rors,Syntax and type checking errors are already covered previouslyJava shows where in the code runtime errors (exceptions) are caused, specifying line numbers and brief reason for error on the console of eclipseIts not always right, but most of the times it is rightIts relatively easy to find the c

20、ause of the error and debug it comparing to other languages I have experienced with,10. Help and documentation,JavadocEclipses support for javadoc (already covered),Conclusion,Java Swing is easier to learn than others because its JavaYou can use any helpful tools out there that are for Java development like eclipse IDE, NetBeans IDELacks live graphical and interactive help while developingHas unlimited possibilities depending on how you implement your software,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 重点行业资料库 > 1

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。