Skip to content
Advertisement

How can make a JTextArea?

I am trying to make a textArea for my input, but it broke my code. It does not draw the characters or grid any more, and all I see is a small button in the top right corner. Screenshot of output

Here’s my code with the JTextArea:

JavaScript

What can I do to make my code work with the JTextArea? I want to replace the scanner with it, if I can get it to work.

Advertisement

Answer

A JFrame (which is what your window is) uses a BorderLayout by default, which has a single area in the middle that expands. If you want more than one item in there, add a JPanel into the JFrame first, and then add them to the JPanel instead.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement