Question

java programming 1.Create a simple SWING Form to Display Student Data.The top part of the form...

java programming

1.Create a simple SWING Form to Display Student Data.The top part of the form should say “Student Information”.The middle part of the form will contain labels and textFields; one each for ID, FirstName, LastName, Email and GPA.The bottom part should have 5 Buttons that read “Find”, “Insert”, “Delete”, “Update” and “Exit”.

2.Add a few neat SWING features, like tooltips, borders, colors, etc. Also the Exit button should work and the “X” at the top right of the Window should also close the Application. Make it so that when the User clicks on the Exit Button, a MessageBox Window popup and ask the User if they are sure that they want to exit. If they say “Yes”, then Exit the App.

Homework Answers

Answer #1

//BottomPanel.java

import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class BottomPanel extends JPanel {
   /**
   *
   */
   private static final long serialVersionUID = 1L;
   JButton find = new JButton("Find");
   JButton insert = new JButton("Insert");
   JButton delete = new JButton("Delete");
   JButton update = new JButton("Update");
   JButton exit = new JButton("Exit");
  
   protected BottomPanel(){
       find.setToolTipText("Click to find a student");
       insert.setToolTipText("Click to add student to database.");
       delete.setToolTipText("Click to delete student from database");
       update.setToolTipText("Click to update student info");
       exit.setToolTipText("Click to exit program");
      
       exit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
   if (JOptionPane.showConfirmDialog(null, "Are you sure?", "WARNING",
   JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
       System.exit(0);
   } // end if
} // end action listener event
}); // end action listener
      
       add(find);
       add(insert);
       add(delete);
       add(update);
       add(exit);
      
   } // end BottomPanel constructor

} // end BottomPanel class

================================================================================

//MiddlePanel.java

import javax.swing.*;

import java.awt.*;

import javax.swing.JPanel;

public class MiddlePanel extends JPanel {
     
  
   protected MiddlePanel(){
       setLayout(new GridLayout(5 , 2));
       setBorder(BorderFactory.createBevelBorder(1));
       add(new JLabel("ID: "));
       add(new JTextField());
       add(new JLabel("FirstName: "));
       add(new JTextField());
       add(new JLabel("Last Name: "));
       add(new JTextField());
       add(new JLabel("Email: "));
       add(new JTextField());
       add(new JLabel("GPA: "));
       add(new JTextField());
      
   } // end MiddlePanel constructor
  
} // end MiddlePanel class

=============================================================================

//StudentData.java

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class StudentData extends JFrame{
   TopPanel top = new TopPanel();
   MiddlePanel mid = new MiddlePanel();
   BottomPanel bottom = new BottomPanel();
  
   public StudentData(){
       JPanel p1=new JPanel();
       p1.setBorder(new EmptyBorder(10,10,10,10));
      
       JPanel p2 = new JPanel();
       p2.setLayout(new BorderLayout());
       p2.add(top, BorderLayout.NORTH);
       p2.add(mid, BorderLayout.CENTER);
       p2.add(bottom, BorderLayout.SOUTH);
      
       p1.add(p2);
      
       add(p1);
   } // end StudentData constructor
  
   public static void main(String[] args) {
       StudentData frame = new StudentData();
       frame.pack();
      
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.setLocationRelativeTo(null);
       frame.setVisible(true);
   }// end main

}// end StudentData class

=======================================================================


//TopPanel.java

import java.awt.FlowLayout;
import java.awt.*;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class TopPanel extends JPanel {
   private JLabel jLbl = new JLabel("Student Information");
  
   protected TopPanel(){
       setLayout(new FlowLayout());
       jLbl.setFont(new Font("Serif", Font.BOLD, 24));
       jLbl.setForeground(Color.GREEN);
       add(jLbl);
      
   }// end TopPanel constructor
  
} // end TopPanel class

======================================================================

sample output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C# Step 1: Create a Windows Forms Application. Step 2: Create a BankAccount class. Include: Private...
C# Step 1: Create a Windows Forms Application. Step 2: Create a BankAccount class. Include: Private data fields to store the account holder's name and the account balance A constructor with 0 arguments A constructor with 1 argument (account holder's name) A constructor with 2 arguments(account holder's name and account balance) Public properties for the account holder's name and the account balance. Do not use auto-implemented properties. A method to increase the balance (deposit) A method to decrease the balance...
Scenario: You recently started working as the mobile app developer for a University and have been...
Scenario: You recently started working as the mobile app developer for a University and have been assigned to build a mobile app that calculates the students' grade. Your app should contain following screens: Screen 1 Labels for subject1, subject2, and subject3 Textboxes for subject1, subject2, and subject3 Labels for MaxGrade, MinGrade, and Avg.Grade Submit button Once user clicks submit button, you need to display letter grade in a label Screen 2 Screen that allows students to register for the course...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT