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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:46:56+00:00 2026-06-09T04:46:56+00:00

I am new to java and I am wondering what is the best way

  • 0

I am new to java and I am wondering what is the best way to go about importing a class to a JFrame since I have a few minor applications I would like to make run in a window other then eclipse.

Here is some of the code I am working with (Its a modified version of some code in the dummies book):

import static java.lang.System.out;
import java.util.Scanner;
import java.util.Random;

public class GuessAgain {

/**
 * @param args
 */
public static void main(String[] args) {
    // Set up input and main info
    Scanner input = new Scanner(System.in);
    int numGuesses = 0;
    int randomNumber = new Random().nextInt(10) + 1;

    // Display welcome message
    out.println("~-=********************=-~");
    out.println("    The Guessing Game!    ");
    out.println("~-=********************=-~");

    // Give instruction
    out.print("Please enter a number between 1 and 10: ");
    int inputNumber = input.nextInt();
    numGuesses++;

    // Recurse till user gets the answer
    while (inputNumber != randomNumber) {
        out.println();
        out.println("~-=********************=-~");
        out.println("     Please try again     ");
        out.println("~-=********************=-~");
        out.print("Enter another number between 1 and ten: ");
        inputNumber = input.nextInt();
        numGuesses++;
    }
    out.print("You won after: " + numGuesses + " guesses");

}

}

So how do I go about putting all of that into a window?

  • 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-09T04:46:58+00:00Added an answer on June 9, 2026 at 4:46 am

    You’ll probably want to take a look at oracle’s swing tutorial, that’s what you need to learn how to use in order to make a frame/window. You can make a nice GUI (Graphic User Interface) for your game with that, rather than just using Eclipse’s console 😉

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

Sidebar

Related Questions

I'm new to web development and am just wondering about best practices for java
I was wondering what would be the best way to execute a java-script code
I am new to rails and am wondering if this is the best way
I was wondering what would be the best way to handle errors in an
I'm wondering what would be the best way to set a NULL (or NIL)
I am new to java text parsing and I'm wondering what is the best
I am very new to Java and I was wondering if it is possible
I'm very new to Python (I'm coming from a JAVA background) and I'm wondering
hey all, I'm new to Java and was wondering if I define a method
We have a current Java EE project and a new requirement to introduce 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.