我是纯Java的初学者,我正在为Android编写简单的应用程序,并且有一个简单的ProgressDialog / Bar可以轻松显示。在这里,在Java中我有一个问题,因为它不想显示。怎么了?
@Override
public void init() {
setSize(Constants._Screen_Width, Constants._Screen_Height);
setBackground(Color.BLACK);
setFocusable(true);
Frame frame = (Frame) this.getParent().getParent();
frame.setTitle("game");
frame.setResizable(false);
try {
background = ImageIO.read( ClassLoader.getSystemResource("data/background.png"));
} catch (IOException e) { e.printStackTrace(); }
this.setBackground(Color.WHITE);
bAnimation1.setFrames(background);
bAnimation1.setXY(0, 0); // first animation is in the left corner
bAnimation1.setDelay(5);
bAnimation2.setFrames(background);
bAnimation2.setXY(1024, 0);
bAnimation2.setDelay(5);
player = new Player(300, 300);
gameloop = new Thread(this);
healthBar=new JProgressBar(0,2000);
healthBar.setBounds(40,40,300,300);
healthBar.setBackground(Color.RED);
healthBar.setValue(50);
healthBar.setStringPainted(true);
add(healthBar);
addKeyListener(this);
}
答案 0 :(得分:0)
尝试(在添加侦听器后最终使用它):
frame.setVisible(true);
我希望有所帮助,我在纯java方面更有经验,而不是在android开发方面。