https://github.com/khaouitiabdelhakim/quiz-java-swing
This is a simple quiz app of 10 questions about Java using the Swing library
https://github.com/khaouitiabdelhakim/quiz-java-swing
Last synced: 6 months ago
JSON representation
This is a simple quiz app of 10 questions about Java using the Swing library
- Host: GitHub
- URL: https://github.com/khaouitiabdelhakim/quiz-java-swing
- Owner: khaouitiabdelhakim
- Created: 2023-03-31T22:48:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-31T23:00:17.000Z (over 2 years ago)
- Last Synced: 2025-02-11T09:17:56.239Z (8 months ago)
- Language: Java
- Size: 373 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# QUIZ-Java-Swing
This is a simple quiz app of 10 questions about Java using the Swing library
In order to add the cover of the game (I mean the image you see in the app), I override the JComponent Class to draw the image as a Canvas element -> I named this Class
TriviaCanvas```
import java.awt.*;
import javax.swing.JFrame;public class TriviaCanvas extends Canvas{
public void paint(Graphics g) {
Toolkit t=Toolkit.getDefaultToolkit();
String image_path = "" // like "assets/image.jpg"
Image i=t.getImage(image_path);
g.drawImage(i, 0,0,this);}
}
```To use your own fontFamily for the displayed text use this
```
try {
assert stream != null;
Font font = Font.createFont(Font.TRUETYPE_FONT, stream).deriveFont(16f);
l.setFont(font);
} catch (FontFormatException | IOException e) {
throw new RuntimeException(e);
}
```