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

Coding Menu

This document is the code for a menu form application written in Java. The form contains menus and menu items for managing students, courses, login/logout, and generating reports from a database. The code initializes the form components, connects to a MySQL database, and defines event handlers for the menu items.

Uploaded by

Muhammad Iqbal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Coding Menu

This document is the code for a menu form application written in Java. The form contains menus and menu items for managing students, courses, login/logout, and generating reports from a database. The code initializes the form components, connects to a MySQL database, and defines event handlers for the menu items.

Uploaded by

Muhammad Iqbal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Nama : MUHAMMAD IRFAN

No. Bp : 1920012
Jurusan : Sistem Komputer
Matkul : Praktikum Bahasa Pemograman II
Dosen Matkul : Imam Gunawan, S.Kom, M.Kom
Judul Tugas : Coding Untuk Form Menu
/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

/*

* menu.java

* Created on Apr 10, 2017, 10:59:40 AM

*/

package praktikum15;

import javax.swing.*;

import java.io.File;

import java.util.*;

import java.sql.*;

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.engine.util.*;

import net.sf.jasperreports.view.JasperViewer;

/**

* @author User

*/
public class menu extends javax.swing.JFrame {

public Connection conn;

public Statement cn;

/** Creates new form menu */

public menu() {

initComponents();

public void koneksi(){

try{

Class.forName("com.mysql.jdbc.Driver");

conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/praktikum15","root","");

cn=conn.createStatement();

}catch(Exception e){

JOptionPane.showMessageDialog(null,"koneksi gagal..");

System.out.println(e.getMessage());

/** 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() {

jTextField1 = new javax.swing.JTextField();

jLabel1 = new javax.swing.JLabel();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jMenuItem1 = new javax.swing.JMenuItem();


jMenuItem2 = new javax.swing.JMenuItem();

jMenuItem3 = new javax.swing.JMenuItem();

jMenu2 = new javax.swing.JMenu();

jMenuItem4 = new javax.swing.JMenuItem();

jMenuItem5 = new javax.swing.JMenuItem();

jMenu3 = new javax.swing.JMenu();

jMenuItem6 = new javax.swing.JMenuItem();

jMenuItem7 = new javax.swing.JMenuItem();

jMenuItem8 = new javax.swing.JMenuItem();

jMenuItem9 = new javax.swing.JMenuItem();

jMenu4 = new javax.swing.JMenu();

jMenuItem10 = new javax.swing.JMenuItem();

jMenu5 = new javax.swing.JMenu();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setText("USER AKTIF");

jMenu1.setText("File");

jMenuItem1.setText("Mahasiswa");

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

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

jMenuItem1ActionPerformed(evt);

});

jMenu1.add(jMenuItem1);

jMenuItem2.setText("Matakuliah");

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

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


jMenuItem2ActionPerformed(evt);

});

jMenu1.add(jMenuItem2);

jMenuItem3.setText("Logout");

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

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

jMenuItem3ActionPerformed(evt);

});

jMenu1.add(jMenuItem3);

jMenuBar1.add(jMenu1);

jMenu2.setText("Poses");

jMenuItem4.setText("Entri KRS");

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

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

jMenuItem4ActionPerformed(evt);

});

jMenu2.add(jMenuItem4);

jMenuItem5.setText("Entri Nilai");

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

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

jMenuItem5ActionPerformed(evt);

});
jMenu2.add(jMenuItem5);

jMenuBar1.add(jMenu2);

jMenu3.setText("Cetak");

jMenuItem6.setText("Laporan Matakuliah");

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

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

jMenuItem6ActionPerformed(evt);

});

jMenu3.add(jMenuItem6);

jMenuItem7.setText("Laporan Mahasiswa");

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

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

jMenuItem7ActionPerformed(evt);

});

jMenu3.add(jMenuItem7);

jMenuItem8.setText("Laporan Nilai");

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

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

jMenuItem8ActionPerformed(evt);

});

jMenu3.add(jMenuItem8);

jMenuItem9.setText("Lembar Hasil Studi (LHS)");


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

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

jMenuItem9ActionPerformed(evt);

});

jMenu3.add(jMenuItem9);

jMenuBar1.add(jMenu3);

jMenu4.setText("Setting");

jMenuItem10.setText("User");

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

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

jMenuItem10ActionPerformed(evt);

});

jMenu4.add(jMenuItem10);

jMenuBar1.add(jMenu4);

jMenu5.setText("Bantuan");

jMenuBar1.add(jMenu5);

setJMenuBar(jMenuBar1);

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

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

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

.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 139,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(3076, Short.MAX_VALUE))

);

layout.setVerticalGroup(

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

.addGroup(layout.createSequentialGroup()

.addGap(22, 22, 22)

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

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel1))

.addContainerGap(2349, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

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

// TODO add your handling code here:

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

// TODO add your handling code here:

new mahasiswa().show();

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


// TODO add your handling code here:

new Matakuliah().show();

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

// TODO add your handling code here:

new KRS().show();

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

// TODO add your handling code here:

new Admin().show();

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

// TODO add your handling code here:

new Nilai().show();

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

// TODO add your handling code here:

try{

String nmFile="./Report/lapmatkul.jasper";

koneksi();

HashMap parameter=new HashMap();

File reportFile=new File(nmFile);

JasperReport jReport=(JasperReport)JRLoader.loadObject(reportFile.getPath());

JasperPrint jPrint=JasperFillManager.fillReport(jReport,parameter,conn);

JasperViewer.viewReport(jPrint,false);

JasperViewer.setDefaultLookAndFeelDecorated(true);

conn.close();
}catch(Exception e){

JOptionPane.showMessageDialog(null,"Laporan Tidak Dapat Dicetak!\n"+

e.getMessage(),"Cetak Laporan",JOptionPane.ERROR_MESSAGE);

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

// TODO add your handling code here:

try{

String nmFile="./Report/lapmhs.jasper";

koneksi();

HashMap parameter=new HashMap();

File reportFile=new File(nmFile);

JasperReport jReport=(JasperReport)JRLoader.loadObject(reportFile.getPath());

JasperPrint jPrint=JasperFillManager.fillReport(jReport,parameter,conn);

JasperViewer.viewReport(jPrint,false);

JasperViewer.setDefaultLookAndFeelDecorated(true);

conn.close();

}catch(Exception e){

JOptionPane.showMessageDialog(null,"Laporan Tidak Dapat Dicetak!\n"+

e.getMessage(),"Cetak Laporan",JOptionPane.ERROR_MESSAGE);

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

// TODO add your handling code here:

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

// TODO add your handling code here:


try{

String nmFile="./Report/lapkrs.jasper";

koneksi();

HashMap parameter=new HashMap();

File reportFile=new File(nmFile);

JasperReport jReport=(JasperReport)JRLoader.loadObject(reportFile.getPath());

JasperPrint jPrint=JasperFillManager.fillReport(jReport,parameter,conn);

JasperViewer.viewReport(jPrint,false);

JasperViewer.setDefaultLookAndFeelDecorated(true);

conn.close();

}catch(Exception e){

JOptionPane.showMessageDialog(null,"Laporan Tidak Dapat Dicetak!\n"+

e.getMessage(),"Cetak Laporan",JOptionPane.ERROR_MESSAGE);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

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

public void run() {

new menu().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JLabel jLabel1;

private javax.swing.JMenu jMenu1;

private javax.swing.JMenu jMenu2;


private javax.swing.JMenu jMenu3;

private javax.swing.JMenu jMenu4;

private javax.swing.JMenu jMenu5;

private javax.swing.JMenuBar jMenuBar1;

private javax.swing.JMenuItem jMenuItem1;

private javax.swing.JMenuItem jMenuItem10;

private javax.swing.JMenuItem jMenuItem2;

private javax.swing.JMenuItem jMenuItem3;

private javax.swing.JMenuItem jMenuItem4;

private javax.swing.JMenuItem jMenuItem5;

private javax.swing.JMenuItem jMenuItem6;

private javax.swing.JMenuItem jMenuItem7;

private javax.swing.JMenuItem jMenuItem8;

private javax.swing.JMenuItem jMenuItem9;

private javax.swing.JTextField jTextField1;

// End of variables declaration

You might also like