Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi guys, I created a code the frame work of my code. How do I add the following? Inheritance Multiple Classes Generics Threads Java FX

Hi guys,

I created a code the frame work of my code. How do I add the following?

  • Inheritance
  • Multiple Classes
  • Generics
  • Threads
  • Java FX
  • Database
  • Data Structures
  • Sorting

Here is my code. Please I really need some help here.

My code:

New.Java

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

public class New extends JFrame{

private static JPanel mainPanel, namePanel, charactersPanel, buttonPanel;

private static JLabel nameLabel;

private static JTextField nameField;

private static ButtonGroup grp;

private static JRadioButton yodaRB, obiWanRB, mickeyRB;

private static JButton subitButton;

public New()

{

mainPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

namePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

nameLabel = new JLabel("Name: ");

nameField = new JTextField(20);

namePanel.add(nameLabel);

namePanel.add(nameField);

charactersPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

grp = new ButtonGroup();

yodaRB = new JRadioButton("Yoda");

obiWanRB = new JRadioButton("Obi-Wan");

mickeyRB = new JRadioButton("Mickey");

grp.add(yodaRB);

grp.add(obiWanRB);

grp.add(mickeyRB);

charactersPanel.add(yodaRB);

charactersPanel.add(obiWanRB);

charactersPanel.add(mickeyRB);

buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

subitButton = new JButton("Submit");

buttonPanel.add(subitButton);

mainPanel.add(namePanel);

mainPanel.add(charactersPanel);

mainPanel.add(buttonPanel);

add(mainPanel);

setTitle("Select Character");

setSize(300, 170);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLocationRelativeTo(null);

setVisible(true);

// action listener for submit button

subitButton.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

new StarWarsPlayGame();

dispose();

}

});

}

}

StarWarsPlay.java

import java.awt.FlowLayout;

import java.awt.GridLayout;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

public class StarWarsPlayGame extends JFrame{

private static JPanel mainPanel, statsPanel, vsPanel, ansPanel, printPanel;

private static JLabel nameLabel, characterLabel, scoreLabel, ansLabel;

private static ButtonGroup grp;

private static JRadioButton rbCharacter1, rbCharacter2;

private static JButton printButton;

public StarWarsPlayGame()

{

mainPanel = new JPanel(new GridLayout(4, 0));

statsPanel = new JPanel(new GridLayout(0, 3, 10, 10));

nameLabel = new JLabel("Name: ");

characterLabel = new JLabel("Character: ");

scoreLabel = new JLabel("Score: ");

statsPanel.add(nameLabel);

statsPanel.add(characterLabel);

statsPanel.add(scoreLabel);

vsPanel = new JPanel(new GridLayout(2, 0));

JPanel charPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

characterLabel = new JLabel("1st Character Vs. 2nd Character");

charPanel.add(characterLabel);

JPanel rbPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

grp = new ButtonGroup();

rbCharacter1 = new JRadioButton("Choose me");

rbCharacter2 = new JRadioButton("Choose me");

grp.add(rbCharacter1);

grp.add(rbCharacter2);

rbPanel.add(rbCharacter1);

rbPanel.add(rbCharacter2);

vsPanel.add(charPanel);

vsPanel.add(rbPanel);

ansPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

ansLabel = new JLabel("Answer");

ansPanel.add(ansLabel);

printPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

printButton = new JButton("Print Report");

printPanel.add(printButton);

mainPanel.add(statsPanel);

mainPanel.add(vsPanel);

mainPanel.add(ansPanel);

mainPanel.add(printPanel);

add(mainPanel);

setTitle("Star Wars Game Play");

setSize(600, 300);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLocationRelativeTo(null);

setVisible(true);

}

}

MainGamePlay.java

public class MainGamePlay {

public static void main(String[] args)

{

new New();

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions