Desktop: Gui Button

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

Desktop: Gui Button
Desktop: Gui slider
Desktop: OpenCV Sharpness Gui
Desktop: Gui show image
Desktop: OpenCV Gui modify Brightness
Desktop: OpenCV Gui change every pixel
[Personal memo] About button (GUI) operation of Docker Desktop for Windows
Desktop: GaussianBlurFix
Desktop: OpenCV_OpenCV_GaussianBlur
Desktop: OpenCV_BoxFilterBlur
Desktop: OpenCV_FaceEyeNoseDetectorQuicklyByWebCam
Desktop: OpenCV Gui Change Alpha and Gamma Value