zoukankan      html  css  js  c++  java
  • java用户界面—创建一个面板

    先从基础学起

    创建一个面板

    代码如下:

    package Day08; import java.awt.FlowLayout; import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel; public class Homework1 extends JFrame {
    public Homework1() {
    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    p1.add(new JButton("JButton1-1"));
    p1.add(new JButton("JButton1-2"));
    p1.add(new JButton("JButton1-3"));
    JPanel p2 = new JPanel();
    p2 .setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
    p2.add(new JButton("JButton2-1"));
    p2.add(new JButton("JButton2-2"));
    p2.add(new JButton("JButton2-3"));
    setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
    add(p1);
    add(p2);
    }

    public static void main(String[] args) {
    Homework1 frame = new Homework1();
    frame.setSize(500, 300);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    } }

    只相信苦尽甘来
  • 相关阅读:
    目标检测评价指标
    DALSA相机SDK不完全教程
    windows 安装pycocotools
    keras第二课:后端函数
    Python中os.mkdir()与os.makedirs()的区别
    ARM知识
    神经网络结构
    PIL 中的 Image 模块
    Matplotlib使用
    keras第一课:Cifar分类
  • 原文地址:https://www.cnblogs.com/F001li/p/7055959.html
Copyright © 2011-2022 走看看