Archive for July, 2007

778 Graphical User Interface Components: Part 2 Chapter (Web hosting contract)

Friday, July 27th, 2007

778 Graphical User Interface Components: Part 2 Chapter 13 92 // set constraints and add component 93 layout.setConstraints( component, constraints ); 94 container.add( component ); 95 } 96 97 // execute application 98 public static void main( String args[] ) 99 { 100 GridBagDemo application = new GridBagDemo(); 101 102 application.setDefaultCloseOperation( 103 JFrame.EXIT_ON_CLOSE ); 104 } 105 106 } // end class GridBagDemo Fig. 13.20 Demonstrating the GridBagLayoutlayout manager (part 3 of 3). The GUI consists of three JButtons, two JTextAreas, a JComboBox and a JTextField. The layout manager for the content pane is GridBagLayout. Lines 22 23 instantiate the GridBagLayoutobject and set the layout manager for the content pane to layout. The GridBagConstraintsobject used to determine the location and size
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Web server type - Chapter 13 Graphical User Interface Components: Part 2

Thursday, July 26th, 2007

Chapter 13 Graphical User Interface Components: Part 2 777 39 40 // textArea1 41 // weightx and weighty are both 0: the default 42 // anchor for all components is CENTER: the default 43 constraints.fill = GridBagConstraints.BOTH; 44 addComponent( textArea1, 0, 0, 1, 3 ); 45 46 // button1 47 // weightx and weighty are both 0: the default 48 constraints.fill = GridBagConstraints.HORIZONTAL; 49 addComponent( button1, 0, 1, 2, 1 ); 50 51 // comboBox 52 // weightx and weighty are both 0: the default 53 // fill is HORIZONTAL 54 addComponent( comboBox, 2, 1, 2, 1 ); 55 56 // button2 57 constraints.weightx = 1000; // can grow wider 58 constraints.weighty = 1; // can grow taller 59 constraints.fill = GridBagConstraints.BOTH; 60 addComponent( button2, 1, 1, 1, 1 ); 61 62 // button3 63 // fill is BOTH 64 constraints.weightx = 0; 65 constraints.weighty = 0; 66 addComponent( button3, 1, 2, 1, 1 ); 67 68 // textField 69 // weightx and weighty are both 0, fill is BOTH 70 addComponent( textField, 3, 0, 2, 1 ); 71 72 // textArea2 73 // weightx and weighty are both 0, fill is BOTH 74 addComponent( textArea2, 3, 2, 1, 1 ); 75 76 setSize( 300, 150 ); 77 setVisible( true ); 78 } 79 80 // method to set constraints on 81 private void addComponent( Component component, 82 int row, int column, int width, int height ) 83 { 84 // set gridx and gridy 85 constraints.gridx = column; 86 constraints.gridy = row; 87 88 // set gridwidth and gridheight 89 constraints.gridwidth = width; 90 constraints.gridheight = height; 91 Fig. 13.20 Demonstrating the GridBagLayoutlayout manager (part 2 of 3).
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Hosting your own web site - 776 Graphical User Interface Components: Part 2 Chapter

Thursday, July 26th, 2007

776 Graphical User Interface Components: Part 2 Chapter 13 Fig. 13.19 GridBagLayoutwith the weights set to zero. 1 // Fig. 13.20: GridBagDemo.java 2 // Demonstrating GridBagLayout. 3 4 // Java core packages 5 import java.awt.*; 6 import java.awt.event.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class GridBagDemo extends JFrame { 12 private Container container; 13 private GridBagLayout layout; 14 private GridBagConstraints constraints; 15 16 // set up GUI 17 public GridBagDemo() 18 { 19 super( “GridBagLayout” ); 20 21 container = getContentPane(); 22 layout = new GridBagLayout(); 23 container.setLayout( layout ); 24 25 // instantiate gridbag constraints 26 constraints = new GridBagConstraints(); 27 28 // create GUI components 29 JTextArea textArea1 = new JTextArea( “TextArea1″, 5, 10 ); 30 JTextArea textArea2 = new JTextArea( “TextArea2″, 2, 2 ); 31 32 String names[] = { “Iron”, “Steel”, “Brass” }; 33 JComboBox comboBox = new JComboBox( names ); 34 35 JTextField textField = new JTextField( “TextField” ); 36 JButton button1 = new JButton( “Button 1″ ); 37 JButton button2 = new JButton( “Button 2″ ); 38 JButton button3 = new JButton( “Button 3″ ); Fig. 13.20 Demonstrating the GridBagLayoutlayout manager (part 1 of 3).
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Space web hosting - Chapter 13 Graphical User Interface Components: Part 2

Wednesday, July 25th, 2007

Chapter 13 Graphical User Interface Components: Part 2 775 Variables gridx and gridy specify the row and column where the upper-left corner of the component is placed in the grid. Variable gridx corresponds to the column and the variable gridy corresponds to the row. In Fig. 13.17, the JComboBox (displaying Iron ) has a gridx value of 1 and a gridy value of 2. Variable gridwidth specifies the number of columns a component occupies. In Fig. 13.17, the JComboBox button occupies two columns. Variable gridheight specifies the number of rows a component occupies. In Fig. 13.17, the JTextArea on the left side of the window occupies three rows. Variable weightx specifies how to distribute extra horizontal space to components in a GridBagLayout when the container is resized. A zero value indicates that the component does not grow horizontally on its own. However, if the component spans a column containing a component with nonzero weightx value, the component with zero weightx value will grow horizontally in the same proportion as the other component(s) in the same column. This is because each component must be maintained in the same row and column in which it was originally placed. Variable weightyspecifies how to distribute extra vertical space to components in a GridBagLayout when the container is resized. A zero value indicates that the component does not grow vertically on its own. However, if the component spans a row containing a component with nonzero weighty value, the component with zero weighty value grows vertically in the same proportion as the other component(s) in the same row. In Fig. 13.17, the effects of weighty and weightx cannot easily be seen until the container is resized and additional space becomes available. Components with larger weight values occupy more of the additional space than components with smaller weight values. The exercises explore the effects of varying weightx and weighty. Components should be given nonzero positive weight values otherwise the components will huddle together in the middle of the container. Figure 13.19 shows the GUI of Fig. 13.17 where all weights have been set to zero. Common Programming Error 13.6 Using a negative value for either weightxor weighty is a logic error. GridBagConstraints instance variable fill specifies how much of the component s area (the number of rows and columns the component occupies in the grid) is occupied. The variable fill is assigned one of the following GridBagConstraints constants: NONE, VERTICAL, HORIZONTALor BOTH. The default value is NONE, which indicates that the component will not grow in either direction. VERTICAL indicates that the component will grow vertically. HORIZONTAL indicates that the component will grow horizontally. BOTH indicates that the component will grow in both directions. GridBagConstraints instance variable anchor specifies the location of the component in the area when the component does not fill the entire area. The variable anchor is assigned one of the following GridBagConstraints constants: NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST or CENTER. The default value is CENTER. The program of Fig. 13.20 uses the GridBagLayout layout manager to arrange the components in the GUI of Fig. 13.17. The program does nothing other than demonstrate how to use GridBagLayout.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

774 Graphical (Http web server) User Interface Components: Part 2 Chapter

Wednesday, July 25th, 2007

774 Graphical User Interface Components: Part 2 Chapter 13 13.15 GridBagLayoutLayout Manager The most complex and most powerful of the predefined layout managers is GridBag- Layout. This layout is similar to GridLayoutbecause GridBagLayoutalso arranges components in a grid. However, GridBagLayout is more flexible. The components can vary in size (i.e., they can occupy multiple rows and columns) and can be added in any order. The first step in using GridBagLayout is determining the appearance of the GUI. This step does not involve any programming; all that is needed is a piece of paper. First, draw the GUI. Next draw a grid over the GUI dividing the components into rows and columns. The initial row and column numbers should be 0 so the GridBagLayout layout manager can properly place the components in the grid. The row and column numbers will be used to place each component in an exact position in the grid. Figure 13.17 demonstrates drawing the lines for the rows and columns over a GUI. To use GridBagLayout, a GridBagConstraints object must be constructed. This object specifies how a component is placed in a GridBagLayout. Several Grid- BagConstraintsinstance variables are summarized in Fig. 13.18. Column 0 12 Row 0 1 2 3 Fig. 13.17Designing a GUI that will use GridBagLayout. 13.17 GridBagConstraints Instance Variable Description gridx The column in which the component will be placed. gridy The row in which the component will be placed. gridwidth The number of columns the component occupies. gridheight The number of rows the component occupies. weightx The portion of extra space to allocate horizontally. The components can become wider when extra space is available. weighty The portion of extra space to allocate vertically. The components can become taller when extra space is available. Fig. 13.18 GridBagConstraintsinstance variables.
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.

Chapter 13 Graphical User Interface Components: Part 2 (Web site design and hosting)

Tuesday, July 24th, 2007

Chapter 13 Graphical User Interface Components: Part 2 773 Fig. 13.16 Demonstrating the CardLayoutlayout manager (part 3 of 3). The constructor method (lines 20 75) builds the GUI. Lines 27 29 create JPanel deck, create CardLayoutobject cardManagerand set the layout manager for deckto cardManager. Next, the constructor creates the JPanels card1, card2, and card3 and their GUI components. As we set up each card, we add the card to deck, using Container method add with two arguments a Componentand a String. The Component is the JPanel object that represents the card. The String argument identifies the card. For example, line 36 adds JPanelcard1to deck and uses JLabellabel1 s label as the Stringidentifier for the card. JPanels card2and card3are added to deck at lines 44 55. Next, the constructor creates the JPanelbuttonsand its JButtonobjects (lines 58 66). Line 64 registers the ActionListenerfor each JButton. Finally, buttonsand deckare added to the content pane s WESTand EASTregions, respectively. Method actionPerformed (lines 78 95) determines which JButton generated the event by using EventObject method getSource. CardLayout methods first, previous, nextand lastare used to display the particular card corresponding to which JButton the user pressed. Method first displays the first card added to the deck. Method previous displays the previous card in the deck. Method next displays the next card in the deck. Method lastdisplays the last card in the deck. Note that deck is passed to each of these methods.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Web hosting rating - 772 Graphical User Interface Components: Part 2 Chapter

Tuesday, July 24th, 2007

772 Graphical User Interface Components: Part 2 Chapter 13 54 card3.add( label3, BorderLayout.CENTER ); 55 deck.add( card3, label3.getText() ); // add card to deck 56 57 // create and layout buttons that will control deck 58 JPanel buttons = new JPanel(); 59 buttons.setLayout( new GridLayout( 2, 2 ) ); 60 controls = new JButton[ names.length ]; 61 62 for ( int count = 0; count < controls.length; count++ ) { 63 controls[ count ] = new JButton( names[ count ] ); 64 controls[ count ].addActionListener( this ); 65 buttons.add( controls[ count ] ); 66 } 67 68 // add JPanel deck and JPanel buttons to the applet 69 container.add( buttons, BorderLayout.WEST ); 70 container.add( deck, BorderLayout.EAST ); 71 72 setSize( 450, 200 ); 73 setVisible( true ); 74 75 } // end constructor 76 77 // handle button events by switching cards 78 public void actionPerformed( ActionEvent event ) 79 { 80 // show first card 81 if ( event.getSource() == controls[ 0 ] ) 82 cardManager.first( deck ); 83 84 // show next card 85 else if ( event.getSource() == controls[ 1 ] ) 86 cardManager.next( deck ); 87 88 // show previous card 89 else if ( event.getSource() == controls[ 2 ] ) 90 cardManager.previous( deck ); 91 92 // show last card 93 else if ( event.getSource() == controls[ 3 ] ) 94 cardManager.last( deck ); 95 } 96 97 // execute application 98 public static void main( String args[] ) 99 { 100 CardDeck cardDeckDemo = new CardDeck(); 101 102 cardDeckDemo.setDefaultCloseOperation( 103 JFrame.EXIT_ON_CLOSE ); 104 } 105 106 } // end class CardDeck Fig. 13.16 Demonstrating the CardLayoutlayout manager (part 2 of 3).
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Database web hosting - Chapter 13 Graphical User Interface Components: Part 2

Monday, July 23rd, 2007

Chapter 13 Graphical User Interface Components: Part 2 771 1 // Fig. 13.16: CardDeck.java 2 // Demonstrating CardLayout. 3 4 // Java core packages 5 import java.awt.*; 6 import java.awt.event.*; 7 8 // Java extension packages 9 import javax.swing.*; 10 11 public class CardDeck extends JFrame implements ActionListener { 12 13 private CardLayout cardManager; 14 private JPanel deck; 15 private JButton controls[]; 16 private String names[] = { “First card”, “Next card”, 17 “Previous card”, “Last card” }; 18 19 // set up GUI 20 public CardDeck() 21 { 22 super( “CardLayout ” ); 23 24 Container container = getContentPane(); 25 26 // create the JPanel with CardLayout 27 deck = new JPanel(); 28 cardManager = new CardLayout(); 29 deck.setLayout( cardManager ); 30 31 // set up card1 and add it to JPanel deck 32 JLabel label1 = 33 new JLabel( “card one”, SwingConstants.CENTER ); 34 JPanel card1 = new JPanel(); 35 card1.add( label1 ); 36 deck.add( card1, label1.getText() ); // add card to deck 37 38 // set up card2 and add it to JPanel deck 39 JLabel label2 = 40 new JLabel( “card two”, SwingConstants.CENTER ); 41 JPanel card2 = new JPanel(); 42 card2.setBackground( Color.yellow ); 43 card2.add( label2 ); 44 deck.add( card2, label2.getText() ); // add card to deck 45 46 // set up card3 and add it to JPanel deck 47 JLabel label3 = new JLabel( “card three” ); 48 JPanel card3 = new JPanel(); 49 card3.setLayout( new BorderLayout() ); 50 card3.add( new JButton( “North” ), BorderLayout.NORTH ); 51 card3.add( new JButton( “West” ), BorderLayout.WEST ); 52 card3.add( new JButton( “East” ), BorderLayout.EAST ); 53 card3.add( new JButton( “South” ), BorderLayout.SOUTH ); Fig. 13.16 Demonstrating the CardLayoutlayout manager (part 1 of 3).
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

770 Graphical User Interface Components: Part 2 Chapter (Bulletproof web design)

Monday, July 23rd, 2007

770 Graphical User Interface Components: Part 2 Chapter 13 ible GUI component that can be used between fixed-size GUI components to occupy additional space. Normally, extra space appears to the right of the last horizontal GUI component or below the last vertical GUI component in a BoxLayout. Glue allows the extra space to be placed between GUI components. Class Box also defines method createVerticalGlue for vertical BoxLayouts. The for structure at lines 47 51 adds three JButtons to boxes[3] (a vertical Box). Before adding each button, lines 48 49 add a rigid area to the container with static method createRigidArea of class Box. A rigid area is an invisible GUI component that always has a fixed pixel width and height. The argument to method createRigidAreais a Dimension object that specifies the width and height of the rigid area. Lines 54 56 create a JPanel object and set its layout in the conventional manner, using Container method setLayout. The BoxLayout constructor receives a reference to the container for which it controls the layout and a constant indicating whether the layout is horizontal (BoxLayout.X_AXIS) or vertical (BoxLayout.Y_AXIS). The for structure at lines 58 61 adds three JButtons to panel.Before adding each button, line 59 adds a glue component to the container with static method create- Glue of class Box. This component expands or contracts based on the size of the Box. The Box containers and the JPanel are attached to the content pane s Border- Layout at lines 64 68. Try executing the application. When the window appears, resize the window to see how the glue components, strut components and rigid area affect the layout in each container. 13.14 CardLayout Layout Manager The CardLayout layout manager arranges components into a deck of cards where only the top card is visible. Any card in the deck can be placed at the top of the deck at any time by using methods of class CardLayout. Each card is usually a container, such as a panel, and each card can use any layout manager. Class CardLayout inherits from Object and implements the LayoutManager2 interface. The program of Fig. 13.16 creates five panels. JPaneldeck uses the CardLayout layout manager to control the card that is displayed. JPanels card1, card2 and card3 are the individual cards in deck. JPanel buttons contains four buttons (with labels First card, Next card, Previous card and Last card) that enable the user to manipulate the deck. When the user clicks the First card button, the first card in deck (i.e., card1) is displayed. When the user clicks the Last card button, the last card (i.e., card3) in deck is displayed. Each time the user clicks the Previous card button, the previous card in deck is displayed. Each time the user clicks the Next card button, the next card in deck is displayed. Clicking the Previous card button or the Next card button repeatedly allows the user to cycle through the deck of cards. Application class CardDeck implements ActionListener, so the action events generated by the JButtons on JPanel buttons are handled by the application in its actionPerformed method. Class CardDeck declares a reference of type CardLayout called cardManager (line 13). This reference is used to invoke CardLayout methods that manipulate the cards in the deck.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Chapter 13 Graphical User Interface Components: Part 2 (Web hosting rating)

Monday, July 23rd, 2007

Chapter 13 Graphical User Interface Components: Part 2 769 Fig. 13.15 Demonstrating the BoxLayoutlayout manager (part 3 of 3). The forstructure at lines 31 32 adds three JButtons to boxes[0](a horizontal Box). The forstructure at lines 35 38 adds three JButtons to boxes[1](a vertical Box). Before adding each button, line 36 adds a vertical strut to the container with staticmethod createVerticalStrutof class Box. A vertical strut is an invisible GUI component that has a fixed pixel height and is used to guarantee a fixed amount of space between GUI components. The argument to method createVerticalStrut determines the height of the strut in pixels. Class Boxalso defines method createHorizontalStrutfor horizontal BoxLayouts. The forstructure at lines 41 44 adds three JButtons to boxes[2](a horizontal Box). Before adding each button, line 42 adds horizontal glue to the container with staticmethod createHorizontalGlueof class Box. Horizontal glue is an invis
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.