Skip to content

Commit 69c1816

Browse files
committed
Merge branch 'JohnDev'
2 parents 12aaa33 + af3aa83 commit 69c1816

13 files changed

Lines changed: 113 additions & 51 deletions

Mini Project/src/CardLayoutFrame.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ private void createGamePanel()
149149
// Fourth Unique Panel Results/Score Screen
150150
private void createResultsPanel()
151151
{
152+
ResultLabelFrame framyLabel = new ResultLabelFrame(); // create LabelFrame
153+
framyLabel.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
154+
framyLabel.setSize( 500, 500 ); // set frame size
155+
framyLabel.setVisible( true ); // display frame
152156
JPanel resultsPanel = new JPanel();
153157
resultsPanel.add(new JLabel("Results Screen: " + username + " scored: " + score));
154158
cardPanel.add(resultsPanel, "R");

Mini Project/src/LabelFrame.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import javax.swing.*;
2+
import java.awt.*;
3+
4+
public class LabelFrame extends JFrame {
5+
public JLabel label3; // JLabel with added text and icon
6+
7+
// LabelFrame constructor adds JLabels to JFrame
8+
public LabelFrame() {
9+
super("Custom Image");
10+
setLayout(new BorderLayout()); // set frame layout
11+
12+
// JLabel constructor with string, Icon and alignment arguments
13+
Icon WelcomingImage = new ImageIcon(getClass().getResource("openImage.jpg"));
14+
15+
label3 = new JLabel(); // JLabel constructor no arguments
16+
label3.setText("Label with icon and text at bottom");
17+
label3.setIcon(WelcomingImage); // add icon to JLabel
18+
label3.setHorizontalTextPosition(SwingConstants.CENTER);
19+
label3.setVerticalTextPosition(SwingConstants.BOTTOM);
20+
label3.setToolTipText("This is label3");
21+
add(label3); // add label3 to JFrame
22+
23+
24+
// add( label2 ); // add label3 to JFrame
25+
26+
}// end LabelFrame constructor
27+
}

Mini Project/src/Main.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ public static void main(String[] args)
66
{
77
CardLayoutFrame frame = new CardLayoutFrame();
88
frame.setSize(800,600);
9-
frame.setTitle("Trivia Game by John");
9+
frame.setTitle("Trivia Game by John and Ella");
10+
LabelFrame labelFrame = new LabelFrame(); // create LabelFrame
11+
labelFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
12+
labelFrame.setSize( 500, 500 ); // set frame size
13+
labelFrame.setVisible( true ); // display frame
1014
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
1115
frame.setLocationRelativeTo(null); // Set the location of this frame by some component. null means center
1216
frame.setVisible(true);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import javax.swing.*;
2+
import java.awt.BorderLayout;
3+
4+
public class ResultLabelFrame extends JFrame {
5+
6+
public JLabel label2; // JLabel with added text and icon
7+
8+
public ResultLabelFrame() {
9+
super( "Custom Image" );
10+
setLayout( new BorderLayout() ); // set frame layout
11+
12+
// JLabel constructor with string, Icon and alignment arguments
13+
Icon ResultsPercentages = new ImageIcon( getClass().getResource( "resultsImage.jpg" ) );
14+
15+
label2 = new JLabel(); // JLabel constructor no arguments
16+
label2.setText("Label with icon and text at bottom");
17+
label2.setIcon(ResultsPercentages ); // add icon to JLabel
18+
label2.setHorizontalTextPosition(SwingConstants.CENTER );
19+
label2.setVerticalTextPosition(SwingConstants.BOTTOM );
20+
label2.setToolTipText("This is label2");
21+
22+
label2.setSize(500,500); // set frame size
23+
label2.setVisible(true); // display frame
24+
25+
add(label2);
26+
}
27+
}

Mini Project/src/openImage.jpg

-589 KB
Loading

Mini Project/src/resultsImage.jpg

-233 KB
Loading
0 Bytes
Binary file not shown.
Binary file not shown.
-1.28 KB
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)