Archive for the 'apache' Category

Java Swing - O Reilly // Create a text (Web site design and hosting)

Wednesday, January 9th, 2008

Java Swing - O Reilly // Create a text area JTextArea ta = new JTextArea(); ta.setLineWrap(true); // Add all actions to the menu (split into two menus to make it more usable) Action[] actions = ta.getActions(); JMenuBar menubar = new JMenuBar(); JMenu actionmenu = new JMenu(”Actions”); menubar.add(actionmenu); JMenu firstHalf = new JMenu(”1st Half”); JMenu secondHalf = new JMenu(”2nd Half”); actionmenu.add(firstHalf); actionmenu.add(secondHalf); int mid = actions.length/2; for (int i=0; iSearching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Java Swing - O Reilly selectionBackwardAction Adjust the current

Wednesday, January 9th, 2008

Java Swing - O Reilly selectionBackwardAction Adjust the current selection by moving the caret back one position selectionBeginAction Adjust the current selection by moving the caret back to the beginning of the document selectionBeginLineAction Adjust the current selection by moving the caret back to the beginning of the current line selectionBeginParagraphAction Adjust the current selection by moving the caret back to the beginning of the current paragraph selectionBeginWordAction Adjust the current selection by moving the caret back to the beginning of the current word selectionDownAction Adjust the current selection by moving the caret down one row selectionEndAction Adjust the current selection by moving the caret to the end of the document selectionEndLineAction Adjust the current selection by moving the caret to the end of the current line selectionEndParagraphAction Adjust the current selection by moving the caret to the end of the current paragraph selectionEndWordAction Adjust the current selection by moving the caret to the end of the current word selectionForwardAction Adjust the current selection by moving the caret forward one position selectionNextWordAction Adjust the current selection by moving the caret to the beginning of the next word selectionPreviousWordAction Adjust the current selection by moving the caret to the beginning of the previous word selectionUpAction Adjust the current selection by moving the caret down one row upAction Move the caret up one position writableAction Set the editor to writable mode; results in a call to setEditable(true) on the JTextComponent 24.1.3.3 Using Actions Let’s look at a simple example that shows how these actions can be used. In this program, we’ll create a JTextArea and add all the available actions to a menu (the list is pretty long, so we split it into two submenus). As we discussed in the chapter on menus, we can add these Action objects directly to the menu. The default action names appear as menu selections. Since JTextArea gets its actions from the DefaultEditorKit, you’ll see each of the actions listed in Table 24.3 when you run this program. By blindly adding all of the actions, we avoid interacting with the editor kit directly in this program. At the end of this section, we’ll look at a much more useful example that uses DefaultEditorKit directly. // TextActionExample.java // import javax.swing.*; import javax.swing.text.*; // Simple TextAction examplepublic class TextActionExample { public static void main(String[] args) { - 794
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Java Swing - O Reilly Hashtable, so that we (Best web hosting site)

Wednesday, January 9th, 2008

Java Swing - O Reilly Hashtable, so that we can access any action we need by name. In this example, we then retrieve the “cut” action from the table using the DefaultEditorKit.cutAction constant: [1] The keen observer will notice that the properties table indicated that there were 47 actions available. One action is not defined as a constant, but is still available by the name “dump-model.” This action just calls dump() on the document of the currently focused JTextComponent (assuming it’s an AbstractDocument), causing the model structure to be printed to System.err. Hashtable actionHash = new Hashtable(); Action[] actions = edKit.getActions(); for (int i=0; iIn case you need quality webspace to host and run your web applications, try our personal web hosting services.

Java Swing - O Reilly by an (Php web hosting) EditorKit that

Tuesday, January 8th, 2008

Java Swing - O Reilly by an EditorKit that wishes to add new actions to the set of actions supported by its superclass. 24.1.2.3 Protected Methods protected final JTextComponent getFocusedComponent() Returns JTextComponent.getFocusedComponent(). protected final JTextComponent getTextComponent(ActionEvent e) Determines the currently active text component, allowing actions to be shared by multiple text components. If the given event has a JTextComponent as its target, that component is returned. If not, the result of getFocusedComponent() is returned. 24.1.3 The DefaultEditorKit Class DefaultEditorKit is a subclass of EditorKit that provides a great deal of default behavior applicable to most document types. As we’ll see below, the most interesting features available in this class are provided by the actions it supports via its numerous inner classes. When used directly, DefaultEditorKit only supports plain text data. Its actions deal with tasks such as copying and pasting data, and its I/O methods read and write only plain text. However, the important thing about this class is that it can be extended to add more features, and the actions it defines will still be applicable. We’ll see extensions of DefaultEditorKit in the sections that follow. 24.1.3.1 Properties DefaultEditorKit defines values for the properties shown in Table 24.2. The actions provided by DefaultEditorKit are discussed below in the “Constants” section. Each action is an instance of an inner class, defined in DefaultEditorKit that is capable of performing a given action. The contentType for editors using DefaultEditorKit is text/plain, indicating that styled text is not supported. The viewFactory property is set to null, indicating that users of this class must provide ViewFactory support via the TextUI. Table 24.2, DefaultEditorKit Properties Property Data Type get is set bound Default Value actions* Action[] Array of 47 TextAction objects contentType* String “text/plain” viewFactory* ViewFactory null See also properties from the EditorKit class (Table 24.1). 24.1.3.2 Constants DefaultEditorKit defines 46[1] different action names (Strings, shown in Table 24.3) as constant values. Behind each action name is an inner class (some classes are used by multiple actions) that extends TextAction to carry out the goal of the action. Several of these action classes are public, so we will define them in more detail after this section. However, even with the nonpublic classes, you can get to an instance of the action using these constants, along with the actions property. The following example shows a common strategy for doing this. We’ll store all of the actions in a local - 792
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Free web hosts - Java Swing - O Reilly These read() and write()

Tuesday, January 8th, 2008

Java Swing - O Reilly These read() and write() methods can support any arbitrary text format. For simple text, the data read and written will be plain text; more advanced editor kits might be able to read attribute and style information, or well-defined mark-up languages like HTML or XML. 24.1.1.4 Other Methods These methods are not abstract, but the default implementations do nothing. public void install( JEditorPane c) Called once the content type for the JEditorPane has been determined. It associates the kit with the editor pane. Subclasses that need to query or listen to the editor pane for any reason should take advantage of this method. public void deinstall( JEditorPane c) Called when the JEditorPane changes its editor kit. For example, subclasses may take advantage of this method to remove listeners from the pane. 24.1.2 The TextAction Class Way back in Chapter 3, we introduced the Action interface and the AbstractAction default implementation. To quickly review, Actions are a new feature in Swing that encapsulate some common piece of functionality, along with a name and (optionally) an icon associated with that functionality. Action extends the ActionListener interface, so any Action can be added as a listener to components that fire Action events. When working with any type of word processor or basic editor, you perform “actions” all the time. The simplest example occurs every time you type a character. Some action is performed to add that character to the document and the display. More interesting examples include making a segment of text bold, copying a selection of text, or changing the current font. Swing provides support for many of these common activities, through classes that extend the TextAction abstract class. The specific actions available are defined as inner classes of the EditorKit subclasses. We’ll cover each of these in the sections that follow. In this section, we’ll briefly cover the TextAction class itself, so you understand what all these new actions have in common. 24.1.2.1 Constructor public TextAction(String name) Passes the action name up to its superclass, where it is assigned to the Action.NAME property. Recall from the discussion of Action that this property is typically the primary key used to identify actions. 24.1.2.2 Static Method public static final Action[] augmentList(Action[] list1, Action[] list2) Adds the actions in the second list to those in the first list. Any action names that appear in both lists will be mapped to the Action specified in the second list. This method can be used - 791
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Java Swing - (Web hosting billing) O Reilly The following methods must

Monday, January 7th, 2008

Java Swing - O Reilly The following methods must be defined by implementations of this class: public abstract Object clone() Should return a copy of the editor kit. EditorKit implements Cloneable so that new instances can be created quickly. public abstract Caret createCaret() Should create a new Caret to be used with the JEditorPane. This method is currently not called anywhere within Swing Carets are initially installed via the createCaret() method in BasicTextUI, and can be reset via a call to setCaret() on any JTextComponent. public abstract Document createDefaultDocument() Called by the BasicTextUI when installing a UI for a component and by JTextComponentbefore loading a new document from a stream. It should return a new Document object of the appropriate type for the kit. Figure 24.2 shows how this method is called when a new JEditorPane is created without specifying a document. Figure 24.2. Default document creation using EditorKit public abstract void read(InputStream in, Document doc, int pos)throws IOException, BadLocationException public abstract void read(Reader in, Document doc, int pos)throws IOException, BadLocationException Should populate the given Document, based on data read from the stream or reader. The data read is inserted at the specified document position (use if this is a new, empty document). public abstract void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException public abstract void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException Should write the specified portion of the document to the specified stream. To write the entire document, just call write(aWriter, aDoc, 0, aDoc.getLength()). - 790
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Java Swing - O Reilly This figure shows several (Web hosting provider)

Monday, January 7th, 2008

Java Swing - O Reilly This figure shows several important things about the EditorKit class. First, each EditorKit instance is associated with a single JEditorPane (though in some cases, it doesn’t care). The EditorKit defines how to create a default document, as well as how to read and write the document to a stream. In addition, each EditorKit may define a ViewFactory responsible for creating View objects for each Element in the document. Finally, the diagram shows that an EditorKit may define a set of Actions that it supports. The other classes shown in the diagram are the subclasses of EditorKit and AbstractAction. We’ll look at each of these classes, as well as some inner classes not shown on the diagram, throughout this chapter. 24.1.1.1 Properties EditorKit defines the properties shown in Table 24.1. The actions property defines the set of actions that can be used on a text component, which uses a model and a view produced by this EditorKit. contentType indicates the MIME type of the data that this kit supports. The viewFactory property is the ViewFactory object used to create View objects for the Elements of the document type produced by the kit. The accessors for all three of these properties are abstract. Table 24.1, EditorKit Properties Property Data Type get is set bound Default Value actions Action[] abstract contentType String abstract viewFactory ViewFactory abstract 24.1.1.2 Constructor public EditorKit() This default constructor has no behavior. 24.1.1.3 Abstract Methods - 789
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Java Swing - O Reilly (Jetty web server) public void paint(Graphics g,

Sunday, January 6th, 2008

Java Swing - O Reilly public void paint(Graphics g, Shape allocation) Calculates the width and height of the cell, adjusting the allocation if the cell spans multiple rows or columns. It calls paintCell() and super.paint(). Chapter 24. EditorKits and TextActions Over the last five chapters we’ve covered just about all of the classes and interfaces that make up the Swing text framework. In this chapter, we’ll look at a class that ties everything together: EditorKit. An EditorKit is used to pull together the document model, document view, document editing actions, and document I/O strategy, serving as a central reference point for a given document type. In addition to looking at EditorKit and its subclasses, this chapter also introduces the TextAction class (an abstract extension of AbstractAction) and the many useful concrete action classes available as inner classes of the EditorKit subclasses. These actions are used for tasks such as copying and pasting text as well as style-oriented tasks such as changing font characteristics. Throughout the course of the chapter, we’ll be building simple but powerful editors for working with increasingly complex document types. 24.1 Overview of the Editor Kits The following sections give an overview of the components of various editor kits. 24.1.1 The EditorKit Class This is the abstract base class for all editor kits. It defines a number of methods that define the model (e.g., createDefaultDocument()), the view (e.g., getViewFactory()), the capabilities (getActions()), and the I/O strategy (read() and write()) for some type of document content. Figure 24.1 shows the EditorKit class and the many classes and interfaces it interacts with. Figure 24.1. EditorKit and related classes - 788
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Java Swing - O Reilly Gives each child the (Web site directory)

Sunday, January 6th, 2008

Java Swing - O Reilly Gives each child the span of the column width for the table. protected void loadChildren(ViewFactory f ) Iterates over the Element’s children, creating a new child view (using the createTableCell() method in the enclosing TableView) for each child Element. The given factory is not used. 23.2.18 The TableView.TableCell Class This inner class extends BoxView and is used to represent a cell in a table. This implementation does not directly support cells that span multiple rows or columns, but subclasses can easily change this. 23.2.18.1 Properties TableView.TableCell defines the properties and default values shown in Table 23.15. The columnCount and rowCount properties define the size of the cell in terms of the number of rows and columns it spans. These are always 1 in this class. The preferredSpan accessor is implemented to return the preferred span for the cell (according to super.preferredSpan()), divided by the number of rows (for Y_AXIS) or columns (for X_AXIS) covered by the cell. The resizeWeight is set to 1. The element represented by the cell is specified in the constructor. Table 23.15, WrappedPlainView Properties Property Data Type get is set bound Default Value columnCount int 1 element* Element From constructor preferredColumnSpan int super.preferredSpan/columnCount preferredSpan (indexed)* float Discussed later resizeWeight (indexed)* int 1 rowCount int 1 See also properties from the BoxView class (Table 23.11). 23.2.18.2 Constructor public TableCell(Element elem) Creates a new view to display the given Element, using a vertical (Y_AXIS) box. 23.2.18.3 New Methods public void setGridLocation(int row, int col) Sets the row and column of the cell. protected void paintCell(Graphics g, Rectangle alloc) This method does nothing. Subclasses can use this method to paint things such as a cell border or background. 23.2.18.4 BoxView Method The following method overrides the implementations provided by BoxView and its subclasses. - 787
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Java Swing - O Reilly Lays out the columns (Web hosting top)

Saturday, January 5th, 2008

Java Swing - O Reilly Lays out the columns to fit in the given span. The offsets and spans parameters are output parameters which will define the appropriate layout. The reqs parameter describes the size requirements for each column. This method uses SizeRequirements.calculateTiledPositions() to do the work. protected void loadChildren(ViewFactory f ) Creates a new TableRow (using createTableRow()) for each child of the view’s Element. It does not use the given factory at all. Once the child rows have been created, invisible “proxy” cells are created to fill any blank spaces left by cells that span multiple rows or columns. This is done to simplify layout. 23.2.16.4 New Protected Methods These methods make it easy to subclass TableView if you want to provide your own TableCell or TableRow implementations. All children of TableView and TableRow are created using these methods: protected TableView.TableCell createTableCell(Element elem) Returns a new instance of TableCell, to display the given Element. protected TabelView.TableRow createTableRow(Element elem) Returns a new instance of TableRow, to display the given Element. 23.2.17 The TableView.TableRow Class This inner class extends BoxView, and represents a horizontal row of cells. 23.2.17.1 Properties The TableView.TableRow class modifies the implementation of the BoxView properties shown in Table 23.14. The resizeWeight property is set to 1 for all rows. The element property is defined in the constructor. Table 23.14, TableView.TableRow Properties Property Data Type get is set bound Default Value element* Element From constructor resizeWeight (indexed)* int 1 See also properties from the BoxView class (Table 23.11). 23.2.17.2 Constructor public TableRow(Element elem) Creates a new view for the given Element, aligned along the X_AXIS. 23.2.17.3 Methods protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) - 786
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.