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
86 lines (75 sloc) 2.49 KB
package view;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import model.DoodadCard;
public class DoodadCardWindow {
private JFrame mainFrame;
private JLabel headerLabel;
private JLabel statusLabel;
private JPanel controlPanel;
public DoodadCardWindow(){
prepareGUI(null);
}
public static void main(String[] args){
DoodadCardWindow DoodadCardWindow = new DoodadCardWindow();
DoodadCardWindow.showButtonDemo();
}
private void prepareGUI(DoodadCard dc){
mainFrame = new JFrame("Doodad");
mainFrame.getContentPane().setBackground(new Color(250, 51, 51));
mainFrame.setSize(350,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);
headerLabel.setFont(headerLabel.getFont().deriveFont(Font.BOLD, 16f));
statusLabel = new JLabel("",JLabel.CENTER);
statusLabel.setSize(350,100);
controlPanel = new JPanel();
controlPanel.setLayout(new FlowLayout());
controlPanel.setBackground(new Color(250, 51, 51));
mainFrame.add(headerLabel);
mainFrame.add(controlPanel);
mainFrame.add(statusLabel);
mainFrame.setVisible(true);
}
public void showButtonDemo(){
headerLabel.setText("Call Doodad Title here");
statusLabel.setText("Call Doodad Description here");
//resources folder should be inside SWING folder.
JButton payDoodad = new JButton("Pay");
// payDoodad.setLayout(null);
// payDoodad.setLocation(10,220);
payDoodad.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//put message that they payDoodad xx dollars after 10 seconds, close window
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// statusLabel.setText("whatever now equals xx dollars");
System.exit(0);
}
});
controlPanel.add(payDoodad);
mainFrame.setVisible(true);
}
}