因此,最后一个错误是一个错字,但是如果您查看下面的代码,您会发现我设置了一个内容窗格,但是如何添加它,更不用说添加JButton了,因为我需要JButton(s) 我的项目。 提前致谢! :D
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
class FPS {
static double FPS = 0;
public static void handle() {
FPS = 60;
}
public static void crunch() {
FPS = FPS / 2.38482984839483829384928392;
}
}
class Clock {
static int ticks = 0;
public static int tick(int args) {
ticks += args;
return ticks;
}
}
class Assets {
public static String RP = "";
public static String getResourcepack(int ID) {
if(ID == 0) {
RP = "default";
}
else {
RP = "custom";
}
return RP;
}
}
public class Frame {
public static String resource = Assets.getResourcepack(0);
public static int Loop = 1;
public static void main(String[] args) {
while(Loop == 1) {
try {
double VersionNumber = 0.01;
Dimension size = new Dimension(800,600);
String widget1 = "resourcepacks\\"+resource+"\\assets\\textures\\widgets\\button.png";
String titleBG = "resourcepacks\\"+resource+"\\assets\\textures\\title\\sky.png";
String Sun = "resourcepacks\\"+resource+"\\assets\\textures\\misc\\sun1.png";
JFrame Window = new JFrame();
Clock time = new Clock();
FPS Frames = new FPS();
int TOD;
int IT = time.tick(1);
Window.setPreferredSize(size);
Window.setMinimumSize(size);
Window.setResizable(false);
Window.setContentPane(new JLabel(new ImageIcon(titleBG)));
Window.pack();
Window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Window.setTitle("Game");
Window.setLocationRelativeTo(null);
Window.setVisible(true);
while(IT >= 0) {
System.out.println(IT);
IT = time.tick(1);
while(IT > 0) {
TOD = IT / 2400000;
}
}
} catch(Exception e) {
Dimension size = new Dimension(800,600);
JFrame Window = new JFrame();
Window.setTitle("Game");
Window.setPreferredSize(size);
Window.setResizable(false);
Window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Window.setLocationRelativeTo(null);
Window.setContentPane(new JLabel("Sorry, an error occurred"));
e.printStackTrace();
Window.pack();
Window.setVisible(true);
}
}
}
}
有人可以帮忙吗?...真的很麻烦...