Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javafx.application.Application;
- import javafx.application.Platform;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Scene;
- import javafx.scene.control.*;
- import javafx.scene.layout.*;
- import javafx.scene.text.Font;
- import javafx.scene.text.Text;
- import javafx.stage.Stage;
- import javafx.scene.layout.StackPane;
- import javafx.collections.*;
- import javafx.scene.paint.*;
- import javafx.scene.text.*;
- import javafx.scene.Group;
- import java.util.Random;
- import javafx.scene.image.Image;
- import javafx.scene.image.ImageView;
- import java.io.FileInputStream;
- public class Pembelian extends Application
- {
- Text textDaftar = new Text("Daftar Penjualan");
- Text textKasir = new Text("User :");
- Text KodeBarang = new Text("");
- Text textHarga = new Text("");
- Text textJumlah = new Text("");
- Text textTotalBayar = new Text("");
- Text NamaBarang = new Text("");
- Text HargaBarang = new Text("");
- Text TotalHargaText = new Text("");
- TextField textFieldJumlah = new TextField ();
- ObservableList<String> optionsKasir = FXCollections.observableArrayList(
- "Natih",
- "Caca",
- "Catrine"
- );
- final ComboBox comboBoxKasir = new ComboBox(optionsKasir);
- ObservableList<String> optionsBarang = FXCollections.observableArrayList(
- "101",
- "102",
- "103"
- );
- final ComboBox comboBoxBarang = new ComboBox(optionsBarang);
- private int TotalHarga;
- private int harga;
- @Override
- public void start(Stage stage) throws Exception
- {
- Scene scene = new Scene(new Group(), 500, 250);
- stage.setTitle("PEMBELIAN BARANG TOKO CANAT");
- textDaftar.setFont(Font.font("SanSerif",18));
- textKasir.setFont(Font.font("SanSerif",18));
- KodeBarang.setFont(Font.font("SanSerif",18));
- textHarga.setFont(Font.font("SanSerif",18));
- textJumlah.setFont(Font.font("SanSerif",18));
- textTotalBayar.setFont(Font.font("SanSerif",18));
- GridPane grid = new GridPane();
- grid.setVgap(10);
- grid.setHgap(10);
- grid.setPadding(new Insets(10, 10, 10, 10));
- grid.add(new Label("Daftar Barang Jual: "), 0, 0);
- Button buttong = new Button("Click here!");
- grid.add(buttong, 1,0);
- buttong.setOnAction(this::buttonClicks);
- grid.add(new Label("User: "), 0, 1);
- grid.add(comboBoxKasir, 1,1);
- grid.add(new Label("ID Barang: "), 0, 2);
- grid.add(comboBoxBarang, 1,2);
- EventHandler<ActionEvent> event =
- new EventHandler<ActionEvent>() {
- public void handle(ActionEvent e)
- {
- if(comboBoxBarang.getValue() == "101")
- {
- NamaBarang.setText("Pulpen Kokoro");
- HargaBarang.setText("Rp2000");
- harga = 2000;
- }
- else if(comboBoxBarang.getValue() == "102")
- {
- NamaBarang.setText("Pulpen Pilot");
- HargaBarang.setText("Rp2000");
- harga = 2000;
- }
- else if(comboBoxBarang.getValue() == "103")
- {
- NamaBarang.setText("Buku Sidu");
- HargaBarang.setText("Rp3000");
- harga = 3000;
- }
- }
- };
- comboBoxBarang.setOnAction(event);
- grid.add(new Label("Keterangan Barang: "), 0, 3);
- grid.add(NamaBarang, 1,3);
- grid.add(new Label("Harga Barang: "), 0, 4);
- grid.add(HargaBarang, 1,4);
- grid.add(new Label("Jumlah Barang: "), 0, 5);
- grid.add(textFieldJumlah, 1,5);
- EventHandler<ActionEvent> eventJumlah = new EventHandler<ActionEvent>() {
- public void handle(ActionEvent e)
- {
- TotalHarga = Integer.parseInt(textFieldJumlah.getText()) * harga;
- TotalHargaText.setText("Rp"+Integer.toString(TotalHarga));
- }
- };
- textFieldJumlah.setOnAction(eventJumlah);
- grid.add(new Label("Total Bayar: "), 0, 6);
- grid.add(TotalHargaText, 1,6);
- Text title=new Text("Hello Canat Teller");
- title.setFont(Font.font("SanSerif",36));
- Button buttons = new Button("Print Nota");
- grid.add(buttons, 1,7);
- buttons.setOnAction(this::buttonClick);
- Group root = (Group)scene.getRoot();
- root.getChildren().add(grid);
- stage.setScene(scene);
- stage.show();
- buttong.setOnAction(new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent ee){
- PENJUALAN p = new PENJUALAN();
- p.setVisible(true);
- }
- });
- }
- public static void main(String[] args) {
- Application.launch(args);
- }
- private void buttonClicks(ActionEvent ee)
- {
- PENJUALAN p = new PENJUALAN();
- //p.Tampilan();
- }
- private void buttonClick(ActionEvent event)
- {
- Cetak c = new Cetak(NamaBarang, textFieldJumlah.getText(), TotalHargaText);
- c.showCetak();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement