Java Tomcat Application Hosting Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting

Alden Hosting provides professional, efficient, and reliable business-class Web hosting services to small- and medium-sized businesses.

WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

Java Tomcat Application Hosting Welcome Java Tomcat Application Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting Java Tomcat Application Hosting Fund Raising, Fundraising, web hosting Java Tomcat Application Hosting Resellers, web Hosting Java Tomcat Application Hosting Web Design, web Hosting Java Tomcat Application Hosting Extra Services,  web Hosting Java Tomcat Application Hosting Traffic Booster, web hosting Java Tomcat Application Hosting Traffic Booster, web hosting Java Tomcat Application Hosting Technical Support,  web Hosting Java Tomcat Application Hosting webmaster tips,  web Hosting Java Tomcat Application Hosting 30 Day Money Back, web hosting Java Tomcat Application Hosting Legal Notices for Web Hosting Java Tomcat Application Hosting Glossary Computer Terms for web Hosting Java Tomcat Application Hosting Contact Information - web hosting

Site Map

  Java Tomcat Application Hosting Web Hosting Sign-Up   Java Tomcat Application Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting    Java Tomcat Application Hosting Resellers web hosting, website hosting, web site hosting   Java Tomcat Application Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting

JAVA, JSP, SERVLETS, TOMCAT, SERVLETS MANAGER,
Private JVM (Java Virtual Machine),
Private Tomcat Server

Alden Hosting offers private JVM (Java Virtual Machine), Java Server Pages (JSP), Servlets, and Servlets Manager with our Web Hosting Plans WEB 4 PLAN and WEB 5 PLAN , WEB 6 PLAN .

At Alden Hosting we eat and breathe Java! We are the industry leader in providing affordable, quality and efficient Java web hosting in the shared hosting marketplace. All our sites run on our Java hosing platform configured for optimum performance using Java 1.6, Tomcat 6.0.X, MySQL 5.0.x, Apache 2.2.xx and web application frameworks such as Struts, Hibernate, Cocoon, Ant, etc.

We offer only one type of Java hosting - Private Tomcat. Hosting accounts on the Private Tomcat environment get their very own Tomcat server. You can start and re-start your entire Tomcat server yourself.


How to Write a Document Listener (The Java™ Tutorials > Creating a GUI with JFC/Swing > Writing Event Listeners)
Trail: Creating a GUI with JFC/Swing
Lesson: Writing Event Listeners
Section: Implementing Listeners for Commonly Handled Events
Home Page > Creating a GUI with JFC/Swing > Writing Event Listeners
How to Write a Document Listener
A Swing text component uses a Document to represent its content. Document events occur when the content of a document changes in any way. You attach a document listener to a text component's document, rather than to the text component itself. See Implementing a Document Filterfor more information.

The following example demonstrates document events on two plain text components.

This screenshot demonstrates the output of DocumentEventDemo example.


Try this: 
  1. Click the Launch button to run DocumentEventDemo using Java™ Web Start (download JDK 6). Alternatively, to compile and run the example yourself, consult the example index.
    Launches the DocumentEventDemo example
  2. Type in the text field at the upper left of the window or the text area beneath the text field.
    One document event is fired for each character typed.
  3. Delete text with the backspace key.
    One document event is fired for each backspace key typed.
  4. Select text and then delete it by typing backspace or by using a keyboard command such as CTRL-X (cut).
    One document event is fired for the entire deletion.
  5. Copy text from one text component into the other using keyboard commands such as CTRL-C (copy) and CTRL-V (paste).
    One document event is fired for the entire paste operation regardless of the length of the text pasted. If text is selected in the target text component before the paste command is issued, an additional document event is fired because the selected text is deleted first.

You can find the demo's code in DocumentEventDemo.java. Here is the demo's document event handling code:

public class DocumentEventDemo ... {
    ...//where initialization occurs:
    textField = new JTextField(20);
    textField.addActionListener(new MyTextActionListener());
    textField.getDocument().addDocumentListener(new MyDocumentListener());
    textField.getDocument().putProperty("name", "Text Field");

    textArea = new JTextArea();
    textArea.getDocument().addDocumentListener(new MyDocumentListener());
    textArea.getDocument().putProperty("name", "Text Area");
    ...

class MyDocumentListener implements DocumentListener {
    String newline = "\n";
 
    public void insertUpdate(DocumentEvent e) {
        updateLog(e, "inserted into");
    }
    public void removeUpdate(DocumentEvent e) {
        updateLog(e, "removed from");
    }
    public void changedUpdate(DocumentEvent e) {
        //Plain text components do not fire these events
    }

    public void updateLog(DocumentEvent e, String action) {
        Document doc = (Document)e.getDocument();
        int changeLength = e.getLength();
        displayArea.append(
            changeLength + " character" +
            ((changeLength == 1) ? " " : "s ") +
            action + doc.getProperty("name") + "." + newline +
            "  Text length = " + doc.getLength() + newline);
    }
}
Document listeners should not modify the contents of the document; The change is already complete by the time the listener is notified of the change. Instead, write a custom document that overrides the insertString or remove methods, or both. See Listening for Changes on a Document for details.

The Document Listener API

The DocumentListener Interface

DocumentListener has no adapter class.
Method Purpose
changedUpdate(DocumentEvent) Called when the style of some of the text in the listened-to document changes. This sort of event is fired only from a StyledDocument — a PlainDocument does not fire these events.
insertUpdate(DocumentEvent) Called when text is inserted into the listened-to document.
removeUpdate(DocumentEvent) Called when text is removed from the listened-to document.

The DocumentEvent Interface

Each document event method is passed an object that implements the DocumentEvent interface. Typically, this is an instance of DefaultDocumentEvent, defined in AbstractDocument.
Method Purpose
Document getDocument() Returns the document that fired the event. Note that the DocumentEvent interface does not inherit from EventObject. Therefore, it does not inherit the getSource method.
int getLength() Returns the length of the change.
int getOffset() Returns the location within the document of the first character changed.
ElementChange getChange(Element) Returns details about what elements in the document have changed and how. ElementChange is an interface defined within the DocumentEvent interface.
EventType getType() Returns the type of change that occurred. EventType is a class defined within the DocumentEvent interface that enumerates the possible changes that can occur on a document: insert text, remove text, and change text style.

Examples that Use Document Listeners

The following table lists the examples that use document listeners.

Example Where Described Notes
DocumentEventDemo This section Reports all document events that occur on the documents for both a text field and a text area. One listener listens to both text components and uses a client property on the document to determine which component fired the event.
TextComponentDemo Listening for Changes on a Document Updates a change log every time text in the listened-to document changes. The document in this example supports styled text, so changedUpdate gets called in this example. Requires this additional source file: DocumentSizeFilter

Previous page: How to Write a Container Listener
Next page: How to Write a Focus Listener

JAVA, JSP, SERVLETS, TOMCAT, SERVLETS MANAGER,
Private JVM (Java Virtual Machine),
Private Tomcat Server

Alden Hosting offers private JVM (Java Virtual Machine), Java Server Pages (JSP), Servlets, and Servlets Manager with our Web Hosting Plans WEB 4 PLAN and WEB 5 PLAN , WEB 6 PLAN .

At Alden Hosting we eat and breathe Java! We are the industry leader in providing affordable, quality and efficient Java web hosting in the shared hosting marketplace. All our sites run on our Java hosing platform configured for optimum performance using Java 1.6, Tomcat 6.0.X, MySQL 5.0.x, Apache 2.2.xx and web application frameworks such as Struts, Hibernate, Cocoon, Ant, etc.

We offer only one type of Java hosting - Private Tomcat. Hosting accounts on the Private Tomcat environment get their very own Tomcat server. You can start and re-start your entire Tomcat server yourself.


Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

http://alden-servlet-Hosting.com
JSP at alden-servlet-Hosting.com
Servlets at alden-servlet-Hosting.com
Servlet at alden-servlet-Hosting.com
Tomcat at alden-servlet-Hosting.com
MySQL at alden-servlet-Hosting.com
Java at alden-servlet-Hosting.com
sFTP at alden-servlet-Hosting.com
http://alden-tomcat-Hosting.com
JSP at alden-tomcat-Hosting.com
Servlets at alden-tomcat-Hosting.com
Servlet at alden-tomcat-Hosting.com
Tomcat at alden-tomcat-Hosting.com
MySQL at alden-tomcat-Hosting.com
Java at alden-tomcat-Hosting.com
sFTP at alden-tomcat-Hosting.com
http://alden-sftp-Hosting.com
JSP at alden-sftp-Hosting.com
Servlets at alden-sftp-Hosting.com
Servlet at alden-sftp-Hosting.com
Tomcat at alden-sftp-Hosting.com
MySQL at alden-sftp-Hosting.com
Java at alden-sftp-Hosting.com
sFTP at alden-sftp-Hosting.com
http://alden-jsp-Hosting.com
JSP at alden-jsp-Hosting.com
Servlets at alden-jsp-Hosting.com
Servlet at alden-jsp-Hosting.com
Tomcat at alden-jsp-Hosting.com
MySQL at alden-jsp-Hosting.com
Java at alden-jsp-Hosting.com
sFTP at alden-jsp-Hosting.com
http://alden-java-Hosting.com
JSp at alden-java-Hosting.com
Servlets at alden-java-Hosting.com
Servlet at alden-java-Hosting.com
Tomcat at alden-java-Hosting.com
MySQL at alden-java-Hosting.com
Java at alden-java-Hosting.com
sFTP at alden-java-Hosting.com
JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . .
.
.
. .
. . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting