Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7078235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:31:18+00:00 2026-05-28T06:31:18+00:00

I have a JTextField as well as a JTextArea in a JFrame. When the

  • 0

I have a JTextField as well as a JTextArea in a JFrame. When the application runs however, the JTextField gets resized if I minimize the window. It usually doubles or triples in height, but it’s not consistent in how it resizes each time. I have no idea why this could be happening. I’m not really asking for a direct solution, just some possible things that could be causing the problem. If you could help me out here that’d be great. Thanks

EDIT: here’s the code I’m using to initialize it:

public class Console extends JPanel implements ActionListener, Serializable {
    boolean ready = false;
    protected JTextField textField;
    protected JTextArea textArea;
    private final static String newline = "\n";
    Game m_game;
    Thread t;

public Console(Game game) {
    super(new GridBagLayout());

    m_game = game;
    textField = new JTextField(20);
    textField.setPreferredSize(null);
    textField.addActionListener(this);

    textArea = new JTextArea(20, 60);
    textArea.setEditable(false);
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    Font comic = new Font("Serif", Font.PLAIN, 14);
    textArea.setFont(comic);
    JScrollPane scrollPane = new JScrollPane(textArea);

    //Add Components to this panel.
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = GridBagConstraints.REMAINDER;

    c.fill = GridBagConstraints.HORIZONTAL;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    add(scrollPane, c);
    add(textField, c);
}

public void actionPerformed(ActionEvent evt) {
    String text = textField.getText();
    m_game.input = text;
    textField.selectAll();
    textArea.setCaretPosition(textArea.getDocument().getLength());
    m_game.wait = false;
    synchronized (m_game){
        ready = true;
        m_game.notifyAll();
    }
}

public void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Game");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Add contents to the window.
    frame.add(new Console(m_game));

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:31:18+00:00Added an answer on May 28, 2026 at 6:31 am

    I think it’s connected with Layout Manager. http://docs.oracle.com/javase/tutorial/uiswing/layout/using.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JFrame that contains a display JPanel with JTextField and a control
We have developed a messaging application in j2me which adds text message, gets pictures
I have a JTextField that I'm not always passing a value to, but it
I have a JTextField with some text. When I click text field the cursor
I have a program that uses three JTextField fields as the main data entry
I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new java.awt.event.MouseAdapter() {
I have a JPanel full of JTextFields... for (int i=0; i<maxPoints; i++) { JTextField
This one's a tough one - I have a JFrame that generates JTextFields. When
I have a simple cocoa application with an editable textfield text1 at the top
I have an application with Textfields in my MainViewController.m file. There is also a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.