Question & Answer: Need this and everything exactly. Thank you!…..

Need this and everything exactly. Thank you!

We are going to re-do the SuperLottoPlus assignment, and turn it into a Java swing application Create a new class called SuperLottoSwing.java that extends JFrame.

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Need this and everything exactly. Thank you!…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Create the GUI Set the window title to “SuperLottoPlus” (10 point)

Create two JPanel objects (north and center panel) (10 point)

Using BorderLayout, set the position of the north and center panel(10 point)

Add 3 JButtons to the north panel: “I’m Feeling Lucky”, “Reset”, and “Print” (10 point)

Made the north panel background color orange (10 point)

Add a text area box (JTextArea) to the center panel (this is where we will display the lotto numbers) (10 point)

When the user clicks the “I’m Feeling Lucky” button: Make the center panel background yellow (10 point)

Display the SuperLotto lottery numbers in the text area box. (10 point)

When the user clicks the “Reset” button, make the center panel background white, and clear the text. (10 point)

When the user clicks the “Print” button, write whatever text is in the center panel to a file called “superlotto.txt” (10 point)

Expert Answer

Java Code
package superlotto.GUI;

import java.awt.BorderLayout;

import java.awt.EventQueue;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;

import java.awt.Color;

import javax.swing.JTextArea;

import javax.swing.JButton;

import java.awt.event.ActionListener;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.awt.event.ActionEvent;

public class SuperLottoSwing extends JFrame {

private JPanel contentPane;

private JTextArea textArea_lottoNum;

// lotto numbers array.

private String[] lottoNumbers = {“8242632441”, “94638782387”, “23465891643”, “35267459824”,

“18953286794”, “91645278542”, “43675489023”};

/**

* Launch the application.

*/

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {

public void run() {

try {

SuperLottoSwing frame = new SuperLottoSwing(“SuperLottoPlus”);

frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

}

/**

* Create the frame.

*/

public SuperLottoSwing(String title) {

this.setTitle(title);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100, 100, 450, 300);

contentPane = new JPanel();

contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

contentPane.setLayout(new BorderLayout(0, 0));

setContentPane(contentPane);

JPanel NorthPanel = new JPanel();

NorthPanel.setBackground(Color.ORANGE);

contentPane.add(NorthPanel, BorderLayout.NORTH);

JPanel CenterPanel = new JPanel();

contentPane.add(CenterPanel, BorderLayout.CENTER);

textArea_lottoNum = new JTextArea(5, 20);

textArea_lottoNum.setEditable(false);

CenterPanel.add(textArea_lottoNum);

// Button I am feeling lucky

JButton btn_feelingLucky = new JButton(“I’m Feeling Lucky”);

btn_feelingLucky.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

CenterPanel.setBackground(Color.orange);

for(String num : lottoNumbers)

textArea_lottoNum.setText(textArea_lottoNum.getText()+num+”n”);

}

});

NorthPanel.add(btn_feelingLucky);

//Button Reset

JButton btn_reset = new JButton(“Reset”);

btn_reset.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

CenterPanel.setBackground(Color.decode(“#f0f0f0”)); // setting to default color

textArea_lottoNum.setText(“”);

}

});

NorthPanel.add(btn_reset);

// Button Print

JButton btn_print = new JButton(“Print”);

btn_print.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

printToFile();

}

});

NorthPanel.add(btn_print);

}

/**

* Method to print to file

*/

public void printToFile()

{

if(!(textArea_lottoNum.getText().equals(“”))){

FileWriter fw = null;

try {

fw = new FileWriter(new File(“superlotto.txt”));

for(String num : lottoNumbers)

fw.write(num+”n”); // printing to file

fw.close();

JOptionPane.showMessageDialog(null, “Lotto Numbers printed to file succesfully.”);

}

catch (IOException e1) {

JOptionPane.showMessageDialog(null, “Error in creating the ‘superlotto.txt’ file”, “ERROR”, JOptionPane.ERROR_MESSAGE);

}

}

else

JOptionPane.showMessageDialog(null, “Nothing in Text Area to print”);

}

}

Instructions: Open your java ide create a new project with package name superlotto.GUI and within this package create a new class named SuperLottoSwing after than copy-paste the above code into the class file and run.

OUTPUT

Grand Paper Writers
Order NOW For A 10% Discount!
Pages (550 words)
Approximate price: -

Our Advantages

Plagiarism Free Papers

All papers are written by the best professional writers to ensure 100% originality. We always provide plagiarism reports whenever we deliver completed papers.

Free Revisions

All papers by Grand Paper Writers are completed and submitted on time. This timely delivery of papers gives you time to go through the paper before the official deadline.

Title-page

As an additional service, we will provide a title page that precedes the contents of your paper. Here, you will provide your personal details.

Bibliography

We also ensure that we provide an extra page for the references or bibliographies following referencing rules.

Originality & Security

At Grandpaperwriters.com, we guarantee students for the provision of security and original work. All your personal information is handled with confidentiality and is not shared with third parties. Additionally, we ensure that we provide original content with accompanying plagiarism reports to show originality.

24/7 Customer Support

Our customer support team is always available 24/7 to provide instant responses to any queries raised by students.

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Grandpaperwriters.com has the best professional essay writers for quality services.

Pricing

Flexible Pricing

Here, a Grandpaperwriters.com, we do not compromise on the time of our clients. We always deliver all completed papers on or before the deadlines.

Communication

Admission Help & Client-Writer Contact

Grandpaperwriters.com provides an interactive portal where students can communicate directly to their writers.

Deadlines

Paper Submission

Here, a Grandpaperwriters.com, we do not compromise on the time of our clients. We always deliver all completed papers on or before the deadlines.

Reviews

Customer Feedback

Grandpaperwriters.com appreciates feedback from our clients to help us improve the delivery of essay writing services. As such, we are constantly changing our policies to ensure maximum customer and writer satisfaction.