e732. the quintessential swing user interface.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 23 行
TXT
23 行
This example creates and shows a frame with a button. To enable the button to respond to button clicks, see e743 Creating a JButton Component.
import java.awt.*;
import javax.swing.*;
public class BasicUI {
public static void main(String[] args) {
JButton button = new JButton("Label");
JFrame frame = new JFrame();
// Add button to the frame
frame.getContentPane().add(button, BorderLayout.CENTER);
// Set initial size
int frameWidth = 300;
int frameHeight = 300;
frame.setSize(frameWidth, frameHeight);
// Show the frame
frame.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?