Archive for the 'apache' Category

Java Swing - O Reilly 24.1.13.2 Constructor public StyledEditorKit() (Cedant web hosting)

Monday, January 14th, 2008

Java Swing - O Reilly 24.1.13.2 Constructor public StyledEditorKit() This default constructor provides no behavior. 24.1.13.3 EditorKit Methods These methods override those defined in DefaultEditorKit or EditorKit: public Object clone() Returns a new StyledEditorKit. that is a copy of this editor kit. public Document createDefaultDocument() Returns a new instance of DefaultStyledDocument. public void install( JEditorPane c) Called when the kit is associated with a JEditorPane. It adds itself (actually, an instance of a nonpublic inner class) as a CaretListener of the given pane. public void deinstall( JEditorPane c) Indicates that the given pane is no longer using this kit. It removes the caret listener added by install(). 24.1.14 The StyledEditorKit.StyledTextAction Class As discussed earlier, StyledEditor defines several public inner classes to perform actions related to styled text. This public abstract class extends TextAction and serves as the base class for all the other action inner classes. 24.1.14.1 Constructor public StyledTextAction(String nm) Passes the action name up to the superclass. 24.1.14.2 Protected Methods These methods are available to any subclass of StyledTextAction. None of them does anything really new, they just save you a few steps for certain common tasks. If you define your own styled text actions, some of these methods will come in handy. protected final JEditorPane getEditor(ActionEvent e) Provides c
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 are passed to the (Cheapest web hosting)

Monday, January 14th, 2008

Java Swing - O Reilly are passed to the specific action class constructor. Additional actions can be created by instantiating the desired action class, passing different values to the constructor. Table 24.4, StyledEditorKit Properties Property Data Type get is set bound Default Value actions* Action[] DefaultEditorKit’s actions plus 18 more characterAttributeRun Element null inputAttributes MutableAttributeSet viewFactory* ViewFactory StyledViewFactory() See also properties from the DefaultEditor class (Table 24.2). Table 24.5, StyledEditorKit Default Actions Action Class Action Name Constructor Argument FontFamilyAction font-family-SansSerif “SansSerif” FontFamilyAction font-family-Monospaced “Monospaced” FontFamilyAction font-family-Serif “Serif” FontSizeAction font-size-8 8 FontSizeAction font-size-10 10 FontSizeAction font-size-12 12 FontSizeAction font-size-14 14 FontSizeAction font-size-16 16 FontSizeAction font-size-18 18 FontSizeAction font-size-24 24 FontSizeAction font-size-36 36 FontSizeAction font-size-48 48 AlignmentAction left-justify StyleConstants.ALIGN_LEFTAlignmentAction center-justify StyleConstants.ALIGN_CENTER AlignmentAction right-justify StyleConstants.ALIGN_RIGHTBoldAction font-bold N/A ItalicAction font-italic N/A UnderlineAction font-underline N/A The characterAttributeRun property is a new property that indicates the Element in which the caret is currently located. This is updated whenever the kit’s JEditorPane fires a CaretEvent. Similarly, inputAttributes provides access to the attribute set in use at the current caret position. This property is used by the JTextPane class whenever content is added to the document. The viewFactory defined by StyledEditorKit is an inner class capable of creating View objects for different types of Elements. The View objects created by this factory depend on the name property of the Element passed to the create() method, as shown in Table 24.6. Table 24.6, StyledEditorKit.StyledViewFactory View Creation Policy Element Name View Class Created AbstractDocument.ContentElementName LabelView AbstractDocument.ParagraphElementName ParagraphView AbstractDocument.SectionElementName BoxView AbstractDocument.ComponentElementName ComponentViewAbstractDocument.IconElementName IconView other LabelView - 804
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 } } Let’s look

Sunday, January 13th, 2008

Java Swing - O Reilly } } Let’s look at a few of the methods from this example. The first interesting method is called hashDefaultActions(). This method creates a Hashtable that maps action names (which we can get from the DefaultEditorKit constants) to Actions, letting us find actions we want to work with later. The next method, getHashedAction(), lets us get the actions we just hashed by providing the action name. Next, we have a method called makeActionsPretty(). This method adds icons to the actions we’re going to display, and changes the text for these actions, as well. This way, our user interface will display nice names like Cut instead of cut-to-clipboard. Next, we’ve defined a method called updateKeymap(). The purpose of this method is to add some common editor functionality: the ability to skip to the next or previous word by holding down CTRL and pressing the right or left arrow key. Holding down SHIFT at the same time will highlight the word, as well. For more details on what we did with the Keymap and KeyStroke classes, refer to discussion of Keymap in Chapter 22. The important thing here is to note that we used our hashed action table to map these keys to the appropriate actions. Subclasses of this editor can add mappings by overriding this method. In createToolBar(), we get instances of two inner classes, OpenAction and SaveAction, and add them to our JToolBar. We get these actions by calling getOpenAction() and getSaveAction() to allow subclasses to provide different implementations of these actions. We then use getHashedAction() again to get the cut, copy, and paste actions. We’ve chosen not to display the text for the actions in the toolbar, so we call setText(”") on the JButton returned by each add() call. For more details on Swing’s handy new JToolBar class, see Chapter 14. The createMenuBar() method is similar to createToolBar(). We add two additional actions here: exit and select-all. In this method, we don’t strip the text from the menu items, allowing both the icon and the text to be displayed. Finally, we define action classes for exiting the application, and for opening and saving files. These last two actions take advantage of the DefaultEditorKit read() and write() methods, which get called by JTextComponent’s read() and write() methods. For more details on another handy new Swing class we’ve used here, JOptionPane, see Chapter 10. 24.1.13 The StyledEditorKit Class StyledEditorKit extends DefaultEditorKit to provide additional features required for documents that allow styled text. It is the kit used by the JTextPane class. Like DefaultEditorKit, this class defines a number of new TextActions. In this class, all of these action classes are public. We’ll look at each of them at the end of this section. 24.1.13.1 Properties StyledEditorKit defines the properties and default values shown in Table 24.4. The actions property is the set of actions defined for DefaultEditorKit, augmented with actions for setting the font family, font size, font style attributes, and text alignment. The exact actions provided are shown in Table 24.4. In this table, the first column gives the name of the inner class, the next column gives the action name (Action.NAME), and the last column gives the parameter values that - 803
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web site hosting - Java Swing - O Reilly class OpenAction extends AbstractAction

Sunday, January 13th, 2008

Java Swing - O Reilly class OpenAction extends AbstractAction { public OpenAction() { super(”Open”, new ImageIcon(”icons/open.gif”)); } // Query user for a filename and attempt to open and read the file into the// text componentpublic void actionPerformed(ActionEvent ev) { String filename = JOptionPane.showInputDialog( SimpleEditor.this, “Enter Filename”); if (filename == null) return; FileReader reader = null; try { reader = new FileReader(filename); textComp.read(reader, null); } catch (IOException ex) { JOptionPane.showMessageDialog(SimpleEditor.this, “File Not Found”, “ERROR”, JOptionPane.ERROR_MESSAGE); } finally { if (reader != null) { try { reader.close(); } catch (IOException x) {} } } } } // An action that saves the document to a fileclass SaveAction extends AbstractAction { public SaveAction() { super(”Save”, new ImageIcon(”icons/save.gif”)); } // Query user for a filename and attempt to open and write the text // component’s content to the file public void actionPerformed(ActionEvent ev) { String filename = JOptionPane.showInputDialog( SimpleEditor.this, “Enter Filename”); if (filename == null) return; FileWriter writer = null; try { writer = new FileWriter(filename); textComp.write(writer); } catch (IOException ex) { JOptionPane.showMessageDialog(SimpleEditor.this, “File Not Saved”, “ERROR”, JOptionPane.ERROR_MESSAGE); } finally { if (writer != null) { try { writer.close(); } catch (IOException x) {} } } } - 802
We recommend high quality webhost to host and run your jsp application: christian web host services.

Java Swing - O Reilly map.addActionForKeyStroke(selPrev, getHashedAction( DefaultEditorKit.selectionPreviousWordAction)); // (Web hosting solutions)

Saturday, January 12th, 2008

Java Swing - O Reilly map.addActionForKeyStroke(selPrev, getHashedAction( DefaultEditorKit.selectionPreviousWordAction)); // Set the Keymap for the text componenttextComp.setKeymap(map); } // Create a simple JToolBar with some buttonsprotected JToolBar createToolBar() { JToolBar bar = new JToolBar(); // Add simple actions for opening & saving bar.add(getOpenAction()).setText(”"); bar.add(getSaveAction()).setText(”"); bar.addSeparator(); // Add cut/copy/paste buttonsbar.add(getHashedAction(DefaultEditorKit.cutAction)).setText(”"); bar.add(getHashedAction(DefaultEditorKit.copyAction)).setText(”"); bar.add(getHashedAction(DefaultEditorKit.pasteAction)).setText(”"); return bar; } // Create a JMenuBar with file & edit menus protected JMenuBar createMenuBar() { JMenuBar menubar = new JMenuBar(); JMenu file = new JMenu(”File”); JMenu edit = new JMenu(”Edit”); menubar.add(file); menubar.add(edit); file.add(getOpenAction()); file.add(getSaveAction()); file.add(new ExitAction()); edit.add(getHashedAction(DefaultEditorKit.cutAction)); edit.add(getHashedAction(DefaultEditorKit.copyAction)); edit.add(getHashedAction(DefaultEditorKit.pasteAction)); edit.add(getHashedAction(DefaultEditorKit.selectAllAction)); return menubar; } // Subclass can override to use a different open actionprotected Action getOpenAction() { return openAction; } // Subclass can override to use a different save actionprotected Action getSaveAction() { return saveAction; } protected JTextComponent getTextComponent() { return textComp; } private Action openAction = new OpenAction(); private Action saveAction = new SaveAction(); private JTextComponent textComp; private Hashtable actionHash = new Hashtable(); // ********** ACTION INNER CLASSES ********** // // A very simple “exit” action public class ExitAction extends AbstractAction { public ExitAction() { super(”Exit”); } public void actionPerformed(ActionEvent ev) { System.exit(0); } } // An action that opens an existing file - 801
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

Web server iis - Java Swing - O Reilly JTextArea ta = new

Saturday, January 12th, 2008

Java Swing - O Reilly JTextArea ta = new JTextArea(); ta.setLineWrap(true); return ta; } // Get all of the actions defined for our text component. Hash each one by name // so we can look for it later. protected void hashDefaultActions() { Action[] actions = textComp.getActions(); for (int i=0; iAction mappings protected void updateKeymap() { // Create a new child Keymap Keymap map = JTextComponent.addKeymap(”NextPrevMap”, textComp.getKeymap()); // Define the keystrokes to be added KeyStroke next = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK, false); KeyStroke prev = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK, false); KeyStroke selNext = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK, false); KeyStroke selPrev = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK|InputEvent.SHIFT_MASK, false); // Add the new mappings used DefaultEditorKit actions map.addActionForKeyStroke(next, getHashedAction( DefaultEditorKit.nextWordAction)); map.addActionForKeyStroke(prev, getHashedAction( DefaultEditorKit.previousWordAction)); map.addActionForKeyStroke(selNext, getHashedAction( DefaultEditorKit.selectionNextWordAction)); - 800
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Web hosting script - Java Swing - O Reilly [2] Text in this

Saturday, January 12th, 2008

Java Swing - O Reilly [2] Text in this and following figures is from A.M. Turing, “Computing Machinery and Intelligence,” Mind, 1950. Figure 24.3. SimpleEditor Here’s the source code for SimpleEditor. It’s designed to be easily extensible, allowing us to add features of the more advanced editor kits. This class serves as the base class for the other examples in this chapter. // SimpleEditor.java // import javax.swing.*; import javax.swing.text.*; import java.awt.*; import java.io.*; import java.awt.event.*; import java.util.Hashtable; // An example showing several DefaultEditorKit features. This class is designed // to be easily extended to add additional functionality. public class SimpleEditor extends JFrame { public static void main(String[] args) { SimpleEditor editor = new SimpleEditor(); editor.addWindowListener(new BasicWindowMonitor()); editor.setVisible(true); } // Create an editor public SimpleEditor() { super(”Swing Editor”); textComp = createTextComponent(); hashDefaultActions(); makeActionsPretty(); updateKeymap(); Container content = getContentPane(); content.add(textComp, BorderLayout.CENTER); content.add(createToolBar(), BorderLayout.NORTH); setJMenuBar(createMenuBar()); setSize(320, 240); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); } // Create the JTextComponent subclass. protected JTextComponent createTextComponent() { - 799
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.

X web hosting - Java Swing - O Reilly public InsertContentAction() Creates an

Friday, January 11th, 2008

Java Swing - O Reilly public InsertContentAction() Creates an action using the name insertContentAction. 24.1.9.2 Method public void actionPerformed(ActionEvent e) Inserts the actionCommand value from the given event into the active JTextComponent, using replaceSelection(). If the action command is null, a beep is sounded. 24.1.10 The DefaultEditorKit.InsertTabAction Class 24.1.10.1 Constructor public InsertTabAction() Creates an action using the name insertTabAction. 24.1.10.2 Method public void actionPerformed(ActionEvent e) Replaces the current selection with a t (tab) character, if an active JTextComponent can be determined. If there is no selection, a tab is inserted. 24.1.11 The DefaultEditorKit.PasteAction Class 24.1.11.1 Constructor public PasteAction() Creates an action using the name pasteAction. 24.1.11.2 Method public void actionPerformed(ActionEvent e) Calls paste() on the active JTextComponent, if it can be determined. 24.1.12 A Simple Text Editor In this first example, we’ll show how to do some of things you’d expect from a basic editor. Our first editor will support the following features: Cut, copy, and paste via toolbar buttons, menu selection, and default key shortcuts Select-all capability via menu selection Quick keyboard navigation using the nextWordAction, previousWordAction, selectionNextWordAction, and selectionPreviousWordAction Saving and loading documents [2] When we run it, our simple editor will look something like Figure 24.3. - 798
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Windows 2003 server web - Java Swing - O Reilly 24.1.5.2 Method public void

Thursday, January 10th, 2008

Java Swing - O Reilly 24.1.5.2 Method public void actionPerformed(ActionEvent e) Calls Toolkit.getDefaultToolkit().beep(). 24.1.6 The DefaultEditorKit.CopyAction Class 24.1.6.1 Constructor public CopyAction() Creates an action using the name copyAction. 24.1.6.2 Method public void actionPerformed(ActionEvent e) Calls copy() on the active JTextComponent, if it can be determined. 24.1.7 The DefaultEditorKit.CutAction Class 24.1.7.1 Constructor public CutAction() Creates an action using the name cutAction. 24.1.7.2 Method public void actionPerformed(ActionEvent e) Calls cut() on the active JTextComponent, if it can be determined. 24.1.8 The DefaultEditorKit.InsertBreakAction Class 24.1.8.1 Constructor public InsertBreakAction() Creates an action using the name insertBreakAction. 24.1.8.2 Method public void actionPerformed(ActionEvent e) Replaces the current selection with a n (return) character, if an active JTextComponent can be determined. If there is no selection, a n is inserted. 24.1.9 The DefaultEditorKit.InsertContentAction Class 24.1.9.1 Constructor - 797
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 - (My web server) O Reilly Returns null. See EditorKit.createCaret().

Thursday, January 10th, 2008

Java Swing - O Reilly Returns null. See EditorKit.createCaret(). public Document createDefaultDocument() Creates a new PlainDocument instance and returns it. public void read(InputStream in, Document doc, int pos)throws IOException, BadLocationException public void read(Reader in, Document doc, int pos)throws IOException, BadLocationException Read plain text from the given Reader (in), adding the text at the specified position. The version that takes an InputStream simply wraps the stream in an InputStreamReader and calls the other version. public void write(OutputStream out, Document doc, int pos, int len)throws IOException, BadLocationException public void write(Writer out, Document doc, int pos, int len)throws IOException, BadLocationException Write len plain text characters to the given Writer (out), starting at position pos. The version that takes an OutputStream simply wraps the stream in an OutputStreamWriter and calls the other version. 24.1.4 The DefaultEditorKit.DefaultKeyTypedAction Class Over the next few pages, we’ll give a brief overview of the actions defined as public static inner classes of DefaultEditorKit. The first of these is the default action, used to insert text into the active JTextComponent. 24.1.4.1 Constructor public DefaultKeyTypedAction() Creates an action using the name defaultKeyTypedAction. 24.1.4.2 Method public void actionPerformed(ActionEvent e) Inserts the actionCommand value from the given event into the active JTextComponent using replaceSelection(). If the first character has a value less than 0×20, this does nothing. 24.1.5 The DefaultEditorKit.BeepAction Class 24.1.5.1 Constructor public BeepAction() Creates an action using the name beepAction. - 796
We recommend high quality webhost to host and run your jsp application: christian web host services.