0% found this document useful (0 votes)
50 views5 pages

Table

This Java code creates a graphical user interface (GUI) for calculating the cost of producing a comic book. It imports various Java GUI and formatting libraries. It defines a frame_komik class that extends JFrame and contains methods to build the GUI, add labels, text fields, radio buttons and buttons. It calculates the cost based on number of grayscale and color pages selected and the radio button for price per page. The results are formatted and displayed on the GUI.

Uploaded by

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

Table

This Java code creates a graphical user interface (GUI) for calculating the cost of producing a comic book. It imports various Java GUI and formatting libraries. It defines a frame_komik class that extends JFrame and contains methods to build the GUI, add labels, text fields, radio buttons and buttons. It calculates the cost based on number of grayscale and color pages selected and the radio button for price per page. The results are formatted and displayed on the GUI.

Uploaded by

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

import javax.swing.

*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.KeyStroke;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
public class frame_komik extends JFrame {
public frame_komik (){
JFrame frame = new JFrame("Pembiayaan Pembuatan Buku komik ");

double hasil;

//1 UKURAN BUKU


JLabel lbl1 = new JLabel("1. Pilih Jenis Gambar Yang Diinginkan ");
JTextField t1 = new JTextField();
lbl1.setBounds(10, 10,250, 25);
frame.add(lbl1);
frame.add(t1);

//GAMBAR KOMIK
JLabel lbl = new JLabel(new ImageIcon ("komik.png"));
frame.add(lbl);
lbl.setBounds ( 0, 5, 800,344 );

//PILIHAN KOMIK
JLabel lbl2 = new JLabel("pilihan_komik");

JRadioButton r1=new JRadioButton("Rp.100.000/Halaman");


JRadioButton r2=new JRadioButton("Rp.200.000/Halaman");
JRadioButton r3=new JRadioButton("Rp.300.000/Halaman");

ButtonGroup bg1 =new ButtonGroup ();

r1.setBounds(25, 30,250, 25);


r2.setBounds(310, 30,250, 25);
r3.setBounds(595, 30,250, 25);

bg1.add(r1);
bg1.add(r2);
bg1.add(r3);

frame.add(r1);
frame.add(r2);
frame.add(r3);

//KETERANGAN GAMBAR 1
JLabel lbl3 = new JLabel("Simpel, minim background");
JTextField t3 = new JTextField();
lbl3.setBounds(30, 300,250, 25);
frame.add(lbl3);
frame.add(t3);

//KETERANGAN GAMBAR 2
JLabel lbl4 = new JLabel("Menengah, semi realis");
JTextField t4 = new JTextField();
lbl4.setBounds(320, 300,250, 25);
frame.add(lbl4);
frame.add(t4);

//KETERANGAN GAMBAR 3
JLabel lbl5 = new JLabel("Detail, realis");
JTextField t5 = new JTextField();
lbl5.setBounds(600, 300,250, 25);
frame.add(lbl5);

//2 BERAPA JUMLAH HALAMAN HITAM PUTIH


JLabel lbl6 = new JLabel("2. Berapa Jumlah Halaman Hitam Putih ");
JTextField t6 = new JTextField();
lbl6.setBounds(10,320,250,25);
frame.add(lbl6);
frame.add(t6);
//KOTAK ISIAN
t3.setBounds(320, 320, 50, 25);
frame.add(t3);
//HALAMAN
JLabel lbl7 = new JLabel("Halaman ");
JTextField t7 = new JTextField();
lbl7.setBounds(375, 320, 250, 25);
frame.add(lbl7);
frame.add(t7);

//3 BERAPA JUMLAH HALAMAN WARNA


JLabel lbl8 = new JLabel("3. Berapa Jumlah Halaman Warna (termasuk cover) ");
JTextField t8 = new JTextField();
lbl8.setBounds(10,350,300,25);
frame.add(lbl8);
frame.add(t8);
//KOTAK ISIAN
t4.setBounds(320, 350, 50, 25);
frame.add(t4);
//HALAMAN
JLabel lbl9 = new JLabel("Halaman ");
JTextField t9 = new JTextField();
lbl9.setBounds(375, 350, 250, 25);
frame.add(lbl9);
frame.add(t9);
//KETERANGAN
JLabel lbl10 = new JLabel("*untuk halaman warna, ");
JTextField t10 = new JTextField();
lbl10.setBounds(20,370,500,25);
frame.add(lbl10);
frame.add(t10);
//KETERANGAN BARIS KEDUA
JLabel lbl11 = new JLabel("harga perhalaman mengalami penambahan Rp.100.000 ");
JTextField t11 = new JTextField();
lbl11.setBounds(23,380,500,25);
frame.add(lbl11);
frame.add(t11);

//tombol
JButton bttn1 = new JButton("HITUNG");
bttn1.setBounds(200, 410, 105, 25);
frame.add(bttn1);

JButton bttn2 = new JButton("RESET");


bttn2.setBounds(315, 410, 105, 25);
frame.add(bttn2);

JButton bttn3 = new JButton("KEMBALI KE MENU");


bttn3.setBounds(200, 440, 220, 25);
frame.add(bttn3);

//kotak isian kosong nanti menampilkan hasil

t5.setBounds(425, 410, 150, 55);


frame.add(t5);

frame.setSize(800, 500);

bttn1.addActionListener(new java.awt.event.ActionListener()
{
public void
actionPerformed(java.awt.event.ActionEvent e)
{

if(e.getSource() == bttn1)
{double jumlah;
int jml_grayscale =
Integer.parseInt(t3.getText());
int jml_color =
Integer.parseInt(t4.getText());

if(r1.isSelected()){
jumlah = (jml_grayscale*100000)+(jml_color*200000);
DecimalFormat jmlBayar = (DecimalFormat) DecimalFormat.getCurrencyInstance();
DecimalFormatSymbols rupiah = new DecimalFormatSymbols();
rupiah.setCurrencySymbol("Rp");
rupiah.setMonetaryDecimalSeparator(',');
rupiah.setGroupingSeparator('.');

jmlBayar.setDecimalFormatSymbols(rupiah);

t5.setText(jmlBayar.format(jumlah));
}else{
if(r2.isSelected()){
jumlah= (jml_grayscale*200000)+(jml_color*300000);
DecimalFormat jmlBayar = (DecimalFormat)
DecimalFormat.getCurrencyInstance();
DecimalFormatSymbols rupiah = new DecimalFormatSymbols();

rupiah.setCurrencySymbol("Rp");
rupiah.setMonetaryDecimalSeparator(',');
rupiah.setGroupingSeparator('.');

jmlBayar.setDecimalFormatSymbols(rupiah);

t5.setText(jmlBayar.format(jumlah));
}else{
if(r3.isSelected()){
jumlah = (jml_grayscale*300000)+(jml_color*400000);
DecimalFormat jmlBayar = (DecimalFormat)
DecimalFormat.getCurrencyInstance();
DecimalFormatSymbols rupiah = new DecimalFormatSymbols();

rupiah.setCurrencySymbol("Rp");
rupiah.setMonetaryDecimalSeparator(',');
rupiah.setGroupingSeparator('.');

jmlBayar.setDecimalFormatSymbols(rupiah);

t5.setText(jmlBayar.format(jumlah));
}
}

}
} }});
bttn3.addActionListener(new java.awt.event.ActionListener()
{
public void
actionPerformed(java.awt.event.ActionEvent e)
{

if(e.getSource() == bttn3)
{new frame_menu().setVisible(true);
setLocationRelativeTo(null);
setResizable(false);
frame.setVisible(false);
}}});
frame.setLayout(null);
frame.setVisible(true);
}
public static void main(String[] args){
new frame_komik ();
}
}

You might also like