Hi people, Iv been working on code for a personal information storage system in Netbeans but i cant seem to get rid of this one error!! can anyone see anything wrong with it?
First off, I have greated the GUI so that all of the variables are the same as in the code.
I get this error:
Compiling 1 source file to C:\Doc\src\personalinformation\PersonalInfo.java:334: '}' expected
1 error
BUILD FAILED (total time: 0 seconds)
The error is at the very bottom, below the variable declaration. the illusive '}'
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
public class form extends JFrame {
public form() {
initComponents();
}
public static void main(
String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new PersonalInfo().setVisible(true);
}
});
}
private void okButtonMouseClicked(MouseEvent e) {
// Error checking - return 0, -1
// 0 if no problems, -1 if missing field or invalid data
// saving data to text file - return 0, -1
// 0 if saved properly, -1 if file corrupt/creation problem
String fileName = "data.txt";
String deliminator = ":";
String rec_marker = "#"; // place at start and end for calculating no. of records
String record = rec_marker + txt_name.getText() + deliminator +
txt_address.getText() + deliminator +
txt_city.getText() + deliminator +
txt_state.getText() + deliminator +
txt_zip.getText() + deliminator +
txt_phone.getText() + deliminator +
txt_birthday.getText() + rec_marker;
writeFile(fileName, record); //this over-writes existing data
}
private void clearButtonMouseClicked(MouseEvent e) {
txt_name.setText("");
txt_address.setText("");
txt_city.setText("");
txt_state.setText("");
txt_zip.setText("");
txt_phone.setText("");
txt_birthday.setText("");
}
private void writeFile(String strFileName, String strText){
boolean flStatus = false;
try {
//Checks if the file name is not null and not blank
if (strFileName != null && strFileName.length() > 0) {
java.io.BufferedWriter outStream = new java.io.BufferedWriter(
new java.io.FileWriter(strFileName));
// Writes text contents to the file
outStream.write(strText);
outStream.close();
flStatus = true;
}
}
catch (java.io.IOException e) {
System.out.println("Error: Invalid IO operation.");
}
}
public static void main(String args[]){
new form();
}
private void initComponents() {
// Component initialization
dialogPane = new JPanel();
contentPanel = new JPanel();
lbl_name = new JLabel();
txt_name = new JTextField();
lbl_address = new JLabel();
scrollPane1 = new JScrollPane();
txt_address = new JTextArea();
lbl_city = new JLabel();
txt_city = new JTextField();
lbl_state = new JLabel();
txt_state = new JTextField();
lbl_code = new JLabel();
txt_zip = new JTextField();
lbl_phone = new JLabel();
txt_phone = new JTextField();
lbl_birthday = new JLabel();
txt_birthday = new JTextField();
buttonBar = new JPanel();
okButton = new JButton();
clearButton = new JButton();
CellConstraints cc = new CellConstraints();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//dialog Pane
{
dialogPane.setBorder(Borders.DIALOG_BORDER);
dialogPane.setLayout(new BorderLayout());
//content Panel
{
contentPanel.setLayout(new FormLayout(
new ColumnSpec[] {
FormFactory.DEFAULT_COLSPEC,
FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
},
new RowSpec[] {
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC,
FormFactory.LINE_GAP_ROWSPEC,
FormFactory.DEFAULT_ROWSPEC
}));
// lbl_name
lbl_name.setText("Name:");
contentPanel.add(lbl_name, cc.xy(1, 1));
contentPanel.add(txt_name, cc.xy(3, 1));
// lbl_address
lbl_address.setText("Address:");
contentPanel.add(lbl_address, cc.xy(1, 3));
// scrollPane1
{
//txt_address
txt_address.setWrapStyleWord(true);
txt_address.setLineWrap(true);
scrollPane1.setViewportView(txt_address);
}
contentPanel.add(scrollPane1, cc.xy(3, 3));
// lbl_city
lbl_city.setText("City:");
contentPanel.add(lbl_city, cc.xy(1, 5));
contentPanel.add(txt_city, cc.xy(3, 5));
// lbl_state
lbl_state.setText("State:");
contentPanel.add(lbl_state, cc.xy(1, 7));
contentPanel.add(txt_state, cc.xy(3, 7));
// lbl_code
lbl_code.setText("Zip Code:");
contentPanel.add(lbl_code, cc.xy(1, 9));
contentPanel.add(txt_zip, cc.xy(3, 9));
// lbl_phone
lbl_phone.setText("Phone:");
contentPanel.add(lbl_phone, cc.xy(1, 11));
contentPanel.add(txt_phone, cc.xy(3, 11));
// lbl_birthday
lbl_birthday.setText("Birthday:");
contentPanel.add(lbl_birthday, cc.xy(1, 13));
contentPanel.add(txt_birthday, cc.xy(3, 13));
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
// buttonBar
{
buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
buttonBar.setLayout(new FormLayout(
new ColumnSpec[] {
FormFactory.GLUE_COLSPEC,
FormFactory.BUTTON_COLSPEC,
FormFactory.RELATED_GAP_COLSPEC,
FormFactory.BUTTON_COLSPEC
},
RowSpec.decodeSpecs("pref")));
// okButton
okButton.setText("OK");
okButton.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
okButtonMouseClicked(e);
}
});
buttonBar.add(okButton, cc.xy(2, 1));
//clearButton
clearButton.setText("Clear");
clearButton.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
clearButtonMouseClicked(e);
}
});
buttonBar.add(clearButton, cc.xy(4, 1));
}
dialogPane.add(buttonBar, BorderLayout.SOUTH);
}
contentPane.add(dialogPane, BorderLayout.CENTER);
pack();
setLocationRelativeTo(getOwner());
setVisible(true);
// End of component initialization
}
public class PersonalInfo extends javax.swing.JFrame {
/** Creates new form PersonalInfo */
public PersonalInfo() {
initComponents();
}
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
lbl_name = new javax.swing.JLabel();
lbl_address = new javax.swing.JLabel();
lbl_city = new javax.swing.JLabel();
lbl_state = new javax.swing.JLabel();
lbl_code = new javax.swing.JLabel();
lbl_phone = new javax.swing.JLabel();
lbl_birthday = new javax.swing.JLabel();
txt_birthday = new javax.swing.JTextField();
txt_phone = new javax.swing.JTextField();
txt_zip = new javax.swing.JTextField();
txt_state = new javax.swing.JTextField();
txt_city = new javax.swing.JTextField();
txt_address = new javax.swing.JTextField();
txt_name = new javax.swing.JTextField();
okButton = new javax.swing.JButton();
clearButton = new javax.swing.JButton();
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
lbl_name.setText("Name");
getContentPane().add(lbl_name, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 50, -1, -1));
lbl_address.setText("Address");
getContentPane().add(lbl_address, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 80, -1, -1));
lbl_city.setText("City");
getContentPane().add(lbl_city, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 140, -1, -1));
lbl_state.setText("State");
getContentPane().add(lbl_state, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 170, -1, -1));
lbl_code.setText("Postcode");
getContentPane().add(lbl_code, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 110, -1, -1));
lbl_phone.setText("Phone");
getContentPane().add(lbl_phone, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 230, -1, -1));
lbl_birthday.setText("Birthday");
getContentPane().add(lbl_birthday, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 200, -1, -1));
getContentPane().add(txt_birthday, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 200, 60, -1));
getContentPane().add(txt_phone, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 230, 60, -1));
getContentPane().add(txt_zip, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 110, 60, -1));
getContentPane().add(txt_state, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 170, 60, -1));
getContentPane().add(txt_city, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 140, 60, -1));
getContentPane().add(txt_address, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 80, 60, -1));
getContentPane().add(txt_name, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 50, 60, -1));
okButton.setText("Ok");
getContentPane().add(okButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 200, -1, -1));
clearButton.setText("Clear");
getContentPane().add(clearButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 230, -1, -1));
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify
private javax.swing.JButton clearButton;
private javax.swing.JLabel lbl_address;
private javax.swing.JLabel lbl_birthday;
private javax.swing.JLabel lbl_city;
private javax.swing.JLabel lbl_code;
private javax.swing.JLabel lbl_name;
private javax.swing.JLabel lbl_phone;
private javax.swing.JLabel lbl_state;
private javax.swing.JButton okButton;
private javax.swing.JTextField txt_address;
private javax.swing.JTextField txt_birthday;
private javax.swing.JTextField txt_city;
private javax.swing.JTextField txt_name;
private javax.swing.JTextField txt_phone;
private javax.swing.JTextField txt_state;
private javax.swing.JTextField txt_zip;
// End of variables declaration
}
[ August 21, 2007: Message edited by: Howard owen ]