Java program to create student report using applet, read the input using text boxes and display the output using buttons.
import java.awt.*;
import java.awt.event.*; /* */
{
Label lblTitle, lblRegno, lblCourse, lblSemester, lblSub1, lblSub2;
TextField txtRegno, txtCourse, txtSemester, txtSub1, txtSub2;
Button cmdReport;
"", heading = "";
public void init ()
{
setLayout (gbag);
cmdReport = new Button ("View Report"); // Define the grid bag gbc.weighty=2.0; gbc.gridwidth=GridBagConstraints.REMAINDER; gbc.anchor=GridBagConstraints.NORTH; gbag.setConstraints(lblTitle,gbc); //Anchor most components to the right gbc.anchor=GridBagConstraints.EAST; gbc.gridwidth=GridBagConstraints.RELATIVE; gbag.setConstraints(lblRegno,gbc); gbc.gridwidth=GridBagConstraints.REMAINDER; gbag.setConstraints(txtRegno,gbc);gbc.gridwidth=GridBagConstraints.RELATIVE; gbag.setConstraints(lblCourse,gbc); gbc.gridwidth=GridBagConstraints.REMAINDER; gbag.setConstraints(txtCourse,gbc);gbc.gridwidth=GridBagConstraints.RELATIVE;
gbag.setConstraints (lblSemester, gbc);
gbag.setConstraints (txtSemester, gbc);
gbag.setConstraints (lblSub1, gbc);
gbag.setConstraints (txtSub1, gbc);
gbag.setConstraints (lblSub2, gbc);
gbag.setConstraints (txtSub2, gbc);
gbag.setConstraints (cmdReport, gbc);
add (lblTitle);
add (lblRegno);
add (txtRegno);
add (lblCourse);
add (txtCourse);
add (lblSemester);
add (txtSemester);
add (lblSub1);
add (txtSub1);
add (lblSub2);
add (txtSub2);
add (cmdReport);
cmdReport.addActionListener (this);
{
try
{
if (ae.getSource () == cmdReport)
{
rno = txtRegno.getText ().trim ();
course = txtCourse.getText ().trim ();
sem = txtSemester.getText ().trim ();
sub1 = txtSub1.getText ().trim ();
sub2 = txtSub2.getText ().trim ();
avg =
"Avg Marks:"
rno = "Register No:" rno;
course = "Course :" course;
sem = "Semester :" sem;
sub1 = "Subject1 :" sub1;
sub2 = "Subject2 :" sub2;
heading = "Student Report";
removeAll ();
showStatus ("");
repaint ();
}
}
{
showStatus ("Invalid Data");
}
}
{
g.drawString (heading, 30, 30);
g.drawString (rno, 30, 80);
g.drawString (course, 30, 100);
g.drawString (sem, 30, 120);
g.drawString (sub1, 30, 140);
g.drawString (sub2, 30, 160);
g.drawString (avg, 30, 180);
}}
Java program to create student report using applet, read the input using text boxes and display the output using buttons.
Reviewed by
on
September 05, 2019
Rating:
No comments: