import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SimpleForm { public static void main(String[] args){ JFrame myFrame = new JFrame("Form Sederhana"); FlowLayout layout = new FlowLayout(FlowLayout.LEFT); layout.setVgap(10); layout.setHgap(10); final JTextField txtPesan = new JTextField(20); JButton cmdTampil = new JButton("Tampil"); cmdTampil.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ JOptionPane.showMessageDialog(null,txtPesan.getText()); } }); JButton cmdClose = new JButton("Keluar"); cmdClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("Keluar"); System.exit(0); } }); myFrame.getContentPane().setLayout(layout); myFrame.getContentPane().add(txtPesan); myFrame.getContentPane().add(cmdTampil); myFrame.getContentPane().add(cmdClose); myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); myFrame.pack(); myFrame.show(); } }
乳児期にはオリゴ糖がおススメ
6 tahun yang lalu
Tidak ada komentar:
Posting Komentar