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 edgar6wallace88877

Write a page to a page and half for each topic and read each topic a.docx
Write a page to a page and half for each topic and read each topic a.docxWrite a page to a page and half for each topic and read each topic a.docx
Write a page to a page and half for each topic and read each topic a.docxedgar6wallace88877
 
Write a page discussing why you believe PMI is focusing BA as the fi.docx
Write a page discussing why you believe PMI is focusing BA as the fi.docxWrite a page discussing why you believe PMI is focusing BA as the fi.docx
Write a page discussing why you believe PMI is focusing BA as the fi.docxedgar6wallace88877
 
Write a page of personal reflection of your present leadership compe.docx
Write a page of personal reflection of your present leadership compe.docxWrite a page of personal reflection of your present leadership compe.docx
Write a page of personal reflection of your present leadership compe.docxedgar6wallace88877
 
Write a page of compare and contrast for the Big Five Personalit.docx
Write a page of compare and contrast for the Big Five Personalit.docxWrite a page of compare and contrast for the Big Five Personalit.docx
Write a page of compare and contrast for the Big Five Personalit.docxedgar6wallace88877
 
Write a page of research and discuss an innovation that includes mul.docx
Write a page of research and discuss an innovation that includes mul.docxWrite a page of research and discuss an innovation that includes mul.docx
Write a page of research and discuss an innovation that includes mul.docxedgar6wallace88877
 
Write a page answering the questions below.Sometimes projects .docx
Write a page answering the questions below.Sometimes projects .docxWrite a page answering the questions below.Sometimes projects .docx
Write a page answering the questions below.Sometimes projects .docxedgar6wallace88877
 
Write a one-paragraph summary of one of the reading assignments from.docx
Write a one-paragraph summary of one of the reading assignments from.docxWrite a one-paragraph summary of one of the reading assignments from.docx
Write a one-paragraph summary of one of the reading assignments from.docxedgar6wallace88877
 
Write a one-paragraph summary of this article.Riordan, B. C..docx
Write a one-paragraph summary of this article.Riordan, B. C..docxWrite a one-paragraph summary of this article.Riordan, B. C..docx
Write a one-paragraph summary of this article.Riordan, B. C..docxedgar6wallace88877
 
Write a one-paragraph response to the following topic. Use the MLA f.docx
Write a one-paragraph response to the following topic. Use the MLA f.docxWrite a one-paragraph response to the following topic. Use the MLA f.docx
Write a one-paragraph response to the following topic. Use the MLA f.docxedgar6wallace88877
 
Write a one-page rhetorical analysis in which you analyze the argume.docx
Write a one-page rhetorical analysis in which you analyze the argume.docxWrite a one-page rhetorical analysis in which you analyze the argume.docx
Write a one-page rhetorical analysis in which you analyze the argume.docxedgar6wallace88877
 
Write a one pageliterature review of your figure( FIGURE A.docx
Write a one pageliterature review of your figure( FIGURE A.docxWrite a one pageliterature review of your figure( FIGURE A.docx
Write a one pageliterature review of your figure( FIGURE A.docxedgar6wallace88877
 
Write a one page-paper documenting the problemneed you wish to .docx
Write a one page-paper documenting the problemneed you wish to .docxWrite a one page-paper documenting the problemneed you wish to .docx
Write a one page-paper documenting the problemneed you wish to .docxedgar6wallace88877
 
Write a one page report on Chapter 1 and 2 with the same style of mo.docx
Write a one page report on Chapter 1 and 2 with the same style of mo.docxWrite a one page report on Chapter 1 and 2 with the same style of mo.docx
Write a one page report on Chapter 1 and 2 with the same style of mo.docxedgar6wallace88877
 
Write a one page reflection about the following1) Identify .docx
Write a one page reflection about the following1) Identify .docxWrite a one page reflection about the following1) Identify .docx
Write a one page reflection about the following1) Identify .docxedgar6wallace88877
 
Write a one page paper on the question belowSome of the current.docx
Write a one page paper on the question belowSome of the current.docxWrite a one page paper on the question belowSome of the current.docx
Write a one page paper on the question belowSome of the current.docxedgar6wallace88877
 
Write a one page paper (double spaced) describing and discussing the.docx
Write a one page paper (double spaced) describing and discussing the.docxWrite a one page paper (double spaced) describing and discussing the.docx
Write a one page paper (double spaced) describing and discussing the.docxedgar6wallace88877
 
write a one page about this topic and provide a reference.Will.docx
write a one page about this topic and provide a reference.Will.docxwrite a one page about this topic and provide a reference.Will.docx
write a one page about this topic and provide a reference.Will.docxedgar6wallace88877
 
Write a one or more paragraph on the following question below.docx
Write a one or more paragraph on the following question below.docxWrite a one or more paragraph on the following question below.docx
Write a one or more paragraph on the following question below.docxedgar6wallace88877
 
Write a one or more page paper on the following belowWhy are .docx
Write a one or more page paper on the following belowWhy are .docxWrite a one or more page paper on the following belowWhy are .docx
Write a one or more page paper on the following belowWhy are .docxedgar6wallace88877
 
Write a one page dialogue in which two characters are arguing but .docx
Write a one page dialogue in which two characters are arguing but .docxWrite a one page dialogue in which two characters are arguing but .docx
Write a one page dialogue in which two characters are arguing but .docxedgar6wallace88877
 

More from edgar6wallace88877 (20)

Write a page to a page and half for each topic and read each topic a.docx
Write a page to a page and half for each topic and read each topic a.docxWrite a page to a page and half for each topic and read each topic a.docx
Write a page to a page and half for each topic and read each topic a.docx
 
Write a page discussing why you believe PMI is focusing BA as the fi.docx
Write a page discussing why you believe PMI is focusing BA as the fi.docxWrite a page discussing why you believe PMI is focusing BA as the fi.docx
Write a page discussing why you believe PMI is focusing BA as the fi.docx
 
Write a page of personal reflection of your present leadership compe.docx
Write a page of personal reflection of your present leadership compe.docxWrite a page of personal reflection of your present leadership compe.docx
Write a page of personal reflection of your present leadership compe.docx
 
Write a page of compare and contrast for the Big Five Personalit.docx
Write a page of compare and contrast for the Big Five Personalit.docxWrite a page of compare and contrast for the Big Five Personalit.docx
Write a page of compare and contrast for the Big Five Personalit.docx
 
Write a page of research and discuss an innovation that includes mul.docx
Write a page of research and discuss an innovation that includes mul.docxWrite a page of research and discuss an innovation that includes mul.docx
Write a page of research and discuss an innovation that includes mul.docx
 
Write a page answering the questions below.Sometimes projects .docx
Write a page answering the questions below.Sometimes projects .docxWrite a page answering the questions below.Sometimes projects .docx
Write a page answering the questions below.Sometimes projects .docx
 
Write a one-paragraph summary of one of the reading assignments from.docx
Write a one-paragraph summary of one of the reading assignments from.docxWrite a one-paragraph summary of one of the reading assignments from.docx
Write a one-paragraph summary of one of the reading assignments from.docx
 
Write a one-paragraph summary of this article.Riordan, B. C..docx
Write a one-paragraph summary of this article.Riordan, B. C..docxWrite a one-paragraph summary of this article.Riordan, B. C..docx
Write a one-paragraph summary of this article.Riordan, B. C..docx
 
Write a one-paragraph response to the following topic. Use the MLA f.docx
Write a one-paragraph response to the following topic. Use the MLA f.docxWrite a one-paragraph response to the following topic. Use the MLA f.docx
Write a one-paragraph response to the following topic. Use the MLA f.docx
 
Write a one-page rhetorical analysis in which you analyze the argume.docx
Write a one-page rhetorical analysis in which you analyze the argume.docxWrite a one-page rhetorical analysis in which you analyze the argume.docx
Write a one-page rhetorical analysis in which you analyze the argume.docx
 
Write a one pageliterature review of your figure( FIGURE A.docx
Write a one pageliterature review of your figure( FIGURE A.docxWrite a one pageliterature review of your figure( FIGURE A.docx
Write a one pageliterature review of your figure( FIGURE A.docx
 
Write a one page-paper documenting the problemneed you wish to .docx
Write a one page-paper documenting the problemneed you wish to .docxWrite a one page-paper documenting the problemneed you wish to .docx
Write a one page-paper documenting the problemneed you wish to .docx
 
Write a one page report on Chapter 1 and 2 with the same style of mo.docx
Write a one page report on Chapter 1 and 2 with the same style of mo.docxWrite a one page report on Chapter 1 and 2 with the same style of mo.docx
Write a one page report on Chapter 1 and 2 with the same style of mo.docx
 
Write a one page reflection about the following1) Identify .docx
Write a one page reflection about the following1) Identify .docxWrite a one page reflection about the following1) Identify .docx
Write a one page reflection about the following1) Identify .docx
 
Write a one page paper on the question belowSome of the current.docx
Write a one page paper on the question belowSome of the current.docxWrite a one page paper on the question belowSome of the current.docx
Write a one page paper on the question belowSome of the current.docx
 
Write a one page paper (double spaced) describing and discussing the.docx
Write a one page paper (double spaced) describing and discussing the.docxWrite a one page paper (double spaced) describing and discussing the.docx
Write a one page paper (double spaced) describing and discussing the.docx
 
write a one page about this topic and provide a reference.Will.docx
write a one page about this topic and provide a reference.Will.docxwrite a one page about this topic and provide a reference.Will.docx
write a one page about this topic and provide a reference.Will.docx
 
Write a one or more paragraph on the following question below.docx
Write a one or more paragraph on the following question below.docxWrite a one or more paragraph on the following question below.docx
Write a one or more paragraph on the following question below.docx
 
Write a one or more page paper on the following belowWhy are .docx
Write a one or more page paper on the following belowWhy are .docxWrite a one or more page paper on the following belowWhy are .docx
Write a one or more page paper on the following belowWhy are .docx
 
Write a one page dialogue in which two characters are arguing but .docx
Write a one page dialogue in which two characters are arguing but .docxWrite a one page dialogue in which two characters are arguing but .docx
Write a one page dialogue in which two characters are arguing but .docx
 

Recently uploaded

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 

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);