Archive for April, 2007

760 Graphical User Interface Components: Part 2 (Yahoo web hosting) Chapter

Friday, April 27th, 2007

760 Graphical User Interface Components: Part 2 Chapter 13 44 45 // attach NORTH panel to content pane 46 container.add( northPanel, BorderLayout.NORTH ); 47 48 // create array for radio buttons 49 radio = new JRadioButton[ strings.length ]; 50 51 // set up panel for SOUTH of BorderLayout 52 JPanel southPanel = new JPanel(); 53 southPanel.setLayout( 54 new GridLayout( 1, radio.length ) ); 55 56 // set up radio buttons for SOUTH panel 57 group = new ButtonGroup(); 58 ItemHandler handler = new ItemHandler(); 59 60 for ( int count = 0; count < radio.length; count++ ) { 61 radio[ count ] = new JRadioButton( strings[ count ] ); 62 radio[ count ].addItemListener( handler ); 63 group.add( radio[ count ] ); 64 southPanel.add( radio[ count ] ); 65 } 66 67 // attach SOUTH panel to content pane 68 container.add( southPanel, BorderLayout.SOUTH ); 69 70 // get installed look-and-feel information 71 looks = UIManager.getInstalledLookAndFeels(); 72 73 setSize( 300, 200 ); 74 setVisible( true ); 75 76 radio[ 0 ].setSelected( true ); 77 } 78 79 // use UIManager to change look-and-feel of GUI 80 private void changeTheLookAndFeel( int value ) 81 { 82 // change look and feel 83 try { 84 UIManager.setLookAndFeel( 85 looks[ value ].getClassName() ); 86 SwingUtilities.updateComponentTreeUI( this ); 87 } 88 89 // process problems changing look and feel 90 catch ( Exception exception ) { 91 exception.printStackTrace(); 92 } 93 } 94 Fig. 13.12 Fig. 13.12 Changing the look-and-feel of a Swing-based GUI (part 2 of 3).
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services

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

Friday, April 27th, 2007

Chapter 13 Graphical User Interface Components: Part 2 759 the look-and-feel to appear as a Microsoft Windows-style look-and-feel or a Motif-style (UNIX) look-and-feel. The program of Fig. 13.12 demonstrates how to change the look-and-feel of a Swing GUI. The program creates several GUI components so you can see the change in the look- and-feel of several GUI components at the same time. The first output window shows the standard metal look-and-feel, the second output window shows the Motif look-and-feel, and the third output window shows the Windows look-and-feel. 1 // Fig. 13.12: LookAndFeelDemo.java 2 // Changing the look and feel. 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 LookAndFeelDemo extends JFrame { 12 13 private String strings[] = { “Metal”, “Motif”, “Windows” }; 14 private UIManager.LookAndFeelInfo looks[]; 15 private JRadioButton radio[]; 16 private ButtonGroup group; 17 private JButton button; 18 private JLabel label; 19 private JComboBox comboBox; 20 21 // set up GUI 22 public LookAndFeelDemo() 23 { 24 super( “Look and Feel Demo” ); 25 26 Container container = getContentPane(); 27 28 // set up panel for NORTH of BorderLayout 29 JPanel northPanel = new JPanel(); 30 northPanel.setLayout( new GridLayout( 3, 1, 0, 5 ) ); 31 32 // set up label for NORTH panel 33 label = new JLabel( “This is a Metal look-and-feel”, 34 SwingConstants.CENTER ); 35 northPanel.add( label ); 36 37 // set up button for NORTH panel 38 button = new JButton( “JButton” ); 39 northPanel.add( button ); 40 41 // set up combo box for NORTH panel 42 comboBox = new JComboBox( strings ); 43 northPanel.add( comboBox ); Fig. 13.12 Fig. 13.12 Changing the look-and-feel of a Swing-based GUI (part 1 of 3).
Note: In case you are looking for affordable webhost to host and run your web application check Vision http web server services

Best web design - 758 Graphical User Interface Components: Part 2 Chapter

Friday, April 27th, 2007

758 Graphical User Interface Components: Part 2 Chapter 13 colorGroup (to maintain one selected JRadioButtonMenuItem at a time) and registers an ActionListener for each menu item. Lines 48 75 register an instance of an anonymous inner class that extends Mouse- Adapter to handle the mouse events of the application window. Methods mouse- Pressed (lines 54 57) and mouseReleased(lines 60 63) check for the popup-trigger event. Each method calls private utility method checkForTriggerEvent (lines 66 71) to determine whether the popup-trigger event occurred. MouseEvent method isPopupTrigger returns true if the popup-trigger event occurred. If so, method show of class JPopupMenu displays the JPopupMenu. The first argument to method show specifies the origin component, whose position helps determine where the JPopupMenu will appear on the screen. The last two arguments are the x-y coordinate from the origin component s upper-left corner at which the JPopupMenu should appear. Look-and-Feel Observation 13.24 Displaying a JPopupMenu for the popup-trigger event of multiple different GUI components requires registering mouse event handlers to check for the popup-trigger event for each of those GUI components. When the user selects a menu item from the popup menu, class ItemHandler s (lines 91 106) method actionPerformed (lines 94 104) determines which JRadioButtonMenuItem the user selected, then sets the background color of the window s content pane. 13.10 Pluggable Look-and-Feel A program that uses Java s Abstract Windowing Toolkit GUI components (package java.awt) takes on the look-and-feel of the platform on which the program executes. A Java program running on a Macintosh looks like other programs running on a Macintosh. A Java program running on Microsoft Windows looks like other programs running on Microsoft Windows. A Java program running on a UNIX platform looks like other programs running on that UNIX platform. This could be desirable, because it allows users of the program on each platform to use the GUI components with which they are already familiar. However, this also introduces interesting portability issues. Portability Tip 13.1 Programs that use Java s Abstract Windowing Toolkit GUI components (package java.awt) take on the look-and-feel of the platform on which they execute. Portability Tip 13.2 GUI components on each platform have different looks that can require different amounts of space to display. This could change the layout and alignments of GUI components. Portability Tip 13.3 GUI components on each platform have different default functionality (e.g., some platforms allow a button with the focus to be pressed with the space bar, and some do not). Swing s lightweight GUI components eliminate many of these issues by providing uniform functionality across platforms and by defining a uniform cross-platform look-andfeel (known as the metal look-and-feel). Swing also provides the flexibility to customize
Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

Web hosting asp - Chapter 13 Graphical User Interface Components: Part 2

Friday, April 27th, 2007

Chapter 13 Graphical User Interface Components: Part 2 757 72 73 } // end anonymous inner clas 74 75 ); // end call to addMouseListener 76 77 setSize( 300, 200 ); 78 setVisible( true ); 79 } 80 81 // execute application 82 public static void main( String args[] ) 83 { 84 PopupTest application = new PopupTest(); 85 86 application.setDefaultCloseOperation( 87 JFrame.EXIT_ON_CLOSE ); 88 } 89 90 // private inner class to handle menu item events 91 private class ItemHandler implements ActionListener { 92 93 // process menu item selections 94 public void actionPerformed( ActionEvent event ) 95 { 96 // determine which menu item was selected 97 for ( int i = 0; i < items.length; i++ ) 98 if ( event.getSource() == items[ i ] ) { 99 getContentPane().setBackground( 100 colorValues[ i ] ); 101 repaint(); 102 return; 103 } 104 } 105 106 } // end private inner class ItemHandler 107 108 } // end class PopupTest Fig. 13.11 Using a PopupMenuobject (part 3 of 3). The constructor for class PopupTest(lines 20 79) defines the JPopupMenuat line 29. The for structure at lines 34 42 creates JRadioButtonMenuItems to add to the JPopupMenu, adds them to the JPopupMenu (line 38), adds them to ButtonGroup
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision shared web hosting services

756 Graphical User Interface (Web design online) Components: Part 2 Chapter

Thursday, April 26th, 2007

756 Graphical User Interface Components: Part 2 Chapter 13 19 // set up GUI 20 public PopupTest() 21 { 22 super( “Using JPopupMenus” ); 23 24 ItemHandler handler = new ItemHandler(); 25 String colors[] = { “Blue”, “Yellow”, “Red” }; 26 27 // set up popup menu and its items 28 ButtonGroup colorGroup = new ButtonGroup(); 29 popupMenu = new JPopupMenu(); 30 items = new JRadioButtonMenuItem[ 3 ]; 31 32 // construct each menu item and add to popup menu; also 33 // enable event handling for each menu item 34 for ( int count = 0; count < items.length; count++ ) { 35 items[ count ] = 36 new JRadioButtonMenuItem( colors[ count ] ); 37 38 popupMenu.add( items[ count ] ); 39 colorGroup.add( items[ count ] ); 40 41 items[ count ].addActionListener( handler ); 42 } 43 44 getContentPane().setBackground( Color.white ); 45 46 // define a MouseListener for the window that displays 47 // a JPopupMenu when the popup trigger event occurs 48 addMouseListener( 49 50 // anonymous inner class to handle mouse events 51 new MouseAdapter() { 52 53 // handle mouse press event 54 public void mousePressed( MouseEvent event ) 55 { 56 checkForTriggerEvent( event ); 57 } 58 59 // handle mouse release event 60 public void mouseReleased( MouseEvent event ) 61 { 62 checkForTriggerEvent( event ); 63 } 64 65 // determine whether event should trigger popup menu 66 private void checkForTriggerEvent( MouseEvent event ) 67 { 68 if ( event.isPopupTrigger() ) 69 popupMenu.show( event.getComponent(), 70 event.getX(), event.getY() ); 71 } Fig. 13.11 Using a PopupMenuobject (part 2 of 3).
Note: If you are looking for cheap webhost to host and run your apache application check Vision jboss web hosting services

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

Thursday, April 26th, 2007

Chapter 13 Graphical User Interface Components: Part 2 755 Method actionPerformed of class ItemHandler (lines 186 206) uses two forstructures to determine which font or color menu item generated the event and sets the font or color of the JLabel display, respectively. The if condition at line 191 uses AbstractButtonmethod isSelectedto determine the selected JRadioButton- MenuItem. The if condition at line 199 uses EventSource method getSource to get a reference to the JRadioButtonMenuItemthat generated the event. Line 201 uses AbstractButtonmethod getTextto obtain the name of the font from the menu item. The program calls method itemStateChanged of class StyleHandler (lines 214 230) if the user selects a JCheckBoxMenuItemin the fontMenu. Lines 219 and 223 determine whether either or both of the JCheckBoxMenuItems are selected and use their combined state to determine the new style of the font. 13.9 Using JPopupMenus Many of today s computer applications provide so-called context-sensitive popup menus. In Swing, such menus are created with class JPopupMenu(a subclass of JComponent). These menus provide options that are specific to the component for which the popup trigger event was generated. On most systems, the popup trigger event occurs when the user presses and releases the right mouse button. Look-and-Feel Observation 13.23 The popup trigger event is platform specific. On most platforms that use a mouse with multiple mouse buttons, the popup trigger event occurs when the user clicks the right mouse button. Figure 13.11 creates a JPopupMenuthat allows the user to select one of three colors and change the background color of the window. When the user clicks the right mouse button on the PopupTest window s background, a JPopupMenu containing colors appears. If the user clicks one of the JRadioButtonMenuItems that represents a color, method actionPerformed of class ItemHandler changes the background color of the window s content pane. 1 // Fig. 13.11: PopupTest.java 2 // Demonstrating JPopupMenus 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 PopupTest extends JFrame { 12 13 private JRadioButtonMenuItem items[]; 14 private Color colorValues[] = 15 { Color.blue, Color.yellow, Color.red }; 16 17 private JPopupMenu popupMenu; 18 Fig. 13.11 Using a PopupMenuobject (part 1 of 3).
Note: In case you are looking for affordable webhost to host and run your web application check Vision http web server services

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

Thursday, April 26th, 2007

754 Graphical User Interface Components: Part 2 Chapter 13 Look-and-Feel Observation 13.19 Menus normally appear left to right in the order that they are added to a JMenuBar. Lines 80 81 create menu formatMenu and set its mnemonic to r (F is not used because that is the File menu s mnemonic). Lines 86 87 create menu colorMenu (this will be a submenu in the Format menu) and set its mnemonic to C. Line 89 creates JRadioButtonMenuItem array colorItems that refers to the menu items in colorMenu. Line 90 creates the Button- Group colorGroup, which ensures that only one of the menu items in the Color submenu is selected at a time. Line 91 defines an instance of inner class ItemHandler (defined at lines 183 208) that responds to selections from the Color submenu and the Font submenu (discussed shortly). The for structure at lines 94 102 creates each JRadioButtonMenuItem in array colorItems, adds each menu item to colorMenu, adds each menu item to colorGroup and registers the ActionListener for each menu item. Line 105 uses AbstractButton method setSelectedto select the first element in the colorItemsarray. Line 108 adds the colorMenu as a submenu of the format- Menu. Look-and-Feel Observation 13.20 Adding a menu as a menu item in another menu automatically makes the added menu a submenu. When the mouse is positioned over a submenu (or the submenu s mnemonic is pressed), the submenu expands to show its menu items. Line 109 adds a separator line to the menu. The separator appears as a horizontal line in the menu. Look-and-Feel Observation 13.21 Separators can be added to a menu to group menu items logically. Look-and-Feel Observation 13.22 Any lightweight GUI component (i.e., a component that subclasses JComponent) can be added to a JMenu or to a JMenuBar. Lines 114 132 create the Font submenu and several JRadioButtonMenuItems and select the first element of JRadioButtonMenuItem array fonts. Line 139 creates a JCheckBoxMenuItem array to represent the menu items for specifying bold and italic styles for the fonts. Line 140 defines an instance of inner class StyleHandler (defined at lines 211 232) to respond to the JCheckBoxMenuItem events. The for structure at lines 143 150 creates each JCheckBoxMenuItem, adds each menu item to fontMenuand registers the ItemListener for each menu item. Line 153 adds font- Menu as a submenu of formatMenu. Line 156 adds the formatMenuto bar. Lines 159 163 create a JLabelfor which the Format menu items control the font, font color and font style. The initial foreground color is set to the first element of array colorValues(Color.black) and the initial font is set to TimesRoman with PLAIN style and 72-point size. Line 165 sets the background color of the window s content pane to Color.cyan, and line 166 attaches the JLabelto the CENTER of the content pane s BorderLayout.
Note: If you are looking for cheap webhost to host and run your apache application check Vision jboss web hosting services

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

Thursday, April 26th, 2007

Chapter 13 Graphical User Interface Components: Part 2 753 Lines 27 72 set up the File menu and attach it to the menu bar. The File menu contains an About menu item that displays a message dialog when the menu item is selected and an Exit menu item that can be selected to terminate the application. Line 27 creates fileMenu and passes to the constructor the string File as the name of the menu. Line 28 uses AbstractButton method setMnemonic (inherited into class JMenu) to indicate that F is the mnemonic for this menu. Pressing the Alt key and the letter F opens the menu, just as clicking the menu name with the mouse would. In the GUI, the mnemonic character in the menu s name is displayed with an underline (see the screen captures). Look-and-Feel Observation 13.17 Mnemonics provide quick access to menu commands and button commands through the keyboard. Look-and-Feel Observation 13.18 Different mnemonics should be used for each button or menu item. Normally, the first letter in the label on the menu item or button is used as the mnemonic. If multiple buttons or menu items start with the same letter, choose the next most prominent letter in the name (e.g., x is commonly chosen for a button or menu item called Exit). Lines 31 32 define JMenuItem aboutItem with the name About… and set its mnemonic to the letter A. This menu item is added to fileMenuat line 51. To access the About… item through the keyboard, press the Alt key and letter F to open the File menu, then press A to select the About… menu item. Lines 34 49 create an ActionListener to process aboutItem s action event. Lines 42 44 display a message dialog box. In most prior uses of showMessageDialog, the first argument has been null. The purpose of the first argument is to specify the parent window for the dialog box. The parent window helps determine where the dialog box will be displayed. If the parent window is specified as null, the dialog box appears in the center of the screen. If the parent window is not null, the dialog box appears centered over the specified parent window. In this example, the program specifies the parent window with MenuTest.this the this reference of class MenuTest. When using the this reference in an inner class, specifying this by itself refers to the inner-class object. To reference the outer-class object s this reference, qualify this with the outer-class name and a dot operator (.). Dialog boxes can be either modal or modeless. A modal dialog box does not allow any other window in the application to be accessed until the dialog box is dismissed. A mode- less dialog box allows other windows to be accessed while the dialog is displayed. By default, the dialogs displayed with class JOptionPane are modal dialogs. Class JDialog can be used to create your own modeless or modal dialogs. Lines 54 72 define menu item exitItem, set its mnemonic to x, register an ActionListener that terminates the application when the user selects exitItem and add exitItemto the fileMenu. Lines 75 77 create the JMenuBar, attach it to the application window with JFrame method setJMenuBar and use JMenuBar method addto attach the fileMenu to the menu bar. Common Programming Error 13.5 Forgetting to set the menu bar with JFramemethod setJMenuBar results in the menu bar not being displayed on the JFrame.
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision shared web hosting services

752 Graphical User Interface Components: (Remote web server) Part 2 Chapter

Wednesday, April 25th, 2007

752 Graphical User Interface Components: Part 2 Chapter 13 210 // inner class to handle item events from check box menu items 211 private class StyleHandler implements ItemListener { 212 213 // process font style selections 214 public void itemStateChanged( ItemEvent e ) 215 { 216 style = 0; 217 218 // check for bold selection 219 if ( styleItems[ 0 ].isSelected() ) 220 style = Font.BOLD; 221 222 // check for italic selection 223 if ( styleItems[ 1 ].isSelected() ) 224 style = Font.ITALIC; 225 226 displayLabel.setFont( new Font( 227 displayLabel.getFont().getName(), style, 72 ) ); 228 229 repaint(); 230 } 231 232 } // end class StyleHandler 233 234 } // end class MenuTest Menu barMnemonic characters Menu Expanded submenu Separator bar Menu items Fig. 13.10 Using JMenus and mnemonics (part 5 of 5). Class MenuTest(line 11) is a completely self-contained class it defines all the GUI components and event handling for the menu items. Most of the code for this application appears in the class s constructor (lines 22 171).
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services


in xanax urinalysis

Modern in xanax urinalysis s have become extremely diverse, leading to phone personalization and customization.

consultation xanax

Those cell phones that do not use consultation xanax Card have the data programmed in to their memory.

and breast feeding xanax

In the event of and breast feeding xanax disaster response crews can locate trapped or injured people using the signals from their and breast feeding xanax s.

is ativan best which xanax or

While many drivers have embraced is ativan best which xanax or of using their cellphone while driving, some jurisdictions have made the practice against the law, such as the Canadian provinces of Quebec and Newfoundland and Labrador.

xanax safety injecting of

In xanax safety injecting of low cost, high speed data may drive forward the fourth generation (4G) as short-range communication emerges.

drug methadone test xanax

In Japan, drug methadone test xanax companies provide immediate notification of earthquakes and other natural disasters to their customers free of charge [26].

meds free xanax online

[8] UCAN claimed that Cingular billed its customers for Jamster! and other similar meds free xanax online services without providing customers with meds free xanax online opt-in, and proof of authorization requirements necessary for such charges.

cymbalta xanax and

The Nordic Mobile Telephone (NMT) system went online in Denmark, Finland, Norway and Sweden in 1981[citation needed].

xanax ambien

Many of these sites are camouflaged to blend with existing environments, particularly in scenic areas.

defects xanax birth type

Numerous studies have reported no significant relationship between defects xanax birth type use and health.

Web hosting account - Chapter 13 Graphical User Interface Components: Part 2

Wednesday, April 25th, 2007

Chapter 13 Graphical User Interface Components: Part 2 751 158 // set up label to display text 159 displayLabel = new JLabel( 160 “Sample Text”, SwingConstants.CENTER ); 161 displayLabel.setForeground( colorValues[ 0 ] ); 162 displayLabel.setFont( 163 new Font( “TimesRoman”, Font.PLAIN, 72 ) ); 164 165 getContentPane().setBackground( Color.cyan ); 166 getContentPane().add( displayLabel, BorderLayout.CENTER ); 167 168 setSize( 500, 200 ); 169 setVisible( true ); 170 171 } // end constructor 172 173 // execute application 174 public static void main( String args[] ) 175 { 176 MenuTest application = new MenuTest(); 177 178 application.setDefaultCloseOperation( 179 JFrame.EXIT_ON_CLOSE ); 180 } 181 182 // inner class to handle action events from menu items 183 private class ItemHandler implements ActionListener { 184 185 // process color and font selections 186 public void actionPerformed( ActionEvent event ) 187 { 188 // process color selection 189 for ( int count = 0; count < colorItems.length; count++ ) 190 191 if ( colorItems[ count ].isSelected() ) { 192 displayLabel.setForeground( colorValues[ count ] ); 193 break; 194 } 195 196 // process font selection 197 for ( int count = 0; count < fonts.length; count++ ) 198 199 if ( event.getSource() == fonts[ count ] ) { 200 displayLabel.setFont( new Font( 201 fonts[ count ].getText(), style, 72 ) ); 202 break; 203 } 204 205 repaint(); 206 } 207 208 } // end class ItemHandler 209 Fig. 13.10 Using JMenus and mnemonics (part 4 of 5).
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web design programs services