Untitled
unknown
java
3 years ago
3.8 kB
10
Indexable
package Finals.com.src;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class MainApp extends JFrame implements ActionListener {
public static void main(String args[])
{
new MainApp();
}
private JButton btnAddtoCart;
private JButton btnInfo;
private JButton btnCheckout;
private JButton btnCheckCart;
private JRadioButton game1, game2, game3, game4, game5, game6, sft1, sft2, sft3;
public MainApp()
{
super("SoftwareXGames");
btnAddtoCart = new JButton("Add to cart");
btnInfo = new JButton("Info");
btnCheckout = new JButton("Checkout");
btnCheckCart = new JButton("View Cart");
JLabel label1 = new JLabel("Games Available");
JFrame frame = new JFrame();
JPanel p = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
//software buttons
game1 = new JRadioButton("NBA 2k22");
game2 = new JRadioButton("Borderlands3");
game3 = new JRadioButton("Fall Guys: Ultimate Knockout");
game4 = new JRadioButton("Grand Theft Auto: V");
game5 = new JRadioButton("Counter Strike: Global Offensive");
game6 = new JRadioButton("Plants vs Zombies GOTY");
sft1 = new JRadioButton("Adobe premiere pro");
sft2 = new JRadioButton("Adobe After Effects");
sft3 = new JRadioButton("Windows 10 Pro");
ButtonGroup g = new ButtonGroup();//group all radio buttons
p.setLayout(new GridLayout(11,2));
p3.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(p3, BorderLayout.SOUTH);
g.add(game1);g.add(game2);g.add(game3);g.add(game4);g.add(game5);g.add(game6);
g.add(sft1);g.add(sft2);g.add(sft3);
p.add(label1);
p.add(game1);
p.add(game2);
p.add(game3);
p.add(game4);
p.add(game5);
p.add(game6);
p.add(sft1);
p.add(sft2);
p.add(sft3);
p.add(p3);
p3.add(btnAddtoCart);
p3.add(btnCheckCart);
p3.add(btnInfo);
p3.add(btnCheckout);
btnAddtoCart.addActionListener(this);
btnCheckCart.addActionListener(this);
btnCheckout.addActionListener(this);
btnInfo.addActionListener(this);
game1.addActionListener(this);
game2.addActionListener(this);
game3.addActionListener(this);
game4.addActionListener(this);
game5.addActionListener(this);
game6.addActionListener(this);
frame.add(p, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
frame.setTitle("GamesXSoftware");
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==btnInfo)
{
}
else if(e.getSource()==btnCheckout)
{
int elem=JOptionPane.showConfirmDialog(null, "Are you sure you want to checkout?", "Checkout", JOptionPane.YES_NO_OPTION);
if(elem==0)
{
JOptionPane.showMessageDialog(null, "Items Checked Out!", "Checkout Confirm", JOptionPane.INFORMATION_MESSAGE);
}
}
else if(e.getSource()==btnAddtoCart)
{
int elem=JOptionPane.showConfirmDialog(null, "Add item to Cart?", "Add to Cart", JOptionPane.YES_NO_OPTION);
if(elem==0)
{
JOptionPane.showMessageDialog(null, "Successfully Added to Cart!", "Add to Cart", JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
Editor is loading...