0% found this document useful (0 votes)
4 views

import-java

The document is a Java program that creates a graphical user interface for a Student Management System using Swing. It includes features for managing student data, such as input fields for name, LRN, course, gender, year level, and status, as well as a table to display the information. The program also implements functionality for adding student data and navigating through pages of entries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

import-java

The document is a Java program that creates a graphical user interface for a Student Management System using Swing. It includes features for managing student data, such as input fields for name, LRN, course, gender, year level, and status, as well as a table to display the information. The program also implements functionality for adding student data and navigating through pages of entries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

import java.awt.

*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.ArrayList;

import javax.swing.*;

import java.util.List;

import javax.swing.table.DefaultTableModel;

public class GUI {

static JTextField nameField;

static JTextField lrnField;

static JComboBox<String> courseComboBox;

static JRadioButton male;

static JRadioButton female;

static JSpinner yearLevel;

static DefaultTableModel deftable;

static ButtonGroup genderGroup;

static JTextField statusField;

static JTable table;

public static void main(String[] args) {

JFrame frame = new JFrame("Student Management System");

frame.setSize(900, 600);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setResizable(true);
frame.setLayout(new BorderLayout(10, 10));

// Top Panel

JPanel topPanel = new JPanel(new BorderLayout());

topPanel.setPreferredSize(new Dimension(frame.getWidth(), 70));

topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

//top panel setUp

JLabel titleLabel = new JLabel("STUDENT MANAGEMENT SYSTEM", JLabel.CENTER);

titleLabel.setFont(new Font("Arial", Font.BOLD, 25));

ImageIcon icon = new ImageIcon("C:/Users/Peter paul


estose/Documents/NetBeansProjects/Copy/src/Photo.jpg");

Image image = icon.getImage();

Image resizedImage = image.getScaledInstance(50, 50,java.awt.Image.SCALE_SMOOTH);

ImageIcon resizedIcon = new ImageIcon(resizedImage);

JLabel iconLabel = new JLabel(resizedIcon);

JLabel Label = new JLabel("DorSU",JLabel.CENTER);

Label.setFont(new Font("Arial",Font.BOLD,15));

JPanel innerpanel = new JPanel();

innerpanel.setLayout(new FlowLayout(FlowLayout.CENTER));

innerpanel.setSize(50,50);

innerpanel.add(iconLabel);

innerpanel.add(Label);

topPanel.add(innerpanel,BorderLayout.EAST);
topPanel.add(titleLabel, BorderLayout.CENTER);

frame.add(topPanel, BorderLayout.NORTH);

// Admin Panel

JPanel westPanel = new JPanel(new GridLayout(5, 1, 0,0 ));

westPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

westPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

westPanel.setPreferredSize(new Dimension(150, 460));

// SULOD SA ADMIN PANEL

JLabel adminLabel = new JLabel("ADMIN", JLabel.CENTER);

adminLabel.setFont(new Font("Arial", Font.BOLD, 15));

westPanel.add(adminLabel);

// Image 1

ImageIcon iconImage1 = new ImageIcon(new ImageIcon("C:/Users/Peter paul


estose/Documents/NetBeansProjects/Copy/src/picture01.jpg")

.getImage().getScaledInstance(40, 40, Image.SCALE_SMOOTH));

JLabel label = new JLabel(iconImage1, JLabel.CENTER);

// Image 2
ImageIcon iconImage2 = new ImageIcon(new ImageIcon("C:/Users/Peter paul
estose/Documents/NetBeansProjects/Copy/src/picture02.jpg")

.getImage().getScaledInstance(40, 40, Image.SCALE_SMOOTH));

JLabel label2 = new JLabel(iconImage2, JLabel.CENTER);

// Image 3

ImageIcon iconImage3 = new ImageIcon(new ImageIcon("C:/Users/Peter paul


estose/Documents/NetBeansProjects/Copy/src/picture03.jpg")

.getImage().getScaledInstance(40, 40, Image.SCALE_SMOOTH));

JLabel label3 = new JLabel(iconImage3, JLabel.CENTER);

// Image 4

ImageIcon iconImage4 = new ImageIcon(new ImageIcon("C:/Users/Peter paul


estose/Documents/NetBeansProjects/Copy/src/picture04.jpg")

.getImage().getScaledInstance(40, 40, Image.SCALE_SMOOTH));

JLabel label4 = new JLabel(iconImage4, JLabel.CENTER);

// Add labels to the panel

westPanel.add(label);

westPanel.add(label2);

westPanel.add(label3);

westPanel.add(label4);
frame.add(westPanel, BorderLayout.WEST);

// Center Panel

JPanel centerpanel = new JPanel(null);

centerpanel.setPreferredSize(new Dimension(500, 350));

centerpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

frame.add(centerpanel, BorderLayout.CENTER);

JLabel manageStudentLabel = new JLabel("MANAGE STUDENT");

manageStudentLabel.setBounds(80, 20, 150, 20);

centerpanel.add(manageStudentLabel);

// Name Label and Text Field

JLabel nameLabel = new JLabel("Name");

nameLabel.setBounds(10, 60, 100, 20);

centerpanel.add(nameLabel);

nameField = new JTextField();

nameField.setBounds(100, 60, 150, 20);

centerpanel.add(nameField);

// LRN Label and Text Field

JLabel lrnLabel = new JLabel("LRN");

lrnLabel.setBounds(10, 110, 100, 20);

centerpanel.add(lrnLabel);

lrnField = new JTextField();

lrnField.setBounds(100, 110, 150, 20);


centerpanel.add(lrnField);

// Course ComboBox

JLabel courseLabel = new JLabel("Course");

courseLabel.setBounds(10, 160, 100, 20);

centerpanel.add(courseLabel);

String[] courses = {"BSN", "BSCE", "BITM", "BSAM"};

courseComboBox = new JComboBox<>(courses);

courseComboBox.setBounds(100, 160, 150, 20);

centerpanel.add(courseComboBox);

// Gender Radio Buttons

JLabel genderLabel = new JLabel("Gender");

genderLabel.setBounds(10, 210, 100, 20);

centerpanel.add(genderLabel);

male = new JRadioButton("M");

male.setBounds(100, 210, 40, 20);

female = new JRadioButton("F");

female.setBounds(150, 210, 40, 20);

genderGroup = new ButtonGroup();

genderGroup.add(male);

genderGroup.add(female);

centerpanel.add(male);

centerpanel.add(female);
// Year Spinner

JLabel yearLevelLabel = new JLabel("Year Level");

yearLevelLabel.setBounds(10, 260, 250, 10);

centerpanel.add(yearLevelLabel);

String[] yearLevels = {"1st Year", "2nd Year", "3rd Year", "4th Year"};

SpinnerListModel model = new SpinnerListModel(yearLevels);

yearLevel = new JSpinner(model);

yearLevel.setBounds(100, 260, 150, 25);

centerpanel.add(yearLevel);

JLabel LABEL = new JLabel("Status");

LABEL.setBounds(10, 320, 100, 20);

centerpanel.add(LABEL);

statusField = new JTextField();

statusField.setBounds(100, 320,150 , 20);

centerpanel.add(statusField);

// Table Panel

JPanel tablePanel = new JPanel(null);

tablePanel.setPreferredSize(new Dimension(400, 300));

tablePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

// Search Text Field and Button

JLabel searchLabel = new JLabel("Search:");

searchLabel.setBounds(10, 20, 50, 20);

tablePanel.add(searchLabel);
JTextField searchField = new JTextField();

searchField.setBounds(70, 20, 175, 20);

tablePanel.add(searchField);

JButton searchButton = new JButton("Search");

searchButton.setBounds(250, 20, 75, 20);

tablePanel.add(searchButton);

// ADD Button

JButton addButton = new JButton("ADD");

addButton.setBounds(10, 50, 80, 25);

addButton.addActionListener(new addactionListener() );

tablePanel.add(addButton);

// Table for displaying student data

String[] columnNames = {"Name", "LRN", "Course", "Year", "Gender", "Status"};

deftable = new DefaultTableModel(columnNames,0);

table = new JTable(deftable);

JScrollPane tableScrollPane = new JScrollPane(table);

tableScrollPane.setBounds(10, 85, 330, 260);

tablePanel.add(tableScrollPane);

// Page navigation

JLabel pageLabel = new JLabel("Page 1 of 10");

pageLabel.setBounds(130, 360, 100, 20);

tablePanel.add(pageLabel);

JButton prevButton = new JButton("Prev");


prevButton.setBounds(10, 360, 80, 30);

tablePanel.add(prevButton);

JButton nextButton = new JButton("Next");

nextButton.addActionListener(new nextButtonListener());

nextButton.setBounds(240, 360, 80, 30);

tablePanel.add(nextButton);

frame.add(tablePanel, BorderLayout.EAST);

JPanel bottomPanel = new JPanel(new GridLayout(1, 3));

bottomPanel.setPreferredSize(new Dimension(frame.getWidth(), 70));

bottomPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

// ABOUT US Panel

JPanel aboutUsPanel = new JPanel();

aboutUsPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

aboutUsPanel.setSize(new Dimension(frame.getWidth(), 300));

aboutUsPanel.setLayout(new BoxLayout(aboutUsPanel, BoxLayout.Y_AXIS));

JLabel aboutUsLabel = new JLabel("ABOUT US");

aboutUsLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

aboutUsLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));

aboutUsPanel.add(aboutUsLabel);

JLabel aboutUsDetails = new JLabel("We provide quality education services.");

aboutUsDetails.setFont(new Font("Arial" ,Font.BOLD,10));

aboutUsDetails.setAlignmentX(Component.CENTER_ALIGNMENT);

aboutUsPanel.add(aboutUsDetails);
// OUR SERVICES Panel

JPanel ourServicesPanel = new JPanel();

ourServicesPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Center text in the panel

ourServicesPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

aboutUsPanel.setSize(new Dimension(frame.getWidth(),300));

JLabel ourServicesLabel = new JLabel("OUR SERVICES");

ourServicesLabel.setBorder(BorderFactory.createEmptyBorder(5,0,5,0));

ourServicesPanel.add(ourServicesLabel);

JLabel ourServicesDetails = new JLabel("Our services include student data management");

ourServicesDetails.setFont(new Font("Arial",Font.BOLD,10));

ourServicesDetails.setAlignmentX(Component.CENTER_ALIGNMENT);

ourServicesPanel.add(ourServicesDetails);

// CONTACT US Panel

JPanel contactUsPanel = new JPanel();

contactUsPanel.setLayout(new BoxLayout(contactUsPanel, BoxLayout.Y_AXIS)); // Use vertical layout

contactUsPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

contactUsPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

JLabel contactUsLabel = new JLabel("CONTACT US");

contactUsLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

contactUsPanel.add(contactUsLabel);

JPanel facebookPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

ImageIcon icon1 = new ImageIcon("C:/Users/Peter paul


estose/Documents/NetBeansProjects/Copy/src/fbb.jpg");

Image image1 = icon1.getImage();


Image resizedImage1 = image1.getScaledInstance(10, 10, java.awt.Image.SCALE_SMOOTH);

ImageIcon resizedIcon1 = new ImageIcon(resizedImage1);

JLabel iconLabel1 = new JLabel(resizedIcon1);

JLabel facebookLabel = new JLabel("FACEBOOK.com");

facebookPanel.add(iconLabel1);

facebookPanel.add(facebookLabel);

JPanel instagramPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

ImageIcon icon2 = new ImageIcon("C:/Users/Peter paul


estose/Documents/NetBeansProjects/Copy/src/ig.png");

Image image2 = icon2.getImage();

Image resizedImage2 = image2.getScaledInstance(10, 10, java.awt.Image.SCALE_SMOOTH);

ImageIcon resizedIcon2 = new ImageIcon(resizedImage2);

JLabel iconLabel2 = new JLabel(resizedIcon2);

JLabel instagramLabel = new JLabel("INSTAGRAM");

instagramPanel.add(iconLabel2);

instagramPanel.add(instagramLabel);

contactUsPanel.add(facebookPanel);

contactUsPanel.add(instagramPanel);

// Add the three panels to the bottom panel

bottomPanel.add(aboutUsPanel);

bottomPanel.add(ourServicesPanel);

bottomPanel.add(contactUsPanel);

frame.add(bottomPanel, BorderLayout.SOUTH);

frame.setVisible(true);
}

public static class addactionListener implements ActionListener {

public void actionPerformed(ActionEvent e) {

String Name = nameField.getText();

String LRN = lrnField.getText();

String course = (String) courseComboBox.getSelectedItem();

String Gender = male.isSelected() ? "Male" :

(female.isSelected() ? "Female" : "");

String Year = (String) yearLevel.getValue();

String Status = statusField.getText();

if(!Name.isEmpty()&& !LRN.isEmpty()&&

!course.isEmpty()&& !Gender.isEmpty()&&

!Year.isEmpty()&&!Status.isEmpty()){

deftable.addRow(new Object[]{Name, LRN, course, Year, Gender,Status});

// Show confirmation dialog using showMessageDialog

JOptionPane.showMessageDialog(null,

"Student information added successfully.",

null,

JOptionPane.PLAIN_MESSAGE);
// Clear input fields after adding the row

nameField.setText("");

lrnField.setText("");

genderGroup.clearSelection();

courseComboBox.setSelectedIndex(0);

yearLevel.setValue("1st Year");

statusField.setText("");

}else{

JOptionPane.showMessageDialog(null,

"Fill all Details Before Adding "

,null,JOptionPane.INFORMATION_MESSAGE);

public static class nextButtonListener implements ActionListener {

@Override

public void actionPerformed(ActionEvent e) {

// Clear the table (show empty)

DefaultTableModel tableModel = (DefaultTableModel) table.getModel();

// tableModel.setRowCount(0);

You might also like