SlideShare a Scribd company logo
1 of 13
Discussion Board 2
William Denison
27 NOV 2014
A Java class that allows writing to files is Class FileWriter.
This class is a part of java.io package and extends (inherits
from) OutputStreamWriter class.
This class allows us to write character files conveniently. The
reason I chose this class is because of the functionality provided
by FileWriter class. It allows us to write to a new file, as well
as append content to an existing file. Given a filename as a
string parameter, it creates the file if it does not already exist.
So, the user is not required to explicitly create a new file before
writing to it using FileWriter class.
FileWriter class provides several constructors, which are as
follows:
1) FileWriter(File file) - takes File object as a parameter,
which corresponds to the file, the data is to be written to.
2) FileWriter(File file, boolean append) - takes two parameters:
one is the File object to which data is to be written to, and
second is a boolean parameter which indicates whether data is
to be appended to the file
3) FileWriter(String filename) - takes a string parameter for the
filename
4) FileWriter(String filename, Boolean append) - takes two
parameters, one for the filename (string) and a Boolean value
indicating whether data should be appended to the file or not
Pseudo code:
1. Create a string array and initialize elements of the array with
given data
String[] dataArray = new String[4];
dataArray[0] = "1001 Jennifer Ward SUPPLIES 2140.20
BOOKS 5200.10 PAPER 455.23 NORTH Phone";
dataArray[1] = "1003 Athena Andrews SUPPLIES 5155.55
BOOKS 6300.50 PAPER 223.25 SOUTH Email";
dataArray[2] = "1005 Andy Smith SUPPLIES 6155.55
BOOKS 300.50 PAPER 55.55 SOUTH Email";
dataArray[3] = "1006 Robert Stearns SUPPLIES 7255.55
BOOKS 8300.50 PAPER 77.77 SOUTH Phone";
2. Create a File object and pass the filename
File file = new File(“data.txt”);
3. Check if file exits by that name, if it does not create a new
file as follows:
file.createNewFile();
4. Create FileWriter object by passing the File object created
above
5. In a for loop write each element of the array to the file:
for(int i=0; i<dataArray.length; i++){
writer.write(dataArray[i]); //write the line to file
writer.write("n"); //write a newline to the file
}
6. Close the writer.
7. Catch any exceptions if thrown
RealCode:
import java.io.*;
class FileWritingExample
{
public static void main(String args[]){
String[] dataArray = new String[4];
dataArray[0] = "1001 Jennifer Ward SUPPLIES
2140.20 BOOKS 5200.10 PAPER 455.23 NORTH Phone";
dataArray[1] = "1003 Athena Andrews SUPPLIES
5155.55 BOOKS 6300.50 PAPER 223.25 SOUTH Email";
dataArray[2] = "1005 Andy Smith SUPPLIES
6155.55 BOOKS 300.50 PAPER 55.55 SOUTH Email";
dataArray[3] = "1006 Robert Stearns SUPPLIES
7255.55 BOOKS 8300.50 PAPER 77.77 SOUTH Phone";
try{
File file = new File("data.txt");
//check if file already exists
if(!file.exists()){
file.createNewFile(); //create a
new file if it does not exist
}
//create FileWriter object using File object
created above
FileWriter writer = new FileWriter(file);
//write content to file
for(int i=0; i<dataArray.length; i++){
writer.write(dataArray[i]); //write
the line to file
writer.write("n"); //write
a newline to the file
}
writer.flush();
writer.close(); //close the writer stream
}catch(IOException ioe){
//display the exception stacktrace
System.out.println("Error while writing to the
file");
ioe.printStackTrace();
}
}
}
ProjectGUI/nbproject/private/private.properties
compile.on.save=true
user.properties.file=/home/an/.netbeans/7.1.1/build.properties
ProjectGUI/src/projectgui/GUI.form
ProjectGUI/src/projectgui/GUI.javaProjectGUI/src/projectgui/G
UI.java/*
* GUI.java
*
*/
package projectgui;
import java.awt.Color;
import javax.swing.JOptionPane;
/**
*
* @author Asma Niaz
*/
publicclass GUI extends javax.swing.JFrame{
/**
* Creates new form SingleNeutronRun
*/
public GUI(){
initComponents();
}
/**
* This method is called from within the constructor to initial
ize 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
privatevoid initComponents(){
operationsButtonGroup =new javax.swing.ButtonGroup();
buttonGroup1 =new javax.swing.ButtonGroup();
districtPanel =new javax.swing.JPanel();
northRadioButton =new javax.swing.JRadioButton();
eastRadioButton =new javax.swing.JRadioButton();
southRadioButton =new javax.swing.JRadioButton();
westRadioButton =new javax.swing.JRadioButton();
inputPanel =new javax.swing.JPanel();
jTextField2 =new javax.swing.JTextField();
jTextField3 =new javax.swing.JTextField();
jTextField1 =new javax.swing.JTextField();
jLabel1 =new javax.swing.JLabel();
jLabel2 =new javax.swing.JLabel();
jLabel3 =new javax.swing.JLabel();
inputPanel1 =new javax.swing.JPanel();
jTextField4 =new javax.swing.JTextField();
jTextField5 =new javax.swing.JTextField();
jTextField6 =new javax.swing.JTextField();
jLabel5 =new javax.swing.JLabel();
jLabel6 =new javax.swing.JLabel();
jLabel4 =new javax.swing.JLabel();
runButton =new javax.swing.JButton();
exitButton =new javax.swing.JButton();
DataPanel=new javax.swing.JPanel();
jScrollPane1 =new javax.swing.JScrollPane();
dataTextArea =new javax.swing.JTextArea();
districtPanel1 =new javax.swing.JPanel();
phoneCheckBox =new javax.swing.JCheckBox();
emailCheckBox =new javax.swing.JCheckBox();
visitCheckBox =new javax.swing.JCheckBox();
setDefaultCloseOperation(javax.swing.WindowConstants.
EXIT_ON_CLOSE);
setTitle("Single Neuron Perceptron");
districtPanel.setBorder(javax.swing.BorderFactory.createT
itledBorder("Select District"));
buttonGroup1.add(northRadioButton);
northRadioButton.setSelected(true);
northRadioButton.setText("North");
buttonGroup1.add(eastRadioButton);
eastRadioButton.setText("East");
buttonGroup1.add(southRadioButton);
southRadioButton.setText("South");
buttonGroup1.add(westRadioButton);
westRadioButton.setText("West");
javax.swing.GroupLayout districtPanelLayout =new javax.
swing.GroupLayout(districtPanel);
districtPanel.setLayout(districtPanelLayout);
districtPanelLayout.setHorizontalGroup(
districtPanelLayout.createParallelGroup(javax.swing.Gr
oupLayout.Alignment.LEADING)
.addGroup(districtPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(districtPanelLayout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)
.addComponent(northRadioButton)
.addComponent(eastRadioButton)
.addComponent(southRadioButton)
.addComponent(westRadioButton))
.addContainerGap(69,Short.MAX_VALUE))
);
districtPanelLayout.setVerticalGroup(
districtPanelLayout.createParallelGroup(javax.swing.Gr
oupLayout.Alignment.LEADING)
.addGroup(districtPanelLayout.createSequentialGroup()
.addComponent(northRadioButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addComponent(southRadioButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addComponent(eastRadioButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addComponent(westRadioButton))
);
northRadioButton.getAccessibleContext().setAccessibleNa
me("northRadioButton");
inputPanel.setBorder(javax.swing.BorderFactory.createTitl
edBorder("Enter Values"));
jTextField2.addFocusListener(new java.awt.event.FocusA
dapter(){
publicvoid focusLost(java.awt.event.FocusEvent evt){
jTextField2FocusLost(evt);
}
});
jTextField3.addFocusListener(new java.awt.event.FocusA
dapter(){
publicvoid focusLost(java.awt.event.FocusEvent evt){
jTextField3FocusLost(evt);
}
});
jTextField1.addFocusListener(new java.awt.event.FocusA
dapter(){
publicvoid focusLost(java.awt.event.FocusEvent evt){
jTextField1FocusLost(evt);
}
});
jLabel1.setText("Sales Rep ID");
jLabel2.setText("Sales Rep First Name");
jLabel3.setText("Sales Rep Last Name");
inputPanel1.setBorder(javax.swing.BorderFactory.createTi
tledBorder("Amounts Sold"));
jTextField4.addFocusListener(new java.awt.event.FocusA
dapter(){
publicvoid focusLost(java.awt.event.FocusEvent evt){
jTextField4FocusLost(evt);
}
});
jTextField5.addFocusListener(new java.awt.event.FocusA
dapter(){
publicvoid focusLost(java.awt.event.FocusEvent evt){
jTextField5FocusLost(evt);
}
});
jTextField6.addFocusListener(new java.awt.event.FocusA
dapter(){
publicvoid focusLost(java.awt.event.FocusEvent evt){
jTextField6FocusLost(evt);
}
});
jLabel5.setText("Books");
jLabel6.setText("Paper");
jLabel4.setText("Office Supplies");
javax.swing.GroupLayout inputPanel1Layout =new javax.s
wing.GroupLayout(inputPanel1);
inputPanel1.setLayout(inputPanel1Layout);
inputPanel1Layout.setHorizontalGroup(
inputPanel1Layout.createParallelGroup(javax.swing.Gr
oupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, in
putPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,S
hort.MAX_VALUE)
.addGroup(inputPanel1Layout.createParallelGroup(javax.swing.
GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel6)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addGroup(inputPanel1Layout.createParallelGroup(javax.swing.
GroupLayout.Alignment.LEADING,false)
.addComponent(jTextField5, javax.swing.GroupLayout.Alignme
nt.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,133,
Short.MAX_VALUE)
.addComponent(jTextField4, javax.swing.GroupLayout.Alignme
nt.TRAILING)
.addComponent(jTextField6))
.addContainerGap())
);
inputPanel1Layout.setVerticalGroup(
inputPanel1Layout.createParallelGroup(javax.swing.Gr
oupLayout.Alignment.LEADING)
.addGroup(inputPanel1Layout.createSequentialGroup()
.addGroup(inputPanel1Layout.createParallelGroup(javax.swing.
GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addGroup(inputPanel1Layout.createSequentialGroup()
.addGap(4,4,4)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
wing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addGroup(inputPanel1Layout.createParallelGroup(javax.swing.
GroupLayout.Alignment.LEADING)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
wing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addGroup(inputPanel1Layout.createParallelGroup(javax.swing.
GroupLayout.Alignment.LEADING)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
wing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)))
);
javax.swing.GroupLayout inputPanelLayout =new javax.s
wing.GroupLayout(inputPanel);
inputPanel.setLayout(inputPanelLayout);
inputPanelLayout.setHorizontalGroup(
inputPanelLayout.createParallelGroup(javax.swing.Gro
upLayout.Alignment.LEADING)
.addGroup(inputPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(inputPanelLayout.createParallelGroup(javax.swing.G
roupLayout.Alignment.LEADING)
.addGroup(inputPanelLayout.createSequentialGroup()
.addGroup(inputPanelLayout.createParallelGroup(javax.swing.G
roupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel3)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.UNRELATED)
.addGroup(inputPanelLayout.createParallelGroup(javax.swing.G
roupLayout.Alignment.LEADING)
.addComponent(jTextField2)
.addComponent(jTextField3, javax.swing.GroupLayout.Alignme
nt.TRAILING)
.addComponent(jTextField1)))
.addGroup(inputPanelLayout.createSequentialGroup()
.addGap(0,21,Short.MAX_VALUE)
.addComponent(inputPanel1, javax.swing.GroupLayout.PREFE
RRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax
.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
inputPanelLayout.setVerticalGroup(
inputPanelLayout.createParallelGroup(javax.swing.Gro
upLayout.Alignment.LEADING)
.addGroup(inputPanelLayout.createSequentialGroup()
.addGroup(inputPanelLayout.createParallelGroup(javax.swing.G
roupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
wing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addGroup(inputPanelLayout.createParallelGroup(javax.swing.G
roupLayout.Alignment.LEADING)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
wing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen
t.RELATED)
.addGroup(inputPanelLayout.createParallelGroup(javax.swing.G
roupLayout.Alignment.LEADING)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFER
RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s
wing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(18,18,18)
.addComponent(inputPanel1, javax.swing.GroupLayout.PREFE
RRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax
.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,S
hort.MAX_VALUE))
);
runButton.setText("ENTER");
runButton.addActionListener(new java.awt.event.ActionLi
stener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
runButtonActionPerformed(evt);
}
});
exitButton.setText("QUIT");
exitButton.addActionListener(new java.awt.event.ActionLi
stener(){
publicvoid actionPerformed(java.awt.event.ActionEvent evt){
exitButtonActionPerformed(evt);
}
});
DataPanel.setBorder(javax.swing.BorderFactory.createTitledBor
der("Sales Representative Data"));
dataTextArea.setColumns(20);
dataTextArea.setRows(5);
jScrollPane1.setViewportView(dataTextArea);
javax.swing.GroupLayoutDataPanelLayout=new javax.swi
ng.GroupLayout(DataPanel);
DataPanel.setLayout(DataPanelLayout);

More Related Content

Similar to Discussion Board 2William Denison27 NOV 2014A Java class t.docx

Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1sotlsoc
 
Input output files in java
Input output files in javaInput output files in java
Input output files in javaKavitha713564
 
Session 23 - JDBC
Session 23 - JDBCSession 23 - JDBC
Session 23 - JDBCPawanMM
 
import required package file import java.io.File; The Filed.pdf
 import required package file import java.io.File; The Filed.pdf import required package file import java.io.File; The Filed.pdf
import required package file import java.io.File; The Filed.pdfanandinternational01
 
Writing Swift code with great testability
Writing Swift code with great testabilityWriting Swift code with great testability
Writing Swift code with great testabilityJohn Sundell
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File HandlingSunil OS
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8WindowsPhoneRocks
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WPNguyen Tuan
 
Please I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfPlease I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfasenterprisestyagi
 
Parameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputParameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputuanna
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docxtheodorelove43763
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdfSudhanshiBakre1
 
file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdfJayaprasanna4
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentationAzeemaj101
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streamsShahjahan Samoon
 
Whitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql ServerWhitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql ServerShahzad
 

Similar to Discussion Board 2William Denison27 NOV 2014A Java class t.docx (20)

Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
Session 23 - JDBC
Session 23 - JDBCSession 23 - JDBC
Session 23 - JDBC
 
import required package file import java.io.File; The Filed.pdf
 import required package file import java.io.File; The Filed.pdf import required package file import java.io.File; The Filed.pdf
import required package file import java.io.File; The Filed.pdf
 
Writing Swift code with great testability
Writing Swift code with great testabilityWriting Swift code with great testability
Writing Swift code with great testability
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
 
09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP09.Local Database Files and Storage on WP
09.Local Database Files and Storage on WP
 
Chapter 6 Java IO File
Chapter 6 Java IO FileChapter 6 Java IO File
Chapter 6 Java IO File
 
Lecture 11.pdf
Lecture 11.pdfLecture 11.pdf
Lecture 11.pdf
 
ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
 
Please I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdfPlease I am trying to get this code to output in -txt file- I need you.pdf
Please I am trying to get this code to output in -txt file- I need you.pdf
 
Parameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple inputParameterization is nothing but giving multiple input
Parameterization is nothing but giving multiple input
 
Description 1) Create a Lab2 folder for this project2.docx
Description       1)  Create a Lab2 folder for this project2.docxDescription       1)  Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
 
file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdf
 
using System.docx
using System.docxusing System.docx
using System.docx
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
 
Understanding java streams
Understanding java streamsUnderstanding java streams
Understanding java streams
 
Whitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql ServerWhitepaper To Study Filestream Option In Sql Server
Whitepaper To Study Filestream Option In Sql Server
 

More from duketjoy27252

Discussion questions – Twain, The Man That Corrupted Hadleyburg.docx
Discussion questions – Twain, The Man That Corrupted Hadleyburg.docxDiscussion questions – Twain, The Man That Corrupted Hadleyburg.docx
Discussion questions – Twain, The Man That Corrupted Hadleyburg.docxduketjoy27252
 
Discussion Questions The difficulty in predicting the future is .docx
Discussion Questions The difficulty in predicting the future is .docxDiscussion Questions The difficulty in predicting the future is .docx
Discussion Questions The difficulty in predicting the future is .docxduketjoy27252
 
Discussion questions – Dunbar Paul Lawrence Dunbar was a pio.docx
Discussion questions – Dunbar Paul Lawrence Dunbar was a pio.docxDiscussion questions – Dunbar Paul Lawrence Dunbar was a pio.docx
Discussion questions – Dunbar Paul Lawrence Dunbar was a pio.docxduketjoy27252
 
Discussion Questions Identify the top three threats to the home.docx
Discussion Questions Identify the top three threats to the home.docxDiscussion Questions Identify the top three threats to the home.docx
Discussion Questions Identify the top three threats to the home.docxduketjoy27252
 
Discussion questions – Hurston Zora Neal Hurston attended Ho.docx
Discussion questions – Hurston Zora Neal Hurston attended Ho.docxDiscussion questions – Hurston Zora Neal Hurston attended Ho.docx
Discussion questions – Hurston Zora Neal Hurston attended Ho.docxduketjoy27252
 
Discussion Questions Compare and contrast through a critical an.docx
Discussion Questions Compare and contrast through a critical an.docxDiscussion Questions Compare and contrast through a critical an.docx
Discussion Questions Compare and contrast through a critical an.docxduketjoy27252
 
Discussion questions (self evaluation)Examine nursing roles th.docx
Discussion questions (self evaluation)Examine nursing roles th.docxDiscussion questions (self evaluation)Examine nursing roles th.docx
Discussion questions (self evaluation)Examine nursing roles th.docxduketjoy27252
 
Discussion QuestionReflecting on what you have learned abou.docx
Discussion QuestionReflecting on what you have learned abou.docxDiscussion QuestionReflecting on what you have learned abou.docx
Discussion QuestionReflecting on what you have learned abou.docxduketjoy27252
 
Discussion questionMotivation is the all-ensuing mechanism t.docx
Discussion questionMotivation is the all-ensuing mechanism t.docxDiscussion questionMotivation is the all-ensuing mechanism t.docx
Discussion questionMotivation is the all-ensuing mechanism t.docxduketjoy27252
 
Discussion QuestionHow much, if any, action on ergonomics in th.docx
Discussion QuestionHow much, if any, action on ergonomics in th.docxDiscussion QuestionHow much, if any, action on ergonomics in th.docx
Discussion QuestionHow much, if any, action on ergonomics in th.docxduketjoy27252
 
Discussion QuestionConsider a popular supplement you andor y.docx
Discussion QuestionConsider a popular supplement you andor y.docxDiscussion QuestionConsider a popular supplement you andor y.docx
Discussion QuestionConsider a popular supplement you andor y.docxduketjoy27252
 
Discussion QuestionDiscuss opportunities for innovation and en.docx
Discussion QuestionDiscuss opportunities for innovation and en.docxDiscussion QuestionDiscuss opportunities for innovation and en.docx
Discussion QuestionDiscuss opportunities for innovation and en.docxduketjoy27252
 
Discussion Question(s)Im interested in the role of women-- in t.docx
Discussion Question(s)Im interested in the role of women-- in t.docxDiscussion Question(s)Im interested in the role of women-- in t.docx
Discussion Question(s)Im interested in the role of women-- in t.docxduketjoy27252
 
Discussion Question(s)Why do you think that Native Allies and Af.docx
Discussion Question(s)Why do you think that Native Allies and Af.docxDiscussion Question(s)Why do you think that Native Allies and Af.docx
Discussion Question(s)Why do you think that Native Allies and Af.docxduketjoy27252
 
Discussion Question(This post must be at least 200 words.)What d.docx
Discussion Question(This post must be at least 200 words.)What d.docxDiscussion Question(This post must be at least 200 words.)What d.docx
Discussion Question(This post must be at least 200 words.)What d.docxduketjoy27252
 
Discussion Question(s)What were the colonial misgivings about m.docx
Discussion Question(s)What were the colonial misgivings about m.docxDiscussion Question(s)What were the colonial misgivings about m.docx
Discussion Question(s)What were the colonial misgivings about m.docxduketjoy27252
 
Discussion Question(s)The reading for this week was a grab bag o.docx
Discussion Question(s)The reading for this week was a grab bag o.docxDiscussion Question(s)The reading for this week was a grab bag o.docx
Discussion Question(s)The reading for this week was a grab bag o.docxduketjoy27252
 
Discussion Question(s)Could Latin American reactions to the Bour.docx
Discussion Question(s)Could Latin American reactions to the Bour.docxDiscussion Question(s)Could Latin American reactions to the Bour.docx
Discussion Question(s)Could Latin American reactions to the Bour.docxduketjoy27252
 
Discussion Question(s)Clearly there is potential for major probl.docx
Discussion Question(s)Clearly there is potential for major probl.docxDiscussion Question(s)Clearly there is potential for major probl.docx
Discussion Question(s)Clearly there is potential for major probl.docxduketjoy27252
 
Discussion Question Week #1·         Discover which agencies, in.docx
Discussion Question Week #1·         Discover which agencies, in.docxDiscussion Question Week #1·         Discover which agencies, in.docx
Discussion Question Week #1·         Discover which agencies, in.docxduketjoy27252
 

More from duketjoy27252 (20)

Discussion questions – Twain, The Man That Corrupted Hadleyburg.docx
Discussion questions – Twain, The Man That Corrupted Hadleyburg.docxDiscussion questions – Twain, The Man That Corrupted Hadleyburg.docx
Discussion questions – Twain, The Man That Corrupted Hadleyburg.docx
 
Discussion Questions The difficulty in predicting the future is .docx
Discussion Questions The difficulty in predicting the future is .docxDiscussion Questions The difficulty in predicting the future is .docx
Discussion Questions The difficulty in predicting the future is .docx
 
Discussion questions – Dunbar Paul Lawrence Dunbar was a pio.docx
Discussion questions – Dunbar Paul Lawrence Dunbar was a pio.docxDiscussion questions – Dunbar Paul Lawrence Dunbar was a pio.docx
Discussion questions – Dunbar Paul Lawrence Dunbar was a pio.docx
 
Discussion Questions Identify the top three threats to the home.docx
Discussion Questions Identify the top three threats to the home.docxDiscussion Questions Identify the top three threats to the home.docx
Discussion Questions Identify the top three threats to the home.docx
 
Discussion questions – Hurston Zora Neal Hurston attended Ho.docx
Discussion questions – Hurston Zora Neal Hurston attended Ho.docxDiscussion questions – Hurston Zora Neal Hurston attended Ho.docx
Discussion questions – Hurston Zora Neal Hurston attended Ho.docx
 
Discussion Questions Compare and contrast through a critical an.docx
Discussion Questions Compare and contrast through a critical an.docxDiscussion Questions Compare and contrast through a critical an.docx
Discussion Questions Compare and contrast through a critical an.docx
 
Discussion questions (self evaluation)Examine nursing roles th.docx
Discussion questions (self evaluation)Examine nursing roles th.docxDiscussion questions (self evaluation)Examine nursing roles th.docx
Discussion questions (self evaluation)Examine nursing roles th.docx
 
Discussion QuestionReflecting on what you have learned abou.docx
Discussion QuestionReflecting on what you have learned abou.docxDiscussion QuestionReflecting on what you have learned abou.docx
Discussion QuestionReflecting on what you have learned abou.docx
 
Discussion questionMotivation is the all-ensuing mechanism t.docx
Discussion questionMotivation is the all-ensuing mechanism t.docxDiscussion questionMotivation is the all-ensuing mechanism t.docx
Discussion questionMotivation is the all-ensuing mechanism t.docx
 
Discussion QuestionHow much, if any, action on ergonomics in th.docx
Discussion QuestionHow much, if any, action on ergonomics in th.docxDiscussion QuestionHow much, if any, action on ergonomics in th.docx
Discussion QuestionHow much, if any, action on ergonomics in th.docx
 
Discussion QuestionConsider a popular supplement you andor y.docx
Discussion QuestionConsider a popular supplement you andor y.docxDiscussion QuestionConsider a popular supplement you andor y.docx
Discussion QuestionConsider a popular supplement you andor y.docx
 
Discussion QuestionDiscuss opportunities for innovation and en.docx
Discussion QuestionDiscuss opportunities for innovation and en.docxDiscussion QuestionDiscuss opportunities for innovation and en.docx
Discussion QuestionDiscuss opportunities for innovation and en.docx
 
Discussion Question(s)Im interested in the role of women-- in t.docx
Discussion Question(s)Im interested in the role of women-- in t.docxDiscussion Question(s)Im interested in the role of women-- in t.docx
Discussion Question(s)Im interested in the role of women-- in t.docx
 
Discussion Question(s)Why do you think that Native Allies and Af.docx
Discussion Question(s)Why do you think that Native Allies and Af.docxDiscussion Question(s)Why do you think that Native Allies and Af.docx
Discussion Question(s)Why do you think that Native Allies and Af.docx
 
Discussion Question(This post must be at least 200 words.)What d.docx
Discussion Question(This post must be at least 200 words.)What d.docxDiscussion Question(This post must be at least 200 words.)What d.docx
Discussion Question(This post must be at least 200 words.)What d.docx
 
Discussion Question(s)What were the colonial misgivings about m.docx
Discussion Question(s)What were the colonial misgivings about m.docxDiscussion Question(s)What were the colonial misgivings about m.docx
Discussion Question(s)What were the colonial misgivings about m.docx
 
Discussion Question(s)The reading for this week was a grab bag o.docx
Discussion Question(s)The reading for this week was a grab bag o.docxDiscussion Question(s)The reading for this week was a grab bag o.docx
Discussion Question(s)The reading for this week was a grab bag o.docx
 
Discussion Question(s)Could Latin American reactions to the Bour.docx
Discussion Question(s)Could Latin American reactions to the Bour.docxDiscussion Question(s)Could Latin American reactions to the Bour.docx
Discussion Question(s)Could Latin American reactions to the Bour.docx
 
Discussion Question(s)Clearly there is potential for major probl.docx
Discussion Question(s)Clearly there is potential for major probl.docxDiscussion Question(s)Clearly there is potential for major probl.docx
Discussion Question(s)Clearly there is potential for major probl.docx
 
Discussion Question Week #1·         Discover which agencies, in.docx
Discussion Question Week #1·         Discover which agencies, in.docxDiscussion Question Week #1·         Discover which agencies, in.docx
Discussion Question Week #1·         Discover which agencies, in.docx
 

Recently uploaded

21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 

Recently uploaded (20)

21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 

Discussion Board 2William Denison27 NOV 2014A Java class t.docx

  • 1. Discussion Board 2 William Denison 27 NOV 2014 A Java class that allows writing to files is Class FileWriter. This class is a part of java.io package and extends (inherits from) OutputStreamWriter class. This class allows us to write character files conveniently. The reason I chose this class is because of the functionality provided by FileWriter class. It allows us to write to a new file, as well as append content to an existing file. Given a filename as a string parameter, it creates the file if it does not already exist. So, the user is not required to explicitly create a new file before writing to it using FileWriter class. FileWriter class provides several constructors, which are as follows: 1) FileWriter(File file) - takes File object as a parameter, which corresponds to the file, the data is to be written to. 2) FileWriter(File file, boolean append) - takes two parameters: one is the File object to which data is to be written to, and second is a boolean parameter which indicates whether data is to be appended to the file 3) FileWriter(String filename) - takes a string parameter for the filename 4) FileWriter(String filename, Boolean append) - takes two parameters, one for the filename (string) and a Boolean value indicating whether data should be appended to the file or not Pseudo code: 1. Create a string array and initialize elements of the array with given data String[] dataArray = new String[4]; dataArray[0] = "1001 Jennifer Ward SUPPLIES 2140.20 BOOKS 5200.10 PAPER 455.23 NORTH Phone";
  • 2. dataArray[1] = "1003 Athena Andrews SUPPLIES 5155.55 BOOKS 6300.50 PAPER 223.25 SOUTH Email"; dataArray[2] = "1005 Andy Smith SUPPLIES 6155.55 BOOKS 300.50 PAPER 55.55 SOUTH Email"; dataArray[3] = "1006 Robert Stearns SUPPLIES 7255.55 BOOKS 8300.50 PAPER 77.77 SOUTH Phone"; 2. Create a File object and pass the filename File file = new File(“data.txt”); 3. Check if file exits by that name, if it does not create a new file as follows: file.createNewFile(); 4. Create FileWriter object by passing the File object created above 5. In a for loop write each element of the array to the file: for(int i=0; i<dataArray.length; i++){ writer.write(dataArray[i]); //write the line to file writer.write("n"); //write a newline to the file } 6. Close the writer. 7. Catch any exceptions if thrown RealCode: import java.io.*; class FileWritingExample { public static void main(String args[]){ String[] dataArray = new String[4];
  • 3. dataArray[0] = "1001 Jennifer Ward SUPPLIES 2140.20 BOOKS 5200.10 PAPER 455.23 NORTH Phone"; dataArray[1] = "1003 Athena Andrews SUPPLIES 5155.55 BOOKS 6300.50 PAPER 223.25 SOUTH Email"; dataArray[2] = "1005 Andy Smith SUPPLIES 6155.55 BOOKS 300.50 PAPER 55.55 SOUTH Email"; dataArray[3] = "1006 Robert Stearns SUPPLIES 7255.55 BOOKS 8300.50 PAPER 77.77 SOUTH Phone"; try{ File file = new File("data.txt"); //check if file already exists if(!file.exists()){ file.createNewFile(); //create a new file if it does not exist } //create FileWriter object using File object created above FileWriter writer = new FileWriter(file); //write content to file for(int i=0; i<dataArray.length; i++){ writer.write(dataArray[i]); //write the line to file writer.write("n"); //write a newline to the file } writer.flush(); writer.close(); //close the writer stream }catch(IOException ioe){ //display the exception stacktrace
  • 4. System.out.println("Error while writing to the file"); ioe.printStackTrace(); } } } ProjectGUI/nbproject/private/private.properties compile.on.save=true user.properties.file=/home/an/.netbeans/7.1.1/build.properties ProjectGUI/src/projectgui/GUI.form ProjectGUI/src/projectgui/GUI.javaProjectGUI/src/projectgui/G UI.java/* * GUI.java * */ package projectgui; import java.awt.Color; import javax.swing.JOptionPane; /** * * @author Asma Niaz */ publicclass GUI extends javax.swing.JFrame{ /**
  • 5. * Creates new form SingleNeutronRun */ public GUI(){ initComponents(); } /** * This method is called from within the constructor to initial ize 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 privatevoid initComponents(){ operationsButtonGroup =new javax.swing.ButtonGroup(); buttonGroup1 =new javax.swing.ButtonGroup(); districtPanel =new javax.swing.JPanel(); northRadioButton =new javax.swing.JRadioButton(); eastRadioButton =new javax.swing.JRadioButton(); southRadioButton =new javax.swing.JRadioButton(); westRadioButton =new javax.swing.JRadioButton(); inputPanel =new javax.swing.JPanel(); jTextField2 =new javax.swing.JTextField(); jTextField3 =new javax.swing.JTextField(); jTextField1 =new javax.swing.JTextField(); jLabel1 =new javax.swing.JLabel(); jLabel2 =new javax.swing.JLabel(); jLabel3 =new javax.swing.JLabel(); inputPanel1 =new javax.swing.JPanel(); jTextField4 =new javax.swing.JTextField(); jTextField5 =new javax.swing.JTextField();
  • 6. jTextField6 =new javax.swing.JTextField(); jLabel5 =new javax.swing.JLabel(); jLabel6 =new javax.swing.JLabel(); jLabel4 =new javax.swing.JLabel(); runButton =new javax.swing.JButton(); exitButton =new javax.swing.JButton(); DataPanel=new javax.swing.JPanel(); jScrollPane1 =new javax.swing.JScrollPane(); dataTextArea =new javax.swing.JTextArea(); districtPanel1 =new javax.swing.JPanel(); phoneCheckBox =new javax.swing.JCheckBox(); emailCheckBox =new javax.swing.JCheckBox(); visitCheckBox =new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants. EXIT_ON_CLOSE); setTitle("Single Neuron Perceptron"); districtPanel.setBorder(javax.swing.BorderFactory.createT itledBorder("Select District")); buttonGroup1.add(northRadioButton); northRadioButton.setSelected(true); northRadioButton.setText("North"); buttonGroup1.add(eastRadioButton); eastRadioButton.setText("East"); buttonGroup1.add(southRadioButton); southRadioButton.setText("South"); buttonGroup1.add(westRadioButton); westRadioButton.setText("West"); javax.swing.GroupLayout districtPanelLayout =new javax. swing.GroupLayout(districtPanel);
  • 7. districtPanel.setLayout(districtPanelLayout); districtPanelLayout.setHorizontalGroup( districtPanelLayout.createParallelGroup(javax.swing.Gr oupLayout.Alignment.LEADING) .addGroup(districtPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(districtPanelLayout.createParallelGroup(javax.swing .GroupLayout.Alignment.LEADING) .addComponent(northRadioButton) .addComponent(eastRadioButton) .addComponent(southRadioButton) .addComponent(westRadioButton)) .addContainerGap(69,Short.MAX_VALUE)) ); districtPanelLayout.setVerticalGroup( districtPanelLayout.createParallelGroup(javax.swing.Gr oupLayout.Alignment.LEADING) .addGroup(districtPanelLayout.createSequentialGroup() .addComponent(northRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addComponent(southRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addComponent(eastRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addComponent(westRadioButton)) ); northRadioButton.getAccessibleContext().setAccessibleNa me("northRadioButton"); inputPanel.setBorder(javax.swing.BorderFactory.createTitl edBorder("Enter Values"));
  • 8. jTextField2.addFocusListener(new java.awt.event.FocusA dapter(){ publicvoid focusLost(java.awt.event.FocusEvent evt){ jTextField2FocusLost(evt); } }); jTextField3.addFocusListener(new java.awt.event.FocusA dapter(){ publicvoid focusLost(java.awt.event.FocusEvent evt){ jTextField3FocusLost(evt); } }); jTextField1.addFocusListener(new java.awt.event.FocusA dapter(){ publicvoid focusLost(java.awt.event.FocusEvent evt){ jTextField1FocusLost(evt); } }); jLabel1.setText("Sales Rep ID"); jLabel2.setText("Sales Rep First Name"); jLabel3.setText("Sales Rep Last Name"); inputPanel1.setBorder(javax.swing.BorderFactory.createTi tledBorder("Amounts Sold")); jTextField4.addFocusListener(new java.awt.event.FocusA dapter(){ publicvoid focusLost(java.awt.event.FocusEvent evt){ jTextField4FocusLost(evt); } });
  • 9. jTextField5.addFocusListener(new java.awt.event.FocusA dapter(){ publicvoid focusLost(java.awt.event.FocusEvent evt){ jTextField5FocusLost(evt); } }); jTextField6.addFocusListener(new java.awt.event.FocusA dapter(){ publicvoid focusLost(java.awt.event.FocusEvent evt){ jTextField6FocusLost(evt); } }); jLabel5.setText("Books"); jLabel6.setText("Paper"); jLabel4.setText("Office Supplies"); javax.swing.GroupLayout inputPanel1Layout =new javax.s wing.GroupLayout(inputPanel1); inputPanel1.setLayout(inputPanel1Layout); inputPanel1Layout.setHorizontalGroup( inputPanel1Layout.createParallelGroup(javax.swing.Gr oupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, in putPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,S hort.MAX_VALUE) .addGroup(inputPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addComponent(jLabel6) .addComponent(jLabel5))
  • 10. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addGroup(inputPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING,false) .addComponent(jTextField5, javax.swing.GroupLayout.Alignme nt.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE,133, Short.MAX_VALUE) .addComponent(jTextField4, javax.swing.GroupLayout.Alignme nt.TRAILING) .addComponent(jTextField6)) .addContainerGap()) ); inputPanel1Layout.setVerticalGroup( inputPanel1Layout.createParallelGroup(javax.swing.Gr oupLayout.Alignment.LEADING) .addGroup(inputPanel1Layout.createSequentialGroup() .addGroup(inputPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addGroup(inputPanel1Layout.createSequentialGroup() .addGap(4,4,4) .addComponent(jTextField4, javax.swing.GroupLayout.PREFER RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s wing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addGroup(inputPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addComponent(jTextField5, javax.swing.GroupLayout.PREFER RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s wing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addGroup(inputPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING)
  • 11. .addComponent(jTextField6, javax.swing.GroupLayout.PREFER RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s wing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6))) ); javax.swing.GroupLayout inputPanelLayout =new javax.s wing.GroupLayout(inputPanel); inputPanel.setLayout(inputPanelLayout); inputPanelLayout.setHorizontalGroup( inputPanelLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING) .addGroup(inputPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(inputPanelLayout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING) .addGroup(inputPanelLayout.createSequentialGroup() .addGroup(inputPanelLayout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel3) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.UNRELATED) .addGroup(inputPanelLayout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING) .addComponent(jTextField2) .addComponent(jTextField3, javax.swing.GroupLayout.Alignme nt.TRAILING) .addComponent(jTextField1))) .addGroup(inputPanelLayout.createSequentialGroup() .addGap(0,21,Short.MAX_VALUE) .addComponent(inputPanel1, javax.swing.GroupLayout.PREFE RRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax .swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap())
  • 12. ); inputPanelLayout.setVerticalGroup( inputPanelLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING) .addGroup(inputPanelLayout.createSequentialGroup() .addGroup(inputPanelLayout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE) .addComponent(jTextField1, javax.swing.GroupLayout.PREFER RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s wing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addGroup(inputPanelLayout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING) .addComponent(jTextField2, javax.swing.GroupLayout.PREFER RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s wing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacemen t.RELATED) .addGroup(inputPanelLayout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING) .addComponent(jTextField3, javax.swing.GroupLayout.PREFER RED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.s wing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addGap(18,18,18) .addComponent(inputPanel1, javax.swing.GroupLayout.PREFE RRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax .swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,S hort.MAX_VALUE)) ); runButton.setText("ENTER");
  • 13. runButton.addActionListener(new java.awt.event.ActionLi stener(){ publicvoid actionPerformed(java.awt.event.ActionEvent evt){ runButtonActionPerformed(evt); } }); exitButton.setText("QUIT"); exitButton.addActionListener(new java.awt.event.ActionLi stener(){ publicvoid actionPerformed(java.awt.event.ActionEvent evt){ exitButtonActionPerformed(evt); } }); DataPanel.setBorder(javax.swing.BorderFactory.createTitledBor der("Sales Representative Data")); dataTextArea.setColumns(20); dataTextArea.setRows(5); jScrollPane1.setViewportView(dataTextArea); javax.swing.GroupLayoutDataPanelLayout=new javax.swi ng.GroupLayout(DataPanel); DataPanel.setLayout(DataPanelLayout);