Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a file named \"Class.dat\" with me, doubtly it can upload here. But pleas

ID: 3750148 • Letter: I

Question

I have a file named "Class.dat" with me, doubtly it can upload here. But please help with this coding by using only JavaFX. Thank you!

Problem 1: Inner Classes (60%) Read all of problem 1 before starting, hints are given throughout the problems statement. See the Execution Examples, below, to see what the GUI should look like Overview Fields and Behaviors: Behavior GUI Component TextArea Will hold the text being searched. It needs to be updated when a word is found This area is horizontal and vertical scrollable Holds the word to be found Every time this button is pressed, the first occurrence of the "find" word in the TextArea will be located and highlighted A named inner class. Clears the TextField that holds the word to match Sets the input focus to the 'find' text field This does NOT clear the text area. An Anonymous inner class. Close using window listener/adapter inner class, and print a "Thank you for using finder" message An Anonymous inner class. Add a WindowListener using WindowAdapter class formatted similar to an ActionListener TextField Find Button Clear Button Windows close Requirements: 1. You need to develop your own inner classes to handle the events. You must handle the window closing and button press events 2. The search is case sensitive. If the case of the letters in the word in the TextArea does not match exactly the word in the TextField, skip over it Page 1 of5

Explanation / Answer

Please find the files below.

ackage cheggfinding;

/**
*
@author abhiramagopaladasa
/
public class CheggFinding {

/**
* @param args the command line arguments
/
public static void main(String[] args) {
Finding2 f = new Finding2();
f.setVisible(true);
}

}

/
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 cheggfinding;

import java.awt.event.MouseAdapter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;

/**
*
@author abhiramagopaladasa
/
public class Finding2 extends javax.swing.JFrame {

class ToFindClass extends MouseAdapter {//This is the named inner class for the find button

@Override
public void mouseClicked(java.awt.event.MouseEvent evt) {
String wordToFind = findTextField.getText();//getting the text from the find text field
String toFindIn = pastedTextArea.getText();

if (toFindIn.contains(wordToFind)) {
Pattern p = Pattern.compile(wordToFind);
Matcher matcher = p.matcher(toFindIn);
matcher.find();
matcher.group();
pastedTextArea.select(matcher.start(), matcher.end());
} else {
JOptionPane.showMessageDialog(rootPane, "String not found");
}
}

}

/**
* Creates new form Finding2
/
public Finding2() {
initComponents();
}

/*
This method is called from within the constructor to initialize the form.
WARNING: Do NOT modify this code. The content of this method is always
regenerated by the Form Editor.
/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

jScrollPane1 = new javax.swing.JScrollPane();
pastedTextArea = new javax.swing.JTextArea();
pastedTextArea.setLineWrap(true);
findButton = new javax.swing.JButton();
clearButton = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
findTextField = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);//to show a dialog which is below on exit.

this.addWindowListener(new java.awt.event.WindowAdapter() {//this says thanks to the user
@Override
public void windowClosing(java.awt.event.WindowEvent windowEvent) {
JOptionPane.showMessageDialog(rootPane, "thanks for using");
System.exit(0);
}

});

pastedTextArea.setColumns(20);
pastedTextArea.setRows(5);
jScrollPane1.setViewportView(pastedTextArea);

findButton.setText("Find");
findButton.addMouseListener(new ToFindClass());//using the named Inner class here for find button

clearButton.setText("Clear");
clearButton.addMouseListener(new java.awt.event.MouseAdapter() {//this is an anonymous inner class as told in the assignment
@Override
public void mouseClicked(java.awt.event.MouseEvent evt) {
findTextField.setText("");
findTextField.requestFocus();
}
});

jLabel1.setText("Find");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 363, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(64, 64, 64)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(findTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(findButton)
.addGap(59, 59, 59)
.addComponent(clearButton)))))
.addContainerGap(19, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(findTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(findButton)
.addComponent(clearButton))
.addGap(21, 21, 21))
);

pack();
}// </editor-fold>//GEN-END:initComponents

/**
* @param args the command line arguments
/
public static void main(String args[]) {
/ Set the Nimbus look and feel /
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/ If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Finding2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Finding2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Finding2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Finding2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/ Create and display the form /
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Finding2().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton clearButton;
private javax.swing.JButton findButton;
private javax.swing.JTextField findTextField;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea pastedTextArea;
// End of variables declaration//GEN-END:variables
}

joptionpane makes it easy to pop up a second dialog box

that propmts users for a value or informs then of something.

for information about using joptionpane ,see

how to make dialogs, a section in java tutorial