如何判斷GoogleAppEngine文檔頁是否適用于第1/2代標(biāo)準(zhǔn)或靈活的環(huán)境我有一個簡單的Java程序,它讀取一個文本文件,將其拆分為“(空格),顯示第一個單詞,等待2秒,顯示下一個.等等.。我想在Spring或其他GUI中這樣做。對于如何輕松地用Spring更新單詞,有什么建議嗎?遍歷我的列表,并以某種方式使用setText();我運氣不好。我用這種方法把我的話打印出來,并添加了JFrame.在Consol中工作很棒,但卻能生產(chǎn)出無窮無盡的jFrame。我在網(wǎng)上發(fā)現(xiàn)了大部分。 private void printWords() {
for (int i = 0; i < words.size(); i++) {
//How many words?
//System.out.print(words.size());
//print each word on a new line...
Word w = words.get(i);
System.out.println(w.name);
//pause between each word.
try{
Thread.sleep(500);
}
catch(InterruptedException e){
e.printStackTrace();
}
JFrame frame = new JFrame("Run Text File");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel textLabel = new JLabel(w.name,SwingConstants.CENTER);
textLabel.setPreferredSize(new Dimension(300, 100));
frame.getContentPane().add(textLabel, BorderLayout.CENTER);
//Display the window. frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
}
}我有一個用JFrame和JLable創(chuàng)建的窗口,但是我希望靜態(tài)文本是動態(tài)的,而不是加載一個新的Spring窗口。我想它閃現(xiàn)一個字,消失,閃過一個字消失。對如何更新JLabel有什么建議嗎?有重新油漆()的東西嗎?我在畫空白。謝謝!最新情況:在下面善良的人們的幫助下,我已經(jīng)讓它正確地打印到控制臺上。這是我的打印方法:private void printWords() {
final Timer timer = new Timer(500, null);
ActionListener listener = new ActionListener() {
private Iterator<Word> w = words.iterator();
@Override
public void actionPerformed(ActionEvent e) {
if (w.hasNext()) {
_textField.setText(w.next().getName());
//Prints to Console just Fine...
//System.out.println(w.next().getName());
}
else {
timer.stop();
}
}
};
}到達那里.。一旦我,或者誰幫我,我就會把它修好。再次感謝!
添加回答
舉報
0/150
提交
取消