Presentation is loading. Please wait.

Presentation is loading. Please wait.

Viewing HTML in Swing.

Similar presentations


Presentation on theme: "Viewing HTML in Swing."— Presentation transcript:

1 Viewing HTML in Swing

2 Homework Display a dialog box that warns the user if a mnemonic is duplicated in a RunMenu Look in the gui.run.RunMenu Its just a warning

3 Midterm write an addressbook using the gui.run components
You will need RunButton, RunMenuItem, RunTextField, RunTextArea, RunMenu Use Mnemonics and Keyboard accelerators

4 Look and feel

5 File Menu Open Save Exit
Use xml.adbk.Address for your address record. Use xml.adbk. AddressBook to store your address.

6 HW For next week Just build the GUI for the addressbook, you don’t have to make anything actually work. No event handling is needed for next week. You will need Run Method, but they will be empty

7 You will learn How to build an HTML viewer About MIME data types
How to synthesize HTML How to generate HTML forms

8 Network Layers physical – bits (sonet) data link layer – PPP (ATM)
Network layer – IP - routing transport layer - TCP session layer – login, creating a connection presentation layer – html /process data application layer - browser

9 How do I know my data type?
StreamSniffer! HTML – enables the decoding of data by using a special string “MIME” Multi-purpose Internet Mail Extension… RFC – 1521 “text/html” “image/gif” “text/rtf” The mime string is in the header! Filename suffix….not reliable.

10 What is an HTML viewer? An application that renders HTML to the screen
Build a help file for my address book program!

11 Why Render HTML? Process Data is decoded at the presentation layer.
Standard Markup language Enables creation of a browser Enables handy documentation viewer Debug of HTML generators Debug web servers

12 How Do I render HTML? gui.html.HtmlViewer renders some canned HTML

13 How does the HTML viewer work?
The heart of the HTML viewer: javax.swing.JEditorPane Embed an instance of the JEP in a javax.swing.JScrollPane jep.setContentType("text/html"); jep.setText(s);/// then just display!

14 Using MIME jep.setContentType("text/html");
sets the type of data in the JEP "text" indicates there is text in the string "html" indicates we have an HTML data type.

15 What is MIME? Multipurpose Internet Mail Extensions
It is a "string" with several predefined values.

16 Why do we have MIME? In the beginning MAIL was only ASCII text.
Somebody wanted BINARY data too. MTA = Mail Transfer Agents. MTA is a program that moves mail from one NODE to another. A node is just a computer than runs an MTA.

17 MIME identifies Data Types
Word documents are of a specific type! They present process data. GIF represents process data “sound/aiff” AU represents process data. “sound/au” There is not limit to the number of different data types. MIME is used to introduce the data types.

18 Examples of Mime "text/html" = html document "text/rtf" = word RTF
"sound/aiff" = audio interchange format "sound/au" = 8 bit voice grade format (SUN) ....Lots of others....All documented in an RFC1521

19 MIME is used for Mail Browsers use MIME (mapping to plugins or helper apps). JEditPanes "text/html", "text/plain", "text/rtf", "image/gif".

20 How do we generate HTML? "<html> <body> sdlkfdslfkj</body> </html>" Just type it in! Another way is to synthesize the HTML! Try to write a toolkit for HTML synthesis.

21 Using the HTML Synthesizer
public String getHtml(String s) { return "<html>\n" + s + "\n</html>"; } String s = getHtml("hello world"); s="<html>\n helloworld \n </html>";

22 Building a list public String getListItem(String s) {
return "<li>\n" + s + "\n</li>"; } s = getHtml(getListItem(li1)); <html>...<li> li1 <li> </html>....


Download ppt "Viewing HTML in Swing."

Similar presentations


Ads by Google