![](/img/trans.png)
[英]java applet: JProgressBar updating/refreshing only at completion
[英]Java Applet JProgressBar not showing
我是純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);
}
嘗試(在添加偵聽器之后,最后使用它):
frame.setVisible(true);
我希望這對我有幫助,我對純Java而不是android開發更有經驗。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.