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

  • Java
  • Thread starter uperkurk
  • Start date
  • Tags
    Java
If it's an applet, I'm not sure what the best way to do it is.In summary, the conversation discusses different methods for positioning the Textbox at the bottom of the applet window, such as using JPanels for a JFrame or trying alternative methods for an applet.
  • #1
uperkurk
167
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);
    }
 
Technology news on Phys.org
  • #2
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.
 

What is Java GridLayout for Applet Window?

Java GridLayout for Applet Window is a layout manager in Java that allows developers to create a grid of cells in an applet window. It helps organize and arrange components in a grid-like fashion.

How do I add words to Java GridLayout for Applet Window?

To add words to Java GridLayout for Applet Window, you first need to create a new instance of the GridLayout class. Then, use the add() method to add components (in this case, words) to the grid. Finally, add the GridLayout to the applet window using the setLayout() method.

How do I display words in Java GridLayout for Applet Window?

To display words in Java GridLayout for Applet Window, you can use the add() method to add components (words) to the grid. The words will automatically be displayed in the grid according to the specified grid layout.

How do I search for words in Java GridLayout for Applet Window?

To search for words in Java GridLayout for Applet Window, you can use the getComponent() method to retrieve the component (word) at a specific grid position. If the component is a label, you can use the getText() method to get the word. You can then compare the word to the search term and perform any desired actions.

How do I remove words from Java GridLayout for Applet Window?

To remove words from Java GridLayout for Applet Window, you can use the remove() method to remove the component (word) at a specific grid position. The grid layout will automatically adjust to fill in the empty space. You can also use the removeAll() method to remove all components from the grid.

Similar threads

  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
12K
Back
Top