1 / 16

XML, HTML & Swing An Overview

XML, HTML & Swing An Overview. Inf 141 Information Retrieval Winter 2007. XML. General purpose mark-up language Extensible because it allows users to define their own elements Example: <start></start> Follows a tree-like structure Must have exactly one root element. XML.

dunnt
Download Presentation

XML, HTML & Swing An Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML, HTML & Swing An Overview Inf 141 Information Retrieval Winter 2007

  2. XML • General purpose mark-up language • Extensible because it allows users to define their own elements • Example: <start></start> • Follows a tree-like structure • Must have exactly one root element

  3. XML • Levels of correctness • Well-formed: if u start with a statement you must end with a statement or it will not be parsed • Example: <start> blah blah blah </start> • Element names are case sensitive • <start /> • Valid: conforms to semantic rules (either user defined or schema included) • Example: if a document contains an undefined element, then it is not valid and will not be parsed

  4. HTML • Predominant markup language for web pages. • It provides a means to describe the structure of text-based information in a document — by denoting certain text as headings, paragraphs, lists, and so on — and to supplement that text with interactive forms, embedded images, and other objects.

  5. HTML • Elements are the basic structure • Properties: • Attributes – contained in the start label • <font size = “8”></font> • Content - located between the labels • <p> hello </p> • Types of markup • Structural: describes purpose; most browsers have formatting standards • Example: • <h2></h2> • Presentational: describes appearance • Example: • <strong> bold </strong> • <em> italics </em> • Hypertext: links to other documents or pages • Example: • <a href="http://en.wikipedia.org/">Wikipedia</a> • Stylesheets may be created and accessed to maintain formatting across pages

  6. HTML • Must start with a document type which determines which rendering mode to use • HTML documents transmitted from a web server to a web browser for viewing

  7. Swing • GUIs are layed out as trees • There is a toplevel container, usually a window • Inside this are multiple panels (often invisible), used to control layout • Swing: Java’s GUI programming toolkit

  8. Swing

  9. Common Swing Widgets • JFrames, JPanels • Layout Managers • JLists • JButtons • JLabels, JTextFields, JTextAreas

  10. Swing: JFrames and JPanels • JFrames are top-level windows • JPanels allow grouping of other widgets • Each JFrame has a panel into which the frame’s contents must go: the contentPane • window = swing.JFrame(”FrameDemo”) • window.contentPane.add(new JButton()) • You must pack and show a JFrame to display it • window.pack() • window.show()

  11. Swing: Layout Managers • Layout Managers control the placement of widgets in a JPanel • Simplest by far: awt.BorderLayout • window.contentPane.layout = awt.BorderLayout() • window.contentPane.add(”Center”, swing.JButton(”Button 2 (CENTER)”)) • Five regions: • North, South: expand horizontally • East, West: expand vertically • Center: expands in both directions

  12. Swing: JLists • JLists are collections of widgets • list = swing.JList() • Put JLists in a JScrollPane to make them scrollable • window.contentPane.add(swing.JScrollPane(list)) • JLists contain a listData member with the contents • list.listData = [’January’, ‘February’, ‘March’, ...] • selectedValue contains the selected item! • >>> print list.selectedValue • ‘March’

  13. Swing: JButtons • JButtons have many fancy features... • Images, labels, tooltips, etc. • Basic use is very simple: • Supply a label when you construct the button • button = swing.JButton(”This is my label!”) • Provide a function to use as a callback • button.actionPerformed = someCallback

  14. Swing: JTextFields, JTextAreas, and JLabels • JLabels are the world’s simplest widgets • years = swing.JLabel(”Years”) • JTextFields are used for single-line text entry • yearValue = swing.JTextField() • print yearValue.text • JTextAreas are used for longer pieces of text • area = swing.JTextArea(24, 80)

  15. Resources • XML: • Wikipedia • Tutorial: http://www.w3schools.com/xml/default.asp • inside out: http://www.xml.com/ • HTML: • Wikipedia • Tutorial: http://www.w3schools.com/html/default.asp • Swing: • Wikipedia • JComponent Class: http://java.sun.com/docs/books/tutorial/uiswing/components/jcomponent.html

  16. Questions ?

More Related