Java GridLayout for Applet Window: Add, Display, Search, and Remove Words

  • Context: Java 
  • Thread starter Thread starter uperkurk
  • Start date Start date
  • Tags Tags
    Java
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
uperkurk
Messages
167
Reaction score
0
Can anyone tell me how to get the Textbox to the bottom of the applet window?
Code:
public void init(){
        setLayout(new GridLayout(6,0,5,5));
        al = new ArrayList();
        addNewWords = new JButton("Add Word");
        displayAllWords = new JButton("Display Words");
        searchForWords = new JButton("Search List");
        removeWords = new JButton("Delete Word");
        removeDuplicates = new JButton("Delete Duplicates");
        removeAllWords = new JButton("Delete all words");
        addNewWords.addActionListener(new ButtonHandlerForAddWord(this));
        newWordTextField = new JTextField("Enter a word", 20);
        add(addNewWords);
        add(displayAllWords);
        add(searchForWords);
        add(removeWords);
        add(removeDuplicates);
        add(removeAllWords);
        add(newWordTextField, BorderLayout.SOUTH);
    }
 
Physics news on Phys.org
uperkurk said:
Can anyone tell me how to get the Textbox to the bottom of the applet window?
Code:
public void init(){
        setLayout(new GridLayout(6,0,5,5));
        al = new ArrayList();
        addNewWords = new JButton("Add Word");
        displayAllWords = new JButton("Display Words");
        searchForWords = new JButton("Search List");
        removeWords = new JButton("Delete Word");
        removeDuplicates = new JButton("Delete Duplicates");
        removeAllWords = new JButton("Delete all words");
        addNewWords.addActionListener(new ButtonHandlerForAddWord(this));
        newWordTextField = new JTextField("Enter a word", 20);
        add(addNewWords);
        add(displayAllWords);
        add(searchForWords);
        add(removeWords);
        add(removeDuplicates);
        add(removeAllWords);
        add(newWordTextField, BorderLayout.SOUTH);
    }

Is this method in an extension of a JFrame or other GUI object? If it is a JFrame, you'll want to use JPanel(s) to control the relative positioning of elements.