0% found this document useful (0 votes)
4 views11 pages

OOP Lab

The document contains Java code for a graphical user interface (GUI) application with a menu and a login form. The 'mymenu' class sets up a JFrame with menu items for File, Edit, and Help, including an action to open a login form. The 'LoginForm' class creates a login interface with fields for user ID and password, along with login and exit buttons.

Uploaded by

Armanul Alam
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 views11 pages

OOP Lab

The document contains Java code for a graphical user interface (GUI) application with a menu and a login form. The 'mymenu' class sets up a JFrame with menu items for File, Edit, and Help, including an action to open a login form. The 'LoginForm' class creates a login interface with fields for user ID and password, along with login and exit buttons.

Uploaded by

Armanul Alam
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/ 11

My Menu

package lab.pkg.menu;

public class mymenu extends javax.swing.JFrame {

public mymenu() {

initComponents();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jProgressBar1 = new javax.swing.JProgressBar();

jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();

jMenuBar1 = new javax.swing.JMenuBar();

File = new javax.swing.JMenu();

Exit = new javax.swing.JMenuItem();

jSeparator1 = new javax.swing.JPopupMenu.Separator();

jMenuItem2 = new javax.swing.JMenuItem();

Edit = new javax.swing.JMenu();

Help = new javax.swing.JMenu();

jCheckBoxMenuItem1.setSelected(true);

jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
File.setText("File");

Exit.setText("Login");

Exit.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

ExitActionPerformed(evt);

});

File.add(Exit);

File.add(jSeparator1);

jMenuItem2.setText("Exit");

File.add(jMenuItem2);

jMenuBar1.add(File);

Edit.setText("Edit");

jMenuBar1.add(Edit);

Help.setText("help");

jMenuBar1.add(Help);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 736, Short.MAX_VALUE)

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGap(0, 564, Short.MAX_VALUE)

);

pack();

}// </editor-fold>

private void ExitActionPerformed(java.awt.event.ActionEvent evt) {

new LoginForm().setVisible(true); // TODO add your handling code here:

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new mymenu().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JMenu Edit;

private javax.swing.JMenuItem Exit;

private javax.swing.JMenu File;

private javax.swing.JMenu Help;


private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;

private javax.swing.JMenuBar jMenuBar1;

private javax.swing.JMenuItem jMenuItem2;

private javax.swing.JProgressBar jProgressBar1;

private javax.swing.JPopupMenu.Separator jSeparator1;

// End of variables declaration

Log in form

package lab.pkg.menu;

import javax.swing.JOptionPane;

/**

* @author HP

*/

public class LoginForm extends javax.swing.JFrame {

/**

* Creates new form LoginForm

*/

public LoginForm() {

initComponents();

/**

* This method is called from within the constructor to initialize the form.

* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

txtUserID = new javax.swing.JTextField();

psdPassword = new javax.swing.JPasswordField();

btnLogin = new javax.swing.JButton();

btnExit = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

jLabel2.setText("USER ID");

jLabel3.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N

jLabel3.setText("Password:");

btnLogin.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

btnLogin.setText("Login");

btnLogin.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnLoginActionPerformed(evt);

});
btnExit.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N

btnExit.setText("Exit");

btnExit.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnExitActionPerformed(evt);

});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(248, 248, 248)

.addComponent(btnLogin)

.addGap(119, 119, 119)

.addComponent(btnExit))

.addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(152, 152, 152)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 150,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(66, 66, 66))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addContainerGap()
.addComponent(jLabel2)

.addGap(83, 83, 83)))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(psdPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 278,


Short.MAX_VALUE)

.addComponent(txtUserID))))

.addContainerGap(148, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(232, 232, 232)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(txtUserID, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING))

.addGap(25, 25, 25)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(psdPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 43,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 43,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119,
Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(btnLogin)

.addComponent(btnExit))

.addGap(89, 89, 89))

);
pack();

setLocationRelativeTo(null);

}// </editor-fold>
#include<iostream>

using namespace std;

public class Bicycle

int geardown,gearup,speed;

static public int numberOfBicycles;

Bicycle()

B.speed=30 ;

B.geardown=B.speed-1;

B.gearup=B.speed+2;
}

Bicycle()

A.speed=20;

A.geardown=A.speed-1;

A.gearup=A.speed+2;

void display()

cout<<"For B Cycle:speed:"<<B.speed<<endl;

cout<<"After Break:speed:"<<B.geardown<<endl;

cout<<"After Speedup:speed:"<<B.gearup<<endl;

cout<<"For A Cycle:speed:"<<A.speed<<endl;

cout<<"After Break:speed:"<<A.geardown<<endl;

cout<<"After Speedup:speed:"<<A.gearup<<endl;

void displayNumber()

cout<<"Number of Bicycles: "<<2<<endl;

};

int main()

Bicycle A,B;

display();
displayNumber();

return 0;

You might also like