CIS3931 - Intro to JAVA Lecture Notes Set 13 19-July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,

Slides:



Advertisements
Similar presentations
How To Make Your Own Web Page: Basic Web Design
Advertisements

JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
HTML.
The Web Warrior Guide to Web Design Technologies
TEA/TUG + ALDOT(Mobile) = H(O+I) The TEA/TUG being hosted by ALDOT in Mobile causes Hurricanes to come to Alabama. The TEA/TUG being hosted by ALDOT in.
SAKAI TUTORIAL Getting Started. Sakai is the new Learning Management System for Bethel University. It provides online classes in a format that is easy.
CIS101 Introduction to Computing Week 12. Agenda Your questions Solutions to practice text Final HTML/JavaScript Project Copy and paste assignment JavaScript:
JEditorPane Chapter 18 - Student. (c) 2005 by Elizabeth Sugar Boese JEditorPane creation Declare a JEditorPane component. JEditorPane pane; Check to see.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Introduction to Java A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
Python and Web Programming
COMP 110 Introduction to Programming Mr. Joshua Stough August 22, 2007 Monday/Wednesday/Friday 3:00-4:15 Gardner Hall 307.
CIS101 Introduction to Computing Week 12 Spring 2004.
Introduction to JavaScript for Python Programmers
Education Google Calendar (GCal) English. Education Upon completion of this course, you will be able to:  Navigate the GCal interface  Search your calendar.
Building a Web Browser CS1316: Representing Structure and Behavior.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Novus HR Application Review Process Human Resources Qualifying Applications HR Sending Applications to Department/Search CommitteeHR Sending Applications.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
ACM Web Development Workshop - PHP By Luis Torres.
Lab Assignment 7 | Web Forms and Manipulating Strings Interactive Features Added In this assignment you will continue the design and implementation of.
MIS 3200 – Unit 6.2 Learning Objectives How to move data between pages – Using Query Strings How to control errors on web pages – Using Try-catch.
JavaScript & jQuery the missing manual Chapter 11
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Adding Content To Your Faculty Page 1.Login 2.Create your Faculty Page 3.
Welcome to CS 3260 Dennis A. Fairclough. Overview Course Canvas Web Site Course Materials Lab Assignments Homework Grading Exams Withdrawing from Class.
MySQL + PHP.  Introduction Before you actually start building your database scripts, you must have a database to place information into and read it from.
So – You want to learn how to put an article onto the state website. (Note: If you have not done so, you will need to review the web training provided.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
Faculty Webpage Design Minimum Requirements. Go to: then High Schoolhttp://gcsc.groupfusion.net/
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
HTML Concepts and Techniques Fifth Edition Chapter 6 Using Frames in a Web Site.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
Diagnostic Pathfinder for Instructors. Diagnostic Pathfinder Local File vs. Database Normal operations Expert operations Admin operations.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
CIS Intro to JAVA Lecture Notes Set June-05 GUI Programming – Assignment 5 Notes.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Testing External Survey Automatic Credit Granting Shepherd University Department of Psychology.
Creating a GUI Class An example of class design using inheritance and interfaces.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
PHP Form Processing * referenced from
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Revised June 2008 Online PD Basic HTML1 Let’s Try It!  Open Notepad oStart > All Programs > Accessories > Notepad oDon’t get WordPad by mistake – won’t.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Intro to Google Docs 2014.
Advanced HTML Tags:.
Adding a File to a Course
Adding Assignments and Learning Units to Your TSS Course
Cookies BIS1523 – Lecture 23.
String Output ICS 111: Introduction to Computer Science I
In Class Program: Today in History
Building Web Applications
About Everything You Always Wanted to Know
Review of Previous Lesson
Intro to Programming (in JavaScript)
Presentation transcript:

CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane, JAR Files

Reminder… As stated in the syllabus, you must pass the final in order to pass the class. Anyone who receives below a 70 on the final will fail the class regardless of how high your other grades are. The majority of the final will be repeated questions from Midterm 1 and 2. There will only be a few new questions from the material we have covered since Midterm 2. A review for the final will take place on the 2 nd of August.

Reminder… Additionally, some review material will be posted online. Specifically, I will list the things that you will need to know for the final. As with Midterm 1 and 2, there will be extra credit available. It will be very similar to the extra credit that was given on Midterm 2.

Reminder… If there are any problems with your grades, you need to let me know immediately. Grades will be submitted the Monday after the last week of class. No grade changes will be permitted after this date.

Reminder … If you would like to see a copy of your Midterm 1 or Midterm 2, please stop by my office. It is recommended that you call before you come over to be sure that I am in the office ( ) –This is a community office number … please ask for Bobby when you call …

Adding actions to a TextField When creating the webbrowser, you need to tell your program to “load” whatever is in the textfield for your URL. Assign listener to the text field so when the user hits “return”, the textfield performs an action.

Adding actions to a TextField //First, create the textField JTextfield sampleTextField = new JTextField(“Enter text here”); //Assign an action listener to the textfield sampleTextField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { //PUT YOUR ACTION CODE HERE } }});

Adding actions to a TextField Example : Creating a TextField that will allow the user to change the text displayed in an JEditorPane See textaction.java

Turning a JEditorPane into an HTML viewer JEditorPane has a method called setPage (String s) setPage will load an HTML page into the editor pane Pass the string containing the URL into the setPage method Since you are dealing with I/O (loading a page from the internet uses an input stream), you need to handle I/O errors by using a try/catch block.

Example method for loading a URL public void showURL(String urlString) { try { //Try to load the webpage samplePane.setPage(urlString); } catch (Exception exception) { //If there is an error, inform the user //by placing text on the EditorPane samplePane.setText("Couldn't open the url : " + urlString + " Reason for error : " + exception); }

Using the showURL method showURL takes in a String as its parameter. It doesn’t return anything. showURL is a very primitive way to load a URL … you will need to expand upon it slightly when using it for your web browser. See htmleditorpane.java for example Note : This example only loads into the JEditorPane. Notice that the links on google’s page won’t work. Making links work will come later in the slides.

Making the links work… As with everything in JAVA, there needs to be an action listener associated with the links on webpages in order to get them to work. Luckily we don’t have to write an action listener for every link on every page (which would be impossible…) Simply assign a “catch all” action listener to the JEditorPane to load pages when a the use clicks on the link… Special actionListener called “HyperlinkListener” exists to handle such a request …

Making the links work … the HyperlinkListener //Assuming the JEditorPane is called samplePane samplePane.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent event) { //Check to see if the user clicked on a link if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { //Call our showURL function //event.getURL() gets the URL from the link showURL("" + event.getURL()); } });

The back and forward buttons Count as 10 (of 100) points for Program 6. The back and forward buttons are not easy to make … If you have trouble with the buttons, just do one of the extra credit things instead

Creating the back and forward buttons Can be done with an array Store each page you visit in the array while keeping track of your “index” position in the array. Hitting the forward button should load the next URL in the array (and increment your current index position by 1) Hitting back button should should load the previous URL in the array (and decrement your current index position by 1)

Creating the back and forward buttons Check for duplicate URLs being added in a row (example : hitting the “home” button 3 times in a row should not add the home URL three times in a row to the array) Make sure you are checking and adding to the array EVERY TIME you click on a link or load a URL from the textfield

JAR Files JAVA Archive files – similar to the UNIX TAR file (… actually, the exact same format). Used to contain multiple JAVA source and class files in one file Can be used to create a packaged “executable” version of your program –Note : The computer executing the JAR file will still need to have the JRE (JAVA Runtime Environment) or the SDK (Software Development Kit) installed

JAR Files Must create a “Manifest” file Manifest file tells JAVA which class file inside of your JAR file should be executed The format of the manifest file is very strict

Manifest File If your JAVA file was called Program6.java, your main class file would be called Program6.class The associated manifest file would be : Main-Class: Program6 It is very important that you hit the carriage return at the end of the line!!! (don’t type the word “carriage return” … this simple means to hit “enter” on the keyboard)

JAR Files When your JAR file doesn’t work, 9 out of 10 times there is a problem with your manifest file Delete your manifest file and try again … You can name your manifest file whatever you want … I usually use manifest.txt

Creating the JAR file See ml for detailed step-by-step instructions. ml

Thursday’s class… Turning a JAVA program into a web- viewable applet A few more notes on program 6 Notes on the “protected”, “private”, “public”, “static”, and “final” modifiers.