Archive for October, 2007

Adult web hosting - Java Swing - O Reilly 22.1.2.2 Events A ChangeEvent

Wednesday, October 31st, 2007

Java Swing - O Reilly 22.1.2.2 Events A ChangeEvent is fired to registered listeners whenever the caret’s position changes. The usual implementations of the following methods are provided: public void addChangeListener(ChangeListener l) public void removeChangeListener(ChangeListener l) protected void fireStateChanged() 22.1.2.3 Fields The following protected fields are available to subclasses of DefaultCaret, though neither should normally be needed: protected EventListenerList listenerList The list of listeners added to this component. protected transientChangeEvent changeEvent The ChangeEvent used whenever the caret position changes. Since the source is always this, there is no reason to create a new event each time. 22.1.2.4 Constructors public DefaultCaret() Creates a nonblinking DefaultCaret. 22.1.2.5 Caret Methods DefaultCaret provides the following implementations of the methods defined by the Caret interface: public void deinstall(JTextComponent c) Causes the caret to remove itself as a listener from the component and its model. If the blink rate has been set, the Timer responsible for the blinking is stopped (see Chapter 27). The Caret should no longer be used once this method has been called. public void install(JTextComponent c) Adds an instance of an inner class as a DocumentListener to the component’s model and as a PropertyListener of the component (so it will be notified if the Document is changed). In addition, the caret itself is added as a FocusListener, MouseListener, and MouseMotionListener of the component. public void moveDot(int dot) Moves the Caret to the specified position, using the component’s Highlighter to highlight the area over which the cursor has been dragged. - 734
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Java Swing - O Reilly public abstract void removeChangeListener(ChangeListener (Windows 2003 server web)

Wednesday, October 31st, 2007

Java Swing - O Reilly public abstract void removeChangeListener(ChangeListener l) 22.1.1.3 Methods In addition to the accessors for the properties listed earlier, the Caret interface defines the following four methods: public abstract void deinstall( JTextComponent c) Indicates that the Caret is no longer responsible for the given component. The Caret should no longer be used once this method has been called. public abstract void install( JTextComponent c) Indicates that the Caret is responsible for the given component. In addition to giving the Caret access to the component, it also provides access to the Document model (which the Caret can listen to so it can update the cursor location when text is added or removed). public abstract void moveDot(int dot) Called when a selection is being made. It should move the Caret to the specified position and update the JTextComponent’s Highlighter to reflect the current selection range. public abstract void paint(Graphics g) Renders the Caret on the given Graphics. 22.1.2 The DefaultCaret Class The DefaultCaret class provides a basic implementation of the Caret interface which renders itself as a thin vertical line. This class implements the FocusListener, MouseListener, and MouseMotionListener interfaces and reacts to these events when they are fired by the JTextComponent with which the caret is associated. Subclassing DefaultCaret, as we’ll see below, is a great way to create your own Caret without having to worry about a lot of the complicated details. 22.1.2.1 Properties DefaultCaret does not add any properties to the Caret interface. Table 22.2 shows the default values it supplies. Table 22.2, DefaultCaret Properties Property Data Type get is set bound Default Value blinkRate* int 0 dot* int 0 magicCaretPosition* Point null mark* int 0 selectionVisible* boolean false visible* boolean false - 733
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

Java Swing - O Reilly class of JTextComponent, which (Web host forum)

Tuesday, October 30th, 2007

Java Swing - O Reilly class of JTextComponent, which we can’t subclass directly. When we get to this section, we’ll see why we typically won’t need to. 22.1.1 The Caret Interface The Caret interface is used to represent the location where new data will be inserted (a caret is often referred to as a “cursor”). This interface provides a number of useful features for dealing with text insertion and selection. 22.1.1.1 Properties The Caret interface defines the properties shown in Table 22.1. The blinkRate property specifies the number of milliseconds between Caret blinks. A value of zero indicates that the Caret doesn’t blink at all. Table 22.1, Caret Properties Property Data Type get is set bound Default Value blinkRate int dot int magicCaretPosition Point mark int selectionVisible boolean visible boolean The dot property reflects the current Caret position, while mark reflects a previous Caret position where a mark was set (used for creating selections). MagicCaretPosition contains the Point used when moving between lines with uneven end positions, to ensure that the up and down arrow keys produce the desired effect. For example, consider the following text: Line 1 is longLine 2 Line 3 is long If the caret was initially positioned before the o in “long” in line three, you’d expect the up arrow key to move the cursor to the end of line two. A second up arrow press should move the caret just before the o in “long” of the first line. That is where the “magic” comes in. The first time the up arrow is pressed, magicCaretPosition is set to the old caret location, so that this position’s x- coordinate can be used if the up arrow is pressed again. You will probably never need to do anything with this property, since all this happens for free in the DefaultEditorKit. The selectionVisible property indicates whether the current selection should be shown, while visible indicates whether or not the Caret itself is visible. These properties allow the caret to decide, for example, what the display should look like when the component loses focus. 22.1.1.2 Events Anytime the Caret’s position changes, a ChangeEvent should be fired to any interested ChangeListeners. Caret defines the following standard methods for managing event listeners: public abstract void addChangeListener(ChangeListener l) - 732
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Java Swing - O Reilly 22.1 JTextComponent UI Properties (Web hosting domains)

Tuesday, October 30th, 2007

Java Swing - O Reilly 22.1 JTextComponent UI Properties JTextComponent has three UI-related properties that you can access and modify directly. These properties are defined by the following interfaces: Caret Defines how the cursor is displayed. This includes the size and shape of the cursor, the blink rate (if any), etc. Highlighter Defines how selected text is highlighted. Typically this is done by painting a solid rectangle “behind” the text, but this is up to the implementation of this interface. Highlighter also defines two inner-interfaces that we’ll look at. Keymap Defines the Actions performed when certain keys are pressed. For example, pressing CTRL-C may copy some text and CTRL-V may paste the cut or copied text at the current cursor location. This is considered a look-and-feel feature because different native look-andfeels have different default keymaps. As you might expect, Swing provides default implementations of these interfaces. Figure 22.1 shows these classes and interfaces, and the relationships between them. Note that each Caret and Highlighter is associated with a single JTextComponent (set by their install() methods), while Keymap has no direct relation to any JTextComponent, and therefore can be used by multiple components. Figure 22.1. JTextComponent UI properties In the next few pages, we’ll take a closer look at these interfaces, as well as the default implementations for Caret and Highlighter. The default implementation of Keymap is an inner - 731
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Java Swing - O Reilly } } Figure 21.7. (Web hosting company)

Tuesday, October 30th, 2007

Java Swing - O Reilly } } Figure 21.7. JTextPane containing JButtons and ImageIcons 21.1.12.6 Other Public Method public void replaceSelection(String content) Inserts, removes, or replaces text. If there is any currently selected text, it is removed. Then, any new text is inserted in its place. If no text is passed in, this is essentially a remove operation. If no text is selected, the given text will be inserted at the current cursor position. Any new text will have the attributes currently defined for new given text (inputAttributes). 21.1.12.7 Protected Methods The following protected methods are defined in JTextPane: protected final StyledEditorKit getStyledEditorKit() Casts the result of getEditorKit() to a StyledEditorKit. protected EditorKit createDefaultEditorKit() Returns a new StyledEditorKit. This is the method called by JEditorPane.getEditorKit(), if it is called before a kit has been set for the pane. Chapter 22. Carets, Highlighters, and Keymaps Like some of the other Swing components (JTree, for example), the text components allow you to do a certain amount of customization without actually implementing your own look-and-feel. Certain aspects of these components’ behavior and appearance can be modified directly using set() methods on JTextComponent. In addition, with the more powerful text components (JEditorPane, and anything that extends it, including JTextPane) you are able to control the View objects created to render each Element of the Document model. In this chapter, we’ll concentrate on the classes and interfaces related to modifying text components without dealing with View objects. This will include an explanation of carets, highlighters, and keymaps. Chapter 23, will examine the various View classes. - 730
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Web server type - Java Swing - O Reilly Inserts an Icon into

Monday, October 29th, 2007

Java Swing - O Reilly Inserts an Icon into the document, replacing anything currently selected. If there is no selection, the icon is inserted at the current cursor position. Inserting an Icon results in a single blank space being inserted into the document. This space is represented by a single Element, with attributes set to indicate that the space represents the given Icon. Here’s a short example showing how these methods work. In it, we create a JTextPane and two buttons: one inserts an Icon, and the second inserts a JButton. Figure 21.7 shows a display after playing with the editor a little bit. // IconAndComp.java // import javax.swing.*; import javax.swing.text.*; import java.awt.*; import java.awt.event.*; // Shows that Icons and Components can be added to a JTextPanepublic class IconAndComp { public static void main(String[] args) { final JTextPane pane = new JTextPane(); // Add an icon button final ImageIcon icon = new ImageIcon(”images/bluepaw.gif”); JButton iconButton = new JButton(icon); iconButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { pane.insertIcon(icon); } }); // Add a “Button” button JButton buttonButton = new JButton(”Insert Button”); buttonButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { pane.insertComponent(new Button(”Click Me”)); } }); // Lay out . . . JPanel buttons = new JPanel(); buttons.add(iconButton); buttons.add(buttonButton); JFrame frame = new JFrame(); frame.addWindowListener(new BasicWindowMonitor()); frame.setSize(300,200); Container c = frame.getContentPane(); c.setLayout(new BorderLayout()); c.add(pane, BorderLayout.CENTER); c.add(buttons, BorderLayout.SOUTH); frame.setVisible(true); - 729
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Sri lanka web server - Java Swing - O Reilly Returns the character attributes

Monday, October 29th, 2007

Java Swing - O Reilly Returns the character attributes that apply to the text at the current cursor location. Only the current cursor position is used; any selected text is irrelevant. If the current cursor position is just after the last character in the document, this method returns an empty set, because the leaf Element containing the text up to the end of the document does not contain the position after the end of the text; there’s actually an extra, empty Element there. public Style getLogicalStyle() Delegates to the pane’s document, passing in the current cursor location. Only the current cursor position is used, any selected text is irrelevant. public AttributeSet getParagraphAttributes() Returns the paragraph attributes that apply to the text at the current cursor location. Only the current cursor position is used; any selected text is irrelevant. public void setCharacterAttributes(AttributeSet attr, boolean replace) Applies the given attributes to the selected portion of the document. If there is no selection, the attributes will be applied to any new text inserted (by updating inputAttributes) into the document. The replace argument specifies whether or not the current attributes should be removed before applying the given attributes. public void setLogicalStyle(Style s) Delegates to the pane’s document, passing in the given Style and the current cursor location. The change is only applied to the paragraph at the current cursor location (unlike the other two set methods); any selected text is irrelevant. public void setParagraphAttributes(AttributeSet attr, boolean replace) Applies the given attributes to any paragraphs that intersect the selected portion of the document. If there is no selection, the attributes are applied to the paragraph at the current cursor position. The replace argument specifies whether or not the current attributes should be removed before applying the given attributes. 21.1.12.5 Adding Non-Text Content In addition to displaying text, JTextPane can be used to display Icons and arbitrary Components. This flexibility makes it possible to display documents with embedded images, or interactive documents such as HTML forms. public void insertComponent(Component c) Inserts a Component into the document, replacing anything currently selected. If there is no selection, the component is inserted at the current cursor position. Inserting a Componentresults in a single blank space being inserted into the document. This space is represented by a single Element with attributes set to indicate that the space represents the given Component. public void insertIcon(Icon c) - 728
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Java Swing - O Reilly See also properties from (Web server logs)

Sunday, October 28th, 2007

Java Swing - O Reilly See also properties from the JEditorPane class (Table 20.7). The characterAttributes , logicalStyle, and paragraphAttributes properties are described in the “Section 21.1.12.4″ section below. We handle them this way because the get() and set() methods are more complicated than basic property accessors and mutators. The default values for these properties come from the document. The inputAttributes property defines the AttributeSet to be used for newly inserted text. This property is managed by the editorKit. Newly inserted text will have the same attributes as the text before the cursor position. The editorKit property reflects the StyledEditorKit used by this class (EditorKits will be covered in detail in Chapter 24). Attempting to set editorKit to a kit that is not a StyledEditorKit (or a subclass) results in an IllegalArgumentException. The scrollableTracksViewportWidth property (from the Scrollable interface) is returned as true by this class, meaning that the pane should be confined to the width of the viewport it is placed in (when used with a JScrollPane, for example). This allows text to be properly wrapped when the end of a line is reached. 21.1.12.2 Constructors public JTextPane() Creates an empty text pane. It creates a new StyledEditorKit and gets its document model from this kit. public JTextPane(StyledDocument doc) Creates a text pane displaying the given document. 21.1.12.3 StyledDocument Delegation Methods The following methods do nothing more than delegate to the pane’s model. For a detailed explanation of Style manipulation, see the description of DefaultStyledDocument presented earlier in this chapter. public Style addStyle(String nm, Style parent) public Style getStyle(String nm) public void removeStyle(String nm) 21.1.12.4 Attribute and Style Methods These methods manipulate the attributes associated with either the current selection or the current cursor position. Pay close attention to which methods take the current selection into account, and which do not. Recall from the discussion of the StyledDocument interface that character attributes are applied to leaf elements, and paragraph attributes are applied to a leaf’s containing element. Styles are also applied at the paragraph level, typically serving as reusable sets of well-known attributes. public AttributeSet getCharacterAttributes() - 727
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Ftp web hosting - Java Swing - O Reilly The following protected methods

Sunday, October 28th, 2007

Java Swing - O Reilly The following protected methods are used by the public methods described previously. In all three cases, much of the detailed work is encapsulated in methods with package-level visibility. protected void changeUpdate() Called by update() to split Elements based on changes made to some portion of the document. protected void insertUpdate(ElementSpec[] data) Called by insert() to add Elements to the document, based on the given specifications. It drills down the Element hierarchy until it reaches a leaf Element, at which point it inserts the new Elements. This method can result in calls to createBranchElement() and createLeafElement() on the enclosing document, causing new Elements to be created and added to the document. protected void removeUpdate() Called by remove(), and does the work of removing Elements from the document. 21.1.12 The JTextPane Class Now that we’ve covered the complete text model for styled text, we can finally fully understand Swing’s most powerful text component, JTextPane. This class was first introduced in Chapter 19, but we didn’t get into the details because so much depended on having at least a basic understanding of the underlying model. Now that this model has been explained, you’ll see that the interface to JTextPane is really fairly simple. Many of the methods are provided as convenient shortcuts to methods we’ve already discussed from the StyledDocument interface. Recall that JTextPane is a subclass of JEditorPane. As such, it must have an EditorKit that describes much of its functionality. We’ll cover JTextPane’s editor kit, DefaultStyledEditorKit, in detail in Chapter 24. 21.1.12.1 Properties JTextPane defines the properties shown in Table 21.20. Both the document and styledDocumentproperties refer to the pane’s StyledDocument model. The styledDocument property provides type-specific access to the inherited document property. Attempting to call setDocument() with a Document that does not implement StyledDocument will result in an IllegalArgumentException. Table 21.20, JTextPane Properties Property Data Type get is set bound Default Value document* Document DefaultStyledDocument UIClassID* String “TextPaneUI” styledDocument StyledDocument DefaultStyledDocument characterAttributes AttributeSet editorKit* EditorKit StyledEditorKit inputAttributes MutableAttributeSet logicalStyle Style paragraphAttributes AttributeSet scrollableTracksViewportWidth* boolean true - 726
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

Web page design - Java Swing - O Reilly rootElement Element From constructor

Saturday, October 27th, 2007

Java Swing - O Reilly rootElement Element From constructor 21.1.11.2 Constructor public ElementBuffer(Element root) Creates a new buffer, using the given Element as the root of the Element structure. 21.1.11.3 Public Methods The first three methods below are called by DefaultStyledDocument to request changes to the document’s Element hierarchy. Each of these takes a DefaultDocumentEvent as a parameter. This event can be modified by the methods to reflect changes made to the hierarchy (recall from the last chapter that this event class extends CompoundEdit, so edits made to the element structure will be added to it). Eventually, the event will be fired by the DefaultStyledDocument method that made the call. The last public method listed here is used internally (by the package-private join() method). public void change(int offset, int length, DefaultDocumentEvent de) Indicates that attributes are being changed for the specified portion of the document. Elements will be split and created as necessary to allow the specified range to be represented by a unique Element. Most of the work is done by changeUpdate(), described below. Before calling it, this method sets local variables that changeUpdate() will use. The given event is updated to reflect the changes made by this call. public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent de) Inserts new Elements in the document at the specified position. The given offset and length indicate the range of the affected text. Most of the work is done by insertUpdate(), described later. Before calling it, this method sets local variables that insertUpdate() will use. The given event is updated to reflect the changes made by this call. public final void remove(int offset, int length, DefaultDocumentEvent de) Removes Elements from the document. Elements that lie within the given range of text will be removed. Most of the work is done by removeUpdate(), described later. Before calling it, this method sets local variables that removeUpdate() will use. The given event is updated to reflect the changes made by this call. public Element clone(Element parent, Element clonee) Creates a copy of a given Element (including any nested structure). The newly created Element will have the specified parent. 21.1.11.4 Protected Methods - 725
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.