[JAVA] Bureau: bouton Gui

Goal
Test Gui Button

Gui_Btn.java


import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Gui_Btn {
    private JFrame frame;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Gui_Btn window = new Gui_Btn();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public Gui_Btn() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 450, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JButton btnNewButton = new JButton("New button");
        btnNewButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("Hello World");
            }
        });
        btnNewButton.setBounds(14, 13, 99, 27);


        frame.getContentPane().add(btnNewButton);
    }
}
Result
![gui_btn.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/f3fe3711-2cc2-cf24-ba5b-023b512597b3.jpeg)

Recommended Posts

Bureau: bouton Gui
Bureau: curseur Gui
Bureau: OpenCV Sharpness Gui
Bureau: Gui afficher l'image
Bureau: OpenCV Gui modifie la luminosité
Bureau: OpenCV Gui change chaque pixel
[Mémo personnel] À propos du fonctionnement du bouton (GUI) de Docker Desktop pour Windows
Bureau: GaussianBlurFix
Bureau: OpenCV_OpenCV_GaussianBlur
Bureau: OpenCV_BoxFilterBlur
Bureau: OpenCV_FaceEyeNoseDetectorQuicklyByWebCam
Bureau: OpenCV Gui Change Alpha et Gamma Value