
![]() Tampilan Aplikasi Berbasis AWT Di Ms Windows | ![]() Tampilan Aplikasi Berbasis AWT Di GNU/Linux |
![]() Tampilan Aplikasi Berbasis AWT Di Ms Windows | ![]() Tampilan Aplikasi Berbasis AWT Di GNU/Linux |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | public class AwtFrame extends java.awt.Frame { private java.awt.CheckboxGroup checkBoxGroup; public AwtFrame() { checkBoxGroup = new java.awt.CheckboxGroup(); initComponents(); } private void initComponents() { panel1 = new java.awt.Panel(); label1 = new java.awt.Label(); txtKdBarang = new java.awt.TextField(); label2 = new java.awt.Label(); txtNmBarang = new java.awt.TextField(); label3 = new java.awt.Label(); checkBoxEceran = new java.awt.Checkbox(); checkBoxPack = new java.awt.Checkbox(); txtArea = new java.awt.TextArea(); button1 = new java.awt.Button(); button2 = new java.awt.Button(); menuBar1 = new java.awt.MenuBar(); menu1 = new java.awt.Menu(); menuItem1 = new java.awt.MenuItem(); menu2 = new java.awt.Menu(); setMinimumSize(new java.awt.Dimension(500, 300)); setTitle("AWT Form Example"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); label1.setText("Kode Barang"); label2.setText("Nama Barang"); label3.setText("Kategori"); checkBoxEceran.setCheckboxGroup(checkBoxGroup); checkBoxEceran.setLabel("Eceran"); checkBoxEceran.setState(true); checkBoxPack.setCheckboxGroup(checkBoxGroup); checkBoxPack.setLabel("Pack"); button1.setLabel("Tambah"); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button1ActionPerformed(evt); } }); button2.setLabel("Clear"); button2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button2ActionPerformed(evt); } }); add(panel1, java.awt.BorderLayout.CENTER); menu1.setLabel("File"); menuItem1.setLabel("Exit"); menuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuItem1ActionPerformed(evt); } }); menu1.add(menuItem1); menuBar1.add(menu1); menu2.setLabel("Edit"); menuBar1.add(menu2); setMenuBar(menuBar1); pack(); }// </editor-fold> /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) { System.exit(0); } private void menuItem1ActionPerformed(java.awt.event.ActionEvent evt) { exitForm(new java.awt.event.WindowEvent(this, WIDTH)); } private void clearField() { txtKdBarang.setText(""); txtNmBarang.setText(""); } private void button1ActionPerformed(java.awt.event.ActionEvent evt) { txtArea.append("\nKode Barang = " + txtKdBarang.getText()); txtArea.append("\nNama Barang = " + txtNmBarang.getText()); txtArea.append("\nKategori Barang = " + checkBoxGroup.getSelectedCheckbox().getLabel()); clearField(); txtKdBarang.requestFocusInWindow(); } private void button2ActionPerformed(java.awt.event.ActionEvent evt) { clearField(); txtArea.setText(""); } // Variables declaration - do not modify private java.awt.Button button1; private java.awt.Button button2; private java.awt.Checkbox checkBoxEceran; private java.awt.Checkbox checkBoxPack; private java.awt.Label label1; private java.awt.Label label2; private java.awt.Label label3; private java.awt.Menu menu1; private java.awt.Menu menu2; private java.awt.MenuBar menuBar1; private java.awt.MenuItem menuItem1; private java.awt.Panel panel1; private java.awt.TextArea txtArea; private java.awt.TextField txtKdBarang; private java.awt.TextField txtNmBarang; } |
Tidak ada komentar:
Posting Komentar