Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

java swing programming

Java programming, Java Swing Programming, SWING GUI Design, desktop application, Getting Started with Swing application development in java, Introduction to GUI based programming in java, Java to standard edition, J2SE, Core Java, Swing package in java

java swing programming

  1. 1. ADVANCE JAVA
  2. 2. ADVANCE JAVA Author Profile  Ankit Desai  Ph.D. Scholar, IET, Ahmedabad University  Education: M. Tech. (C.E.), B. E. (I. T.)  Experience: 8 years (Academic and Research)  Research Interest: IoT, Big Data Analytics, Machine Learning, Data Mining, Algorithms. Classified e-Material 2
  3. 3. Classified e-Material 3 Swing Features PasswordStore shows some of the rich functionality of a particular Swing application. This lesson discusses the general features available to applications using the Java SE platform and, in particular, the Swing toolkit.
  4. 4. Classified e-Material 4 Index  Swing Features 1. A Visual Guide to Swing Components (Java Look and Feel) 2. A Visual Guide to Swing Components (Windows Look and Feel) 3. Pluggable Look and Feel 4. Data Transfer 5. Internationalization and Localization 6. Accessibility 7. Integrating with the Desktop System Tray Icon Support
  5. 5. Classified e-Material 5 Swing Features  1. A Visual Guide to Swing Components (Java Look and Feel)  Swing is primarily known for its rich set of GUI components. This section provides a visual menu of Swing's components, grouped by type, using the Java look and feel.
  6. 6. Classified e-Material 6 Swing Features  2. A Visual Guide to Swing Components (Windows Look and Feel)  This section shows the same components, using the Windows look and feel.
  7. 7. Classified e-Material 7 A Visual Guide to Swing Components (Java Look and Feel v/s Windows Look and Feel)
  8. 8. Classified e-Material 8 Basic Controls  Simple components that are used primarily to get input from the user; they may also show simple state.
  9. 9. Classified e-Material 9 JAVA Look v/s Windows Look JAVA Look Windows Look JButton JCheckBox JComboBox JList
  10. 10. Classified e-Material 10 JAVA Look v/s Windows Look JAVA Look Windows Look JMenu JRadioButton JSpinner
  11. 11. Classified e-Material 11 JAVA Look v/s Windows Look JAVA Look Windows Look JPasswordField JSlider JTextField
  12. 12. Classified e-Material 12 Interactive Displays of Highly Formatted Information  These components display highly formatted information that (if you choose) can be modified by the user.
  13. 13. Classified e-Material 13 JAVA Look Windows Look JColorChooser JAVA Look v/s Windows Look
  14. 14. Classified e-Material 14 JAVA Look v/s Windows Look JAVA Look Windows Look JFileChooser JTable
  15. 15. Classified e-Material 15 JAVA Look Windows Look JTextArea JEditorPane and JTextPane
  16. 16. Classified e-Material 16 JAVA Look Windows Look JTree
  17. 17. Classified e-Material 17 Uneditable Information Displays  These components exist solely to give the user information.
  18. 18. Classified e-Material 18 JAVA Look Windows Look JSeparator JProgressBar JLabel JToolTip
  19. 19. Classified e-Material 19 Top-Level Containers  At least one of these components must be present in any Swing application.
  20. 20. Classified e-Material 20 JAVA Look Windows Look JFrame JDialog JApplet
  21. 21. Classified e-Material 21 General-Purpose Containers  These general-purpose containers are used in most Swing applications.
  22. 22. Classified e-Material 22 JAVA Look Windows Look JSplitPane JTabbedPane
  23. 23. Classified e-Material 23 JAVA Look Windows Look JScrollPane JPanel JToolBar
  24. 24. Classified e-Material 24 Special-Purpose Containers  These special-purpose containers play specific roles in the UI.
  25. 25. Classified e-Material 25 JAVA Look Windows Look JLayeredPanel JInternalFrame
  26. 26. Classified e-Material 26 JAVA Look Windows Look Root panel
  27. 27. Classified e-Material 27 Swing Features  3. Pluggable Look and Feel  The pluggable look and feel architecture allows a program to have control over its appearance. This section describes what options are available to the programmer.
  28. 28. Classified e-Material 28 Pluggable Look and Feel  The Swing toolkit allows you to decide how to configure the particular look and feel of your application. If you don't specify a look and feel, the Swing UI manager figures out which one to use.
  29. 29. Classified e-Material 29 Java look and feel
  30. 30. Classified e-Material 30 Windows look and feel
  31. 31. Classified e-Material 31 CDE/Motif look and feel
  32. 32. Classified e-Material 32 Default Alloy look and feel
  33. 33. Classified e-Material 33 Synthetica look and feel
  34. 34. Classified e-Material 34 Swing Features  4. Data Transfer  Most programs will want to use drag and drop or cut, copy and paste. This section talks a bit about data transfer and what is implemented for you.
  35. 35. Classified e-Material 35 Drag and Drop  Drag-and-drop support can be easily enabled for many of Swing's components (sometimes with a single line of code). For example, it's trivial to enable drag and drop and copy and paste support for JTable, Swing's table component. All you need to provide is the data representing the selection and how to get your data from the clipboard — that's it!
  36. 36. Classified e-Material 36 Cut, Copy, and Paste  Most of the text-based components, such as editor pane and text field, support cut/copy and paste out of the box. Of course, menu items need to be created and "wired up" to the appropriate actions. Other components, such as list and tree, can support cut, copy, and paste with some minimal work.
  37. 37. Classified e-Material 37 Swing Features  5. Internationalization and Localization  Internationalizing an application makes it easy to tailor it to the customs and languages of end users around the world. This section describes the difference between internationalization and localization.
  38. 38. Classified e-Material 38 Internationalization vs Localization  Internationalization is the process of designing an application so that the user can run it using his or her cultural preferences without modifying or recompiling the code.  Localization is the process of translating the text to a particular language and adding any locale-specific components.
  39. 39. Classified e-Material 39 PasswordStore in Japanese PasswordStore in Arabic
  40. 40. Classified e-Material 40 Swing Features  6. Accessibility  Making your program accessible means that it can be used, without modification, by anyone with permanent or temporary disabilities who may require special devices. And, in many countries, making programs accessible is the law.
  41. 41. Classified e-Material 41 Accessibility  The PasswordStore demo follows the rules set out for accessibility. In the following figure, you can see an example of tool tip text. PasswordStore With a Tooltip
  42. 42. Classified e-Material 42 Swing Features  7. Integrating with the Desktop  An application that is well integrated with the desktop will, where appropriate, allow the user to launch the default mail application or internet browser, pre-populating text fields as needed. It will also allow the user to launch another application to open, edit or print a file associated with that application.
  43. 43. Classified e-Material 43 Types  Three types of integration are supported:  Default browser with a specific Uniform Resource Identifier (URI).  Default email client.  Applications to open, edit, or print files associated with those applications.
  44. 44. Classified e-Material 44 Example  Click on the link that is displayed in the text pane — it opens the specified URI in the default browser. Click on the URI and it opens in the Default Browser
  45. 45. Classified e-Material 45 Swing Features  8. System Tray Icon Support  Some platforms, such as Microsoft Windows, feature a system tray on the desktop. As of version 6 of the Java SE, your application can now add a tray icon to the system tray.
  46. 46. Classified e-Material 46 Snap Shot  The desktop of some platforms, such as Microsoft Windows, includes a system tray, as shown in the following screenshot:
  47. 47. Classified e-Material 47 Questions  Questions and Exercises: Graphical User Interfaces  1. Does Swing support multiple look and feels?  2. True or False: The Java look and feel is the only look and feel that works across all platforms.  3. True or False: Swing's Undo Framework supports an unlimited number of actions to undo (and redo).  4. Can Swing's list component (JList) only display text?  5. Which Swing component provides undo support out of the box?  6. Can Java applications interact with the native desktop? components.  7. Can I deploy my Swing application on the web?
  48. 48. Classified e-Material 48 Answers to Questions and Exercises: Graphical User Interfaces  1. Does Swing support multiple look and feels? Yes. Sun provides implementations for the GTK+ look and feel, Windows look and feel, CDE/Motif look and feel, Synth (a customizable look and feel), and two variants of the Java look and feel.  2. True or False: The Java look and feel is the only look and feel that works across all platforms.  True. The Java look and feel (also called Metal) comes in two themes. Previous to the 5.0 release, the theme was called Steel. The theme for 5.0 and beyond, is called Ocean.
  49. 49. Classified e-Material 49  3. True or False: Swing's Undo Framework supports an unlimited number of actions to undo (and redo).  True. Undo support is built-in to Swing's text component and can be added to other components.  4. Can Swing's list component (JList) only display text?  No, as the demo illustrated you can display anything you want in a JList, including rich graphics.  5. Which Swing component provides undo support out of the box?  Swing's text components.
  50. 50. Classified e-Material 50  6. Can Java applications interact with the native desktop? components.  Certainly, the Desktop API allows you to open up the browser and various other services and the TrayIcon API allows you to put a Swing component into the desktop tray.  7. Can I deploy my Swing application on the web?  Certainly. You can use either Java Web Start or Java Plugin.

×