2 Replies Latest reply on Jun 2, 2010 8:10 PM by darrylburke

    Textfield and BorderLayout problem


      I'm still somewhat new to Java programming and I've been doing this great online course I found on the Stanford site. Anyways, I'm on the last programming project there and using swing for the first time and I've noticed weird behavior with a textfield when I use the default border layout. Basically the issue is that if the textfield is in the NORTH or WEST section the textfield works perfectly. However, if put the textfield in the SOUTH or EAST quadrants it never shows a cursor when I select the field and never displays what I am typing. I do know that it's taking my input though because it provides the output correctly when I click the button to retrieve the text from the field. I've looked all over the web for someone else having this issue but I haven't had any luck. Any ideas? Here's the code I'm using:
      import acm.program.*;
      import java.awt.event.*;
      import javax.swing.*;
      import java.awt.*;
      /* Change ConsoleProgram back to regular Program once the GUI is working */
      public class NameSurfer extends ConsoleProgram implements NameSurferConstants {
      /* Method: init() */
       * This method has the responsibility for reading in the data base
       * and initializing the interactors at the bottom of the window.
           public void init() {
             //JPanel cPanel=new JPanel();
             add(new JLabel("Name  "), NORTH);
             name=new JTextField("Name",NAME_FIELD);
             add(name, BorderLayout.EAST);
             add(new JButton("Graph"), NORTH);
             add(new JButton("Clear"), NORTH);
             //add(cPanel, SOUTH);
      /* Method: actionPerformed(e) */
       * This class is responsible for detecting when the buttons are
       * clicked, so you will have to define a method to respond to
       * button actions.
           public void actionPerformed(ActionEvent e) {
                     println("Graph: " + name.getText());
                     println("Graph: " + name.getText());
           private JTextField name;