Optimized submenu
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package model.objects;
|
||||
|
||||
import image.Images;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
public class DifficultyButton {
|
||||
|
||||
@@ -10,27 +14,35 @@ public class DifficultyButton {
|
||||
private int y;
|
||||
private String str;
|
||||
private Color color;
|
||||
|
||||
private VolatileImage button;
|
||||
|
||||
public DifficultyButton(int y, String str, Color color) {
|
||||
this.y = y;
|
||||
this.str = str;
|
||||
this.color = color;
|
||||
generateButton();
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2) {
|
||||
public void generateButton(){
|
||||
button = Images.initVolatileImage(305, 80, Transparency.OPAQUE);
|
||||
Graphics2D g2 = button.createGraphics();
|
||||
g2.setColor(Color.WHITE);
|
||||
g2.fillRect(x, y, 300, 75);
|
||||
g2.fillRect(0, 0, 300, 75);
|
||||
g2.setColor(Color.ORANGE);
|
||||
g2.drawRect(x, y, 300, 75);
|
||||
g2.drawRect(x-2, y-2, 304, 79);
|
||||
g2.drawRect(0, 0, 300, 75);
|
||||
g2.drawRect(0-2, 0-2, 304, 79);
|
||||
|
||||
g2.setColor(color);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
g2.setFont(textFont2);
|
||||
|
||||
g2.drawString(str, x+5, y+50);
|
||||
|
||||
g2.drawString(str, 0+5, 0+50);
|
||||
g2.dispose();
|
||||
button.createGraphics();
|
||||
}
|
||||
|
||||
public void draw(Graphics2D g2) {
|
||||
g2.drawImage(button, x, y, 305, 80, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user