Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create SDStockCard.java
  • Loading branch information
sss13010 committed Apr 7, 2017
1 parent 6afa078 commit 9a99d87
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/view/SDStockCard.java
@@ -0,0 +1,84 @@
package view;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SDStockCard {
private JFrame mainFrame;
private JLabel headerLabel;
private JLabel statusLabel;
private JPanel controlPanel;

public SDStockCard(){
prepareGUI();
}
public static void main(String[] args){
SDStockCard SDStockCard = new SDStockCard();
SDStockCard.showButtonDemo();
}
private void prepareGUI(){
mainFrame = new JFrame("Small Deal");
mainFrame.setSize(400,250);
//need to set this to null and position everything manually
mainFrame.setLayout(new GridLayout(3, 1));

mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent windowEvent){
System.exit(0);
}
});
headerLabel = new JLabel("", JLabel.CENTER);
statusLabel = new JLabel("",JLabel.CENTER);
statusLabel.setSize(350,100);

controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());

mainFrame.add(headerLabel);
mainFrame.add(controlPanel);
mainFrame.add(statusLabel);
mainFrame.setVisible(true);
}

private void showButtonDemo(){
headerLabel.setText("Small Deal Stock Title");
statusLabel.setText("Small Deal Stock Description");

//resources folder should be inside SWING folder.

JTextField BuyStock = new JTextField();
BuyStock.setPreferredSize(new Dimension(25, 25));

JButton NoStocks = new JButton("Don't Buy Stocks");
NoStocks.setHorizontalTextPosition(SwingConstants.LEFT);

BuyStock.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//put message that they BuyStockd xx dollars after 10 seconds, close window
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

statusLabel.setText("You bought xx stocks");


System.exit(0);
}
});

NoStocks.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//put message that they are greedy. after 10 seconds, close window
System.exit(0);
}
});

controlPanel.add(BuyStock);
controlPanel.add(NoStocks);
mainFrame.setVisible(true);
}
}

0 comments on commit 9a99d87

Please sign in to comment.