JAVAGUI编程初识之Swing

news2024/9/27 5:53:18

文章目录

  • 一 常用窗口
    • 1.1 JFrame框架窗口
    • 1.2 演示-JFRame,JLable的使用
    • 1.3 JDialog标签
      • 1.3.1 演示-JDialog标签
  • 二 标签组件
    • 2.1 标签
    • 2.2 图标
      • 2.2.1 ICon接口简介
      • 2.2.2 演示-用Icon接口创建图标
    • 2.3 图片图标
      • 2.3.1 演示-图片图标
  • 三 布局管理器
    • 3.1 绝对布局
      • 3.1.1 绝对布局简介
      • 3.1.2 演示-AbsoluteLayout
    • 3.2 流式布局管理器
      • 3.2.1 FlowLayout简介
      • 3.2.1 演示-FlowLayout
    • 3.3 边界布局管理器
      • 3.3.1 BorderLayout简介
      • 3.3.2 演示-BorderLayout使用
    • 3.4 网格布局管理器
      • 3.4.1 GridLayout简介
      • 3.4.2 演示-GridLayout使用
  • 四 面板
    • 4.1 JPanel
    • 4.2 JScrollPane
      • 4.2.1 JScrollPane简介
      • 4.2.2 演示
  • 五 按钮组件
    • 5.1 提交按钮组件(JButton)
    • 5.2 JButton演示
    • 5.3 单选按钮组件(JRadioButton)
    • 5.4 复选框组件(JCheckBox)
  • 六 列表组件
    • 6.1 下拉列表(JComBox)
    • 6.2 列表框(JList)
  • 七 文本组件
    • 7.1 文本框(JTextField)
    • 7.2 密码框(JPasswordField)
    • 7.3 文本域(JTextArea)

一 常用窗口

  • Swing窗体是Swing的一个组件,同时也是创建图形化用户界面的容器,可以将其它组件放置在窗体容器中。

1.1 JFrame框架窗口

  • JFrame窗体是一个容器,在Swing开发中它是Swing程序中各个组件的载体。
JFrame jf = new JFrame(title);
  • 在开发中更常用的方式是通过继承java.swing.JFrame类创建一个窗体,可通过this关键字调用其方法。
  • 在JFrame对象创建完成后,需要调用getContentPane()方法将窗体转换为容器,然后在容器中添加组件
  • 或设置布局管理器,通常这个容器用来包含和显示组件。如果需要将组件添加至容器,可以使用来自Container类的add()方法进行设置。

1.2 演示-JFRame,JLable的使用

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-16:29
 */
public class TestJFrame {
    public void init() {
        //顶级窗口
        JFrame jFrame = new JFrame("这是一个窗口");
        jFrame.setBounds(300,300,500,500);
        jFrame.setVisible(true);
        //设置背景颜色不起作用 要在先获得容器,然后在容器里书写
        Container container = jFrame.getContentPane();
        container.setBackground(Color.yellow);
        JLabel jlabel=new JLabel("欢迎使用!");
        Font font = new Font("隶书",Font.PLAIN,40);
        jlabel.setFont(font);
        jlabel.setHorizontalAlignment(SwingConstants.CENTER);

        jFrame.add(jlabel);

        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
    public static void main(String[] args) {
        new TestJFrame().init();
    }
}

在这里插入图片描述

常用的窗体关闭方式说明
DO_NOTHING_ON_CLOSE什么也不做就将窗体关闭
DISPOSE_ON_CLOSE任何注册监听程序对象后会自动隐藏并释放窗体
HIDE_ON_CLOSE隐藏窗口的默认窗口关闭
EXIT_ON_CLOSE退出应用程序默认窗口关闭

1.3 JDialog标签

  • JDialog窗体是Swing组件中的对话框,继承了AWT组件中的java.awt.Dialog类。功能是从一个窗体中弹出另一个窗体。

1.3.1 演示-JDialog标签

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author 缘友一世
 * date 2022/12/29-17:24
 */
public class TestDialog extends JFrame {
    public TestDialog() {
        super("弹窗测试窗口");
        this.setBounds(200,200,600,600);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setLayout(null);
        //JFrame 容器
        Container container = this.getContentPane();
        container.setLayout(null); //设置绝对定位
        container.setBackground(Color.gray);
        JButton jButton = new JButton("点击弹出对话框");
        Font font = new Font("隶书",Font.PLAIN,20);
        jButton.setFont(font);
        jButton.setBounds(200,200,200,100);
        container.add(jButton);

        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new MyDialog();
            }
        });
    }

    public static void main(String[] args) {
        new TestDialog();
    }
}
class MyDialog extends JDialog{
    public MyDialog() {
        this.setVisible(true);
        this.setBounds(500,500,300,300);
        Container container = this.getContentPane();
        container.setLayout(null);
        JLabel jLabel = new JLabel("恭喜,测试弹窗成功!");
        Font font = new Font("隶书",Font.PLAIN,20);
        jLabel.setFont(font);
        jLabel.setVisible(true);
        jLabel.setBounds(20,20,300,100);
        container.add(jLabel);
    }
}

在这里插入图片描述

二 标签组件

  • 在Swing中显示文本或提示信息的方法是使用标签,它支持文本字符串和图标。如:JLabel

2.1 标签

  • 标签由JLabel类定义,可以显示一行只读文本、一个图像或带图像的文本。
  • JLabel类提供了许多构造方法,如显示只有文本的标签、只有图标的标签或包含文本与图标的标签等。
  • 常用语法格式如下,创建的是一个不带图标和文本的JLabel对象:
JLabel jLable = new JLabel();

在这里插入图片描述

2.2 图标

2.2.1 ICon接口简介

  • Swing中的图标可以放置在按钮、标签等组件上,用于描述组件的用途。
  • 图标可以用Java支持的图片文件类型进行创建,也可以使用java.awt.Graphics类提供的功能方法来创建。
  • 在Swing中通过Icon接口来创建图标,可以在创建时给定图标的大小、颜色等特性。
  • Icon是接口,在使用Icon接口的时候,必须实现Icon接口的三个方法
public int getIconHeight()
public int getIconWidth()
public void paintIcon(Component arg0, Graphics arg1, int arg2, int arg3)
  • 前两个方法用于获取图片的长宽,paintIcon()方法用于实现在指定坐标位置画图

2.2.2 演示-用Icon接口创建图标

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-18:37
 */
//icon 图标
public class TestIcon extends JFrame implements Icon {
    private int width;
    private int height;
    public TestIcon() {

    }
    public TestIcon(int width,int height) {
        this.width=width;
        this.height=height;
    }
    public void init() {
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setBounds(300,300,500,500);
        TestIcon testIcon = new TestIcon(100, 100);
        JLabel label = new JLabel("IconTest", testIcon, SwingConstants.CENTER);
        Container container = getContentPane();
        container.add(label);
    }


    @Override
    public void paintIcon(Component c, Graphics g, int x, int y) {
        g.setColor(Color.green);
        g.fillOval(x,y,width,height);
    }

    @Override
    public int getIconWidth() {
        return width;
    }

    @Override
    public int getIconHeight() {
        return height;
    }
    public static void main(String[] args) {
        new TestIcon().init();
    }
}

在这里插入图片描述

2.3 图片图标

  • Swing中的图标除了可以绘制之外,还可以使用某个特定的图片创建。利用javax.swing.ImageIcon类根据现有图片创建图标。

2.3.1 演示-图片图标

import javax.swing.*;
import java.awt.*;
import java.net.URL;

/**
 * @author 缘友一世
 * date 2022/12/29-18:58
 */
public class TestImageIcon extends JFrame {
    public TestImageIcon() {

        Container container = getContentPane();
        //获取资源地址
        //相对路径 直接以本java源代码所在的目录为默认目录
        //绝对路径 以/开头,默认的路径是src下的目录
        URL url = TestImageIcon.class.getResource("picture01.jpeg");
        JLabel label = new JLabel("ImageIcon");
        label.setBounds(20,20,700,700);
        //创建图片图标
        ImageIcon imageIcon = new ImageIcon(url);
        //放入label
        label.setIcon(imageIcon);
        container.add(label);

        setBounds(200,200,800,800);
        setVisible(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
    public static void main(String[] args) {
        new TestImageIcon();
    }
}

在这里插入图片描述

三 布局管理器

  • Swing中,每个组件在容器中都有一个具体的位置和大小,入布局管理器它提供了基本的布局功能,可以有效的处理整个窗体的布局。
  • 常用的布局管理器包括流布局管理器、边界布局管理器、网格布局管理器等。

3.1 绝对布局

3.1.1 绝对布局简介

  • 硬性指定组件在容器中的位置和大小,可以使用绝对坐标的方式来指定组件的位置。
  • 使用步骤:
    1. 使用Container.setLayout(null)方法取消布局管理器
    2. 使用Container.setBounds()方法设置每个组件的位置和大小
Container container = getContentPane(); // 创建容器
container.setLayout(null);//取消布局管理器
JButton jb = new JButton("按钮"); // 创建按钮
jb.setBounds(10, 30, 100, 30); // 设置按钮位置和大小
container.add(jb); // 将按钮添加到容器中

3.1.2 演示-AbsoluteLayout

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/31-10:38
 */
public class TestAbsoluteLayout extends JFrame {
    public TestAbsoluteLayout() {
        setVisible(true);
        setBounds(300,300,300,300);
        Container container = getContentPane(); // 创建容器
        container.setLayout(null);//取消布局管理器
        JButton jb = new JButton("按钮"); // 创建按钮
        jb.setBounds(10, 30, 100, 30); // 设置按钮位置和大小
        container.add(jb); // 将按钮添加到容器中
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestAbsoluteLayout();
    }
}

在这里插入图片描述

3.2 流式布局管理器

3.2.1 FlowLayout简介

  • 流布局管理器是布局管理器中最基本的布局管理器,使用FlowLayout类,像“流”一样从左到右摆放组件,直到占据了这一行的所有空间,再向下移动一行。组件在每一行的位置默认居中排列,要更改位置可自行设置。
  • 在FlowLayout的有参构造方法中:
    • alignment设置为0时,每一行的组件将被指定左对齐排列;
    • 当alignment被设置为2时,每一行的组件将被指定右对齐排列;
    • 当alignment被设置为1时,是默认的居中排列。

3.2.1 演示-FlowLayout

/**
 * @author 缘友一世
 * date 2022/12/31-10:34
 */
public class TestFlowLayout extends JFrame {
    public TestFlowLayout() {
        Container container = this.getContentPane();
        // 设置流布局管理器,2是右对齐,后两个参数分别为组件间的水平间隔和垂直间隔
        //this.setLayout(new FlowLayout(0, 10, 10));
        //this.setLayout(new FlowLayout(2, 10, 10));
        this.setLayout(new FlowLayout(1, 10, 10));
        // 循环添加按钮
        for(int i=0; i<=7; i++) {
            container.add(new JButton("按钮" + i));
        }
        this.setSize(300, 200);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
    public static void main(String[] args) {
        new TestFlowLayout();
    }

}

在这里插入图片描述

3.3 边界布局管理器

3.3.1 BorderLayout简介

  • 在不指定窗体布局时,Swing组件默认的布局管理器是边界布局管理器,使用的是BorderLayout类。

3.3.2 演示-BorderLayout使用

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/31-10:44
 */
public class TestBorderLayout extends JFrame {
    public TestBorderLayout() {
        String[] borderPosition={BorderLayout.CENTER,BorderLayout.NORTH,BorderLayout.SOUTH,BorderLayout.WEST,BorderLayout.EAST};
        String[] buttonContents={"中","北","南","西","东"};
        Container container = this.getContentPane();
        //设置容器为边界布局管理器
        this.setLayout(new BorderLayout());
        //添加按钮
        for (int i = 0; i < 5; i++) {
            //第一个参数 设置布局
            //第二个参数 创建按钮
            container.add(borderPosition[i],new JButton(buttonContents[i]));
        }
        setVisible(true);
        setBounds(300,300,300,200);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestBorderLayout();
    }
}

在这里插入图片描述

3.4 网格布局管理器

3.4.1 GridLayout简介

  • 网格布局管理器将容器划分为网格,组件按行按列排列,使用GridLayout类。在此布局管理器中,每个组件的大小都相同,且会填满整个网格,改变窗体大小,组件也会随之改变。

3.4.2 演示-GridLayout使用

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/31-11:00
 */
public class TestGridLayout extends JFrame {
    public TestGridLayout() {
        Container container = this.getContentPane();
        //行数 列数 网格间的行间距 网格间的竖直间距
        this.setLayout(new GridLayout(3,3,3,3));
        // 循环添加按钮
        for(int i=0; i<=7; i++) {
            container.add(new JButton("按钮" + i));
        }
        this.setSize(300, 200);
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestGridLayout();
    }
}

在这里插入图片描述

四 面板

  • 面板也是一个容器,可作为容器容纳其他组件,但也必须被添加到其他容器中。Swing中常用面板有JPanel面板和JScrollPane面板。

4.1 JPanel

  • JPanel面板可以聚集一些组件来布局。继承自java.awt.Container类。
import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-19:14
 */
//面板
public class TestJPanel extends JFrame {
    public TestJPanel() {
        setBounds(200,200,600,600);
        setVisible(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container container = getContentPane();
        container.setLayout(new GridLayout(2,1,10,10));

        JPanel panel = new JPanel(new GridLayout(1, 3));
        panel.add(new JButton("01"));
        panel.add(new JButton("02"));
        panel.add(new JButton("03"));

        container.add(panel);

    }

    public static void main(String[] args) {
        new TestJPanel();
    }
}

在这里插入图片描述

4.2 JScrollPane

4.2.1 JScrollPane简介

  • 若遇到一个较小的容器窗体中显示一个较大部分内容的情况,可用JScrollPane面板。这是一个带滚动条的面板,就像平时浏览网页,经常遇到的滚动条一样。
  • 如果需要在JScrollPane面板中放置多个组件,需将这多个组件放置在JPanel面板上,然后将JPanel面板作为一个整体组件添加在JScrollPane面板上。

4.2.2 演示

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-19:24
 */
public class TestJScroll extends JFrame {
    public TestJScroll() {
        Container container = getContentPane();
        //文本域
        JTextArea textArea = new JTextArea(10, 30);
        textArea.setText("欢迎使用!");
        //scroll面板
        JScrollPane scrollPane = new JScrollPane(textArea);
        container.add(scrollPane);
        container.setVisible(true);
        //如果写在前面会导致,打开之后动一下窗口才可以显示
        setBounds(200,200,300,300);
        setVisible(true);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJScroll();
    }
}

在这里插入图片描述

五 按钮组件

5.1 提交按钮组件(JButton)

  • JButton在之前的例子中已经出现多次,是较为常用的组件,用于触发特定动作。可以在按钮上显示文本标签,还可以显示图标。

5.2 JButton演示

import javax.swing.*;
import java.awt.*;
import java.net.URL;

/**
 * @author 缘友一世
 * date 2022/12/29-19:36
 */
//图片按钮
public class TestJButton extends JFrame {
    public TestJButton() {
        Container container = this.getContentPane();

        //把图片变为一个图标
        URL url = TestJButton.class.getResource("picture01.jpeg");
        ImageIcon icon = new ImageIcon(url);
        //将图片放到按钮上
        JButton button = new JButton();
        button.setIcon(icon);
        button.setToolTipText("图片按钮");

        container.add(button);

        setVisible(true);
        setBounds(200,200,600,600);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJButton();
    }
}

在这里插入图片描述

5.3 单选按钮组件(JRadioButton)

  • 默认情况下,单选按钮显示一个圆形图标,通常在其旁放置一些说明性文字。当用户选中某个单选按钮后,按钮组中其它按钮将被自动取消,这时就需要按钮组(ButtonGroup)来将同组按钮放在一起,该按钮组中的按钮只能选择一个,而不在此按钮中的按钮不受影响。
import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-19:43
 */
public class TestJRadioButton extends JFrame {
    public TestJRadioButton() {
        Container container = this.getContentPane();

        JRadioButton button01 = new JRadioButton("button01");
        JRadioButton button02 = new JRadioButton("button02");
        JRadioButton button03 = new JRadioButton("button03");
        //分组
        ButtonGroup group = new ButtonGroup();
        group.add(button01);
        group.add(button02);
        group.add(button03);

        container.add(button01,BorderLayout.NORTH);
        container.add(button02,BorderLayout.CENTER);
        container.add(button03,BorderLayout.SOUTH);

        setVisible(true);
        setBounds(200,200,600,600);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJRadioButton();
    }
}

在这里插入图片描述

5.4 复选框组件(JCheckBox)

  • 复选框是一个方块图标,外加一段描述性文字,与单选按钮的区别就是可以多选。每一个复选框都提供“选中”与“不选中”两种状态。
import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-19:43
 */
public class TestJCheckBox extends JFrame {
    public TestJCheckBox() {
        Container container = this.getContentPane();

        JCheckBox checkBox01 = new JCheckBox("checkBox01");
        JCheckBox checkBox02 = new JCheckBox("checkBox02");

        container.add(checkBox01,BorderLayout.WEST);
        container.add(checkBox02,BorderLayout.EAST);

        setVisible(true);
        setBounds(200,200,600,600);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJCheckBox();
    }
}

在这里插入图片描述

六 列表组件

6.1 下拉列表(JComBox)

/**
 * @author 缘友一世
 * date 2022/12/29-21:53
 */
public class TestComboBox extends JFrame {
    public TestComboBox() {
        Container container = getContentPane();
        JPanel panel = new JPanel();
        panel.setBounds(20,20,100,100);
        JComboBox comboBox = new JComboBox();
        comboBox.addItem(null);
        comboBox.addItem("文件");
        comboBox.addItem("视图");
        comboBox.addItem("工具");
        panel.add(comboBox);
        container.add(panel);

        setVisible(true);
        setBounds(300,300,500,500);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestComboBox();
    }
}

在这里插入图片描述

6.2 列表框(JList)

  • 列表框只是在窗体上占据固定的大小,如果要使列表框具有滚动效果,可以将列表框放入滚动面板中。
import javax.swing.*;
import java.awt.*;
import java.util.Vector;

/**
 * @author 缘友一世
 * date 2022/12/29-22:06
 */
//列表框
public class TestJList extends JFrame {
    public TestJList() {
        Container container = getContentPane();
        JPanel panel = new JPanel();
        panel.setBounds(20,20,100,100);
        Vector contents = new Vector();
        contents.add("香蕉");
        contents.add("苹果");
        contents.add("桃子");
        //列表框
        JList jList = new JList(contents);
        Font font = new Font("隶书",Font.PLAIN,30);
        jList.setFont(font);
        container.add(jList);
        setVisible(true);
        setBounds(300,300,500,500);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJList();
    }
}

在这里插入图片描述

七 文本组件

7.1 文本框(JTextField)

  • 文本框用来显示或编辑一个单行文本
import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-22:16
 */
public class TestTextField extends JFrame{
    public TestTextField() {
        Container container = getContentPane();
        Font font = new Font("隶书",Font.PLAIN,40);
        JPanel panel = new JPanel();
        panel.setBounds(20,20,100,100);
        panel.setLayout(new GridLayout(2,1));
        JTextField field1 = new JTextField("我是上边的文本域");
        JTextField field2 = new JTextField("我是下边的文本域",10);
        field1.setFont(font);
        field2.setFont(font);
        panel.add(field1);
        panel.add(field2);
        container.add(panel);

        setVisible(true);
        setBounds(300,300,500,500);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestTextField();
    }
}

在这里插入图片描述

7.2 密码框(JPasswordField)

  • 密码框与文本框的定义与用法类似,但会使用户输入的字符串以某种符号进行加密。
import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/29-22:24
 */
public class TestJPasswordField extends JFrame {
    public TestJPasswordField() {
        Container container = getContentPane();
        Font font = new Font("隶书",Font.PLAIN,40);

        JPasswordField passwordField = new JPasswordField();
        passwordField.setVisible(true);
        passwordField.setEchoChar('*');
        passwordField.setFont(font);
        container.add(passwordField);

        setVisible(true);
        setBounds(300,300,500,500);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJPasswordField();
    }
}

在这里插入图片描述

7.3 文本域(JTextArea)

import javax.swing.*;
import java.awt.*;

/**
 * @author 缘友一世
 * date 2022/12/31-12:45
 */
public class TestJTextArea extends JFrame {

    public TestJTextArea() {
        Container container = getContentPane();
        Font font = new Font("隶书",Font.PLAIN,40);
        JTextField textField = new JTextField();
        textField.setFont(font);
        textField.setText("这是一个文本域!");
        textField.setBounds(10,10,100,100);

        container.add(textField);
        setVisible(true);
        setBounds(300,300,500,500);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        new TestJTextArea();
    }
}

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/130828.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

年末再看指针。看来搞C/C++,如影随形的指针就得门清~~~

继上篇博文因内核页表引出的指针问题&#xff0c;后来又研究了一番&#xff0c;这次应该比较清楚了&#xff0c;这里再总结一下。 目录 0 前言 1 普通指针&#xff1a; 2 指针的指针&#xff1a; 3 普通指针参数&#xff1a; 4 指针的指针参数&#xff1a; 5 函数指针&a…

[Kettle] 认识Kettle

1.初识Kettle Kettle是ETL数据整合与处理工具&#xff0c;翻译成中文是"水壶"的意思&#xff0c;可理解为希望把各种数据放到一个壶里&#xff0c;像水一样以一种指定的格式流出&#xff0c;表达数据流的含义 ETL(Extract - Transform - Load)是将数据从数据来源端…

centos7部署rancher2.5

一、 什么是 Rancher Rancher 是为使用容器的公司打造的容器管理平台。Rancher 简化了使用 Kubernetes 的流程&#xff0c;开发者可以随处运行 Kubernetes&#xff08;Run Kubernetes Everywhere&#xff09;&#xff0c;满足 IT 需求规范&#xff0c;赋能 DevOps 团队。 Ran…

单纯形法与对偶单纯形法的通俗理解

cigma<0,a>0 min cigma/(a) 决定出基变量 1对偶单纯形法 意思是看c就是所有货物的价值&#xff0c;去看一眼这些货物单价组合售卖的价值&#xff0c;这些价值肯定要都大于0&#xff0c;而且&#xff0c;组成这个c的系数也应该是都是正的&#xff0c; c最小证明对min&a…

港科夜闻|香港科大-越秀集团百万奖金国际创业大赛2022年度前8强20强项目评审结果公布...

关注并星标每周阅读港科夜闻建立新视野 开启新思维1、“香港科大-越秀集团”百万奖金国际创业大赛2022年度前8强&20强项目评审结果公布。2022年赛事中的各赛区前三名项目&#xff0c;共计23个项目自动入围年度总决赛&#xff0c;本轮评审在这23个项目中&#xff0c;评选出了…

Hudi学习02 -- Hudi核心概念

文章目录基本概念时间轴&#xff08;Timeline&#xff09;文件布局&#xff08;File Layout&#xff09;索引&#xff08;Index&#xff09;索引原理索引类型索引的选择策略表类型&#xff08;Table Types&#xff09;查询类型&#xff08;Query Types&#xff09;写操作&#…

Qt第五十二章:Qt Design Studio使用技巧。

一、运行项目和Debugging项目【快捷键&#xff1a;CtrR】 二、 预览单Qml文件 三、添加资源文件 &#xff08;使用资源&#xff1a;将资源拖动到Editor中的矩形中即可&#xff09; 四、多状态【正常状态、按下状态、划过状态、已点击状态...】 注意&#xff1a;多状态看起来像…

java短网址平台

git地址 Reduce: 短网址平台&#xff0c;Coody Framework首秀&#xff0c;自写IOC、MVC、ORM、TASK、JSON、DB连接池、服务器。百毫秒启动&#xff0c;全项目仅2.1M&#xff08;低配服可运行&#xff09; reduce短网址平台 测试站地址&#xff1a;http://dev.icoody.cn/ 技…

DOM事件

鼠标事件监听 键盘事件监听 表单事件监听 常见的页面事件监听 事件传播 事件传播顺序&#xff1a;从内到外&#xff08;冒泡阶段&#xff09;onxxx这样写法只能监听冒泡阶段 addEventListener()方法第三个参数如果为true监听捕获阶段&#xff0c;false监听冒泡阶段(默认) 最…

C语言及算法设计课程实验二:数据类型、运算符和简单的输入输出

C语言及算法设计课程实验二&#xff1a;数据类型、运算符和简单的输入输出一、实验目的二、实验内容2.1、输入并运行教材第3章第4题给出的程序&#xff1a;2.2、输入第3章第5题的程序2.3、输入以下程序&#xff1a;2.4、程序设计题&#xff1a;假如我国国民生产总值的年增长率为…

遗传算法解决函数优化问题

遗传算法解决函数优化问题 作者: Cukor丘克环境: MatlabR2020a vscode 为什么要学习遗传算法 为什么要学习遗传算法&#xff0c;或者说遗传算法有什么厉害的地方。例如求解以下函数优化问题&#xff1a;minf(x1,x2)x12x1225∗(sin2x1sin2x2),−10≤x1≤10,−10≤x2≤10.min…

【ACWING】【图的深度优先遍历】【846树的重心】

给定一颗树&#xff0c;树中包含 n个结点&#xff08;编号 1∼n&#xff09;和 n−1条无向边。 请你找到树的重心&#xff0c;并输出将重心删除后&#xff0c;剩余各个连通块中点数的最大值。 重心定义&#xff1a;重心是指树中的一个结点&#xff0c;如果将这个点删除后&…

js复习之正则表达式正向肯定与否定预查询

正则表达式(regular expression)描述了一种字符串匹配的模式&#xff08;pattern&#xff09;&#xff0c;可以用来检查一个串是否含有某种子串、将匹配的子串替换或者从某个串中取出符合某个条件的子串等。 正则表达式_百度百科 除开常用基本匹配模式&#xff0c;偶尔也会用到…

回顾艰难且不失温度的 2022 年 | 文中附「双12免单王」获奖名单

今天是 2022 年最后一天&#xff0c;回忆往昔&#xff0c;这一年经历了太多的不可思议和无可奈何之事。在年末的短短几周&#xff0c;寒气长驱直下以惊人的速度传给每一个人。我们真诚地希望大家都可以平安渡过这一难关。 即使步步难行&#xff0c;亦要踱步前行&#xff01;无…

力扣刷题记录——190. 颠倒二进制位、191. 位1的个数、202. 快乐数

本专栏主要记录力扣的刷题记录&#xff0c;备战蓝桥杯&#xff0c;供复盘和优化算法使用&#xff0c;也希望给大家带来帮助&#xff0c;博主是算法小白&#xff0c;希望各位大佬不要见笑&#xff0c;今天要分享的是——《190. 颠倒二进制位、191. 位1的个数、202. 快乐数》。 目…

Gradle学习笔记之依赖

文章目录依赖的方式直接依赖项目依赖本地jar包依赖依赖的类型api和implementation的区别依赖冲突及解决方案移除某个依赖不允许依赖传递强制使用某个版本依赖冲突时立刻构建失败依赖的方式 Gradle中的依赖方式有直接依赖、项目依赖和本地jar包依赖三种&#xff1a; dependenc…

【一起从0开始学习人工智能0x02】字典特征抽取、文本特征抽取、中文文本特征抽取

注&#xff1a;最后有面试挑战&#xff0c;看看自己掌握了吗 文章目录什么是特征工程&#xff1f;用什么做&#xff1f;1.特征提取特征值化&#xff1a;特征提取API字典特征提取---向量化---类别--》one-hot编码哑变量one-hot-------直接1234会产生歧义&#xff0c;不公平应用场…

Python 10k+ 面试试题,看看你是否掌握

前言 大家早好、午好、晚好吖 ❤ ~ 面试实战题&#xff1a;采集世界最大旅游平台Tripadvisor 另我给大家准备了一些资料&#xff0c;包括: 2022最新Python视频教程、Python电子书10个G &#xff08;涵盖基础、爬虫、数据分析、web开发、机器学习、人工智能、面试题&#xff…

Python GUI编程:音乐播放器(多线程、爬虫、进度条、文件)

文章目录1. 程序运行结果2.程序实现原理3. GUI布局4. 功能介绍5. 代码实现1. 程序运行结果 Python实现音乐播放器(爬虫、多线程、进度条、文件)2.程序实现原理 本音乐播放器GUI方面运用Python的tkinter实现&#xff0c;播放的音乐来自网络爬虫和本电脑已经有的。为了使整个程序…

Android studio设置全屏显示的两种方式

两种在Androidstudio中设置全屏的方式&#xff0c;推荐第二种 第一种&#xff08;Java文件中设置&#xff09; 直接在onCreate()函数中设置 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);package com.exa…