Gesamte Klasse:
package de.alxanderbu.game03.label;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferStrategy;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import de.alxanderbu.game03.engine.EventHandler;
import de.alxanderbu.game03.main.Var;
public class Label1920x1080 extends JLabel {
BufferStrategy buff;
private static final long serialVersionUID = 1L;
public void Renderer() {
new Thread().start();
}
protected void paintComponent(final Graphics g) {
super.paintComponent(g);
Graphics2D gd2 = (Graphics2D)g;
Var.jf1 = new JFrame();
Var.buttonstart = new JButton();
gd2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
//Background
if(Var.counter < 5000) {
g.setColor(new Color(0, 0, 0, 255));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
}
/*if(Var.fadein < 255) {
try {
Var.fadein = Var.fadein - 1;
g.setColor(new Color(0, 0, 0, Var.fadein));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
Thread.sleep(20);
} catch(Exception e) { e.printStackTrace(); }
}*/
//Counter
if(Var.counter < 3000) {
Var.counter = Var.counter + 1;
}
//Intro
if(Var.counter <= 1900) {
g.drawImage(Var.background, 760, 340, 400, 400, null);
g.setColor(new Color(255, 255, 255, 255));
g.setFont(new Font("Arial", 0, 12));
g.drawString("©ProjectHub-Games", 1760, 1020);
g.setFont(new Font("Arial", Font.BOLD, 60));
g.drawString("Transport King", 730, 150);
if(Var.fadein == true) {
if(Var.fadein1 > 0) {
try {
Var.fadein1 = Var.fadein1 - 1;
g.setColor(new Color(0, 0, 0, Var.fadein1));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
Thread.sleep(6);
} catch(Exception e) { e.printStackTrace(); }
}
}
if(Var.counter >= 1650 && Var.counter < 2000) {
if(Var.fadeout == true) {
if(Var.fadeout1 >= 0) {
try {
Var.fadeout1 = Var.fadeout1 + 1;
g.setColor(new Color(0, 0, 0, Var.fadeout1));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
Thread.sleep(6);
} catch(Exception e) { e.printStackTrace(); }
}
if(Var.fadeout1 == 255) {
Var.fadeout = false;
}
}
}
}
//Mainmenu
if(Var.counter > 2900) {
Var.buttonstart = new JButton(Var.bstartgame);
g.setColor(new Color(0, 0, 0, 255));
g.setFont(new Font("Arial", 0, 40));
g.drawString("Transport King", 500, 100);
g.setColor(new Color(200, 200, 255, 255));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
Var.buttonstart.setBounds(100, 20, 910, 600);
Var.buttonstart.setBackground(new Color(200, 200, 200));
Var.buttonstart.setFocusPainted(false);
Var.buttonstart.setBorder(BorderFactory.createLineBorder(Color.BLACK));
Var.buttonstart.addActionListener(new EventHandler());
Var.buttonstart.setVisible(true);
Var.jf1.add(Var.buttonstart);
Var.jf1.setVisible(true);
if(Var.fadein == true) {
if(Var.fadein2 > 0) {
try {
Var.fadein2 = Var.fadein2 - 1;
g.setColor(new Color(0, 0, 0, Var.fadein2));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
Thread.sleep(4);
} catch(Exception e) { e.printStackTrace(); }
}
if(Var.fadein2 == 0) {
Var.fadein = false;
}
}
}
//Pausemenu
if(Var.pause) {
g.setColor(new Color(0, 0, 0, 100));
g.fillRect(0, 0, Var.screenwidth, Var.screenheight);
}
repaint();
}
}