SlideShare a Scribd company logo
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 java
Kavitha713564
 
Session 23 - JDBC
Session 23 - JDBCSession 23 - JDBC
Session 23 - JDBC
PawanMM
 
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
anandinternational01
 
File Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handlingFile Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handling
abdulsamadbrohi461
 
Writing Swift code with great testability
Writing Swift code with great testabilityWriting Swift code with great testability
Writing Swift code with great testability
John Sundell
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
Sunil OS
 
File Input and Output in Java Programing language
File Input and Output in Java Programing languageFile Input and Output in Java Programing language
File Input and Output in Java Programing language
BurhanKhan774154
 
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
WindowsPhoneRocks
 
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
Nguyen Tuan
 
Chapter 6 Java IO File
Chapter 6 Java IO FileChapter 6 Java IO File
Chapter 6 Java IO File
Khirulnizam Abd Rahman
 
Lecture 11.pdf
Lecture 11.pdfLecture 11.pdf
Lecture 11.pdf
SakhilejasonMsibi
 
ExtraFileIO.pptx
ExtraFileIO.pptxExtraFileIO.pptx
ExtraFileIO.pptx
NguynThiThanhTho
 
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
asenterprisestyagi
 
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.docx
theodorelove43763
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
SudhanshiBakre1
 
file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdf
Jayaprasanna4
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
Azeemaj101
 

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
 
File Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handlingFile Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handling
 
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
 
File Input and Output in Java Programing language
File Input and Output in Java Programing languageFile Input and Output in Java Programing language
File Input and Output in Java Programing language
 
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
 

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.docx
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 
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
edgar6wallace88877
 

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

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 

Recently uploaded (20)

Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 

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