久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <small id='Yf1A1'></small><noframes id='Yf1A1'>

        <bdo id='Yf1A1'></bdo><ul id='Yf1A1'></ul>
      <tfoot id='Yf1A1'></tfoot>
    1. <i id='Yf1A1'><tr id='Yf1A1'><dt id='Yf1A1'><q id='Yf1A1'><span id='Yf1A1'><b id='Yf1A1'><form id='Yf1A1'><ins id='Yf1A1'></ins><ul id='Yf1A1'></ul><sub id='Yf1A1'></sub></form><legend id='Yf1A1'></legend><bdo id='Yf1A1'><pre id='Yf1A1'><center id='Yf1A1'></center></pre></bdo></b><th id='Yf1A1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Yf1A1'><tfoot id='Yf1A1'></tfoot><dl id='Yf1A1'><fieldset id='Yf1A1'></fieldset></dl></div>

    2. <legend id='Yf1A1'><style id='Yf1A1'><dir id='Yf1A1'><q id='Yf1A1'></q></dir></style></legend>
    3. java中的事件處理和java中actionPerformed方法的執行

      event handling in java and the execution of actionPerformed method in java(java中的事件處理和java中actionPerformed方法的執行)

          <bdo id='yOwPs'></bdo><ul id='yOwPs'></ul>

          <small id='yOwPs'></small><noframes id='yOwPs'>

          1. <tfoot id='yOwPs'></tfoot>

                <tbody id='yOwPs'></tbody>
              <i id='yOwPs'><tr id='yOwPs'><dt id='yOwPs'><q id='yOwPs'><span id='yOwPs'><b id='yOwPs'><form id='yOwPs'><ins id='yOwPs'></ins><ul id='yOwPs'></ul><sub id='yOwPs'></sub></form><legend id='yOwPs'></legend><bdo id='yOwPs'><pre id='yOwPs'><center id='yOwPs'></center></pre></bdo></b><th id='yOwPs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yOwPs'><tfoot id='yOwPs'></tfoot><dl id='yOwPs'><fieldset id='yOwPs'></fieldset></dl></div>
                <legend id='yOwPs'><style id='yOwPs'><dir id='yOwPs'><q id='yOwPs'></q></dir></style></legend>

                本文介紹了java中的事件處理和java中actionPerformed方法的執行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我用java寫了一個simpleGUI的小代碼.

                I have written a small code in java for simpleGUI.

                package guidemo1;
                
                import java.awt.event.ActionEvent;
                import java.awt.event.ActionListener;
                import javax.swing.JButton;
                import javax.swing.JFrame;
                
                public class GuiDemo1 implements ActionListener{
                 JButton button;
                    /**
                     * @param args the command line arguments
                     */
                    public static void main(String[] args) {
                        GuiDemo1 gui=new GuiDemo1();
                        gui.go();
                    }
                
                    public void go()
                    {
                        JFrame frame=new JFrame();
                        button=new JButton();
                        frame.getContentPane().add(button);
                        button.addActionListener(this);
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        frame.setSize(300, 200);
                        frame.setVisible(true);
                
                    }
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        //throw new UnsupportedOperationException("Not supported yet.");
                        button.setText("I've been clicked");
                    }
                }
                

                我是 JAVA 的新手.我有幾個關于這個程序的問題.

                I am newbie to JAVA.I have few questions related to this program.

                有人能解釋一下 actionPerformed 方法是如何在沒有任何調用的情況下執行的嗎?

                Can some one explain how actionPerformed method gets executed with out any call?

                在這里,我在 go() 方法中定義了本地框架對象,我們在 actionPerformed 中使用按鈕,這是另一種方法.這怎么可能?按鈕不是嵌入在框架上嗎?

                Here I have defined frame object locally to the go() method and we are using button in actionPerformed which is another method.How is that possible?Isn't the button gets embedded on the frame?

                謝謝..

                推薦答案

                有人能解釋一下 actionPerformed 方法是如何在沒有任何調用的情況下執行的嗎?

                Can some one explain how actionPerformed method gets executed with out any call?

                GUI 框架 Swing 在后臺運行動作處理代碼.每當按下按鈕或用戶以其他方式與 GUI 交互時,Swing 都會通過許多 Listener 接口之一通知您的應用程序.為了接收這些事件,您的類需要實現正確的 Listener 接口,并在它感興趣的每個組件上注冊為偵聽器.

                The GUI framework Swing runs action handling code in the background. Whenever a button is pressed or the user interacts with the GUI in some other way, Swing will notify your application through one of many Listener interfaces. In order to receive these events, your class needs to implement the proper Listener interface and be registered as a listener on each component it is interested in.

                您的類實現了 ActionListener 接口并調用 addActionListener 將自身注冊到按鈕.當單擊按鈕時,Swing 將嘗試通過調用它們的 actionPerformed 方法來通知所有已注冊的 ActionListener.魔法"就是這樣發生的.

                Your class implements the ActionListener interface and calls addActionListener to register itself to the button. When a button is clicked, Swing will attempt to notify all registered ActionListeners by calling their actionPerformed method. That's how the "magic" happens.

                在這里,我在 go() 方法中定義了本地框架對象,我們在 actionPerformed 中使用按鈕,這是另一種方法.這怎么可能?按鈕不是嵌入在框架上嗎?

                Here I have defined frame object locally to the go() method and we are using button in actionPerformed which is another method.How is that possible?Isn't the button gets embedded on the frame?

                您將按鈕 添加 到框架的內容窗格中 - 這會將按鈕放在框架內的 布局 中,而不是放在 代碼 中.因為您通過將 JButton button; 放在任何方法之外來將 button 聲明為實例變量,所以仍然可以從任何(非 static)方法訪問它在那個班級.

                You add the button to the frame's content pane - this puts the button inside the frame in your layout, not in your code. Because you declare button as an instance variable by putting JButton button; outside any method, it is still accessible from any (non-static) method in that class.

                這篇關于java中的事件處理和java中actionPerformed方法的執行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                How to convert Integer to int?(如何將整數轉換為整數?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                      <tbody id='Oh8RI'></tbody>

                        <bdo id='Oh8RI'></bdo><ul id='Oh8RI'></ul>
                      • <small id='Oh8RI'></small><noframes id='Oh8RI'>

                      • <tfoot id='Oh8RI'></tfoot>

                      • <legend id='Oh8RI'><style id='Oh8RI'><dir id='Oh8RI'><q id='Oh8RI'></q></dir></style></legend>

                        1. <i id='Oh8RI'><tr id='Oh8RI'><dt id='Oh8RI'><q id='Oh8RI'><span id='Oh8RI'><b id='Oh8RI'><form id='Oh8RI'><ins id='Oh8RI'></ins><ul id='Oh8RI'></ul><sub id='Oh8RI'></sub></form><legend id='Oh8RI'></legend><bdo id='Oh8RI'><pre id='Oh8RI'><center id='Oh8RI'></center></pre></bdo></b><th id='Oh8RI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Oh8RI'><tfoot id='Oh8RI'></tfoot><dl id='Oh8RI'><fieldset id='Oh8RI'></fieldset></dl></div>
                        2. 主站蜘蛛池模板: 日韩在线观看网站 | 久久成人一区 | 狠狠的干狠狠的操 | 日韩成人av在线 | 波多野结衣一二三区 | 一区二区三区四区不卡视频 | 成人做爰69片免费观看 | 中文字幕在线观看av | 久久精品av麻豆的观看方式 | 日韩精品免费视频 | 日韩成人免费av | 亚洲va中文字幕 | 精品国产乱码久久久久久图片 | 特一级毛片 | 自拍偷拍亚洲一区 | 中文字幕精品一区 | 免费在线观看一区二区三区 | 国产成人精品一区二三区在线观看 | 成年视频在线观看 | 99热都是精品 | 婷婷午夜天 | 亚洲精品性视频 | 一区久久 | 性福视频在线观看 | 青青久草| 黄色毛片免费看 | 神马九九 | 午夜免费观看网站 | 亚洲 欧美 精品 | 国产精品美女久久久免费 | 91免费小视频| 日韩 欧美 综合 | 欧美精品综合在线 | 一区二区三区中文字幕 | 久久久精品一区二区 | 日韩电影免费在线观看中文字幕 | 亚洲综合大片69999 | 日韩国产欧美在线观看 | 观看av | 色噜噜狠狠色综合中国 | 欧美视频成人 |