created WindowBuildTest

This commit is contained in:
buzz-lightsnack-2007 2024-01-23 13:05:45 +08:00
parent 6ce4e4c344
commit c9e2f054cf

View file

@ -0,0 +1,87 @@
package xs_ibdpcompsci_javaintro;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JToolBar;
import javax.swing.JEditorPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JToggleButton;
import javax.swing.JRadioButton;
import java.awt.Font;
public class WindowBuildTest extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
WindowBuildTest frame = new WindowBuildTest();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
static void test_status_return() {
System.out.println("Clicked");
}
public WindowBuildTest() {
Font WINDOW_FONT = new Font("Segoe UI Variable", Font.PLAIN, 13);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JRadioButton rdbtnNewRadioButton1 = new JRadioButton("Automatically close");
rdbtnNewRadioButton1.setFont(WINDOW_FONT);
rdbtnNewRadioButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Selected");
}
});
JButton btnNewButton1 = new JButton("Refresh");
btnNewButton1.setFont(WINDOW_FONT);
btnNewButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
test_status_return();
}
});
JButton btnNewButton2 = new JButton("Close");
btnNewButton2.setFont(WINDOW_FONT);
btnNewButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
test_status_return();
}
});
contentPane.add(rdbtnNewRadioButton1);
contentPane.add(btnNewButton1);
contentPane.add(btnNewButton2);
}
}