Java Window有时候不会加载任何东西,但有时会加载?

时间:2017-07-24 19:28:39

标签: java eclipse jframe window frame

我的Java应用程序有时在eclipse上运行时没有显示任何内容,但有时会显示,有时会显示黑屏(应该是这样),但之后别无其他。 这是我的代码: MainFrame.java

package com.event.main;
import java.awt.*;
import LIBRARY2.APPLICATION.*;
import LIBRARY2.EVENT.*;
import LIBRARY2.UTILITY.*;
import LIBRARY2.VISUAL.*;
public class MainFrame extends ApplicationWindow {
    private static final long serialVersionUID=-7441236L;
    public static MainFrame frame;
    public MainFrame()
    {
        super("KeyMouseCodeChecker",400,400,new MainApplication(new Size(400,400)));
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        this.addThread(new Thread2(this,0));
        this.setVisible(true);
    }
    public void run()
    {

    }
    public void renderGraphics(Graphics2 g2)
    {

    }
    public void renderHUD(Graphics2 g2) 
    {
        KeyboardInput k=this.getKeyboardInput(0);
        MouseInput m=this.getMouseInput(0);
        int KeyCode=k.getKeyCode();
        int MouseCode=m.getMouseCode();
        Coordinate MousePosition=m.getMouseLocation();
        this.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
        g2.background(new Color2(0,0,0));
        g2.toGraphics().setFont(new Font("Tahoma",0,16));
        g2.setColor(new Color2(255,255,255));
        g2.CenterString("KeyCode: "+Integer.toString(KeyCode),200,190,320,20);
        g2.CenterString("MouseCode: "+Integer.toString(MouseCode),200,210,320,20);
        int l=MousePosition.toString().length();
        g2.CenterString("MousePosition: "+MousePosition.toString().substring(28,l),(int)MousePosition.getX(),(int)MousePosition.getY(),320,20);
        if(k.IsThisKeyPressed(27))
        {
            System.exit(0);
        }
    }
    public void doPerSecond(int frames)
    {
        if(frames<95||frames>105)
        {
            System.out.println("FPS: "+frames);
        }
    }
    public static void main(String[] args)
    {
        MainFrame.frame=new MainFrame();
        MainFrame.frame.start();
    }
}

这是我的代码,但是我使用的是图书馆,如果您不理解,我会将代码发布在超类中。

0 个答案:

没有答案