Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import javafx.application.Application;
  2. import javafx.application.Platform;
  3. import javafx.event.ActionEvent;
  4. import javafx.event.EventHandler;
  5. import javafx.geometry.Insets;
  6. import javafx.geometry.Pos;
  7. import javafx.scene.Scene;
  8. import javafx.scene.control.*;
  9. import javafx.scene.layout.*;
  10. import javafx.scene.text.*;
  11. import javafx.scene.text.Text.*;
  12. import javafx.stage.Stage;
  13. import javafx.scene.control.TextField;
  14. import javafx.scene.layout.VBox;
  15. import javafx.collections.*;
  16.  
  17.  
  18. public class pointofsales extends Application
  19. {
  20.     int harganya;
  21.     @Override
  22.     public void start (Stage stage) throws Exception
  23.     {
  24.        
  25.         GridPane gridPane = new GridPane();  
  26.         gridPane.setMinSize(200, 200);
  27.         gridPane.setPadding(new Insets(10, 10, 10, 10));
  28.         gridPane.setVgap(5);
  29.         gridPane.setHgap(5);
  30.        
  31.         Text title = new Text      ("Nama Kasir  : ");
  32.         Text kodebarang = new Text ("Kode Barang : ");
  33.         Text namabarang = new Text ("Nama Barang : ");
  34.         Text harga = new Text      ("Harga       : ");
  35.         Text jumlahbeli = new Text ("jumlah beli : ");
  36.         Text totalbayar = new Text ("Total Bayar : ");
  37.        
  38.         Button cetak = new Button("Cetak");
  39.        
  40.         TextField textField1 = new TextField();
  41.         TextField textField2 = new TextField();
  42.         //Text final_box = new Text();
  43.         Text hargabar = new Text();
  44.         Text namabox = new Text();
  45.         Text hargatot = new Text();
  46.        
  47.         //String kasir[]= {"Chintya", "Natasha", "Miranda", "Tanyaqila", "Fitriana"};
  48.         //ComboBox final_box =
  49.         //             new ComboBox(FXCollections.observableArrayList(kasir));
  50.        
  51.         gridPane.add(new Label("Nama Kasir: "), 0,1 );
  52.         //gridPane.add(final_box, 1,0);
  53.         gridPane.add(kodebarang, 0, 2);
  54.         gridPane.add(namabarang, 0, 3);
  55.         gridPane.add(harga, 0, 4);
  56.         gridPane.add(jumlahbeli, 0, 5);
  57.         gridPane.add(totalbayar, 0, 6);
  58.        
  59.         gridPane.add(textField1, 1, 1);
  60.         gridPane.add(textField2, 1, 5);
  61.        
  62.         gridPane.add(cetak,3,8);
  63.        
  64.        
  65.        
  66.         String kodebar[] = {"S001","S002","S003","S004","S005", "S006", "S007", "S008",
  67.                             "S009","S010"};
  68.         ComboBox combo_box =
  69.                      new ComboBox(FXCollections.observableArrayList(kodebar));
  70.                      
  71.         gridPane.add(combo_box,1,2);
  72.         EventHandler<ActionEvent> event =
  73.                   new EventHandler<ActionEvent>()
  74.                  
  75.         {
  76.             public void handle(ActionEvent e)
  77.             {
  78.                  if (combo_box.getValue()=="S001")
  79.                  {
  80.                      namabox.setText ("Sabun");
  81.                      hargabar.setText ( "Rp. 2500");
  82.                      harganya=2500;
  83.                     }
  84.                  else if (combo_box.getValue()== "S002")
  85.                  {
  86.                      namabox.setText ("Sampo");
  87.                      hargabar.setText ( "Rp. 3000");
  88.                      harganya=3000;
  89.                  }
  90.                  else if (combo_box.getValue()== "S003")
  91.                  {
  92.                      namabox.setText ("Odol");
  93.                      hargabar.setText ( "Rp. 15000");
  94.                      harganya =15000;
  95.                  }
  96.                  else if (combo_box.getValue()== "S004")
  97.                  {
  98.                      namabox.setText ("Facewash");
  99.                      hargabar.setText ( "Rp. 55000");
  100.                      harganya=55000;
  101.                  }
  102.                  else if (combo_box.getValue()== "S005")
  103.                  {
  104.                      namabox.setText ("Sikat Gigi");
  105.                      hargabar.setText ( "Rp. 25000");
  106.                      harganya=25000;
  107.                  }
  108.                  else if (combo_box.getValue()== "S006")
  109.                  {
  110.                      namabox.setText ("Lulur");
  111.                      hargabar.setText ( "Rp. 34000");
  112.                      harganya=34000;
  113.                  }
  114.                  else if (combo_box.getValue()== "S007")
  115.                  {
  116.                      namabox.setText ("Conditioner");
  117.                      hargabar.setText ( "Rp. 24000");
  118.                      harganya=24000;
  119.                  }
  120.                  else if (combo_box.getValue()== "S008")
  121.                  {
  122.                      namabox.setText ("Toner");
  123.                      hargabar.setText ( "Rp. 57000");
  124.                      harganya=57000;
  125.                  }
  126.                  else if (combo_box.getValue()== "S009")
  127.                  {
  128.                      namabox.setText ("Cleature Vitamin E+");
  129.                      hargabar.setText ( "Rp. 550000");
  130.                      harganya=550000;
  131.                  }
  132.                  else if (combo_box.getValue()== "S010")
  133.                  {
  134.                      namabox.setText ("Cleanser Oil Free");
  135.                      hargabar.setText ( "Rp. 170000");
  136.                      harganya=170000;
  137.                  }
  138.             }
  139.         };
  140.         combo_box.setOnAction(event);
  141.         gridPane.add(namabox,1,3);
  142.         gridPane.add(hargabar,1,4);
  143.        
  144.         EventHandler<ActionEvent> event1 = new EventHandler<ActionEvent>()
  145.         {
  146.             public void handle(ActionEvent e)
  147.             {
  148.                 int jumlah = Integer.parseInt(textField2.getText());
  149.                 jumlah = jumlah * harganya;
  150.                 hargatot.setText (String.valueOf("Rp. " + jumlah));
  151.             }
  152.         };
  153.         textField2.setOnAction(event1);
  154.         gridPane.add(hargatot,1,6);  
  155.        
  156.         EventHandler<ActionEvent> ebutton = new EventHandler<ActionEvent>()
  157.         {
  158.             public void handle(ActionEvent e)
  159.             {
  160.                 VBox box = new VBox();
  161.                 box.setPadding(new Insets(20));
  162.                 box.setSpacing(20);
  163.                 box.setAlignment(Pos.TOP_LEFT);
  164.                
  165.                 Text bukti = new Text("BUKTI PEMBAYARAN TOKO BERSIH POL");
  166.                 //Text kasirkuq = new Text("Nama Kasir : "+kasir.getText());
  167.                 Text nambar = new Text("Nama Barang : "+namabox.getText());
  168.                 Text jumbar = new Text("Jumlah Barang : "+textField2.getText());
  169.                 Text harpi = new Text(" Harga Barang : " +hargabar.getText());
  170.                 Text harbar = new Text("Total Bayar : "+hargatot.getText());
  171.                 Text ywd = new Text("Transaction :: Success");
  172.                 Text yeddd = new Text ("Nama Kasir : " +textField1.getText());
  173.                 Text bacot = new Text (" - Suwun Pol Pelangganku - ");
  174.                
  175.                 box.getChildren().add(bukti);
  176.                 box.getChildren().add(yeddd);
  177.                 box.getChildren().add(nambar);
  178.                 box.getChildren().add(jumbar);
  179.                 box.getChildren().add(harpi);
  180.                 box.getChildren().add(harbar);
  181.                 box.getChildren().add(ywd);
  182.                 box.getChildren().add(bacot);
  183.                
  184.                
  185.                 Scene scene1= new Scene(box,400,400);
  186.                 stage.setTitle (" Point Of Sales");
  187.                 stage.setScene(scene1);
  188.                 stage.show();
  189.             }
  190.         };
  191.         cetak.setOnAction(ebutton);
  192.        
  193.        
  194.         Scene scene= new Scene(gridPane,400,400);
  195.         stage.setTitle (" Point Of Sales");
  196.         stage.setScene(scene);
  197.     stage.show();
  198.     }
  199. }