0% found this document useful (0 votes)
54 views3 pages

Tugas Prak

This document contains the code for a Java program that creates a graphical user interface (GUI) for inputting and processing patient medical data. The GUI contains labels and text fields for inputting a patient's ID, name, illness, medication name, quantity, price and calculating the total cost. Buttons are included to process the input, save it, and exit the program. The code implements event handlers for the buttons that perform the respective actions like calculating totals, displaying an output dialog, and closing the application.

Uploaded by

Rizky Nogami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Tugas Prak

This document contains the code for a Java program that creates a graphical user interface (GUI) for inputting and processing patient medical data. The GUI contains labels and text fields for inputting a patient's ID, name, illness, medication name, quantity, price and calculating the total cost. Buttons are included to process the input, save it, and exit the program. The code implements event handlers for the buttons that perform the respective actions like calculating totals, displaying an output dialog, and closing the application.

Uploaded by

Rizky Nogami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sintax pada Notepad .

import javax.swing.*;
import java.awt.event.*;
public class dvd extends JFrame implements ActionListener {
String IDsewa;
String Jasasewa;
String nma;
String Lama;
String Jumlah;
String Harga;
String Total;
private JPanel jpdvd = new JPanel();
private JLabel lblIDsewa = new JLabel("ID"),
lblJasasewa = new JLabel("Nama Pasien"),
lblnma= new JLabel("Penyakit"),
lblLama= new JLabel("Nama Obat"),
lblJumlah= new JLabel("Jumlah Obat"),
lblHarga= new JLabel("Harga Obat"),
lblTotal= new JLabel("Total Bayar");
private JTextField txtIDsewa = new JTextField(),
txtJasasewa = new JTextField(),
txtnma = new JTextField(),
txtLama = new JTextField(),
txtJumlah = new JTextField(),
txtHarga = new JTextField(),
txtTotal = new JTextField();
private JButton btnProses = new JButton("Proses"),btnSimpan = new
JButton("Simpan"),btnKeluar= new JButton("Keluar");
dvd(){
super("Data Pasien Pukesmas");
setSize(500,500);
jpdvd.setLayout(null);
lblIDsewa.setBounds(15, 20, 100, 25);
lblJasasewa.setBounds(15, 60, 100, 25);
lblnma.setBounds(15, 100, 100, 25);
lblLama.setBounds(15, 140, 100, 25);
lblJumlah.setBounds(15, 180, 100, 25);
lblHarga.setBounds(15, 220, 100, 25);
lblTotal.setBounds(15, 260, 100, 25);
txtIDsewa.setBounds(115, 20, 100, 25);
txtJasasewa.setBounds(115, 60, 100, 25);
txtnma.setBounds(115, 100, 100, 25);
txtLama.setBounds(115, 140, 100, 25);
txtJumlah.setBounds(115, 180, 100, 25);
txtHarga.setBounds(115, 220, 100, 25);
txtTotal.setBounds(115, 260, 100, 25);
btnProses.setBounds(340, 20, 85, 25);
btnSimpan.setBounds(340, 100, 85, 25);
btnKeluar.setBounds(340, 170, 85, 25);
jpdvd.add(lblIDsewa);
jpdvd.add(lblJasasewa);
jpdvd.add(lblnma);
jpdvd.add(lblLama);
jpdvd.add(lblJumlah);
jpdvd.add(lblHarga);
Rizky syah Putra
1220305059

jpdvd.add(lblTotal);
jpdvd.add(txtIDsewa);
jpdvd.add(txtJasasewa);
jpdvd.add(txtnma);
jpdvd.add(txtLama);
jpdvd.add(txtJumlah);
jpdvd.add(txtHarga);
jpdvd.add(txtTotal);
jpdvd.add(btnProses);
jpdvd.add(btnSimpan);
jpdvd.add(btnKeluar);
btnProses.addActionListener(this);
btnSimpan.addActionListener(this);
btnKeluar.addActionListener(this);
getContentPane().add(jpdvd);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new dvd();
// TODO code application logic here
}
public void actionPerformed(ActionEvent e) {
double Lama,Jumlah,jmlh,Harga,Total;
if (e.getSource()==btnProses)
{
Lama=Double.parseDouble(txtLama.getText());
Jumlah=Double.parseDouble(txtJumlah.getText());
Harga=Double.parseDouble(txtHarga.getText());
jmlh=Jumlah*Harga;
txtTotal.setText("jmlh =");
txtTotal.setText(""+jmlh);
}

Object obj = e.getSource();


if(obj == btnProses);
if(obj == btnSimpan){
Proses();
}
if(obj == btnKeluar){
Keluar();
}
}
void Proses() {
JOptionPane.showMessageDialog(null,("ID :"+txtIDsewa.getText()
+"\nNama Pasien :"+txtJasasewa.getText()
+"\nPenyakit :"+txtnma.getText()+"\nNama obat :"+txtLama.getText()+"\nJumlah
Obat :"+txtJumlah.getText()+"\nHarga Obat:"+txtHarga.getText()+"\nTotal
Bayar :"+txtTotal.getText()));
}
void Keluar() {
setVisible(true);
Rizky syah Putra
1220305059

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
System.exit(1);
}
}
Output Program

Klik simpan lalu keluar message

Rizky syah Putra


1220305059

You might also like