e743. creating a jbutton component.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 13 行

TXT
13
字号
Although it is possible to create a button with just a label, it is highly recommended to use an action to create a button. The action can then be shared by other components such as a toolbar. 
    // Create an action
    Action action = new AbstractAction("Button Label") {
        // This method is called when the button is pressed
        public void actionPerformed(ActionEvent evt) {
            // Perform action...
        }
    };
    
    // Create the button
    JButton button = new JButton(action);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?