Simple flow layout drop-down checkbox

import java.awt.*;
import javax.swing.*;
public class Main extends JFrame{
        public static void main(String[] args) {
            // create JFrame
            Main  frame = new Main();
            //
            frame.setTitle("This is the flow layout");
            // set size
            frame.setSize(500, 100);
            // JFrame is centered on the screen
            frame.setLocationRelativeTo(null);
            // Action when JFrame is closed
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // show JFrame
            frame.setVisible(true);
        }
    public Main() {
//        super.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
        JPanel p1 = new JPanel();
        p1.setSize(500,100);
        add(p1);
        p1.add(new JTextField(10));

        String [] list={"+","-","*","/"};     //下拉列表
        JComboBox jcombo = new JComboBox(list); //Instantiate the drop-down list
        p1.add(jcombo);

        p1.add(new JTextField(10));
        p1.add(new JButton("="));
        p1.add(new JTextField(10));
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324696071&siteId=291194637