在益智游戏中刷新 [英] refresh in puzzle game
本文介绍了在益智游戏中刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在益智游戏中,我该如何刷新游戏
at puzzle game , how can i refresh the game
refreshButton = new JButton( "Refresh" );
refreshButton.setBorder( BorderFactory.createRaisedBevelBorder() );
refreshButton.addActionListener( this );
// Add the button to the frame
getContentPane().add( refreshButton, BorderLayout.NORTH );
how that make refresh?
推荐答案
添加按钮:
Add the button:
refreshButton.setText("Refresh");
然后添加侦听器:
And then the listener is added thus:
refreshButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
refreshButtonActionPerformed(evt);
}
});
然后添加方法refreshButtonActionPerformed
:
Then add the method refreshButtonActionPerformed
:
private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here
}
hmmm-您真的认为,他在要求ActionListener吗?那是由IDE提示的,那不应该是问题.
我认为他正在要求ActionPerformed中的代码:
hmmm - do you really think, he''s asking for the ActionListener? That one is prompted by the IDE, that should not be the problem.
I think he''s asking for the code in the ActionPerformed:
private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
someJPanel.repaint();
}
因此,您基本上需要重新粉刷周围的容器.方法重新绘制() [
so you basically need to repaint your surrounding Container. The method repaint()[^] is located in the general Component JComponent and available at most graphical stuff.
regards
Torsten
这篇关于在益智游戏中刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文