Archive for December, 2007

Java Swing - O Reilly In this figure, we

Monday, December 31st, 2007

Java Swing - O Reilly In this figure, we show what happens when a new JTree component gets created. The process is the same for any Swing component. First, the constructor calls updateUI(). Each Swing component class provides an updateUI() method that looks something like this: public void updateUI() { setUI((TreeUI)UIManager.getUI(this)); } The updateUI() method asks the UIManager class (via its static getUI() method) for an appropriate UI delegate object. The UIManager consults an instance of UIDefaults (set up when the L&F was first installed) for the appropriate UI delegate. The UIDefaults object goes back to the component to get the UI class ID. In our JTree example, “TreeUI” will be returned. UIDefaults then looks up the Class object for the class ID. In this case, it finds the MetalTreeUI class. The static method createUI() is called (using reflection) on this UI delegate class. This static method is responsible for returning an instance of the UI delegate class. In some cases, a single instance is shared by all components. In other cases, a new instance is created each time. In this diagram, we show a new instance of MetalTreeUI being created and returned from createUI(). At last, the JTree has a UI delegate. The updateUI() method now calls setUI(). If a UI delegate was already installed (in this example, we’re creating a new component, so there is no delegate installed yet), setUI() would call uninstallUI() on the old delegate. setUI() now calls installUI() on the new UI delegate, passing in the component. The installUI() methods for different components do different things. Often (as shown here), installUI() is used to install listeners (allowing the UI delegate to keep track of changes made to the component), set defaults (e.g., fonts and colors), and add keyboard actions. Now that the new component has been associated with its UI delegate, it can use the delegate for all L&F-related operations. The JComponent base class delegates the following methods to its UI: paintComponent() (called by paint(); calls ui.update()) getPreferredSize() getMaximumSize() getMinimumSize() contains() The three size accessors only delegate to the UI if a value has not been explicitly set on the component itself via a call to setPreferredSize(), setMaximumSize(), or setMinimumSize(). Now let’s take a second look under the hood and see how the delegation of the painting process actually happens. The process in Figure 26.2 is pretty straight-forward. Figure 26.2. Swing painting delegation - 860
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web hosting bandwidth - Java Swing - O Reilly An overview of

Sunday, December 30th, 2007

Java Swing - O Reilly An overview of how the Swing component classes work together with the UI-delegate classes. A detailed explanation of the various PLAF-related classes in the javax.swing package, as well as some of the important classes and interfaces from javax.swing.plaf. An explanation of how PLAF fits into JFC’s accessibility framework using the MultiLookAndFeel. Detailed discussions of strategies for customizing the look-and-feel of your applications using the following techniques: o Modification of specific component properties o Modification of resource defaults o Use of themes in the Metal L&F o Use of customized client properties in the Metal look-and-feel (L&F) o Replacement of specific UI delegates o Creation of a new L&F from scratch This chapter contains a lot of technical detail. You can do a lot with Swing’s PLAF architecture without understanding everything we cover here. If you’re interested in customizing the look-andfeel of your applications, but don’t mind if there are a few things that don’t quite make sense, you can skim the next few sections and jump right into Section 26.4. If you want to understand exactly how everything works, read on. 26.1 How Does It Work? As you probably already know, each instance of a given Swing component uses a UI delegate to render the component using the style of the currently installed L&F. To really understand how things work, it helps to peek under the hood for a moment to see what methods get called at a few key points. The first point of interest is component creation time. When a new Swing component is instantiated, it must associate itself with a UI delegate object. Figure 26.1 shows the important steps[1] in this process. [1] We do not show every method call. It is intended as a high-level overview of the process. Figure 26.1. UI delegate installation - 859
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Java Swing - O Reilly Figure 25.2 below shows

Sunday, December 30th, 2007

Java Swing - O Reilly Figure 25.2 below shows the result. We’ve connected our assistive technology to one of the menu examples from Chapter 14. Because Swing components support accessibility, we didn’t need to modify the menu example. Below that, we added our assistive technology to the accessible AWT button we developed earlier, showing that we can communicate with it. Figure 25.2. The assistive example Note that while using JDK 1.2 accessibility, we had to check to see if the GUI was ready for us to start firing accessibility-related commands to it. We do this by checking the EventQueueMonitor.isGUIInitialized() method. This method returns a boolean indicating whether the GUI will accept accessibility commands. If it does, then we’re fine. If it doesn’t, then we must register ourselves to be notified when the GUI becomes available. This makes use of the GUIInitializedListener interface, which is explained earlier in the chapter. Finally, note that we have a single button in our assistive example that performs to first action reported by the accessible context. You can use the TAB key to bring this button into focus while pointing with the mouse. Then, press the space bar to fire off the action. Chapter 26. Look & Feel Way back in Chapter 1, we introduced the concept of Swing’s pluggable look-and-feel (PLAF ) architecture. In this chapter, we’ll get into a variety of topics related to PLAF. The chapter includes: - 858
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 } public void actionPerformed(ActionEvent (Web site counters)

Saturday, December 29th, 2007

Java Swing - O Reilly } public void actionPerformed(ActionEvent e) { // Find the component currently under the mouse. Point currentPosition = EventQueueMonitor.getCurrentMousePosition(); Accessible comp = EventQueueMonitor.getAccessibleAt(currentPosition); // If the user pressed the button, and the component // has an accessible action, then execute it. if (e.getActionCommand() == “Perform Action”) { AccessibleContext context = comp.getAccessibleContext(); AccessibleAction action = context.getAccessibleAction(); if (action != null) action.doAccessibleAction(0); else System.out.println(”No accessible action present!”); return; } // Otherwise, the timer has fired. Stop it and update the window. timer.stop(); updateWindow(comp); } private void updateWindow(Accessible component) { // Reset the check boxes actionCheckBox.setSelected(false); selectionCheckBox.setSelected(false); textCheckBox.setSelected(false); componentCheckBox.setSelected(false); valueCheckBox.setSelected(false); hypertextCheckBox.setSelected(false); // Get the accessibile context of the component in questionAccessibleContext context = component.getAccessibleContext(); nameLabel.setText(”Name: ” + context.getAccessibleName()); descriptionLabel.setText(”Desc: ” + context.getAccessibleDescription()); // Check the context for each of the accessibility types if (context.getAccessibleAction() != null) actionCheckBox.setSelected(true); if (context.getAccessibleSelection() != null) selectionCheckBox.setSelected(true); if (context.getAccessibleText() != null) { textCheckBox.setSelected(true); if (context.getAccessibleText() instanceof AccessibleHypertext) hypertextCheckBox.setSelected(true); } if (context.getAccessibleComponent() != null) componentCheckBox.setSelected(true); if (context.getAccessibleValue() != null) valueCheckBox.setSelected(true); repaint(); } } - 857
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 valueCheckBox = new JCheckBox(”Value”, (Tomcat web server)

Saturday, December 29th, 2007

Java Swing - O Reilly valueCheckBox = new JCheckBox(”Value”, false); componentCheckBox = new JCheckBox(”Component”, false); actionCheckBox = new JCheckBox(”Action”, false); hypertextCheckBox = new JCheckBox(”Hyperlink”, false); performAction = new JButton(”Perform Action”); setLayout(new GridLayout(10,1)); add(nameLabel); add(descriptionLabel); add(new JSeparator()); add(selectionCheckBox); add(textCheckBox); add(valueCheckBox); add(componentCheckBox); add(hypertextCheckBox); add(actionCheckBox); add(performAction); setBorder(new TitledBorder(”Accessible Component”)); performAction.addActionListener(this); frame.getContentPane().add(”Center”, this); frame.pack(); frame.show(); // Check to see if the GUI subsystem is initialized // correctly. (This is only needed in JDK 1.2). If it // isn’t, then we have to wait. if (EventQueueMonitor.isGUIInitialized()) { createGUI(); } else { EventQueueMonitor.addGUIInitializedListener(this); } performAction.grabFocus(); } public void guiInitialized() { createGUI(); } public void createGUI() { // We want to track the mouse motions, so notify the // Swing event monitor of this. SwingEventMonitor.addMouseMotionListener(this); // Start a Timer object to measure how long the mouse stays // over a particular area. timer = new Timer(500, this); } public void mouseMoved(MouseEvent e) { // If the mouse moves, restart the timer. timer.restart(); } public void mouseDragged(MouseEvent e) { // If the mouse is dragged, restart the timer. timer.restart(); - 856
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 25.6 Interfacing with Accessibility (Web domain)

Friday, December 28th, 2007

Java Swing - O Reilly 25.6 Interfacing with Accessibility The following code shows how to create a simple assistive technology that can monitor events on the system event queue and interface with accessible components. The example consists of one class, AssistiveExample. This class creates a small window, containing two labels and five check boxes, which are repeatedly updated when the mouse comes to rest over an accessible component for longer than half a second. Note that while using JDK 1.2 accessibility, we had to check to see if the GUI was ready for us to start firing accessibility-related commands to it. We do this by checking the EventQueueMonitor.isGUIInitialized() method. This method returns a boolean indicating whether the GUI will accept accessibility commands. If it does, then we’re fine. If it doesn’t, then we must register ourselves to be notified when the GUI becomes available. This makes use of the GUIInitialized-Listener interface, which is explained earlier in the chapter. Finally, note that we have a single button in our assistive example that performs to first action reported by the accessible context. You can use the TAB key to bring this button into focus while pointing with the mouse. Then, press the space bar to fire off the action. // AssistiveExample.java// import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import javax.accessibility.*; import com.sun.java.accessibility.util.*; public class AssistiveExample extends JPanelimplements MouseMotionListener, ActionListener, GUIInitializedListener { Timer timer; static JFrame frame; JLabel nameLabel; JLabel descriptionLabel; JCheckBox selectionCheckBox; JCheckBox textCheckBox; JCheckBox valueCheckBox; JCheckBox componentCheckBox; JCheckBox actionCheckBox; JCheckBox hypertextCheckBox; JButton performAction; public AssistiveExample() { frame = new JFrame(”Assistive Example”); // Create and insert the appropriate labels and check boxes nameLabel = new JLabel(); descriptionLabel = new JLabel(); selectionCheckBox = new JCheckBox(”Selection”, false); textCheckBox = new JCheckBox(”Text”, false); - 855
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Java Swing - (Web hosting domain names) O Reilly Add or remove a

Friday, December 28th, 2007

Java Swing - O Reilly Add or remove a listener for Swing TreeSelectionEvents. public static addUndoableEditListener(UndoableEditListener l) public static removeUndoableEditListener(UndoableEditListener l) Add or remove a listener for Swing UndoableEditEvents. public static addVetoableChangeListener(VetoableChangeListener l) public static removeVetoableChangeListener(VetoableChangeListener l) Add or remove a listener for VetoableChangeEvents. 25.5.4 The TopLevelWindowListener Interface This is a simple listener that assistive technologies can implement and register with the addTopLevelWindowListener() and removeTopLevelWindowListener() methods of the EventQueueMonitor class if they want to receive notification when a top-level window is created or destroyed. The interface contains two methods: 25.5.4.1 Methods public abstract void topLevelWindowCreated(Window w) Invoked when a top-level window has been created. public abstract void topLevelWindowDestroyed(Window w) Invoked when a top-level window has been destroyed. 25.5.5 The GUIInitializedListener Interface GUIInitializedListener is a simple interface that was added with the 1.2 Accessibilitypackage. This interface contains a single method, guiInitialized(), which is called via the EventQueueMonitor when the GUI subsystem of the Java VM is ready to have assistive technologies interface with it (i.e., register event listeners for components). 25.5.5.1 Method public void guiInitialized() Invoked by the EventQueueMonitor when the GUI subsystem has completed initializing itself and is ready to interface with assistive technologies. This interface is necessary because the GUI subsystem for JDK 1.2 may not be ready to deal with outside technologies by the time the assistive technology is loaded into the virtual machine. Hence, you should always check in the constructor of your assistive technology class to see if the GUI is initialized (using the static method EventQueueMonitor.isGUIInitialized()), and if it isn’t, register a class that implements this interface with the EventQueueMonitor. When the GUI is ready, it will invoke this method, and the assistive technology can complete its initialization. (See the example at the end of the chapter for the code to do this.) - 854
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 (Web proxy server) public static removeColumnModelListener(TableColumnModelListener l)

Friday, December 28th, 2007

Java Swing - O Reilly public static removeColumnModelListener(TableColumnModelListener l) Add or remove a listener for Swing TableColumnModelEvents. public static addDocumentListener(DocumentListener l) public static removeDocumentListener(DocumentListener l) Add or remove a listener for Swing DocumentEvents. public static addListDataListener(ListDataListener l) public static removeListDataListener(ListDataListener l) Add or remove a listener for Swing ListDataEvents. public static addListSelectionListener(ListSelectionListener l) public static removeListSelectionListener(ListSelectionListener l) Add or remove a listener for Swing ListSelectionEvents. public static addMenuListener(MenuListener l) public static removeMenuListener(MenuListener l) Add or remove a listener for Swing MenuEvents. public static addPopupMenuListener(PopupMenuListener l) public static removePopupMenuListener(PopupMenuListener l) Add or remove a listener for Swing PopupMenuEvents. public static addPropertyChangeListener(PropertyChangeListener l) public static removePropertyChangeListener(PropertyChangeListener l) Add or remove a listener for PropertyChangeEvents. public static addTableModelListener(TableModelListener l) public static removeTableModelListener(TableModelListener l) Add or remove a listener for Swing TableModelEvents. public static addTreeExpansionListener(TreeExpansionListener l) public static removeTreeExpansionListener(TreeExpansionListener l) Add or remove a listener for Swing TreeExpansionEvents. public static addTreeModelListener(TreeModelListener l) public static removeTreeModelListener(TreeModelListener l) Add or remove a listener for Swing TreeModelEvents. public static addTreeSelectionListener(TreeSelectionListener l) public static removeTreeSelectionListener(TreeSelectionListener l) - 853
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Affordable web hosting - Java Swing - O Reilly protected static getComponentWithFocus() Returns

Thursday, December 27th, 2007

Java Swing - O Reilly protected static getComponentWithFocus() Returns the component that currently has the keyboard focus. 25.5.3 The SwingEventMonitor Class The SwingEventMonitor extends the AWTEventMonitor class and provides event registration for all Swing events as well. This class contains a series of protected listener arrays, and allows applications to register listeners for any and all AWT and Swing events that pass through the event queue. Note that SwingEventMonitor contains all the functionality of AWTEventMonitor; use this class to gain access to both types of windowing events. 25.5.3.1 Fields protected static EventListenerList listenerList Stores all the listeners registered by other classes. The event monitor’s add and remove methods are the only public means for modifying this list. protected static SwingEventListener swingListener The listener that’s actually installed on components. 25.5.3.2 Constructor public SwingEventMonitor() The default constructor. There is no need for the programmer to invoke it. 25.5.3.3 Methods public static addAncestorListener(AncestorListener l) public static removeAncestorListener(AncestorListener l) Add or remove a listener for Swing AncestorEvents. public static addCaretListener(CaretListener l) public static removeCaretListener(CaretListener l) Add or remove a listener for Swing CaretEvents. public static addCellEditorListener(CellEditorListener l) public static removeCellEditorListener(CellEditorListener l) Add or remove a listener for Swing CellEditorEvents. public static addChangeListener(ChangeListener l) public static removeChangeListener(ChangeListener l) Add or remove a listener for Swing ChangeEvents. public static addColumnModelListener(TableColumnModelListener l) - 852
We recommend high quality webhost to host and run your jsp application: christian web host services.

Java Swing - (Best web hosting site) O Reilly Add or remove a

Thursday, December 27th, 2007

Java Swing - O Reilly Add or remove a listener for AWT ActionEvents from the monitor. public static addAdjustmentListener(AdjustmentListener l) public static removeAdjustmentListener(AdjustmentListener l) Add or remove a listener for AWT AdjustmentEvents from the monitor. public static addComponentListener(ComponentListener l) public static removeComponentListener(ComponentListener l) Add or remove a listener for AWT ComponentEvents from the monitor. public static addContainerListener(ContainerListener l) public static removeContainerListener(ContainerListener l) Add or remove a listener for AWT ContainerEvents from the monitor. public static addFocusListener(FocusListener l) public static removeFocusListener(FocusListener l) Add or remove a listener for AWT FocusEvents from the monitor. public static addItemListener(ItemListener l) public static removeItemListener(ItemListener l) Add or remove a listener for AWT ItemEvents from the monitor. public static addKeyListener(KeyListener l) public static removeKeyListener(KeyListener l) Add or remove a listener for AWT KeyEvents from the monitor. public static addMouseListener(MouseListener l) public static removeMouseListener(MouseListener l) Add or remove a listener for AWT MouseEvents from the monitor. public static addMouseMotionListener(MouseMotionListener l) public static removeMouseMotionListener(MouseMotionListener l) Add or remove a listener for AWT MouseMotionEvents from the monitor. public static addTextListener(TextListener l) public static removeTextListener(TextListener l) Add or remove a listener for AWT TextEvents from the monitor. public static addWindowListener(WindowListener l) public static removeWindowListener(WindowListener l) Add or remove a listener for AWT WindowEvents from the monitor. - 851
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.