亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JFrame等待用戶輸入

JFrame等待用戶輸入

UYOU 2021-04-16 15:15:32
我有一個程序,我需要通過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();

}


查看完整回答
反對 回復 2021-04-21
  • 1 回答
  • 0 關注
  • 193 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號