Archive for January, 2008

Java Swing - (Ftp web hosting) O Reilly This field contains a

Thursday, January 31st, 2008

Java Swing - O Reilly This field contains a wrapped reference to the editor component. The EditorDelegateinner class delegates calls such as isCellEditable() to the component it contains, but also listens for events that indicate editing has stopped. For the three possible types of editors, a “stop event” from the contained component would be either an action event for text fields, or an item event for checkboxes and combo boxes. protected int clickCountToStart This field stores the value for the clickCountToStart property. 27.2.4.5 Tree and Table Editor Methods Most of the methods in DefaultCellEditor are implementations of the CellEditor methods. The only other methods in the DefaultCellEditor class that are new are the methods required to implement the TableCellEditor and TreeCellEditor interfaces. public Component getTreeCellEditorComponent(JTree tree,Object value, boolean isSelected, boolean expanded, boolean leaf, int row) Returns a valid tree cell editor and is discussed in more detail in Chapter 17. public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) Returns a valid table cell editor and is discussed in more detail in Chapter 15. 27.3 Event Utilities If you extend one of the Swing components to add functionality, or indeed, build your own component from scratch, you need to handle event listeners for any events you might generate. The EventListenerList class is designed to aid in that task. This class is similar in many ways to the AWTEventMulticaster; however, it supports any type of listener and assumes you’ll use only the appropriate listeners for a given event type. Unlike the AWT multicaster, it does not assume all of the listeners support the same events. The KeyStroke class can also help handle keyboard events. Rather than listening to every key that gets pressed and throwing out the things you don’t care about, you can use the KeyStroke class to register specific actions with specific keys. 27.3.1 The EventListenerList Class If your component generates events, it must contain methods to add and remove interested listeners. Following the JavaBeans design patterns, these are the addTypeListener() and removeTypeListener() methods. Typically you store the listeners in a vector, and then use the vector as a rollcall for who to send events to when the time comes. This is a very common task for components that generate events, and the EventListenerList can help lift some (but certainly not all) of the burden of coding the event firing. The EventListenerList stores listeners as pairs of objects, one object to hold the listener’s type and one to hold the listener itself. At any time, you can retrieve all of the current listeners as an array of Objects and use that array to fire off any events you need. - 927
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Web hosting domain names - Java Swing - O Reilly 27.2.4.1 Properties The DefaultCellEditor

Thursday, January 31st, 2008

Java Swing - O Reilly 27.2.4.1 Properties The DefaultCellEditor class contains the properties listed in Table 27.6. The cellEditorValue property contains the value of the cell editor. This value can be used or ignored when editing stops, depending on whether editing is stopped or canceled. The clickCountToStart property determines how many clicks it takes to begin editing a cell. For checkboxes and combo boxes, that values is 1; for text fields, the default value of this property is 2, meaning that the user has to double click to start editing. The component property contains the actual component that the cell editor returns when getTableCellEditorComponent() or getTreeCellEditorComponent() is called. Table 27.6, DefaultCellEditor Properties Property Data Type get is set bound Default Value cellEditorValue* Object null clickCountToStart int Determined by constructor component Component Determined by constructor 27.2.4.2 Events As dictated by the CellEditor interface, the DefaultCellEditor class implements the add and remove methods for cell editor listeners. It also provides these convenience methods for generating those events. protected void fireEditingStopped() protected void fireEditingCanceled() Both of these methods notify registered listeners that editing has stopped. The cell editor is listed as the source of these events. 27.2.4.3 Constructors You can create your own cell editor using any of the following constructors. You can pre-configure any of the components you pass in as well. For example, you might pass in a right-justified text field or a checkbox with custom icons. public DefaultCellEditor(JTextField x) public DefaultCellEditor(JCheckBox x) public DefaultCellEditor(JComboBox x) 27.2.4.4 Fields protected EventListenerList listenerList protected transient ChangeEvent changeEvent These fields support the cell edit events generated by the editor. The listenerList field stores the list of all registered listeners interested in hearing about stop or cancel events. The changeEvent field holds the single change event passed to listeners when events are fired. protected JComponent editorComponent This field contains the value for the component property. protected DefaultCellEditor.EditorDelegate delegate - 926
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Java Swing - (Business web hosting) O Reilly public abstract boolean isCellEditable(EventObject

Wednesday, January 30th, 2008

Java Swing - O Reilly public abstract boolean isCellEditable(EventObject anEvent) Should return true if anEvent is a valid trigger for starting this kind of editor. For example, if you want the user to double click on a field to invoke the editor, this method would test whether anEvent is a double click mouse event. If it was only a single click, you could return false. If it was a double click, you could return true. public abstract boolean shouldSelectCell(EventObject anEvent) This method should return true if the cell to be edited should also be selected. While you usually want to select the cell, there are some situations in which not selecting the cell is preferable. For example, you might be implementing a table that lets the user edit cells that are part of an ongoing selection. Since you want the selection to remain in place, you would implement this method to return false. The cell can still be edited. public abstract boolean stopCellEditing() public abstract void cancelCellEditing() You should use these methods to tell the editor to stop editing the cell. The stopCellEditing() method indicates that editing is over and the new value supplied should replace the old value of the cell. The cancelCellEditing() method indicates editing is over and the new value the user entered (if any) should be ignored. The stopCellEditing() method can return a false value if the editor is unable to stop editing. (This might occur if your editor validates input and currently contains an invalid entry.) As an example, you can use these to programmatically stop or cancel editing before starting to edit another cell or upon losing focus. 27.2.3 The CellEditorListener Interface The CellEditorListener interface defines how an object can listen for events generated by a cell editor. Cell editors generate a ChangeEvent when editing is canceled or stopped (a better term might be “finished”). Typically, the object “hosting” the editor (for example, a JTree allowing the user to enter a new filename) would register as a listener. When the event occurs, the JTree would read the cell’s new value from the editor, tear down the editor, and repaint the cell with its new value. public void editingStopped(ChangeEvent e) Indicates successful editing has been completed. You can get the new value of the cell from the editor component, which is contained in the source property of the change event. public void editingCanceled(ChangeEvent e) Indicates that editing has been canceled. You should ignore any partially edited value that might be present in the editor. 27.2.4 The DefaultCellEditor Class Swing provides a default editor with a fair amount of flexibility. The DefaultCellEditor class implements the CellEditor interface and provides constructors that let you use a text field, check box, or combo box for entering the new value. - 925
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 These overridden Container methods (Web hosting solutions)

Wednesday, January 30th, 2008

Java Swing - O Reilly These overridden Container methods ensure the editor pane behaves properly and does not adversely affect the component using the editor or the editor itself. The paint() and update() methods are both empty and the documentation states that they should not be called. public void paintComponent(Graphics g, Component c, Container p, Rectangle r) public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w,int h) public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w,int h, boolean shouldValidate) These methods do the actual work of painting the component c on the graphics context g. These methods provide the implementation for the methods of the same signatures in the SwingUtilities class, discussed previously in this chapter. The shouldValidate parameter determines whether or not c is validated before it is painted. (The first two methods end up calling the third with a false value for shouldValidate.) 27.2.1.5 Inner Classes protected class CellRendererPane.AccessibleCellRendererPane extends AccessibleContext implements Serializable, AccessibleComponent This class defines the accessible role object for CellRendererPane. 27.2.2 The CellEditor Interface This interface governs the basic functionality required of an editor. It has methods for retrieving a new value and determining when to start and stop editing. The basic process for editing is: The user clicks the required number of times on the cell (varies from editor to editor). The component (usually JTree or JTable) replaces the cell with its editor. The user types or chooses a new value. The user ends the editing session (e.g., hitting enter in a textfield). The editor fires a change event to interested listeners (usually the tree or table containing the cell), stating that editing is finished. The component reads the new value and replaces the editor with the cell’s renderer. 27.2.2.1 Events The CellEditor interface requires methods for adding and removing cell editor listeners, which are objects interested in finding out whether editing is finished or cancelled. The CellEditorListener class is discussed below. public abstract void addCellEditorListener(CellEditorListener l) public abstract void removeCellEditorListener(CellEditorListener l) 27.2.2.2 Methods public Object getCellEditorValue() Accesses the only property of a cell editor, which is the cell’s current value. After successful editing, a table or tree will call this method to retrieve the new value for the cell. - 924
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Anonymous web server - Java Swing - O Reilly As with all of

Tuesday, January 29th, 2008

Java Swing - O Reilly As with all of the other Swing components, this method updates the look-and-feel for the tooltip based on the UIManager. 27.2 Editing and Rendering Utilities Both the JTree and JTable classes make use of cell renderers to display cells and cell editors to modify cell values. The CellEditor interface is the basis for these editors, and the DefaultCellEditor class provides a good implementation of this interface. Unless you’re doing something exotic, you should be able to base your cell editors on the DefaultCellEditor class. 27.2.1 The CellRendererPane Class This utility class was built to keep renderers from propagating repaint() and validate() calls to the components using renderer components such as JTree and JList. If you played around with creating your own renderers for any of the Swing components that use them, you’ll recall that you did not use this class yourself. Normally this pane is wrapped around the renderer and the paintComponent() methods below are used to do the actual drawing. Developers will not normally need to worry about this class. 27.2.1.1 Property The CellRendererPane has only one property containing its accessible context, shown in Table 27.5. Table 27.5, CellRendererPane Property Property Data Type get is set bound Default Value accessibleContext AccessibleContext CellRendererPane.AccessibleCellRendererPane 27.2.1.2 Field protected AccessibleContext accessibleContext This field supports the accessibleContext property. 27.2.1.3 Constructor This class has only one constructor. public CellRendererPane() This constructor creates a new renderer pane that has a null layout and is not initially visible. 27.2.1.4 Methods protected void addImpl(Component x, Object constraints, int index) public void invalidate() public void paint(Graphics g) public void update(Graphics g) - 923
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 india - Java Swing - O Reilly public void registerComponent(JComponent component)

Tuesday, January 29th, 2008

Java Swing - O Reilly public void registerComponent(JComponent component) Registers component with the ToolTipManager to make sure that its tips get shown after an appropriate mouse event occurs. public static ToolTipManager sharedInstance() Returns the global ToolTipManager. You can use this to get access to the manager and changes its delay properties. For example, you could cut the initial delay to 250 milliseconds like this: ToolTipManager.sharedInstance().setInitialDelay(250); public void unregisterComponent(JComponent component) Unregisters component from the ToolTipManager. Tooltips will no longer be shown for this component. 27.1.5 The JToolTip Class Of course, the whole purpose of having a tooltip manager is to manage tooltips. The tooltips themselves are simple popups containing a short, descriptive string that often shows up if you let your mouse cursor rest too long over a component. They are embodied here in the JToolTip class. JToolTip is a fairly simple class, thanks to the MVC architecture in place for Swing. All it really needs to know is what text to display, and who to display it for. 27.1.5.1 Properties The properties that support the JToolTip class are shown in Table 27.4. The component property determines which component this tip applies to. The tipText property contains the text to display for the tip. Both of these properties are currently stored in package private variables. Table 27.4, JToolTip Properties Property Data Type get is set bound Default Value UI* TreeUI From L&F UIClassID* String “ToolTipUI” accessibleContext AccessibleContext JToolTip.Accessible-JToolTip() component Component null tipText String null 27.1.5.2 Constructor The JToolTip class has only one constructor: public JToolTip() This creates a new JToolTip object with no text or component association. 27.1.5.3 UI Method public void updateUI() - 922
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web site traffic - Java Swing - O Reilly dismissDelay int 4000 enabled

Monday, January 28th, 2008

Java Swing - O Reilly dismissDelay int 4000 enabled boolean true initialDelay int 750 lightWeightPopupEnabled[1] boolean true reshowDelay int 500 [1] Deprecated as of Swing 1.1/JDK1.2 beta4. 27.1.4.2 Fields protected boolean lightWeightPopupEnabled Stores the value of the lightWeightPopupEnabled property. Deprecated in Swing 1.1/JDK1.2 beta4. protected boolean heavyWeightPopupEnabled This field is used to help manage heavyweight (not bound by window constraints) tooltips. It is initially set to false. 27.1.4.3 Mouse Event Methods public void mouseDragged(MouseEvent event) This method is empty. (By definition, you can’t drag a tool tip.) public void mouseEntered(MouseEvent event) Gets the system ready to show the tooltip text (if any exists) in initialDelay milliseconds. public void mouseExited(MouseEvent event) Checks to make sure you’re really exiting the component (you could be mousing out of the component but into the tooltip, for example), and if so, hides the popup and starts the reshow countdown. public void mouseMoved(MouseEvent event) Monitors your movements and keeps tips active as you move from one component to the next (so that they show up immediately). public void mousePressed(MouseEvent event) Hides the popup and stops the timer watching for the initialDelay to pass. 27.1.4.4 Miscellaneous Methods If need be, you can manually register or unregister components with the manager. Normally this is done using the JComponent.setToolTipText() method for the component itself. If you pass in a non-null tip string, the component is registered. If you pass in a null tip string, the component is unregistered. - 921
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Web hosting faq - Java Swing - O Reilly super(”" + new Date());

Monday, January 28th, 2008

Java Swing - O Reilly super(”" + new Date()); Timer t = new Timer(1000, this); t.start(); } public void actionPerformed(ActionEvent ae) { setText(”" + new Date()); } } And here’s the application that displays the ClockLabel object: // ClockTest.java // A demonstration framework for the Timer driven ClockLabel class. // import javax.swing.*; import java.awt.*; public class ClockTest extends JFrame { public ClockTest() { super(”Timer Demo”); setSize(300, 100); addWindowListener(new BasicWindowMonitor()); ClockLabel clock = new ClockLabel(); getContentPane().add(clock, BorderLayout.NORTH); } public static void main(String args[]) { ClockTest ct = new ClockTest(); ct.setVisible(true); } } 27.1.4 The ToolTipManager Class This class manages the tooltips for an application. Any given virtual machine will have, at most, one ToolTipManager at any time a new instance is created when the class is loaded. You can retrieve the current manager using the ToolTipManager.sharedInstance() method. 27.1.4.1 Properties The ToolTipManager properties shown in Table 27.3 give you control over the delays (in milliseconds) involved in showing tooltips and determines whether or not tooltips are even active. The enabled property determines whether or not tooltips are active. The dismissDelay determines how long a tootip remains on the screen if you don’t do something to dismiss it manually (such as move the mouse outside the component’s borders). The initialDelay determines how long the mouse must rest inside a component before the tooltip pops up, and the reshowDelay determines how long you must wait after leaving a component before the same tooltip will show up again when you re-enter the component. If the lightWeightPopupEnabled property is true, all-Java tooltips will be used. A false value indicates native tooltips should be used. Table 27.3, ToolTipManager Properties Property Data Type get is set bound Default Value - 920
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 The list of listeners (How to cite a web site)

Monday, January 28th, 2008

Java Swing - O Reilly The list of listeners interested in receiving notification each time the timer generates an event. 27.1.3.4 Constructor public Timer(int delay, ActionListener listener) Creates a Timer object that notifies its listener every delay milliseconds. The listener argument can be null. The timer is not started right away; you must manually call the start() method. 27.1.3.5 Timer Control Methods You also have a few methods to control the timer at runtime: public void start() Starts the timer. The first event comes after initialDelay milliseconds, and if it’s a repeating timer, every delay seconds after that. public void restart() Restarts the timer. This method calls stop() and then start(). public void stop() Stops the timer. Any timer events that have not yet been fired will be deleted. Figure 27.2 shows a ClockLabel that updates itself every minute, using events from a Timer. The code to prouce our ticking label is remarkably short when we use a Timer. Figure 27.2. The Timer class in action with a ClockLabel // ClockLabel.java // An extension of the JLabel class that listens to events from // a Timer object to update itself with the current date & time. // import java.util.*; import java.awt.event.*; import javax.swing.*; public class ClockLabel extends JLabel implements ActionListener { public ClockLabel() { - 919
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Java Swing - O Reilly 27.1.3 The Timer Class (Anonymous web server)

Sunday, January 27th, 2008

Java Swing - O Reilly 27.1.3 The Timer Class The Timer class behaves like an invisible component. It has properties and events, and thus can be used in application builders that understand JavaBeans. Its purpose is to fire an ActionEvent at a given time. The event can be set to repeat, and an optional initial delay can be set before the repeating event starts. 27.1.3.1 Properties The Timer class properties give you access to the timer delays and nature of the event firing loops. They are listed in Table 27.2. The delay property dictates the length between repeated timer events (if repeats is true) and initialDelay determines how long to wait before starting the regular, repeating events. If your timer is not repeating, then the value of initialDelay determines when the timer fires its event. You can check to see if the timer is running with the running property. The coalesce property dictates whether or not the timer will combine pending events into one single event (to help listeners keep up). For example, if the timer fires a tick every 10 milliseconds, but the application is busy and has not handled events for 100 milliseconds, 10 action events are queued up for delivery. If coalesce is false, all 10 of these will be delivered in rapid succession. If coalesce is true (the default) only one event will be fired. The logTimers property can be turned on to generate simple debugging information to the standard output stream, each time an event is processed. Table 27.2, Timer Propertiessv Property Data Type get is set bound Default Value delay int from constructor coalesce boolean true initialDelay int this.delay logTimers boolean false repeats boolean true running boolean false 27.1.3.2 Events A Timer generates an ActionEvent whenever it “goes off.” You can listen for ActionEvent if you want to react to a timer tick. public void addActionListener(ActionListener l) public void removeActionListener(ActionListener l) Add and remove listeners interested in receiving action events from the timer. The Timer class also contains its own fireActionPerformed() method to facilitate event reporting if you subclass Timer. protected void fireActionPerformed(ActionEvent e) Sends ActionEvent objects to any registered listeners. 27.1.3.3 Fields protected EventListenerList listenerList - 918
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.