Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can somebody please make this into javafx? im struggling! JAVA FX ONLY PLEASE import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener;

can somebody please make this into javafx? im struggling!

JAVA FX ONLY PLEASE

image text in transcribed

import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Random;

import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField;

@SuppressWarnings("unused") public class GuessGame extends JFrame {

private static final long serialVersionUID = 1L; private JButton try_Button; private JButton NewGame_button; private JButton Exit_butt; private JTextField GuessNo; private JLabel gLabel; private JLabel hLabel; private JTextField rField; int Number; int cnt;

public GuessGame() { setTitle("Number Guessing Game"); setSize(350, 3500); Random rnd=new Random(); Number=rnd.nextInt(1000)+1; cnt=0; try_Button = new JButton("Try Number"); Exit_butt = new JButton("Exit"); NewGame_button = new JButton("New Game"); gLabel = new JLabel("Enter your GuessNo:"); hLabel = new JLabel("Let's play game I have a Number between 1 and 1000, GuessNo the Number?"); GuessNo = new JTextField(5); rField = new JTextField(25); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

button_handlerr tbHandler = new button_handlerr(); try_Button.addActionListener(tbHandler);

Exit_but_handler eHandler = new Exit_but_handler(); Exit_butt.addActionListener(eHandler);

Newgame_but_handler ngHandler = new Newgame_but_handler(); NewGame_button.addActionListener(ngHandler);

try_Button.setMnemonic('T'); Exit_butt.setMnemonic('E'); NewGame_button.setMnemonic('N');

rField.setBackground(Color.white); rField.setEditable(false); rField.setText("");

setLayout(new FlowLayout(FlowLayout.CENTER));

add(hLabel); add(gLabel); add(GuessNo); add(try_Button); add(Exit_butt); add(NewGame_button); add(rField); }

class button_handlerr implements ActionListener { public void actionPerformed(ActionEvent arg0) { int GuessNo=0; cnt++; try{ GuessNo=Integer.parseInt(GuessNo.getText()); }catch (Exception e) { } if(GuessNo==Number){ rField.setText("Correct! The Numberber of GuessNoes: "+cnt); }else if(GuessNo

class Exit_but_handler implements ActionListener { public void actionPerformed(ActionEvent arg0) { System.exit(0); }

}

class Newgame_but_handler implements ActionListener { public void actionPerformed(ActionEvent arg0) { Random rnd=new Random(); Number=rnd.nextInt(1000)+1; rField.setText(""); GuessNo.setText(""); cnt=0; } }

public static void main(String[] args) { GuessGame g=new GuessGame(); g.setVisible(true); } }

4:13

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions