Archive for October, 2007

Now you can define some event (Unlimited web hosting) processing for

Wednesday, October 31st, 2007

Now you can define some event processing for the new button. Right-click the selected button. In the context menu choose Events, and in the cascading submenu select actionPerformed. Now, sit back and watch how the source code for this event is generated: jButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println(”actionPerformed()”); // TODO Auto-generated Event stub actionPerformed() } }); If you now run the program again after saving it, the text actionPerformed() appears in the Console View when you click OK. The Events submenu, however, lists only the most relevant events for a component. Other event types can be reached via the Add Event function. For example, if you want to react to the resizing of components, you need to invoke the Events > Add Event … context function. In the dialog that appears, expand the Component class. Then select the componentResized event type. Finally, you may specify whether a subclass of the ComponentAdapter class is to be generated or whether a complete implementation of the ComponentListener interface is to be generated. Afterwards, you can complete the definition of the componentResized() method in the source code area as needed. This concludes our short introduction into the Eclipse Visual Editor. In Chapter 5 I will demonstrate the VE in the design of a more complex GUI in the context of a larger application. Summary This chapter has given you a glimpse of the Eclipse Visual Editor. Novices especially often find it easier to design GUI surfaces visually. Currently the Eclipse Visual Editor supports only Swing GUIs. If you need help creating SWT GUIs (see Chapter 8) , you still have to rely on third-party GUI designers, some of which are listed in Appendix A. Another possibility is to use the SWT Layout example plug-in as a code generator. In the next chapter we will take a more detailed look into the Eclipse workbench. 50 Chapter 3
Would you like to be a member of headache free web site owner’s community. Now you can. We focus in IX Web Hosting, go go go!

text content starts to the left of the (Web hosting script)

Tuesday, October 30th, 2007

text content starts to the left of the component. To fix this, select the component jLabel in the Java Beans View. (You may want to rename this component using the context function Rename Field.) In the Properties View, find the property named horizontalAlignment. This property currently has the value LEADING. Select this entry with the mouse. An arrow button appears beside LEADING. Now click this button and select CENTER, and the text is centered. VE supports almost any of the properties of the Swing components with a few exceptions. For example, you cannot specify client properties (putClientProperty()) in the Properties view, and for JLabel components you cannot specify target components for mnemonic codes (setLabelFor()). Such properties must be set manually in the source code. Layouts Now select the component jContentPane in the Java Beans View. Like all Swing containers, this container, too, has a layout. You will find the property layout in the Properties View. As you can see, this container is already equipped with a BorderLayout. Clicking the arrow button gives you a list of the available layout options. At the left of the layout entry is a plus sign. Clicking this sign expands the entry and allows you to make further specifications for this layout manager, such as horizontal gap and vertical gap. Finally, there is an option to work without a layout manager. To do so, select the null option in the list of layout managers. Then you can position the JLabel component freely within the content pane. Normally, you should change layout settings only after you have filled a container with components. This is because with some layouts, empty containers have a size of zero, and it can become quite tricky to place a component into a container of zero size. However, if something like this should happen, there is always a way out: instead of placing a component into a container within the design area, apply the same operation to the Java Beans View. If you later want to move components to a different position or even to a different container, this is easy: both the design area and the Java Beans View support moving components by drag and drop. However, the VE does not support cut-and-paste operations for components. If you need detailed information about Swing and Swing layout managers, please refer to the resources listed in Appendix D, for example to the book Swing by Robinson and Vorobiev. Event Processing Finally, let s see how event processing can be programmed with the help of the VE. Let s first create one more component, a JButton, in the content pane of the JFrame container. You can select the position freely, for example, the South area (if you are still using the BorderLayout manager). If you are working without a layout manager, reduce the size of the JLabel component somewhat to make room for the new JButton component. Then, find the entry text in the Properties View and enter OK as the button text. Alternatively, you can just click the button in the design area and enter OK in the text input area. 49 The Art of (Visual) Composition
Are you a Mac user in a search of Mac web hosting provider? We are. once upon a time, we were just like you, trying to find somebody who knows. Unfortunately, we had no luck, so we decided to help many others like you, and us. our team developed Mac friendly web hosting plans, feature packed, constantly monitored, and more than affordable. With us, you are home. Sign up.

This figure shows the components of the VE. (Tomcat web hosting)

Monday, October 29th, 2007

This figure shows the components of the VE. At the top left you see the selection menu for the GUI elements. Adjoining to the right is the working area, consisting of the design area and the source code editor. On the far left is the Outline View, as already known from the Java editor. At the bottom I have docked the Java Beans View to the right of the Properties View (see the Arranging Editors and Views section in Chapter 4), in order to allow for comfortable editing. You may store this arrangement as your own perspective (see the Managing Perspectives section in Chapter 4). As you can see in the Outline View (and in the source code, too), these actions have generated the methods getJFrame(), getJContentPane(), and getJLabel(). All that remains to do is to invoke the method getJFrame() from the main() method. To do so, modify the main() method in the source code area as follows: public static void main(String[] args) { HelloVE hello = new HelloVE(); javax.swing.JFrame frame = hello.getJFrame(); frame.setVisible(true); } After saving this code with Ctrl+S, you can execute this program immediately by issuing the command Run > Run As > Java Application. Beans and Bean Properties All the components available in the VE s GUI element menu are provided in the form of Java Beans. Java Beans are Java classes that follow certain coding standards. For example, a Java Bean must always have a standard constructor without any parameters. The features of such a Java Bean are described in an associated class, a BeanInfo class. The VE uses this information via introspection to display the component in an appropriate form and to generate code. Generic Beans The VE is not restricted to AWT and Swing components. In principle, any Java Bean can be placed onto the design area. You may even write your own beans, which then can be used in the VE. You can select such beans by clicking the Choose Bean button in the selection menu. Detailed information about the implementation of Java Beans is found in the book Java Beans 101 by Steams. The Java Beans View shows the hierarchy of beans used in the design area, so it is easy to keep an overview of the construction of the GUI. The Java Beans View also helps during the selection of components, for example, if a component is hidden in the design area by another component. In this case you can use the Java Beans View to select the component. Properties The properties of a bean are displayed in the Properties View and can be modified there. In the above example, the label text is not centered correctly, despite the fact that the JLabel component was placed into the Center area. The reason is that the component stretches across the whole content pane, and its 48 Chapter 3
The UK has been a member of the European Union since 1973. The attitude of the present government towards further integration is conservative, with the official opposition favoring a return of some powers and competencies to the UK.From our experience, we can recommend Cheap UK Web Hosting services.

Try it with a small example. In HelloWorld (Apache web server tutorial)

Sunday, October 28th, 2007

Try it with a small example. In HelloWorld project, just create a new class named HelloVE as described in Chapter 1 (with a main() method). Then close the Java editor. In the Package Explorer, apply the context function Open with > Visual Editor to HelloVE. Now open the Swing Containers group in the GUI element menu of the VE. Select the component JFrame. Then click the target position in the design area. The smallest possible JFrame instance now appears at the target position. Click the bottom-right corner of this component and drag it to the desired size. As you can see in the Java Beans View, the JFrame instance already contains a content pane (JPanel instance), which fills the entire area of the JFrame instance. Now click the Swing Components group to open it. Select the JLabel component and release the mouse button. Then move the mouse over the (still selected) JFrame component in the design area. As you move the mouse, different areas labeled North, Center, South, East, and West will appear because the content pane is already equipped with a BorderLayout (see below in section Layouts ). Now, click the mouse to place the JLabel component into the Center area. In this area you will now see a JLabel instance named JLabel.It may well be that this instance appears at a slightly different position because the BorderLayout manager performs automatic positioning. Now click the already selected JLabel instance once again. A text input area opens, where you can overwrite the text JLabel with Hello VE, as shown in Figure 3.1. 47 The Art of (Visual) Composition GUI-element menu (expanded) Design area Switch between design and source code Properties-View Beans-View Figure 3.1
Here java web hosting you will find professional-grade java web hosting at affordable prices.

Invocation After installation, the (Web site translator) VE is hard to

Saturday, October 27th, 2007

Invocation After installation, the VE is hard to notice. When you open Eclipse help, you will see a separate chapter for the Visual Editor. After a short browse through the supplied information, you may find out that the VE can be applied to any Java compilation unit. To do so, you must open a closed Java file with the context function Open with > Visual Editor. Afterwards, this file will be always opened with the VE when you double-click it in the Package Explorer. During your first steps with the VE you will soon notice that a large screen is required to work with the VE efficiently, because the editor area is subdivided into a visual design area and an area for the source code. As a matter of fact, you can maximize the editor area by double-clicking its title bar. Unfortunately, this is not a good solution because the Java Beans View and the Properties View are used frequently during the design process. So, it is better to switch back to the normal workbench mode. Bad news for notebook users, it seems. A nice feature is that the division of the design area and the source code area is not fixed but can be varied by moving the sash between the areas. By clicking one of the arrows on the sash you can maximize one area or the other. Furthermore, there is a viewing mode switch in the Java Beans View (second button from the left), which you can use to switch this view to a navigator function: the view shows the design area in reduced size, and by moving the gray rectangle you can easily navigate within a large layout. Preferences Of course, you can also opt not to use this split-screen editor but use a tabbed folder instead. In this case, both the design area and the source code area completely fill the editor area of the workbench and are activated by selecting the appropriate tab at the bottom of the editor area. This mode is especially useful for smaller screens (notebook users enjoy!). To activate this mode, go to Window > Preference > Java > Visual Editor. On the Appearance page, from the Show the Visual Editor and Source Editor section, select the On Separate Notebook Tabs option. On the same page you can also determine the skin (Look&Feel) to be used for generated Swing GUIs. If you own a fast computer, you may also want to shorten the delay for updating the source code after design changes (or vice versa). This is done on the Code Generation page under Source Synchronization Delay. The default value is 500 msec. Composition Composing GUIs with the VE is quite simple. On the left margin of the VE you will find a menu with GUI elements. These are organized in groups: Swing Components, Swing Containers, Swing Menus, and AWT Controls. Clicking such a group will expand it and collapse all others. However, clicking the pin at the right-hand side of the group name lets you keep a group open permanently. To move a GUI element to the design area, first select it with the mouse. Then click the target position in the design area. You don t drag and drop elements, but rather you move them as you would move cards in the card game Freecell. 46 Chapter 3
Our unmatched NT experience allows us to provide the most reliable and affordable hosting for our customers, just check NT Web Hosting services.

The Art of (Visual) Composition (Windows 2003 server web) One of the

Friday, October 26th, 2007

The Art of (Visual) Composition One of the more frequently asked questions directed to the Eclipse development team was if and when a visual GUI editor would be available for Eclipse. Eclipse 2 SDK did not provide a visual editor, but after a while several third-party GUI editor plug-ins appeared on the market (see Appendix A). Then, at Christmas 2003, eclipse.org released the first version (0.5) of the Eclipse Visual Editor for Java (VE) that, initially, supports only the design of Swing GUIs under Eclipse 2.1. In May 2004, VE M1 was released for the Eclipse 3 platform. Support of SWT GUIs is planned for version 1.0. What s nice about this tool is that it is completely free and that it is Open Source. But this is not its only advantage. The VE has like Eclipse its roots in Visual Age, despite the fact that it was implemented from scratch in Java. One of the main features of the VE is that it supports two-way programming: changes in the visual layout appear immediately in the generated Java code, while changes in the Java code are reflected back to the visual layout as soon as the source code is saved with Ctrl+S. With this feature, the VE completely refrains from using metadata but derives all information from the source code. Installation In this task the VE relies on the facilities of the Eclipse Modeling Framework (EMF). Therefore, before installing the VE, you must install the EMF. The EMF can be downloaded from www.eclipse.org/emf/. To install it, just unpack the downloaded archive into the /eclipse root directory. Then start the Eclipse platform and follow the instructions of the Update Manager. After restarting Eclipse, you can install the VE in the same manner. The VE download can be obtained from www.eclipse.org/vep/. 3
Check our reliable web hosting section. Most often, a reliable protocol is also connection-oriented. However, this is not always so. For example, TCP/IP is a connection-oriented protocol, with the virtual circuit ID consisting of source and destination IP addresses and port numbers. However, there are also unreliable protocols that are connection-oriented as well. These include ATM and Frame Relay, on which 90% or more of all Internet traffic is passed.

Figure 2.8 Summary After studying this chapter you

Thursday, October 25th, 2007

Figure 2.8 Summary After studying this chapter you should know about the main productivity techniques embodied in the Eclipse platform and the Eclipse Java SDK. Features such as help and hover, and especially the content assistants and templates, allow you to work without constantly searching programming guides and manuals. Instead, the information is provided where and when it is needed. Strong navigation functions allow you to get around in your application quickly. Especially in large applications such functions are essential. Various assistants for source code completion, refactoring, and bug fixes help you to adopt an agile programming style. In Chapter 16 I will discuss how these functions support the Extreme Programming approach. In the next chapter I will introduce the Eclipse Visual Editor. 44 Chapter 2
Do you want truly affordable web hosting? With us, what you see is what you get, just click on affordable web hosting services.

Undoing the Refactor functions (see the Refactoring Code (Managed web hosting)

Wednesday, October 24th, 2007

Undoing the Refactor functions (see the Refactoring Code section) is a special case. The normal Undo function can only revert these functions in several steps and then only partially. To undo a Refactor function, it is better to use the special Undo (Ctrl+Shift+Z) and Redo (Ctrl+Shift+Y) functions in the Refactor submenu. Local History The Local History function group belongs to Eclipse s most powerful functionality for maintaining source code. For each compilation unit, Eclipse stores a configurable number of older versions that are updated with each Save operation. You can set the number of stored versions in Preferences > Workbench > Local History. The default value is 50 versions, with a maximum age of seven days and a maximum file size of 1 Mb. If you use the Save key (Ctrl+S) as frequently as I do, it would be better to increase the maximum number of versions a bit. The Local History functions work for any type of resource, not just for Java source code. Comparing Resources The context function Compare > Local History allows you to compare the current version of a compilation unit with previous versions. First, you get a selection list with the previous versions nicely grouped by days. Clicking one of these versions will compare the selected version with the current version. You can invoke this function from the Package Explorer or from the Resource Navigator. It can also be called from the editor, where it is applied to the selected element only for example, a method. In Figure 2.8 I have deleted and modified some comments and extracted the println() statement as a separate method. The comparison shows the deleted lines on the right and the inserted lines on the lefthand side on a gray background. The right vertical ruler shows all modifications to the file: the selected modification has a black border, and all other modifications have a gray border. The window at the topright corner (Java Structure Compare) allows the comparison of single methods. Replacing with an Older Version The function Replace > Local History works very similarly to Compare > Local History. The window is additionally equipped with a Replace button with which you can replace the current version with the version in the right window. In contrast, this function does not have a Java Structure Compare window. Restore Deleted Resource Mistakenly deleting a resource is not a tragedy either. The function Restore from Local History provides a selection list for previously deleted resources that can be restored by simply marking their check boxes. 43 Effective Programming with Eclipse
File Transfer Protocol comes together with anonymous ftp access with every FTP Web Hosting account we offer today. Enjoy burs table ftp transfers together with fast FTP connection.

Geocities web hosting - System.out.println(”Status 0″); break; } } After: private int

Tuesday, October 23rd, 2007

System.out.println(”Status 0″); break; } } After: private int status; public void process() { switch (getStatus()) { case 0 : System.out.println(”Status 0″); break; } } public void setStatus(int status) { this.status = status; } public int getStatus() { return status; } . Convert Local Variable to Field. The function Refactor > Convert Local Variable to Field can convert a local variable that is defined in a method body into an instance field. Constants . Extract/Inline Constant. The extract and inline functions discussed for variables are available for constants, too. For example, select the string Hello World and invoke the function Refactor > Extract Constant In the dialog that appears, assign the name HELLOWORLD to the new constant. Eclipse now inserts the line private static final String HELLOWORLD = “Hello World”; and replaces all occurrences of Hello World with HELLOWORLD. Vice versa, the function Refactor > Inline allows you to resolve the names of constants by replacing them with the constant s value. Undo and Redo With Edit > Undo (Ctrl+Z) it is possible to revert previous actions. The Undo function can be applied over many steps no limit seems to exist. Undo can even undo actions across previous Save operations. With Edit > Redo (Ctrl+Y) you can once again execute actions that were previously undone by applying the Undo function. 42 Chapter 2
If you need complete web hosting solution you come to right place,try mac web hosting services.

. Use (Yahoo web space) Supertype. After creating the interface IHelloWorld

Monday, October 22nd, 2007

. Use Supertype. After creating the interface IHelloWorld you can call the function Refactor > Use Supertype Where Possible for class HelloWorld. This function offers you a choice between the types IHelloWorld and Object. Both are supertypes of HelloWorld. If you now select IHelloWorld, Eclipse will replace all references to HelloWorld with references to IHelloWorld, provided that this will not result in compilation errors. . Convert Nested Type to Top Level. Inner classes and interfaces can be separated into their own compilation unit (.java file) by applying the method Refactor > Convert Nested Type to Top Level to them. The new compilation unit is equipped with the necessary import statements. In the type definition that previously contained the inner type, a new class field is generated whose type declaration refers to the newly generated top-level type. In addition, the constructor of the container type is extended with a new parameter that supplies the new field with an instance of the new top-level type. . Convert Anonymous Type to Nested Type. Anonymous classes are used quite often as event listeners. Such anonymous classes can be converted easily into named inner classes by applying the function Refactor > Convert Anonymous to Nested . Variables . Extract Local Variable. The function Refactor > Extract Local Variable replaces the selected expression with the name of a new variable. A suitable variable assignment is inserted before the modified expression. For example, in System.out.println(”Hello World”); select HelloWorld and apply the function. In the dialog that appears, specify hi for the variable name. The result is: String hi = “Hello World”; System.out.println(hi); Optionally, all occurrences of HelloWorld are replaced with a reference to the variable hi. . Inline method or local variable. The function Refactor > Inline works in the opposite way. For example, if you select the variable hi and apply this function, all occurrences of hi are replaced with the value of hi (the string Hello World). Before the replacement is performed, a dialog box shows you the effects of the replacement by comparing the old version with the new version of the compilation unit (see the Local History section). Similarly, you can resolve a method by selecting the method name and invoking this function. . Encapsulate. The function Refactor > Self Encapsulate allows you to convert a public variable into a private variable. It generates the access method for this variable (see also Generate Getter and Setter in the Encapsulating Fields section) and updates all read and write access to this variable accordingly. Before: public int status; public void process() { switch (status) { case 0 : 41 Effective Programming with Eclipse
Our facility is located in Orlando, Florida. Our Orlando web hosting data center gives you assurance that your website will work smoothly . Check more in Orlando Web Hosting.