I dont know how to add a next button that will continue to a next page.
The next page will have:
Prelim Exam Grade
Midterm Exam Grade
Final Exam Grade
Compute Button
Exit Button


Here is the code i have done.
HELP ME PLEASE. THANKS.

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;

public class Grade extends JFrame
{
    private JLabel lastnameL, firstnameL, middlenameL, studentnoL, courseL;
    
    private JTextField lastnameTF, firstnameTF, middlenameTF, studentnoTF;
    
    private JComboBox courseCB;
    private static final String[] courseList = 
    {                
        "BS Information Technology", 
        "BS Computer Science"
    };

    private JButton continueB, exitB;
    
    private ExitButtonHandler ebHandler;
    
    public Grade()
    {
        lastnameL = new JLabel("Last Name:", SwingConstants.LEFT);
        firstnameL = new JLabel("First Name:", SwingConstants.LEFT);
        middlenameL = new JLabel("Middle Name:", SwingConstants.LEFT);
        studentnoL = new JLabel("Student Number:", SwingConstants.LEFT);
        courseL = new JLabel("Course:", SwingConstants.LEFT);

        lastnameTF = new JTextField(10);
        firstnameTF = new JTextField(10);
        middlenameTF = new JTextField(10);
        studentnoTF = new JTextField(10);

        courseCB = new JComboBox(courseList);
	
        continueB = new JButton("Continue");
        
        exitB = new JButton("Exit");
        ebHandler = new ExitButtonHandler();
        exitB.addActionListener(ebHandler);
        
        setTitle("Grades");
        
        Container pane;
        pane = getContentPane();
        
        pane.setLayout(new GridLayout(6,2));
        
        pane.add(lastnameL);
        pane.add(lastnameTF);
        pane.add(firstnameL);
        pane.add(firstnameTF);
        pane.add(middlenameL);
        pane.add(middlenameTF);
        pane.add(studentnoL);
        pane.add(studentnoTF);
        pane.add(courseL);
        pane.add(courseCB);
        pane.add(continueB);
        pane.add(exitB);

        setSize(300,200);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);  

                
                
    }
    
private class ExitButtonHandler implements ActionListener
{
    public void actionPerformed(ActionEvent e)
    {
        System.exit(0);
    }
}

public static void main(String[] args)
{
    Grade newGrade = new Grade();
}

}

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

Create a class for your next page - just like the one you have already done.
In the action listener for your next button hide the first page and create a new instance of the second page. If the second page needs any info from the first you can pass it as parameters to the second page's constructor.

ps. Next time post your code in code tags.

Edited 5 Years Ago by JamesCherrill: n/a

This article has been dead for over six months. Start a new discussion instead.