Samiludin La ResiTugas&Praktik - PBO - Pertemuan10

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Hasil Kegiatan Praktikum

Program Studi Teknik Komputer


Mata Kuliah / Kelas Pemrograman Berorientasi Objek
NPM 5221011052
Nama Samiludin L.R

Hari Kamis
Tanggal 14-12-1023
Ruang Zoom
Materi Jform

KEGIATAN PRAKTIKUM DI LAB


0 Kegiatan yang Dilakukan Membuat jform biodata dengan format Nama, Asal, dan Agama
Deskripsi Menampilkan hasil runningnya
Kode Program:
import javax.swing.table.DefaultTableModel;

public class Jform11 extends javax.swing.JPanel {

/**
* Creates new form Jform11
*/
public Jform11() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
tabel.addRow(new Object[] {
Nama_input.getText(),
Asal_input.getText(),
(String)Agama_input.getSelectedItem()
});
Tabel_Biodata.setModel(tabel);
Nama_input.setText("");
Asal_input.setText("");
}
private javax.swing.JComboBox<String> Agama_input;
private javax.swing.JTextField Asal_input;
private javax.swing.JTextField Nama_input;
private javax.swing.JTable Tabel_Biodata;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JScrollPane jScrollPane1;
int baris = 0;
static Object kolom[] = {"Nama", "Asal", "Agama"};
DefaultTableModel tabel = new DefaultTableModel(kolom, baris);

Hasil Running Program:


TUGAS TAKEHOME
1 Soal - Buat project dengan Nama NPM Anda.
- Buat formulir pemesanan tiket acara dengan JForm di NetBeans. Formulir
tersebut harus mencakup input untuk nama acara, tanggal, jumlah tiket, dan
cara pembayaran.
- Lakukan penambahan pada tabel sebanyak 15 baris data
- Capture hasil project Anda
- hasil screenshoot harus menampilkan nama Project Anda

import javax.swing.table.DefaultTableModel;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/

/**
*
* @author ACER
*/
public class SamiludinLR extends javax.swing.JFrame {

/**
* Creates new form SamiludinLR
*/
public SamiludinLR() {
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() {

jLabel4 = new javax.swing.JLabel();


Pembayaran_input = new javax.swing.JComboBox<>();
Tanggal_input = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
Acara_input = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
Jumlah_input = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
Table_Konser = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel4.setText("Tanggal");

Pembayaran_input.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Gopay",


"Transfer Bank", "Dana", "Shoppypay" }));
Pembayaran_input.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Pembayaran_inputActionPerformed(evt);
}
});

Tanggal_input.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Tanggal_inputActionPerformed(evt);
}
});

jLabel2.setText("Nama Pemesan");

jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Form Pemesanan Tiket Konser xxxtentacion");

Acara_input.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Acara_inputActionPerformed(evt);
}
});

jLabel3.setText("Cara Pembayaran");

jLabel5.setText("Jumlah Tiket");

jButton1.setText("ADD");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("Delate");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

Table_Konser.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Nama Acara", "Tanggal", "Jumlah Tiket", "Cara Pembayaran"
}
){
boolean[] canEdit = new boolean [] {
false, false, true, false
};

public boolean isCellEditable(int rowIndex, int columnIndex) {


return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(Table_Konser);

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(72, 72, 72)
.addComponent(jButton1)
.addGap(48, 48, 48)
.addComponent(jButton2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(Acara_input, javax.swing.GroupLayout.DEFAULT_SIZE, 198,
Short.MAX_VALUE)
.addComponent(Jumlah_input)
.addComponent(Tanggal_input))
.addComponent(Pembayaran_input, javax.swing.GroupLayout.PREFERRED_SIZE,
80, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 5, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(Acara_input, 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.LEADING)
.addComponent(jLabel4)
.addComponent(Tanggal_input, 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.LEADING)
.addComponent(jLabel5)
.addComponent(Jumlah_input, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(Pembayaran_input, 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.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(164, 164, 164))
);

pack();
}// </editor-fold>

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


// TODO add your handling code here:
}

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


// TODO add your handling code here:
}

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


// TODO add your handling code here:
}

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


// Method ADD
tabel.addRow(new Object[] {
Acara_input.getText(),
Tanggal_input.getText(),
Jumlah_input.getText(),
Pembayaran_input.getSelectedItem()
});
Table_Konser.setModel(tabel);
Acara_input.setText("");
Tanggal_input.setText("");
Jumlah_input.setText("");

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


// Method Delete
int barisDipilih = Table_Konser.getSelectedRow();
if (barisDipilih >= 0){
tabel.removeRow (barisDipilih);
}
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
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(SamiludinLR.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(SamiludinLR.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(SamiludinLR.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(SamiludinLR.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>

/* Create and display the form */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new SamiludinLR().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JTextField Acara_input;
private javax.swing.JTextField Jumlah_input;
private javax.swing.JComboBox<String> Pembayaran_input;
private javax.swing.JTable Table_Konser;
private javax.swing.JTextField Tanggal_input;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
int baris = 0;
static Object kolom [] = {"Nama Acara", "Tanggal", "Jumlah Tiket", "Cara Pembayaran"};
DefaultTableModel tabel = new DefaultTableModel (kolom,baris);
}
Hasil Running Program:
1. Buat project dengan Nama NPM Anda.

2. Buat formulir pemesanan tiket acara dengan JForm di NetBeans. Formulir tersebut harus mencakup
input untuk nama acara, tanggal, jumlah tiket, dan cara pembayaran.
3. Lakukan penambahan pada tabel sebanyak 15 baris data dan Capture hasil project Anda

You might also like