/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test1exp; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * * @author jcmt */ public class Window2Buttons extends JFrame implements ActionListener { private JButton bButton; private JButton cButton; private JFrame bwindow; private JPanel panel; private JTextField text; private Integer n; private int aP=0; private double ck=0; private Purchase purchase; public Window2Buttons() { n = new Integer(0); bwindow = new JFrame("Sun"); bwindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); bwindow.setVisible(true); } public void AddBWindow( String[] args) { final int WINDOW_WIDTH = 250; final int WINDOW_HEIGHT = 100; purchase = new Purchase(); purchase.setTotalAmount(67.99); bwindow = new JFrame(); bwindow.setSize(WINDOW_WIDTH, WINDOW_HEIGHT); bwindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Total Amount: "); ck = purchase.getTotalAmount(); JLabel label2 = new JLabel(" " + ck+ " "); bButton = new JButton("Back"); cButton = new JButton("Continue"); panel = new JPanel(); panel.add(label); panel.add(label2); panel.add(bButton); panel.add(cButton); bButton.setActionCommand("back"); cButton.setActionCommand("continue"); bButton.addActionListener(this); cButton.addActionListener(this); bwindow.add(panel); bwindow.setVisible(true); } /* private class Bbc extends ActionListener */ @Override public void actionPerformed(ActionEvent e) { if ("back".equals(e.getActionCommand())) { JOptionPane.showMessageDialog(Window2Buttons.this, String.format("Go Back")); } else if ("continue".equals(e.getActionCommand())) { JOptionPane.showMessageDialog(Window2Buttons.this, String.format("Continue")); } } }