Question

in Java, design your favorite GUI application, and allow new customer/user to be entered on the...

in Java, design your favorite GUI application, and allow new customer/user to be entered on the GUI so that a customer (or user) can access your application.   

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi According to your requirement I should do a coding of my favorite GUI application in JAVA

My favorite GUI Application is guessing number game between 1 to 1000 so I have done coding for that GUI application and given you the code below along with sample output screens

Code:

GuessingNumber.java

Test.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;

/**
*
* @author miracle
*/
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.SwingUtilities;

public class Test extends JFrame {
private int Guesses = 1;
private int GuessOld = 0;
private int number;   
private JTextField guessInputJTextField;   
private JLabel prompt1JLabel;
private JLabel prompt2JLabel;
private JLabel messageJLabel;   
private JLabel message2JLabel;
private JLabel random1 = new JLabel("");
private JButton newGameJButton;   
private Color background;   


public Test() {
super("Guessing Game");

setLayout(new FlowLayout());
background = Color.LIGHT_GRAY;   
prompt1JLabel = new JLabel("I have a number between 1 and 1000.");
add(prompt1JLabel);
prompt2JLabel = new JLabel("I'm thinking of a number between 1 and 1000. Guess it!\":");
add(prompt2JLabel);
guessInputJTextField = new JTextField(5);
guessInputJTextField.addActionListener(new GuessHandler());
add(guessInputJTextField);
messageJLabel = new JLabel("");
add(messageJLabel);
message2JLabel = new JLabel("");
add(message2JLabel);
newGameJButton = new JButton("New Game");   
add(newGameJButton);

Random generator = new Random();
number = generator.nextInt(1001);

newGameJButton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e) {

guessInputJTextField.setText("");
Random generator = new Random();
number = generator.nextInt(1001);
random1.setText("" + number);
SwingUtilities.updateComponentTreeUI(random1);
messageJLabel.setText("");
guessInputJTextField.setEditable(true);
Guesses = 0;
message2JLabel.setText("Number of Guesses: " + Guesses);
Guesses++;
}   
}
);
theGame();
}

public void theGame() {

}

class GuessHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {

int Guess;

Guess = Integer.parseInt(guessInputJTextField.getText());

if (Math.abs(number - Guess) < Math.abs(number - GuessOld)) {

getContentPane().setBackground(Color.RED);

} else {

  
getContentPane().setBackground(Color.BLUE);
}
GuessOld = Guess;
if (Guess > number) {
messageJLabel.setText("Too High.");
SwingUtilities.updateComponentTreeUI(messageJLabel);

}
if (Guess < number) {

messageJLabel.setText("Too Low.");
SwingUtilities.updateComponentTreeUI(messageJLabel);

}   
if (Guess == number) {
messageJLabel.setText("Correct!");
SwingUtilities.updateComponentTreeUI(messageJLabel);
guessInputJTextField.setEditable(false);

}
message2JLabel.setText("Number of Guesses: " + Guesses++);
}

}
}   

Sample Output Screens:

Output screen1:

Output screen 2:

Output screen 3:

Hope This Helps, Please Thumbs UP, If you have any doubts Please do comment I will get back to you.

Add a comment
Know the answer?
Add Answer to:
in Java, design your favorite GUI application, and allow new customer/user to be entered on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Select one favorite application of yours (in e-commence, education, games, and so on). Design a Java...

    Select one favorite application of yours (in e-commence, education, games, and so on). Design a Java FxGUI for a "customer" to access the application of your design. the application of your design. 1. Makes sure you have sufficient components (2 or more buttons, text fields/areas, a selection list, 1 or more images and other optional components of your choice). In addition, add an "account" information so that a customer/user may access or utilize the application. Your GUI application shall also...

  • In Java. Write a GUI contact list application. The program should allow you to input names...

    In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...

  • Please design a Java GUI application with two JTextField for user to enter the first name...

    Please design a Java GUI application with two JTextField for user to enter the first name and last name. Add two JButtons with action events so when user click on one button to generate a full name message from the user input and put it in a third JTextField which is not editable; and click on the other button to clear all three JTextField boxes. Please run the attached nameFrame.class file (Note: because there is an actionhandler inner class in...

  • This project is designed to help you practice Graphical User Interfaces (GUI) using Java. Design and...

    This project is designed to help you practice Graphical User Interfaces (GUI) using Java. Design and write a class needed to simulate a pizza shop ordering system GUI. Your ordering system should allow the user to select whether the order is to be delivered or picked up, the items ordered from the menu and the name of the person making the order. When the user presses the place order button, the display should show the delivery status, the items ordered,...

  • use java to design the application, the GUI should appear as in the picture shown ....

    use java to design the application, the GUI should appear as in the picture shown . Use java language: Requirements Document A local bank intends to install a new automated teller machine (ATM) to allow users (i.e., bank customers) to perform basic financial transactions. Each user can have only one account at the bank. ATM users should be able to view their account balance, withdraw cash (i.e., take money out of an account) and deposit funds (i.e., place money into...

  • In Java please, thank you! Design a GUI application as shown below and perform the following...

    In Java please, thank you! Design a GUI application as shown below and perform the following tasks: The text field is for data file name, the file extension must be.txt, otherwise, prompt user to provide a valid file name. Load the content of the data file and display on the textarea. 1. 2. Loading Files File Name: data.tt Load File

  • Create a new Netbeans project application from scratch called MyAge. Create a GUI that accepts user...

    Create a new Netbeans project application from scratch called MyAge. Create a GUI that accepts user input. The final script should be able to calculate your age when your date of birth is entered. Include a simple try and catch for arithmetic errors.

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

  • The purpose of this Java application is to create a simple user interface on top of...

    The purpose of this Java application is to create a simple user interface on top of a relational database. The database you should use is the Java DB database. Setup of the Java DB database is covered in section 24.5. The user interface will allow a user to insert, delete, and update names from a table in the database. The database table will look like this: ID FIRST_NAME LAST_NAME 1452962065165       Rita                           Red                           1452962067770       Oscar                          Orange                        1452962070010       Yet                            The ID value...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT