- package test;
- import java.awt.Component;
- import java.awt.EventQueue;
- import java.awt.FlowLayout;
- import java.awt.SystemColor;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import javax.swing.AbstractListModel;
- import javax.swing.BorderFactory;
- import javax.swing.DefaultComboBoxModel;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JList;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JPopupMenu;
- import javax.swing.JRadioButton;
- import javax.swing.JTextArea;
- import javax.swing.border.Border;
- import javax.swing.border.EmptyBorder;
- import javax.swing.border.TitledBorder;
- public class payment_1905701 {
- private JFrame frame;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- payment_1905701 window = new payment_1905701();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public payment_1905701() {
- setTitle("Roll No:1905701 Payment Application\r\n");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 480, 397);
- JPanel p2 = new JPanel();
- p2.setBackground(SystemColor.controlHighlight);
- p2.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(p2);
- p2.setLayout(null);
- JPanel p1 = new JPanel();
- p1.setToolTipText("");
- p1.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
- p1.setBackground(SystemColor.controlHighlight);
- p1.setBounds(0, 11, 464, 47);
- p2.add(p1);
- p1.setLayout(null);
- Border b = BorderFactory.createTitledBorder("Billing");
- p1.setBorder(b);
- JRadioButton cl = new JRadioButton("Card Number");
- cl.setBounds(33, 17, 109, 23);
- p1.add(cl);
- JRadioButton cl1 = new JRadioButton("Bill Customer");
- cl1.setBounds(159, 17, 109, 23);
- p1.add(cl1);
- JLabel lblNewLabel = new JLabel("Card Type");
- lblNewLabel.setBounds(23, 92, 72, 20);
- p2.add(lblNewLabel);
- JPanel panel_1 = new JPanel();
- panel_1.setBounds(142, 81, 282, 65);
- p2.add(panel_1);
- panel_1.setLayout(null);
- JList list = new JList();
- list.setModel(new AbstractListModel() {
- String[] values = new String[] {"Visa", "Master Card", "American Express"};
- public int getSize() {
- return values.length;
- }
- public Object getElementAt(int index) {
- return values[index];
- }
- });
- list.setBounds(0, 0, 179, 54);
- panel_1.add(list);
- JLabel lblNewLabel_1 = new JLabel("Card Number");
- lblNewLabel_1.setBounds(23, 177, 72, 20);
- p2.add(lblNewLabel_1);
- JTextArea t = new JTextArea();
- t.setBounds(142, 175, 282, 22);
- p2.add(t);
- JLabel lblNewLabel_2 = new JLabel("Expiration Date:");
- lblNewLabel_2.setBounds(23, 218, 98, 20);
- p2.add(lblNewLabel_2);
- JPanel panel_2 = new JPanel();
- panel_2.setBackground(SystemColor.controlHighlight);
- panel_2.setBounds(0, 249, 464, 47);
- p2.add(panel_2);
- panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
- JCheckBox v = new JCheckBox("Varified");
- panel_2.add(v);
- JButton accept = new JButton("Accept");
- accept.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showConfirmDialog(accept, this, "accept", 0);
- accept.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- String str = " ";
- String yv = "";
- if (cl.isSelected()) {
- if (cl1.isSelected()) {
- yv = "Card has been Verified";
- }
- else {
- yv = "Card has been not verified";
- }
- JComboBox mon;
- JComboBox year;
- str = "Bill " + list.getSelectedValue() + System.lineSeparator() + "Number+" + t.getText() + System.lineSeparator() + "Expiary date: " + mon.getSelectedItem() +","+ year.getSelectedItem() + System.lineSeparator();
- }
- else if (list.isSelected()) {
- str = "Customer will be billed";
- }
- else {
- str = "Please Choose a Billing Option";
- }
- // JOptionPane.showMessageDialog(PaymentApp_1905698.this, String.valueOf(str + yv);
- }
- });
- }
- });
- accept.setForeground(SystemColor.windowText);
- accept.setBackground(SystemColor.textHighlight);
- accept.setBounds(257, 324, 89, 23);
- p2.add(accept);
- // jf.setTitle("aja");
- JButton exit = new JButton("Exit");
- exit.setBounds(365, 324, 89, 23);
- p2.add(exit);
- accept.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- }
- });
- JComboBox mon = new JComboBox();
- mon.setBackground(SystemColor.controlHighlight);
- mon.setModel(new DefaultComboBoxModel(new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}));
- mon.setBounds(152, 217, 100, 22);
- p2.add(mon);
- JComboBox year = new JComboBox();
- year.setBackground(SystemColor.controlHighlight);
- year.setModel(new DefaultComboBoxModel(new String[] {"1990", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023"}));
- year.setBounds(278, 217, 78, 22);
- p2.add(year);
- }
- private void setContentPane(JPanel p2) {
- // TODO Auto-generated method stub
- }
- private void setBounds(int i, int j, int k, int l) {
- // TODO Auto-generated method stub
- }
- private void setDefaultCloseOperation(int exitOnClose) {
- // TODO Auto-generated method stub
- }
- private void setTitle(String string) {
- // TODO Auto-generated method stub
- }
- // private void jButtonActionperformed(java.awt.event.ActionEvent evt) {
- // JOptionPane.showInputDialog(f, "jsdaa", "exit");
- //
- // }
- private static void addPopup(Component component, final JPopupMenu popup) {
- component.addMouseListener(new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- if (e.isPopupTrigger()) {
- showMenu(e);
- }
- }
- public void mouseReleased(MouseEvent e) {
- if (e.isPopupTrigger()) {
- showMenu(e);
- }
- }
- private void showMenu(MouseEvent e) {
- popup.show(e.getComponent(), e.getX(), e.getY());
- }
- });
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.setBounds(100, 100, 450, 300);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- }
Hacking Course: Explore a vast array of courses spanning different subjects, from technology and arts to business and personal development. Our expert instructors curate each course to ensure you receive top-notch, up-to-date content.
Please click on ads
Please click on ads
Wednesday, 3 November 2021
create a payment application in java by using swing -eclipse
Subscribe to:
Post Comments (Atom)
-
https://drive.google.com/drive/u/0/my-drive
-
click here
No comments:
Post a Comment