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

Programming

This document contains Java code to create a GUI application for student information registration. It declares objects for labels, text fields, panels and a frame. It then sets the layout, adds components and makes the frame visible.
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)
19 views

Programming

This document contains Java code to create a GUI application for student information registration. It declares objects for labels, text fields, panels and a frame. It then sets the layout, adds components and makes the frame visible.
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/ 4

Sandra Lamban Mesongco | DICT 12M2 | Programming

Codes:

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class Sample1 implements ActionListener

{//declare all the objects to used

private JFrame frm1;

private JPanel mp, p1, p2, p3, p4, p5, p6, p7, p8;

private JLabel lbl1n,lbl2n, lbl3n, lbl4n, lbl5n, lbl6n, lbl7n, lbl8n;

private JTextField tf1n,tf2n, tf3n, tf4n, tf5n, tf6n, tf7n, tf8n;

public static void main(String[] args)

new Sample1();

public Sample1()//initialize variable as object to used in GUI and to design GUI

frm1= new JFrame("Student Information Registration");

mp = new JPanel();

p1=new JPanel();

p2=new JPanel();

p3=new JPanel();

p4=new JPanel();

p5=new JPanel();

p6=new JPanel();

p7=new JPanel();
p8=new JPanel();

lbl1n=new JLabel("Student ID Number");

lbl2n=new JLabel("Name of Student");

lbl3n=new JLabel("Course");

lbl4n=new JLabel("Year");

lbl5n=new JLabel("Address");

lbl6n=new JLabel("Age");

lbl7n=new JLabel("School Name");

lbl8n=new JLabel("School Address");

tf1n=new JTextField(10);

tf2n=new JTextField(10);

tf3n=new JTextField(10);

tf4n=new JTextField(10);

tf5n=new JTextField(10);

tf6n=new JTextField(10);

tf7n=new JTextField(10);

tf8n=new JTextField(10);

p1.setLayout(new GridLayout(1,2));

p1.add(lbl1n);

p1.add(tf1n);

p2.setLayout(new GridLayout(1,2));

p2.add(lbl2n);

p2.add(tf2n);

p3.setLayout(new GridLayout(1,2));
p3.add(lbl3n);

p3.add(tf3n);

p4.setLayout(new GridLayout(1,2));

p4.add(lbl4n);

p4.add(tf4n);

p5.setLayout(new GridLayout(1,2));

p5.add(lbl5n);

p5.add(tf5n);

p6.setLayout(new GridLayout(1,2));

p6.add(lbl6n);

p6.add(tf6n);

p7.setLayout(new GridLayout(1,2));

p7.add(lbl7n);

p7.add(tf7n);

p8.setLayout(new GridLayout(1,2));

p8.add(lbl8n);

p8.add(tf8n);

mp.setLayout(new GridLayout(8,1));

mp.add(p1);

mp.add(p2);

mp.add(p3);

mp.add(p4);

mp.add(p5);
mp.add(p6);

mp.add(p7);

mp.add(p8);

frm1.setContentPane(mp);

frm1.setSize(400, 250);

frm1.show();

frm1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frm1.setResizable(true);

public void actionPerformed(ActionEvent ae)//used to declare the function or event of an object

You might also like