Re: [問題] 如何在視窗輸入參數後,繼續執行main?
※ 引述《popcorny (畢業了..@@")》之銘言:
: 發現真的很多人想要在main去拿UI的資料耶...
: 我隨便寫一個...拿去用用看
: https://gist.github.com/4351530
感謝這位板友的回應
我原來的程式是將事件處理寫在TextFieldGUI.java的listener裡
//負責各種元件和listener
public class TextFieldGUI extends JFrame {
private JButton queryButton, addButton, updateButton, delButton;
.
.
.
queryButton = new JButton("查詢");
componentList.add(queryButton);
queryButton.addActionListener(new QueryButtonListener());
addButton = new JButton("新增");
componentList.add(addButton);
addButton.addActionListener(new AddButtonListener());
.
.
.
//實作QueryButton listener
class QueryButtonListener implements ActionListener {
public void actionPerformed(ActionEvent evtnt) {
//當user按下Button後 呼叫對應的QueryProcessing類別處理,
//textValue為textFiled值
QueryProcessing queryP = new QueryProcessing(textValue);
.
.
.
}
}
//實作AddButton listener
class AddButtonListener implements ActionListener { ... }
}
//負責QueryButton處理方法
public class QueryProcessin {...}
因為我在網路上看到所謂的MVC架構
所以才想到讓TextFieldGUI.java單純接收和回傳value
當作view
由Main.java透過get method接收TextFieldGUI.java的value
並根據不同的button呼叫對應的類別如 QueryProcessing.java
當作control
像QueryProcessing.java就是負責處理queryButton的model
但是就發生Main thread一直執行下去的問題
根據板友的說明 在主程式呼叫似乎很不可取
有方法能像我想的用MVC架構來寫這程式嗎?如果有的話希望能多加提點
或者我想的是錯誤的
請各位板友指教 謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 36.226.23.229
推
12/22 00:17, , 1F
12/22 00:17, 1F
推
12/22 00:22, , 2F
12/22 00:22, 2F
→
12/22 00:52, , 3F
12/22 00:52, 3F
→
12/22 00:56, , 4F
12/22 00:56, 4F
→
12/22 01:01, , 5F
12/22 01:01, 5F
→
12/22 01:04, , 6F
12/22 01:04, 6F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 7 之 7 篇):