我有一個程序,我需要通過Jframe窗口從用戶那里獲取輸入。它就像一個while循環,在這里我調用Jframe窗口并從用戶那里獲取輸入。但是JFrame窗口不會等待輸入并運行循環,直到上一次它應該運行,才在那里等待輸入。我想讓Jframe窗口在while循環的每次迭代中等待輸入。有什么辦法嗎?.../** * Create the frame. */public Janela3(KieSession kSession) { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 462, 447); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); kSession.setGlobal("J3", this); contentPane.setLayout(null); JPanel panelMain = new JPanel(); panelMain.setBackground(new Color(248, 148, 6)); panelMain.setBounds(0, 0, 448, 44); contentPane.add(panelMain); tituloJanela = new JLabel(); tituloJanela.setFont(new Font("Tahoma", Font.BOLD, 24)); tituloJanela.setForeground(new Color(255, 255, 255)); panelMain.add(tituloJanela); kSession.setGlobal("TJ3", tituloJanela); JPanel childPugh = new JPanel(); childPugh.setBounds(0, 44, 448, 364); ...}
1 回答

暮色呼如
TA貢獻1853條經驗 獲得超9個贊
如果我是正確的話,您有一個while循環,您可以在其中獲得用戶輸入,但是如果沒有輸入,循環可能不會繼續嗎?目前,您提供的信息太有限,無法給出具體答案,但我會給您一個機會。
您可以通過使用另一個等待輸入的while循環來解決此問題。檢查下面的“偽半實碼”。
input = getInput();
while (input == null)
{
input = getInput();
}
添加回答
舉報
0/150
提交
取消