import java.awt.*;
import javax.swing.*;
import java.text.NumberFormat;
import javax.swing.JFormattedTextField;
import java.awt.event.*;
import java.text.*;

public class Database extends JFrame
{

	private		JSplitPane	splitPaneV;
	private		JSplitPane	splitPaneH;
	private		JPanel		panel1;
	private		JPanel		panel2;
	private		JPanel		panel3;
	
	private int X1, X2, X3, X4, X5, Y;
	
	private JLabel gradeL, equivL;
	private JFormattedTextField gradeTF, equivTF;
	private JButton calculateBC, clearBC;
	
	private CalculateButtonHandlerC cbHandlerC;
	private ClearButtonHandlerC clHandlerC;
	
	private JLabel prelimL, midtermL, endtermL, finalL;
	private JFormattedTextField prelimTF, midtermTF, endtermTF, finalTF;
	private JButton calculateBS, clearBS;
	
	private CalculateButtonHandlerS cbHandlerS;
	private ClearButtonHandlerS clHandlerS;
	
	private JLabel FirstNameL, LastNameL, IDNoL, GradeL, EquivL, CourseL, SubjectL, TeacherL, NoOfStudntsL;
	private JTextField TeacherTF, CourseTF, SubjectTF, NoOfStudntsTF;
	
	private JTextField[][] IDNoTF, LastNameTF, FirstNameTF, GradeTF, EquivTF;
	
	private int index1, index2;
	
	private JScrollPane scroll;

	public void createPanel2()
	{
		panel2 = new JPanel();
		panel2.setLayout(new GridLayout(5,2));

		gradeL= new JLabel("Final Grade: ", SwingConstants.RIGHT);
		equivL = new JLabel("Equivalent: ", SwingConstants.RIGHT);
		
		NumberFormat real = NumberFormat.getNumberInstance();
		real.setGroupingUsed(false);
		real.setMaximumFractionDigits(2);
		real.setMinimumFractionDigits(2);
		
		gradeTF = new JFormattedTextField(real);
		equivTF = new JFormattedTextField(real);
	
		calculateBC = new JButton("Calculate");
		cbHandlerC = new CalculateButtonHandlerC();
		calculateBC.addActionListener(cbHandlerC);
		
		clearBC = new JButton("Clear");
		clHandlerC = new ClearButtonHandlerC();
		clearBC.addActionListener(clHandlerC);
		
		equivTF.setEditable(false);
		
		panel2.add(gradeL);
		panel2.add(gradeTF);
		panel2.add(equivL);
		panel2.add(equivTF);
		panel2.add(calculateBC);
		panel2.add(clearBC);

	}

	public void createPanel1()
	{
		panel1 = new JPanel();
		panel1.setLayout(new GridLayout(5,2));

		prelimL = new JLabel("Prelim Grade: ", SwingConstants.RIGHT);
		midtermL = new JLabel("Midterm Grade: ", SwingConstants.RIGHT);
		endtermL = new JLabel("Endterm Grade: ", SwingConstants.RIGHT);
		finalL = new JLabel("Final Grade: ", SwingConstants.RIGHT);
		
		NumberFormat real = NumberFormat.getNumberInstance();
		real.setGroupingUsed(false);
		real.setMaximumFractionDigits(2);
		real.setMinimumFractionDigits(2);
		
		prelimTF = new JFormattedTextField(real);
		midtermTF = new JFormattedTextField(real);
		endtermTF = new JFormattedTextField(real);
		finalTF = new JFormattedTextField(real);
				
		calculateBS = new JButton("Calculate");
		cbHandlerS = new CalculateButtonHandlerS();
		calculateBS.addActionListener(cbHandlerS);
		
		clearBS = new JButton("Clear");
		clHandlerS = new ClearButtonHandlerS();
		clearBS.addActionListener(clHandlerS);
		
		finalTF.setEditable(false);
		
		panel1.add(prelimL);
		panel1.add(prelimTF);
		panel1.add(midtermL);
		panel1.add(midtermTF);
		panel1.add(endtermL);
		panel1.add(endtermTF);
		panel1.add(finalL);
		panel1.add(finalTF);
		panel1.add(calculateBS);
		panel1.add(clearBS);
		
	}

	public void createPanel3()
	{
		IDNoTF = new JTextField[1][14];
		LastNameTF = new JTextField[1][14];
		FirstNameTF = new JTextField[1][14];
		GradeTF = new JTextField[1][14];
		EquivTF = new JTextField[1][14];
		
		panel3 = new JPanel();
		panel3.setLayout(null);
        panel3.setSize(750,800);

		
		TeacherL = new JLabel("TEACHER: ", SwingConstants.RIGHT);
		CourseL = new JLabel("COURSE: ", SwingConstants.RIGHT);
		SubjectL = new JLabel("SUBJECT: ", SwingConstants.RIGHT);
		NoOfStudntsL = new JLabel("NUMBER OF STUDENTS: ", SwingConstants.LEFT);
		
		IDNoL = new JLabel("ID #", SwingConstants.RIGHT);
		FirstNameL = new JLabel("FIRST NAME", SwingConstants.RIGHT);
		LastNameL = new JLabel("LAST NAME", SwingConstants.RIGHT);
		GradeL = new JLabel("GRADE", SwingConstants.RIGHT);
		EquivL = new JLabel("EQUIVALENT", SwingConstants.RIGHT);
		
		TeacherTF = new JTextField();
		CourseTF = new JTextField();
		SubjectTF = new JTextField();
		NoOfStudntsTF = new JTextField();
		
		TeacherL.setBounds(25, 25, 70, 25);
		TeacherTF.setBounds(100, 25, 250, 25);
		CourseL.setBounds(25, 60, 70, 25);
		CourseTF.setBounds(100, 60, 70, 25);
		NoOfStudntsL.setBounds(480, 25, 140, 25);
		NoOfStudntsTF.setBounds(630, 25, 30, 25);
		SubjectL.setBounds(550, 60, 70, 25);
		SubjectTF.setBounds(630, 60, 70, 25);
		
		IDNoL.setBounds(80, 130, 50, 25);
		LastNameL.setBounds(200, 130, 75, 25);
		FirstNameL.setBounds(330, 130, 75, 25);
		GradeL.setBounds(441, 130, 65, 25);
		EquivL.setBounds(542, 130, 75, 25);
		
		for(index1=0, index2=0, X1=83, X2=176, X3=310, X4=460, X5=545, Y=160 ; index2<14; index2++)
		{
			IDNoTF[index1][index2] = new JTextField();
			LastNameTF[index1][index2] = new JTextField();
			FirstNameTF[index1][index2] = new JTextField();
			GradeTF[index1][index2] = new JTextField();
			EquivTF[index1][index2] = new JTextField();
			
			IDNoTF[index1][index2].setBounds(X1, Y, 75, 25);
			LastNameTF[index1][index2].setBounds(X2, Y, 121, 25);
			FirstNameTF[index1][index2].setBounds(X3, Y, 128, 25);
			GradeTF[index1][index2].setBounds(X4, Y, 55, 25);
			EquivTF[index1][index2].setBounds(X5, Y, 70, 25);
			
			Y+=34;
			
			panel3.add(LastNameTF[index1][index2]);
			panel3.add(FirstNameTF[index1][index2]);
			panel3.add(GradeTF[index1][index2]);
			panel3.add(EquivTF[index1][index2]);
			panel3.add(IDNoTF[index1][index2]);
		}
		

		panel3.add(TeacherL);
		panel3.add(TeacherTF);
		panel3.add(CourseL);
		panel3.add(CourseTF);
		panel3.add(NoOfStudntsL);
		panel3.add(NoOfStudntsTF);
		panel3.add(SubjectL);
		panel3.add(SubjectTF);
		
		panel3.add(IDNoL);
		panel3.add(FirstNameL);
		panel3.add(LastNameL);
		panel3.add(GradeL);
		panel3.add(EquivL);
		
		
		
	}
	
	public Database()
	{
		setTitle( "Database" );
		
		JFrame frame = new JFrame("Database");

		JPanel topPanel = new JPanel();
		topPanel.setLayout( new BorderLayout() );
		getContentPane().add( topPanel );

		// Create the panels
		createPanel1();
		createPanel2();
		createPanel3();

		// Create a splitter pane
		splitPaneV = new JSplitPane( JSplitPane.VERTICAL_SPLIT );
		topPanel.add( splitPaneV, BorderLayout.CENTER );

		splitPaneH = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT );
		splitPaneH.setLeftComponent( panel1 );
		splitPaneH.setRightComponent( panel2 );

		splitPaneV.setLeftComponent( splitPaneH );
		splitPaneV.setRightComponent( panel3 );
		
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible( true );
		setSize(750,800);


	}
	
	public static void main( String args[] )
	{
		// Create an instance of the test application
		Database frame	= new Database();

	}
	
	private class CalculateButtonHandlerC implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			double grade, finalg;
			
			grade = Double.parseDouble(gradeTF.getText());
			
			if(grade>=99.50 && grade<101)
				finalg = 1.00;
			else if(grade<99.50 && grade>=98.50)
				finalg = 1.10;
			else if(grade<98.50 && grade>=97.50)
				finalg = 1.20;
			else if(grade<97.50 && grade>=96.50)
				finalg = 1.30;
			else if(grade<96.50 && grade>=95.50)
				finalg = 1.40;
			else if(grade<95.50 && grade>=94.50)
				finalg = 1.50;
			else if(grade<94.50 && grade>=93.50)
				finalg = 1.60;
			else if(grade<93.50 && grade>=92.50)
				finalg = 1.70;
			else if(grade<92.50 && grade>=91.50)
				finalg = 1.80;
			else if(grade<91.50 && grade>=90.50)
				finalg = 1.90;
			else if(grade<90.50 && grade>=89.50)
				finalg = 2.00;
			else if(grade<89.50 && grade>=88.50)
				finalg = 2.10;
			else if(grade<88.50 && grade>=87.50)
				finalg = 2.20;
			else if(grade<87.50 && grade>=86.50)
				finalg = 2.30;
			else if(grade<86.50 && grade>=85.50)
				finalg = 2.40;
			else if(grade<85.50 && grade>=84.50)
				finalg = 2.50;
			else if(grade<84.50 && grade>=83.50)
				finalg = 2.60;
			else if(grade<83.50 && grade>=82.50)
				finalg = 2.70;
			else if(grade<82.50 && grade>=81.50)
				finalg = 2.80;
			else if(grade<81.50 && grade>=80.50)
				finalg = 2.90;
			else if(grade<80.50 && grade>=79.50)
				finalg = 3.00;
			else if(grade<79.50 && grade>=78.50)
				finalg = 3.10;
			else if(grade<78.50 && grade>=77.50)
				finalg = 3.20;
			else if(grade<77.50 && grade>=76.50)
				finalg = 3.30;
			else if(grade<76.50 && grade>=75.50)
				finalg = 3.40;
			else if(grade<75.50 && grade>=74.50)
				finalg = 3.50;
			else
				finalg = 5.0;
				
			equivTF.setText("" + finalg);
			equivTF.setEditable(false);
		}
	}
	
	private class ClearButtonHandlerC implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			gradeTF.setText("");
			equivTF.setText("");
		}
	}
	
	private class CalculateButtonHandlerS implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			double prelim, midterm, endterm, finalg;
			
			DecimalFormat df = new DecimalFormat("#.##");
			prelim = Double.parseDouble(prelimTF.getText());
			midterm = Double.parseDouble(midtermTF.getText());
			endterm = Double.parseDouble(endtermTF.getText());
			
			finalg = (prelim * .30) + (midterm * .30) + (endterm * .40);
			
			finalTF.setText("" + df.format(finalg));
			finalTF.setEditable(false);
		}
	}
	
	private class ClearButtonHandlerS implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			prelimTF.setText("");
			midtermTF.setText("");
			endtermTF.setText("");
			finalTF.setText("");
		}
	}
}

I don't know how to put a JScrollPane in the third panel

I tried
JScrollPane scroll = new JScrollPane();
getContentPane.add(scroll) but it doesn't work

I haven't seen an example of how JScrollPane works when it has no contents - maybe that's your problem? Try it with something in it, even a humble JLabel with a short text should be enough.

JScrollPane scroll = new JScrollPane(new JLabel("Hello"));
add(scroll);

ps the getContentPane() has been redundant since about Java 1.5

Edited 6 Years Ago by JamesCherrill: n/a

the problem is, there is no scroll bar in panel3. The third panel contains JTextFields and JLabels, and I want to put more JTextFields but it won't fit anymore, so I want to make a JScrollPane so that I can still add more JTextField and all I have to do is scroll it down.

have you done a Search here for JScrollPane to see some examples of how it is used?
Or read the API doc? Especially about the constructors.
Or looked at James's post for an example.

Edited 6 Years Ago by NormR1: n/a

Yes I did search for examples. My program builds but there is no scroll bar at the side even though only half of the JTextFields cannot be seen anymore.

I used this code but it won't work.

JScrollPane scroll = new JScrollPane(panel3);
frame.add(scroll);

it won't work

Please explain. It looks like what I use and have work.
There must be something else in your code that is the problem.

Try using setPreferreedSize vs setSize for panel3

Oh God, Why?, Why? Why?

panel3.setLayout(null);

IMHO this is the worst thing that you can do. Especially when you are only using standard labels and text fields. In some rare corner cases it may be advantageous, but for this? No!

If I dont use

panel3.setLayout(null)

the setBounds doesn't work.

I'm giving up already. I've read an something that there is an incompatibility with JSplitPane and JScrollPane.

You must not have tried all the suggestions. Here is what I have with your code.
Have you set the preferred size for the the panel in the scrollpane?

Edited 6 Years Ago by NormR1: n/a

Attachments ScrollPane.jpg 142.6 KB

how did you make this? I already tried setting the preferred size but it still won't work on me. Can you please give me the code?

Did you follow all the suggestions made?
Could you post your code so we can see what the problem is.

import java.awt.*;
import javax.swing.*;
import java.text.NumberFormat;
import javax.swing.JFormattedTextField;
import java.awt.event.*;
import java.text.*;
import java.io.*;
import java.util.Scanner;

public class Database extends JFrame
{

	private		JSplitPane	splitPaneV;
	private		JSplitPane	splitPaneH;
	private		JPanel		panel1;
	private		JPanel		panel2;
	private		JPanel		panel3;
	private		JPanel		panel4;
	
	private		JTextArea   textArea;
	
	private int X1, X2, X3, X4, X5, Y;
	
	private JLabel gradeL, equivL;
	private JFormattedTextField gradeTF, equivTF;
	private JButton calculateBC, clearBC;
	
	private CalculateButtonHandlerC cbHandlerC;
	private ClearButtonHandlerC clHandlerC;
	
	private JLabel prelimL, midtermL, endtermL, finalL;
	private JFormattedTextField prelimTF, midtermTF, endtermTF, finalTF;
	private JButton calculateBS, clearBS;
	
	private CalculateButtonHandlerS cbHandlerS;
	private ClearButtonHandlerS clHandlerS;
	
	private JLabel FirstNameL, LastNameL, IDNoL, GradeL, EquivL, CourseL, SubjectL, TeacherL, NoOfStudntsL;
	private JTextField TeacherTF, CourseTF, SubjectTF, NoOfStudntsTF;
	
	private JTextField[][] IDNoTF, LastNameTF, FirstNameTF, GradeTF, EquivTF;
	
	private int index1, index2;
	
	private JScrollPane scroll;
	
	private JButton OKb, Clearb;
	
	private OkButtonHandler obHandler;
	private ClearbButtonHandler clHandler; 

	public void createPanel2()
	{
		panel2 = new JPanel();
		panel2.setLayout(new GridLayout(5,2));

		gradeL= new JLabel("Final Grade: ", SwingConstants.RIGHT);
		equivL = new JLabel("Equivalent: ", SwingConstants.RIGHT);
		
		NumberFormat real = NumberFormat.getNumberInstance();
		real.setGroupingUsed(false);
		real.setMaximumFractionDigits(2);
		real.setMinimumFractionDigits(2);
		
		gradeTF = new JFormattedTextField(real);
		equivTF = new JFormattedTextField(real);
	
		calculateBC = new JButton("Calculate");
		cbHandlerC = new CalculateButtonHandlerC();
		calculateBC.addActionListener(cbHandlerC);
		
		clearBC = new JButton("Clear");
		clHandlerC = new ClearButtonHandlerC();
		clearBC.addActionListener(clHandlerC);
		
		equivTF.setEditable(false);
		
		panel2.add(gradeL);
		panel2.add(gradeTF);
		panel2.add(equivL);
		panel2.add(equivTF);
		panel2.add(calculateBC);
		panel2.add(clearBC);

	}

	public void createPanel1()
	{
		panel1 = new JPanel();
		panel1.setLayout(new GridLayout(5,2));

		prelimL = new JLabel("Prelim Grade: ", SwingConstants.RIGHT);
		midtermL = new JLabel("Midterm Grade: ", SwingConstants.RIGHT);
		endtermL = new JLabel("Endterm Grade: ", SwingConstants.RIGHT);
		finalL = new JLabel("Final Grade: ", SwingConstants.RIGHT);
		
		NumberFormat real = NumberFormat.getNumberInstance();
		real.setGroupingUsed(false);
		real.setMaximumFractionDigits(2);
		real.setMinimumFractionDigits(2);
		
		prelimTF = new JFormattedTextField(real);
		midtermTF = new JFormattedTextField(real);
		endtermTF = new JFormattedTextField(real);
		finalTF = new JFormattedTextField(real);
				
		calculateBS = new JButton("Calculate");
		cbHandlerS = new CalculateButtonHandlerS();
		calculateBS.addActionListener(cbHandlerS);
		
		clearBS = new JButton("Clear");
		clHandlerS = new ClearButtonHandlerS();
		clearBS.addActionListener(clHandlerS);
		
		finalTF.setEditable(false);
		
		panel1.add(prelimL);
		panel1.add(prelimTF);
		panel1.add(midtermL);
		panel1.add(midtermTF);
		panel1.add(endtermL);
		panel1.add(endtermTF);
		panel1.add(finalL);
		panel1.add(finalTF);
		panel1.add(calculateBS);
		panel1.add(clearBS);
		
	}

	public void createPanel3()
	{
		
		IDNoTF = new JTextField[1][14];
		LastNameTF = new JTextField[1][14];
		FirstNameTF = new JTextField[1][14];
		GradeTF = new JTextField[1][14];
		EquivTF = new JTextField[1][14];
		
		OKb = new JButton("OK");
		obHandler = new OkButtonHandler();
		OKb.addActionListener(obHandler);
		
		Clearb = new JButton("CLEAR");
		clHandler = new ClearbButtonHandler();
		Clearb.addActionListener(clHandler);
		
		panel3 = new JPanel();
        
        panel3.setLayout(null);
        panel3.setPreferredSize( new Dimension( 400, 100 ) );
        panel3.setMinimumSize( new Dimension( 100, 50 ) );

		
		TeacherL = new JLabel("TEACHER: ", SwingConstants.RIGHT);
		CourseL = new JLabel("COURSE: ", SwingConstants.RIGHT);
		SubjectL = new JLabel("SUBJECT: ", SwingConstants.RIGHT);
		NoOfStudntsL = new JLabel("NUMBER OF STUDENTS: ", SwingConstants.LEFT);
		
		IDNoL = new JLabel("ID #", SwingConstants.RIGHT);
		FirstNameL = new JLabel("FIRST NAME", SwingConstants.RIGHT);
		LastNameL = new JLabel("LAST NAME", SwingConstants.RIGHT);
		GradeL = new JLabel("GRADE", SwingConstants.RIGHT);
		EquivL = new JLabel("EQUIVALENT", SwingConstants.RIGHT);
		
		TeacherTF = new JTextField();
		CourseTF = new JTextField();
		SubjectTF = new JTextField();
		NoOfStudntsTF = new JTextField();
		
		TeacherL.setBounds(25, 25, 70, 25);
		TeacherTF.setBounds(100, 25, 250, 25);
		CourseL.setBounds(25, 60, 70, 25);
		CourseTF.setBounds(100, 60, 70, 25);
		NoOfStudntsL.setBounds(480, 25, 140, 25);
		NoOfStudntsTF.setBounds(630, 25, 30, 25);
		SubjectL.setBounds(550, 60, 70, 25);
		SubjectTF.setBounds(630, 60, 70, 25);
		
		IDNoL.setBounds(80, 130, 50, 25);
		LastNameL.setBounds(200, 130, 75, 25);
		FirstNameL.setBounds(330, 130, 75, 25);
		GradeL.setBounds(441, 130, 65, 25);
		EquivL.setBounds(542, 130, 75, 25);
		
		for(index1=0, index2=0, X1=83, X2=176, X3=310, X4=460, X5=545, Y=160 ; index2<14; index2++)
		{
			IDNoTF[index1][index2] = new JTextField();
			LastNameTF[index1][index2] = new JTextField();
			FirstNameTF[index1][index2] = new JTextField();
			GradeTF[index1][index2] = new JTextField();
			EquivTF[index1][index2] = new JTextField();
			
			IDNoTF[index1][index2].setBounds(X1, Y, 75, 25);
			LastNameTF[index1][index2].setBounds(X2, Y, 121, 25);
			FirstNameTF[index1][index2].setBounds(X3, Y, 128, 25);
			GradeTF[index1][index2].setBounds(X4, Y, 55, 25);
			EquivTF[index1][index2].setBounds(X5, Y, 70, 25);
			
			Y+=34;
			
			panel3.add(LastNameTF[index1][index2]);
			panel3.add(FirstNameTF[index1][index2]);
			panel3.add(GradeTF[index1][index2]);
			panel3.add(EquivTF[index1][index2]);
			panel3.add(IDNoTF[index1][index2]);
		}

		panel3.add(TeacherL);
		panel3.add(TeacherTF);
		panel3.add(CourseL);
		panel3.add(CourseTF);
		panel3.add(NoOfStudntsL);
		panel3.add(NoOfStudntsTF);
		panel3.add(SubjectL);
		panel3.add(SubjectTF);
		
		panel3.add(IDNoL);
		panel3.add(FirstNameL);
		panel3.add(LastNameL);
		panel3.add(GradeL);
		panel3.add(EquivL);
		
		OKb.setBounds(235, 100, 100, 25);
		Clearb.setBounds(355, 100, 100, 25);
		
		
		
		panel3.add(OKb);
		panel3.add(Clearb);
		
		scroll = new JScrollPane(panel3, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		scroll.setBorder(BorderFactory.createEmptyBorder());
		
		
		
	}
	
	public Database()
	{
		setTitle( "Database" );
		
		JFrame frame = new JFrame("Database");

		JPanel topPanel = new JPanel();
		topPanel.setLayout( new BorderLayout() );
		getContentPane().add( topPanel );

		// Create the panels
		createPanel1();
		createPanel2();
		createPanel3();

		// Create a splitter pane
		splitPaneV = new JSplitPane( JSplitPane.VERTICAL_SPLIT );
		topPanel.add( splitPaneV, BorderLayout.CENTER );

		splitPaneH = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT );
		splitPaneH.setLeftComponent( panel1 );
		splitPaneH.setRightComponent( panel2 );

		splitPaneV.setLeftComponent( splitPaneH );
		splitPaneV.setRightComponent( scroll );
		
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible( true );
		setSize(750,800);


	}
	
	public static void main( String args[] )
	{
		// Create an instance of the test application
		Database frame	= new Database();

	}
	
	private class OkButtonHandler implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			double students;
			
			students = Double.parseDouble(NoOfStudntsTF.getText());
				
			index1 = 0;
			index2 = 0;
			
			try
			{
				PrintWriter ofs = null;
				Scanner i = new Scanner(System.in);
				String n;		
			
				n=CourseTF.getText()+ "-" + TeacherTF.getText() + ".txt";
			
				ofs = new PrintWriter(new FileOutputStream (n, true));
			
				ofs.println(TeacherTF.getText() + "\t\t\t" + NoOfStudntsTF.getText() );
				ofs.println(CourseTF.getText() + "\t\t\t" + SubjectTF.getText());
			
				for(int x=1; x<=students; x++)
				{
				
					ofs.println(x + "\t" + IDNoTF[index1][index2].getText() + "\t" + LastNameTF[index1][index2].getText() + "\t" + FirstNameTF[index1][index2].getText() + "\t" + GradeTF[index1][index2].getText() + "\t" + EquivTF[index1][index2].getText());
					index2++;
				}
				
				ofs.close();
			}
			
			catch(FileNotFoundException f)
			{
				System.out.println(f.getMessage());
				System.exit(0);
			}
			
			textArea = new JTextArea();
			
			JFrame frame = new JFrame("OUTPUT");
			
			index1=0;
			index2=0;
			
			int y = 1;			 
			for(int x=1; x<=students; x++)
			{
				if(y==1)
				{
					textArea.setText(TeacherTF.getText() + "\t\t\t" + NoOfStudntsTF.getText()
									 + "\n" + CourseTF.getText() + "\t\t\t" + SubjectTF.getText()
							 		+ "\n\n\n");
				}
							 		
				if (y!=0)
				{
					textArea.append(x + "\t" + IDNoTF[index1][index2].getText() + "\t" + LastNameTF[index1][index2].getText() + "\t" + FirstNameTF[index1][index2].getText() + "\t" + GradeTF[index1][index2].getText() + "\t" + EquivTF[index1][index2].getText() + "\n\n");
					index2++;
				}
				
				y++;
				
			}
			
			textArea.setEditable(false);
			frame.add(textArea);
			frame.setSize(650,550);
			frame.setVisible(true);
			frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		}
	}
	
	private class ClearbButtonHandler implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
				int index1=0;
				int index2=0;
				Double students;
			
				students = Double.parseDouble(NoOfStudntsTF.getText());
			
				TeacherTF.setText("");
				NoOfStudntsTF.setText("");
				CourseTF.setText("");
				SubjectTF.setText("");
			
				for(int x=0; x<students; x++)
				{
					IDNoTF[index1][index2].setText("");
					LastNameTF[index1][index2].setText("");
					FirstNameTF[index1][index2].setText("");
					GradeTF[index1][index2].setText("");
					EquivTF[index1][index2].setText("");
					
					index2++;
				
				}
					
		}
	}
	
	private class CalculateButtonHandlerC implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			double grade, finalg;
			
			grade = Double.parseDouble(gradeTF.getText());
			
			if(grade>=99.50 && grade<101)
				finalg = 1.00;
			else if(grade<99.50 && grade>=98.50)
				finalg = 1.10;
			else if(grade<98.50 && grade>=97.50)
				finalg = 1.20;
			else if(grade<97.50 && grade>=96.50)
				finalg = 1.30;
			else if(grade<96.50 && grade>=95.50)
				finalg = 1.40;
			else if(grade<95.50 && grade>=94.50)
				finalg = 1.50;
			else if(grade<94.50 && grade>=93.50)
				finalg = 1.60;
			else if(grade<93.50 && grade>=92.50)
				finalg = 1.70;
			else if(grade<92.50 && grade>=91.50)
				finalg = 1.80;
			else if(grade<91.50 && grade>=90.50)
				finalg = 1.90;
			else if(grade<90.50 && grade>=89.50)
				finalg = 2.00;
			else if(grade<89.50 && grade>=88.50)
				finalg = 2.10;
			else if(grade<88.50 && grade>=87.50)
				finalg = 2.20;
			else if(grade<87.50 && grade>=86.50)
				finalg = 2.30;
			else if(grade<86.50 && grade>=85.50)
				finalg = 2.40;
			else if(grade<85.50 && grade>=84.50)
				finalg = 2.50;
			else if(grade<84.50 && grade>=83.50)
				finalg = 2.60;
			else if(grade<83.50 && grade>=82.50)
				finalg = 2.70;
			else if(grade<82.50 && grade>=81.50)
				finalg = 2.80;
			else if(grade<81.50 && grade>=80.50)
				finalg = 2.90;
			else if(grade<80.50 && grade>=79.50)
				finalg = 3.00;
			else if(grade<79.50 && grade>=78.50)
				finalg = 3.10;
			else if(grade<78.50 && grade>=77.50)
				finalg = 3.20;
			else if(grade<77.50 && grade>=76.50)
				finalg = 3.30;
			else if(grade<76.50 && grade>=75.50)
				finalg = 3.40;
			else if(grade<75.50 && grade>=74.50)
				finalg = 3.50;
			else
				finalg = 5.0;
				
			equivTF.setText("" + finalg);
			equivTF.setEditable(false);
		}
	}
	
	private class ClearButtonHandlerC implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			gradeTF.setText("");
			equivTF.setText("");
		}
	}
	
	private class CalculateButtonHandlerS implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			double prelim, midterm, endterm, finalg;
			
			DecimalFormat df = new DecimalFormat("#.##");
			prelim = Double.parseDouble(prelimTF.getText());
			midterm = Double.parseDouble(midtermTF.getText());
			endterm = Double.parseDouble(endtermTF.getText());
			
			finalg = (prelim * .30) + (midterm * .30) + (endterm * .40);
			
			finalTF.setText("" + df.format(finalg));
			finalTF.setEditable(false);
		}
	}
	
	private class ClearButtonHandlerS implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			prelimTF.setText("");
			midtermTF.setText("");
			endtermTF.setText("");
			finalTF.setText("");
		}
	}
}
This article has been dead for over six months. Start a new discussion instead.