document.write('
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.Font;
  11. import javafx.scene.text.Text;
  12. import javafx.stage.Stage;
  13. import javafx.scene.layout.StackPane;
  14. import javafx.collections.*;
  15. import javafx.scene.paint.*;
  16. import javafx.scene.text.*;
  17. import javafx.scene.Group;
  18. import java.util.Random;
  19.  
  20. public class Pembelian extends Application
  21. {
  22. Text textKasir = new Text("Kasir :");
  23. Text KodeBarang = new Text("");
  24. Text textHarga = new Text("");
  25. Text textJumlah = new Text("");
  26. Text textTotalBayar = new Text("");
  27. Text NamaBarang = new Text("");
  28. Text HargaBarang = new Text("");
  29. Text TotalHargaText = new Text("");
  30. TextField textFieldJumlah = new TextField ();
  31.  
  32. ObservableList<String> optionsKasir = FXCollections.observableArrayList(
  33. "Faqih",
  34. "Hiqaf",
  35. "Doi"
  36. );
  37. final ComboBox comboBoxKasir = new ComboBox(optionsKasir);
  38. ObservableList<String> optionsBarang = FXCollections.observableArrayList(
  39. "AA111",
  40. "BB222",
  41. "CC333"
  42. );
  43. final ComboBox comboBoxBarang = new ComboBox(optionsBarang);
  44.  
  45. private int TotalHarga;
  46. private int harga;
  47.  
  48. @Override
  49. public void start(Stage stage) throws Exception
  50. {
  51. Scene scene = new Scene(new Group(), 500, 250);
  52. stage.setTitle("Pembelian");
  53.  
  54. textKasir.setFont(Font.font("SanSerif",18));
  55. KodeBarang.setFont(Font.font("SanSerif",18));
  56. textHarga.setFont(Font.font("SanSerif",18));
  57. textJumlah.setFont(Font.font("SanSerif",18));
  58. textTotalBayar.setFont(Font.font("SanSerif",18));
  59.  
  60. GridPane grid = new GridPane();
  61. grid.setVgap(10);
  62. grid.setHgap(10);
  63. grid.setPadding(new Insets(10, 10, 10, 10));
  64. grid.add(new Label("Kasir: "), 0, 0);
  65. grid.add(comboBoxKasir, 1,0);
  66. grid.add(new Label("Kode Barang: "), 0, 1);
  67. grid.add(comboBoxBarang, 1,1);
  68.  
  69. EventHandler<ActionEvent> event =
  70. new EventHandler<ActionEvent>() {
  71. public void handle(ActionEvent e)
  72. {
  73. if(comboBoxBarang.getValue() == "AA111")
  74. {
  75. NamaBarang.setText("Bar-end Mirror");
  76. HargaBarang.setText("Rp150000");
  77. harga = 150000;
  78. }
  79. else if(comboBoxBarang.getValue() == "BB222")
  80. {
  81. NamaBarang.setText("Velg");
  82. HargaBarang.setText("Rp2500000");
  83. harga = 2500000;
  84. }
  85. else if(comboBoxBarang.getValue() == "CC333")
  86. {
  87. NamaBarang.setText("Led");
  88. HargaBarang.setText("Rp100000");
  89. harga = 100000;
  90. }
  91.  
  92. }
  93. };
  94.  
  95. comboBoxBarang.setOnAction(event);
  96.  
  97. grid.add(new Label("Nama Barang: "), 0, 2);
  98. grid.add(NamaBarang, 1,2);
  99. grid.add(new Label("Harga: "), 0, 3);
  100. grid.add(HargaBarang, 1,3);
  101. grid.add(new Label("Jumlah: "), 0, 4);
  102.  
  103. grid.add(textFieldJumlah, 1,4);
  104.  
  105. EventHandler<ActionEvent> eventJumlah = new EventHandler<ActionEvent>() {
  106. public void handle(ActionEvent e)
  107. {
  108. TotalHarga = Integer.parseInt(textFieldJumlah.getText()) * harga;
  109. TotalHargaText.setText("Rp"+Integer.toString(TotalHarga));
  110. }
  111. };
  112.  
  113. textFieldJumlah.setOnAction(eventJumlah);
  114.  
  115. grid.add(new Label("Total Bayar: "), 0, 5);
  116. grid.add(TotalHargaText, 1,5);
  117.  
  118. Text title=new Text("POS");
  119. title.setFont(Font.font("SanSerif",36));
  120. Button button = new Button("Cetak");
  121. grid.add(button, 1,6);
  122.  
  123. button.setOnAction(this::buttonClick);
  124.  
  125. Group root = (Group)scene.getRoot();
  126. root.getChildren().add(grid);
  127. stage.setScene(scene);
  128. stage.show();
  129.  
  130.  
  131. }
  132.  
  133. private void buttonClick(ActionEvent event)
  134. {
  135. Cetak c = new Cetak(NamaBarang, textFieldJumlah.getText(), TotalHargaText);
  136. c.showCetak();
  137. }
  138.  
  139. }
');