Documente Academic
Documente Profesional
Documente Cultură
Assignment – 3
Object Oriented Concepts / 18CS45
Submitted by,
Name : Sreerang R
USN : 1GD18CS052
Implementation
//Login Page
import javax.swing.JOptionPane;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Font;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.JTextArea;
public class LoginPage extends javax.swing.JFrame {
private javax.swing.JLabel Name;
private javax.swing.JLabel Password;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPasswordField pass;
private javax.swing.JTextField user;
private javax.swing.JLabel username;
public LoginPage()
{
initComponents();
}
private void initComponents()
{
Name = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
username = new javax.swing.JLabel();
Password = new javax.swing.JLabel();
user = new javax.swing.JTextField();
pass = new javax.swing.JPasswordField();
pass.setEchoChar('*');
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Login Page");
Name.setFont(new Font("Times New Roman", Font.BOLD, 20)); // NOI18N
Name.setForeground(new java.awt.Color(0, 0, 204));
Name.setText("GOPALAN COLLEGE OF ENGINEERING AND MANAGEMENT");
jLabel2.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
jLabel2.setText("Library Management System");
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/2.jpg")));
jLabel3.setText("jLabel3");
username.setText("Username:");
Password.setText("Password;");
jButton1.setText("Submit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
System.exit(0);
}
});
btnCancel.setText("Cancel");
.addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1,
GroupLayout.PREFERRED_SIZE, 106, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)))
.addComponent(btnCancel,
GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
.addComponent(pass,
GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
.addComponent(user,
GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE))
.addGap(349))))
.addGroup(layout.createSequentialGroup()
.addGap(411)
.addComponent(jLabel2, GroupLayout.DEFAULT_SIZE, 425,
Short.MAX_VALUE)
.addGap(309))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3)
.addGap(35)
.addComponent(Name)
.addGap(18)
.addComponent(jLabel2)
.addGap(39)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(username)
.addComponent(user, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(Password)
.addComponent(pass, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addComponent(chckbxShowPassword)
.addGap(18)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(btnCancel, GroupLayout.DEFAULT_SIZE, 31,
Short.MAX_VALUE)
.addComponent(jButton1, GroupLayout.PREFERRED_SIZE, 32,
GroupLayout.PREFERRED_SIZE))
.addContainerGap(155, Short.MAX_VALUE))
);
getContentPane().setLayout(layout);
pack();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
String un=user.getText();
String p=pass.getText();
}
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LoginPage().setVisible(true);
}
});
}
}
//Menu Page
public class MenuPage extends javax.swing.JFrame {
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
public MenuPage() {
initComponents();
}
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton2.setText("Departments");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
pack();
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MenuPage().setVisible(true);
}
});
}
}
//Data Entry page
import javax.swing.JOptionPane;
public DataEntry()
{
initComponents();
}
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel3.setText("User ID:");
jLabel4.setText("Username:");
jLabel5.setText("Father's Name:");
jLabel6.setText("Semester:");
jLabel8.setText("Institute");
jButton1.setText("submitt");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel7.setText("GO BACK");
jLabel7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel7MouseClicked(evt);
}
});
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(171, 171, 171)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(jLabel5)
.addComponent(jLabel4)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE, 189,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(216, 216, 216)
.addComponent(jLabel7)
.addGap(62, 62, 62))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(uid,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ins,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sem,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(un,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fn,
javax.swing.GroupLayout.PREFERRED_SIZE, 223,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA
ILING)
.addComponent(jButton1)
.addComponent(jLabel1))
.addGap(283, 283, 283))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel7)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel3)
.addComponent(uid,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel4)
.addComponent(un,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(7, 7, 7)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel5)
.addComponent(fn,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel6)
.addComponent(sem,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel8)
.addComponent(ins,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13,
Short.MAX_VALUE)
.addComponent(jButton1)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
String username=un.getText();
String userid=uid.getText();
String father=fn.getText();
String semester=sem.getText();
String institute=ins.getText();
JOptionPane.showMessageDialog(rootPane, "UserID:
"+userid+"\nUsername: "+username+"\nFather's name: "+father+
"\nSemester: "+semester+ "\nInstitute: "+institute+"\n
Data Stored");
}//GEN-LAST:event_jButton1ActionPerformed
}//GEN-LAST:event_jLabel7MouseClicked
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new DataEntry().setVisible(true);
}
});
}
}
//Department Page
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout;
public LibDepartment()
{
initComponents();
}
private void initComponents()
{
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/3.jfif")));
jLabel3.setText("jLabel3");
jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel3MouseClicked(evt);
}
});
jLabel4.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/4.jfif")));
jLabel4.setText("jLabel4");
jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel4MouseClicked(evt);
}
});
jLabel5.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/5.jfif")));
jLabel5.setText("jLabel5");
jLabel5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel5MouseClicked(evt);
}
});
jLabel6.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/6.jfif")));
jLabel6.setText("jLabel6");
jLabel6.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel6MouseClicked(evt);
}
});
jLabel7.setText("Go BACK");
jLabel7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel7MouseClicked(evt);
}
});
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jLabel5, 0, 0,
Short.MAX_VALUE)
.addComponent(jLabel3,
GroupLayout.PREFERRED_SIZE, 226, GroupLayout.PREFERRED_SIZE))
.addGap(107, 107, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jLabel6, 0, 0,
Short.MAX_VALUE)
.addComponent(jLabel4, Alignment.TRAILING,
GroupLayout.PREFERRED_SIZE, 227, GroupLayout.PREFERRED_SIZE))
.addContainerGap(153, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(29)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(33)
.addComponent(jLabel2))
.addComponent(jLabel7))
.addGap(27)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(jLabel3,
GroupLayout.PREFERRED_SIZE, 190, GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4,
GroupLayout.PREFERRED_SIZE, 192, Short.MAX_VALUE))
.addGap(43)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(jLabel5,
GroupLayout.PREFERRED_SIZE, 216, GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6,
GroupLayout.PREFERRED_SIZE, 216, GroupLayout.PREFERRED_SIZE))
.addContainerGap(583, Short.MAX_VALUE))
);
getContentPane().setLayout(layout);
pack();
}
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run()
{
new LibDepartment().setVisible(true);
}
});
}
}
//Mech Dept page
import javax.swing.JOptionPane;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
public class EngDep extends javax.swing.JFrame
{
private javax.swing.JComboBox<String> eng;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JButton sub;
private JButton sub1;
private JButton btnReturn;
public EngDep()
{
initComponents();
}
private void initComponents()
{
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
sub.setText("NOT ISSUED");
jLabel3.setText("GO BACK");
jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel3MouseClicked(evt);
}
});
}
});
.addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(51)
.addComponent(lblIssued)
.addGroup(layout.createParallelGroup(Alignment.LEADING, false)
.addGroup(Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(33)
.addComponent(btnReturn,
GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(sub1,
GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE))
.addComponent(eng,
Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)))
.addGap(279))))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(33)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(20)
.addComponent(jLabel3)))
.addGap(70)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(eng, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED, 30,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(sub)
.addComponent(lblIssued, GroupLayout.PREFERRED_SIZE, 18,
GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(sub1)
.addComponent(btnReturn, GroupLayout.PREFERRED_SIZE, 23,
GroupLayout.PREFERRED_SIZE))
.addGap(22))
);
getContentPane().setLayout(layout);
pack();
}
sub.setText(eng.getSelectedItem().toString());
java.awt.EventQueue.invokeLater(new Runnable()
{
public void run() {
new EngDep().setVisible(true);
}
});
}
}
//Electronics Dept page
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public phydep()
{
initComponents();
}
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
sub.setText("NOT ISSUED");
sub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});
jLabel3.setText("GO BACK");
jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel3MouseClicked(evt);
}
});
}
});
button.setText("OK");
.addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addComponent(phy,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(lblLabel,
GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(31)
.addComponent(button_1,
GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE)))
.addGap(14)
.addGroup(layout.createParallelGroup(Alignment.TRAILING)
.addComponent(sub)
.addGroup(layout.createSequentialGroup()
.addComponent(button,
GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)))))
.addGap(159))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(ComponentPlacement.RELATED,
78, Short.MAX_VALUE)
.addComponent(jLabel3)
.addGap(42))))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel3))
.addGap(71)
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(phy, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(47)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(sub)
.addComponent(lblLabel, GroupLayout.PREFERRED_SIZE,
18, GroupLayout.PREFERRED_SIZE))
.addGap(29)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(button)
.addComponent(button_1))
.addContainerGap(101, Short.MAX_VALUE))
);
getContentPane().setLayout(layout);
pack();
}
private void subActionPerformed(java.awt.event.ActionEvent evt) {
sub.setText(phy.getSelectedItem().toString());
JOptionPane.showMessageDialog(rootPane, "Book has been Issued");
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(phydep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(phydep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(phydep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(phydep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new phydep().setVisible(true);
}
});
}
}
//CivilDept page
import javax.swing.JOptionPane;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public chemdep()
{
initComponents();
}
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setText("GO BACK");
jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel2MouseClicked(evt);
}
});
sub.setText("NOT ISSUED");
sub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});
lblLabel = new JLabel("");
lblLabel.setFont(new Font("Tahoma", Font.BOLD, 13));
.addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(lblLabel)
.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(sub))
.addComponent(chem,
GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))))
.addContainerGap(290, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addGap(10)
.addComponent(jLabel2)))
.addGap(61)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(chem, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(42)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(sub)
.addComponent(lblLabel, GroupLayout.PREFERRED_SIZE, 18,
GroupLayout.PREFERRED_SIZE))
.addGap(31)
.addGroup(layout.createParallelGroup(Alignment.BASELINE)
.addComponent(sub1)
.addComponent(button_1))
.addContainerGap(161, Short.MAX_VALUE))
);
getContentPane().setLayout(layout);
pack();
}
private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-
FIRST:event_jLabel2MouseClicked
LibDepartment obj=new LibDepartment();
obj.setVisible(true);
dispose();
}
sub.setText(chem.getSelectedItem().toString());
JOptionPane.showMessageDialog(rootPane, "Book has been issued");
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(chemdep.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(chemdep.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(chemdep.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(chemdep.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new chemdep().setVisible(true);
}
});
}
}
//Computer Science Dept page
import javax.swing.JOptionPane;
import javax.swing.JButton;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class NewspaperDep extends javax.swing.JFrame
{
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JComboBox<String> news;
private javax.swing.JButton sub;
private JButton button;
private JButton button_1;
private JLabel lblLabel
public NewspaperDep()
{
initComponents();
}
private void initComponents()
{
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel2.setFont(new Font("Tahoma", Font.BOLD, 11));
news = new javax.swing.JComboBox<>();
sub = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
sub.setText("NOT ISSUED");
sub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});
jLabel3.setText("GO BACK");
jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel3MouseClicked(evt);
}
});
pack();
}
private void subActionPerformed(java.awt.event.ActionEvent evt) {
sub.setText(news.getSelectedItem().toString());
JOptionPane.showMessageDialog(rootPane, "Book has been issued");
}
private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {
LibDepartment obj=new LibDepartment();
obj.setVisible(true);
dispose();
}
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewspaperDep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewspaperDep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewspaperDep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewspaperDep.class.getName()).log(java.util.logging.Level.SEV
ERE, null, ex);
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewspaperDep().setVisible(true);
}
});
}
}
Output