⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e571. creating a container.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
A container holds one or more child components. A container has a layout that determines how the child components are arranged within the container. This example creates a frame with a text area in the center and a row of buttons at the bottom. The buttons are placed in a container. 
    // Create a container with a flow layout, which arranges its children horizontally
    Panel panel = new Panel();
    
    // A container can also be created with a specific layout
    panel = new Panel(new FlowLayout(FlowLayout.RIGHT));
    
    // Add several buttons to the container
    panel.add(new Button("A"));
    panel.add(new Button("B"));
    panel.add(new Button("C"));
    
    // Create frame with a text area in the center
    Frame frame = new Frame();
    Component comp = new TextArea();
    frame.add(comp, BorderLayout.CENTER);
    
    // Add the container to the bottom of the frame
    frame.add(panel, BorderLayout.SOUTH);
    
    // Show the frame
    int width = 300;
    int height = 300;
    frame.setSize(width, height);
    frame.setVisible(true);

⌨️ 快捷键说明

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