I wanted to make a GUI, so I made it using Swing. I will summarize what I made for the first time, so it will be for beginners. If you make a mistake or find something better, please let me know.
macOS Catalina (version 10.15.1) Eclipse ~~ To install the plug-in, click How to plug Swing into Eclipse 2019-03 ver. Installed with reference to ~~ The page is gone. ..
You can arrange it freely on the [Design] tab. I wanted to arrange it freely this time, so I created it with Absolute layout
title | component |
---|---|
☆ 彡 Hotel | JLabel |
username | JLabel |
password | JLabel |
Next to the username | JFormattedTextField |
Next to the password | JpasswordField |
Login | JButton |
As it is now, the UI is only displayed, so pressing the login button does nothing. Make sure that the event fires when you click the login button. This time, after pressing the login button, another screen will be displayed.
It's a little difficult to understand, The frame of frame.dispose (); is the login screen, The frame of a.frame.setVisible (true); will be another screen. If an error occurs in the frame of a.frame.setVisible (true) ;, delete the private of "private JFrame frame;" on the screen to be displayed. 4. Almost ready, let's run When executed, the login screen will be displayed.
When you press the login button ... Another screen will be displayed.
I'm not a professional, so please use it as a reference level ... Also, when creating with Absolute layout, it is nice to be able to freely change the size of the component, but when I change the size of the screen, it does not move nicely from the original position, so it makes me a little sad. .. If you know a good way, please let me know ... I will write an article again when the one I am making is completed.
Recommended Posts