In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you how java realizes the relevant knowledge points of the student information input interface. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Complete the programming as follows:
1. Create a student information entry interface. Students have student number, name, age, class and grade information, and the interface contains "OK" and "reset" buttons.
2. to realize the event handling, click the "OK" button to encapsulate the student information into the object, and display the student information on the terminal console through the output object; click the information entered by the user in the situation interface of the "reset" button.
Package work;import java.awt.Button;import java.awt.Frame;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;public class work6 implements ActionListener,WindowListener,FocusListener {JTextField jt1 = new JTextField (30); JTextField jt2 = new JTextField (30) JTextField jt3 = new JTextField (30); JTextField jt4 = new JTextField (30); JTextField jt5 = new JTextField (30); public work6 () {Frame f = new Frame (Student Information Management system); JPanel jp1,jp2,jp3,jp4,jp5,jp6; jp1=new JPanel (); / / create 6 panels jp2=new JPanel (); jp3=new JPanel (); jp4=new JPanel () Jp5=new JPanel (); jp6=new JPanel (); JLabel L1 = new JLabel ("student number"); JLabel L2 = new JLabel ("name"); JLabel L3 = new JLabel ("age"); JLabel L4 = new JLabel ("class"); JLabel L5 = new JLabel ("grade"); Button b1 = new Button ("OK"); Button b2 = new Button ("reset") F.setLayout (new GridLayout (6,1)); f.add (jp1); f.add (jp2); f.add (jp3); f.add (jp4); f.add (jp5); f.add (jp6); jp1.add (L1); jp1.add (jt1); jp2.add (L2); jp2.add (jt2) Jp3.add (L3); jp3.add (jt3); jp4.add (L4); jp4.add (jt4); jp5.add (L5); jp5.add (jt5); jp6.add (b1); jp6.add (b2); f.setLocation (300,300); f.setSize (500,450) / f.setBounds (300,300,500,500); f.setVisible (true); / / MyListener M1 = new MyListener (); b1.addActionListener (this); b2.addFocusListener (this); f.addWindowListener (this);} public static void main (String [] args) {/ / TODO Auto-generated method stub new work6 () } @ Override public void windowActivated (WindowEvent arg0) {/ / TODO Auto-generated method stub} @ Override public void windowClosed (WindowEvent arg0) {/ / TODO Auto-generated method stub} @ Override public void windowClosing (WindowEvent arg0) {/ / TODO Auto-generated method stub System.exit (0) @ Override public void windowDeactivated (WindowEvent arg0) {/ / TODO Auto-generated method stub} @ Override public void windowDeiconified (WindowEvent arg0) {/ / TODO Auto-generated method stub} @ Override public void windowIconified (WindowEvent arg0) {/ / TODO Auto-generated method stub} @ Override public void windowOpened (WindowEvent arg0) { / / TODO Auto-generated method stub} @ Override public void actionPerformed (ActionEvent arg0) {/ / TODO Auto-generated method stub System.out.println ("Student\ nStudent ID:" + jt1.getText () + "\ nname:" + jt2.getText () + "\ nAge:" + jt3.getText () + "\ nClass:" + jt4.getText () + "\ nGrade:" + jt5.getText ()) / / System.out.println ("student");} @ Override public void focusGained (FocusEvent e) {/ / TODO Auto-generated method stub jt1.setText ("); jt2.setText ("); jt3.setText (""); jt4.setText (""); jt5.setText ("") } @ Override public void focusLost (FocusEvent e) {/ / TODO Auto-generated method stub}}
Result
Click to confirm:
Click reset:
These are all the contents of the article "how to implement the student information input interface in java". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.