Photography web hosting - 750 Graphical User Interface Components: Part 2 Chapter
Wednesday, April 25th, 2007750 Graphical User Interface Components: Part 2 Chapter 13 106 107 // add format menu to menu bar 108 formatMenu.add( colorMenu ); 109 formatMenu.addSeparator(); 110 111 // create Font submenu 112 String fontNames[] = { “Serif”, “Monospaced”, “SansSerif” }; 113 114 JMenu fontMenu = new JMenu( “Font” ); 115 fontMenu.setMnemonic( ‘n’ ); 116 117 fonts = new JRadioButtonMenuItem[ fontNames.length ]; 118 fontGroup = new ButtonGroup(); 119 120 // create Font radio button menu items 121 for ( int count = 0; count < fonts.length; count++ ) { 122 fonts[ count ] = 123 new JRadioButtonMenuItem( fontNames[ count ] ); 124 125 fontMenu.add( fonts[ count ] ); 126 fontGroup.add( fonts[ count ] ); 127 128 fonts[ count ].addActionListener( itemHandler ); 129 } 130 131 // select first Font menu item 132 fonts[ 0 ].setSelected( true ); 133 134 fontMenu.addSeparator(); 135 136 // set up style menu items 137 String styleNames[] = { "Bold", "Italic" }; 138 139 styleItems = new JCheckBoxMenuItem[ styleNames.length ]; 140 StyleHandler styleHandler = new StyleHandler(); 141 142 // create style checkbox menu items 143 for ( int count = 0; count < styleNames.length; count++ ) { 144 styleItems[ count ] = 145 new JCheckBoxMenuItem( styleNames[ count ] ); 146 147 fontMenu.add( styleItems[ count ] ); 148 149 styleItems[ count ].addItemListener( styleHandler ); 150 } 151 152 // put Font menu in Format menu 153 formatMenu.add( fontMenu ); 154 155 // add Format menu to menu bar 156 bar.add( formatMenu ); 157 Fig. 13.10 Using JMenus and mnemonics (part 3 of 5).
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision best web hosting services