e559. creating a frame.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 26 行
TXT
26 行
A frame is a top-level window with a title bar and buttons for iconizing, maximizing, and closing the frame.
See also e733 Creating a JFrame.
// Create frame
String title = "Frame Title";
Frame frame = new Frame(title);
// Create a component to add to the frame
Component comp = new TextArea();
// Add the component to the frame; by default, the frame has a border layout
frame.add(comp, BorderLayout.CENTER);
// Show the frame
int width = 300;
int height = 300;
frame.setSize(width, height);
frame.setVisible(true);
// See also e560 Setting the Icon for a Frame
// See also e561 Making a Frame Non-Resizable
Related Examples
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?