@@ -68,7 +68,7 @@ public void windowClosed(WindowEvent event) {
6868 }
6969 public void windowOpened (WindowEvent event ) {
7070 // delegate to enable subclass to overwrite
71- // onWindowOpened(args );
71+ // onWindowOpened();
7272 }});
7373
7474
@@ -91,8 +91,8 @@ public void actionPerformed(ActionEvent event) {
9191 if (actionCmd .equals (EXIT )) {
9292 dispose ();
9393 System .exit (0 );
94- } else if (actionCmd .equals ("Dialog " )) {
95- System .out .println ("Dialog pressed\n " );
94+ } else if (actionCmd .equals ("Open a dialog " )) {
95+ System .out .println ("Open a dialog pressed\n " );
9696 new Dialog (this );
9797 } else if (actionCmd .equals (XML_EXAMPLE )) {
9898 System .out .println ("Run the XML example ..." );
@@ -159,11 +159,15 @@ public JButton addButton(String name, int col, int row, String control) {
159159 */
160160 public JMenuBar createMenu () {
161161
162- JMenu menu = new JMenu ("XXX Menu" );
163- JMenuItem menuItem = createMenuItem (EXIT , true , EXIT );
164- menu .add (menuItem );
165162 JMenuBar menuBar = new JMenuBar ();
163+ JMenu menu = new JMenu ("File" );
164+ menuBar .add (menu );
165+ menu .setMnemonic (KeyEvent .VK_F );
166+ JMenuItem menuItem = createMenuItem (EXIT , true , KeyEvent .VK_X , EXIT );
167+ menu .add (menuItem );
168+ menu = new JMenu ("Help" );
166169 menuBar .add (menu );
170+ menu .setMnemonic (KeyEvent .VK_H );
167171 return menuBar ;
168172 }
169173
@@ -172,13 +176,15 @@ public JMenuBar createMenu() {
172176 *
173177 * @param text the text of the menu item
174178 * @param enabled true if the item is enabled, false otherwise
179+ * @param mnemonic the mnemonic of the menu item
175180 * @param actionCmd the action command for the event, if clicked
176181 * @return the menu item
177182 */
178- private JMenuItem createMenuItem (String text , boolean enabled , String actionCmd ) {
183+ private JMenuItem createMenuItem (String text , boolean enabled , int mnemonic , String actionCmd ) {
179184
180185 JMenuItem menuItem = new JMenuItem (text );
181186 menuItem .setEnabled (enabled );
187+ menuItem .setMnemonic (mnemonic );
182188 menuItem .addActionListener (this );
183189 menuItem .setActionCommand (actionCmd );
184190 return menuItem ;
@@ -193,10 +199,12 @@ protected JToolBar createStatusBar() {
193199
194200 JToolBar statusBar = new JToolBar ();
195201 statusBar .setFloatable (false );
196- JLabel label1 = new JLabel ();
197- label1 .setText ("now XXX" );;
198- statusBar .add (label1 );
199- statusBar .addSeparator ();
202+ // statusBar.setBorder(BorderFactory.createMatteBorder(1, 2, 1, 2, Color.LIGHT_GRAY));
203+ statusBar .setMargin (new Insets (1 , 3 , 1 , 1 ));
204+ JLabel label = new JLabel ();
205+ label .setText ("Status: XY" );
206+ statusBar .add (label );
207+ // statusBar.addSeparator();
200208
201209// statusBar.add(anotherComponent); // TODO
202210
@@ -212,12 +220,12 @@ protected JToolBar createToolBar() {
212220
213221 JToolBar tb = new JToolBar ();
214222 tb .setFloatable (false );
223+ tb .setMargin (new Insets (1 , 3 , 1 , 1 ));
215224
216225// buttonNew = createToolBarButton("New", null, KeyEvent.VK_N,
217226// "Start a new XXX", ACTION_NEW, this);
218227// tb.add(buttonNew);
219- tb .addSeparator ();
220- JButton btn = createToolBarButton ("MyToolBarComp" , null , KeyEvent .VK_M , "Hello, I am a tooltip" , "myActionCmd" );
228+ JButton btn = createToolBarButton ("ToolBarButton" , null , KeyEvent .VK_T , "Hello, I am a tooltip" , "myToolBarButton" );
221229// btn.setEnabled(false);
222230
223231 tb .add (btn );
@@ -254,7 +262,7 @@ protected JButton createToolBarButton(String label, ImageIcon icon, int mnemonic
254262 }
255263
256264 /**
257- * GUI init .
265+ * GUI initialization .
258266 *
259267 * @throws Exception in case of an unexpected exception
260268 */
@@ -295,7 +303,7 @@ private void initFrame() throws Exception {
295303 getContentPane ().add (statusBar , BorderLayout .SOUTH );
296304
297305 centerPanel = new JPanel ();
298- centerPanel .setPreferredSize (new Dimension (600 , 300 ));
306+ centerPanel .setPreferredSize (new Dimension (800 , 500 ));
299307// centerPanel.setPreferredSize(new Dimension(
300308// AppCtx.getIntProperty("main.window.size.x"),
301309// AppCtx.getIntProperty("main.window.size.y")));
@@ -320,9 +328,20 @@ private void initFrame() throws Exception {
320328 // label
321329 JLabel label = new JLabel ("This is a label" );
322330 centerPanel .add (label , new Gbc (0 , 0 , 1 , 1 , 1.0 , 0 , "H" ));
331+ // text field
332+ JTextField textField = new JTextField ();
333+ centerPanel .add (textField , new Gbc (1 , 0 , "W" ));
334+ textField .setPreferredSize (new Dimension (Gui .CHAR_WIDTH * 20 , Gui .COMP_HEIGHT ));
335+ textField .setText ("Text field" );
336+ textField .addFocusListener (new FocusAdapter () {
337+ @ Override
338+ public void focusGained (FocusEvent e ) {
339+ // TODO focus events
340+ }
341+ });
342+
323343 // buttons
324- addButton ("XXX" , 1 , 0 , "W t" );
325- addButton ("Dialog" , 1 , 1 , "W" );
344+ addButton ("Open a dialog" , 1 , 1 , "W" );
326345 centerPanel .add (Gbc .filler (), new Gbc (2 , 2 , 1 , 1 , 1.0 , 100.0 , "S B" ));
327346
328347 exitBtn = addButton (EXIT , 3 , 2 , "SE b r" );
0 commit comments