Project | Class | Code |
Tri-Vial | App |
public class App {
|
Tri-Vial | CongrantsView | import java.awt.BorderLayout;
import java.awt.Color; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; public class CongratsView extends JPanel { JTextArea picture; JLabel congratsPicture; CongratsViewBottomPanel congratsBottom; CongratsView(String name, int score, int totalTime) { congratsBottom = new CongratsViewBottomPanel(name, score, totalTime); picture = new JTextArea("Congradulations! \n\n * All questions on this level are finished!"); congratsPicture = new JLabel(new ImageIcon("src/pkgfinal/Image/congrats.png")); setLayout(new BorderLayout()); setBackground(Color.RED); if(score > 10000){ setBackground(Color.GREEN); } add(picture, BorderLayout.NORTH); add(congratsPicture, BorderLayout.CENTER); add(congratsBottom, BorderLayout.SOUTH); } public JLabel getCongratsButton() { return congratsPicture; } public JTextArea getPicture() { return picture; } public void setPicture(JTextArea picture) { this.picture = picture; } public void setCongratsButton(JLabel CongratsButton) { this.congratsPicture = CongratsButton; } } |
Tri-Vial | CongratsViewBottomPanel | import javax.swing.JLabel;
import javax.swing.JPanel; public class CongratsViewBottomPanel extends JPanel { JLabel userScoreLabel; JLabel userNameLabel; JLabel timeLabel; public CongratsViewBottomPanel(String name, int score, int totalTime) { super(); userNameLabel = new JLabel(" Congrats " + name + "."); userScoreLabel = new JLabel("Your Total Score Was " + String.valueOf(score) + "."); timeLabel = new JLabel("Your Total Time Was " + String.valueOf(totalTime) + "s."); add(userScoreLabel); add(userNameLabel); add(timeLabel); } } |