Skip to content
Permalink
12cc15c255
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
147 lines (129 sloc) 4.43 KB
package view;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import model.*;
public class DealCardWindow {
private JFrame mainFrame;
private JLabel headerLabel;
private JLabel statusLabel;
private JPanel controlPanel;
private JFrame mainFrame2;
private JLabel headerLabel2;
private JLabel statusLabel2;
private JPanel controlPanel2;
public int response;
public DealCardWindow(){
prepareGUI();
}
public static void main(String[] args){
DealCardWindow DealCardWindow = new DealCardWindow();
DealCardWindow.showButtonDemo();
}
private void prepareGUI(){
mainFrame = new JFrame("Deal");
mainFrame.setSize(400,250);
//need to set this to null and position everything manually
mainFrame.setLayout(new GridLayout(3, 1));
mainFrame.getContentPane().setBackground(new Color(38, 230, 58));
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
headerLabel = new JLabel("", JLabel.CENTER);
headerLabel.setFont(headerLabel.getFont().deriveFont(Font.BOLD, 16f));
statusLabel = new JLabel("",JLabel.CENTER);
//new statuslabel of "10% of your whatever is XX dollars"
statusLabel.setSize(350,100);
controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());
controlPanel.setBackground(new Color(38, 230, 58));
mainFrame.add(headerLabel);
mainFrame.add(controlPanel);
mainFrame.add(statusLabel);
mainFrame.setVisible(true);
mainFrame2 = new JFrame("Deal");
mainFrame2.getContentPane().setBackground(new Color(38, 230, 58));
mainFrame2.setSize(400,250);
//need to set this to null and position everything manually
mainFrame2.setLayout(new GridLayout(3, 1));
mainFrame2.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
headerLabel2 = new JLabel("", JLabel.CENTER);
headerLabel2.setFont(headerLabel.getFont().deriveFont(Font.BOLD, 16f));
statusLabel2 = new JLabel("",JLabel.CENTER);
//new statusLabel2 of "10% of your whatever is XX dollars"
statusLabel2.setSize(350,100);
controlPanel2 = new JPanel();
controlPanel2.setLayout(new FlowLayout());
controlPanel2.setBackground(new Color(38, 230, 58));
mainFrame2.add(headerLabel2);
mainFrame2.add(controlPanel2);
mainFrame2.add(statusLabel2);
mainFrame2.setVisible(true);
}
private int showButtonDemo(){
headerLabel.setText("Deal");
statusLabel.setText("What type of deal would you like?");
//resources folder should be inside SWING folder.
JButton BigDeal = new JButton("BigDeal");
JButton SmallDeal = new JButton("SmallDeal");
SmallDeal.setHorizontalTextPosition(SwingConstants.LEFT);
final JButton AcceptDeal = new JButton("Accept Deal");
final JButton DeclineDeal = new JButton("Decline Deal");
DeclineDeal.setHorizontalTextPosition(SwingConstants.LEFT);
BigDeal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//open big deal stuffs
response = 1;
headerLabel2.setText("Big Deal title goes here");
statusLabel2.setText("Big Deal Description goes here");
controlPanel2.add(AcceptDeal);
controlPanel2.add(DeclineDeal);
mainFrame2.setVisible(true);
AcceptDeal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//update methods
System.exit(0);
}
});
DeclineDeal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
});
SmallDeal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
response = 0;
//something to check if stock or not (check via title)
//if not stock
headerLabel2.setText("Small Deal title goes here");
statusLabel2.setText("Small Deal Description goes here");
controlPanel2.add(AcceptDeal);
controlPanel2.add(DeclineDeal);
mainFrame2.setVisible(true);
AcceptDeal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//update methods
System.exit(0);
}
});
DeclineDeal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
});
controlPanel.add(BigDeal);
controlPanel.add(SmallDeal);
mainFrame.setVisible(true);
return response;
}
}