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 7860425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:16:57+00:00 2026-06-02T22:16:57+00:00

I have tried to narrow this down a bit but my program keeps on

  • 0

I have tried to narrow this down a bit but my program keeps on freezing at the bit of code:

try {
    MainMenu.start();
} catch (IOException e1) {
    System.out.print(e1.getCause());
}

I type a couple of random lines in the JTextField, press enter and then the program freezes.

Here is the whole code if you need it.

package Main;

import java.awt.BorderLayout;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class window extends JFrame implements KeyListener {
/**
 * 
 */
private static final long serialVersionUID = 7092006413113558324L;
private static int NewSize;
public static String MainInput;
public static JTextField input = new JTextField(10);
public static JTextArea output = new JTextArea(main.Winx, NewSize);

public window() {
    super("Satine");
    NewSize = main.Winy - 20;
    setLayout(new BorderLayout());
    output.setToolTipText("");
    add(input, BorderLayout.PAGE_END);
    add(output, BorderLayout.CENTER);
    input.addKeyListener(this);
    input.requestFocus();
}

@Override
public void keyPressed(KeyEvent e) {
    int key = e.getKeyCode();
    if (key == KeyEvent.VK_ENTER) {
        String MainInput = input.getText();
        try {
            MainMenu.start();
        } catch (IOException e1) {
            System.out.print(e1.getCause());
        }
        output.append(MainInput + "\n");
        input.setText("");
    }
}

@Override
public void keyReleased(KeyEvent e) {
}

@Override
public void keyTyped(KeyEvent e) {
}
}

Thank you for taking time out to assess this.

Also i forgot here is MainMenu.java

package Main;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import java.util.StringTokenizer;

public class MainMenu {
public static String InputText = window.MainInput;
public static String CompleteInput, noCaseCompleteInput, A1, A2, A3, A4,
        A5; // Command
// Inputs
public static String Advance = "Y";
public static String Advance2 = "Y";
public String Command;
public static String CorrectP;
public static StringTokenizer st;

public static void start() throws IOException{
    window.output.append("Satine. /InDev-01/ " + "\n");
    do {
        CompleteInput = InputText;
        noCaseCompleteInput = CompleteInput.toLowerCase();
        st = new StringTokenizer(noCaseCompleteInput);
        switch (st.nextToken()) {
        case "help":
            helpData.HelpDefine();
            continue;
        case "end":
            System.exit(0);
        case "newworld":
            newWorldRun.NewWorld();
            break;
        case "save":
            Save.SaveFull();
            continue;
        case "load":
            Save.FileName = st.nextToken();
            Read.ReadFull();
            continue;
        case "profile":
            profileData.profile();
            break;
        case "dp":
            debugPrint.print();
            continue;
        case "move":
            Movement.MoveCommand();
            continue;
        case "equip":
            equip.equip();
            break;
        case "attack":
            MonsterEvents.attackStart();
            break;
        default:
            window.output.append("Please Enter A Valid Command" + "\n");
            System.out.println("Please Enter A Valid Command");
        }
        window.input.setText("");
        } while (Advance.equals("Y"));
    }
   }
  • 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-06-02T22:16:59+00:00Added an answer on June 2, 2026 at 10:16 pm

    String MainInput = input.getText(); shadows the object instance variable MainInput and hence is not used in MainMenu.start(). Also, if MainMenu.Advance is not set to a value other than Y, it’ll endlessly loop.

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

Sidebar

Related Questions

I have tried running the code without the collision, and it works fine. But
I have tried searching for an answer to this but my searches have come
Have tried to find solutions for this and can't really come up with anything.
I have tried var dateHeaders = HttpContext.Current.Request.Headers[Date] but it contains null, apparently there is
I have tried the following: $(shell ./libpng/configure) ./libpng/configure under this context all : build_jpeg
I have tried to use stripersist with mysql but was not successful. I have
I have tried using sp.core.user.canonicalUsername and m.User in various variants, I even tried to
I have tried to find an answer online and maybe there is an answer
I have tried to create a hello world Web Service using visual studio 2008,
I have tried <ul id=contact_list> <li id=phone>Local 604-555-5555</li> <li id=i18l_phone>Toll-Free 1-800-555-5555</li> </ul> with #contact_list

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.