Home > Back-end >  Please bosses, modify and query of event listeners how to code
Please bosses, modify and query of event listeners how to code

Time:09-25

Package homework;

import javax.swing.*;
The import javax.mail. Swing. Event. ListSelectionEvent;
The import javax.mail. Swing. Event. ListSelectionListener;
The import javax.mail. Swing. Table. DefaultTableModel;
import java.awt.*;
Import the Java. The awt. Event. An ActionEvent;
Import the Java. The awt. Event. ActionListener;
Import the Java. Util. ArrayList;
import java.util.Arrays;
Import the Java. Util. Vector;

Public class Surface {

Private static String [] [] data={
https://bbs.csdn.net/topics/{" 1 ", "Tom" and "male", "big data", "001", "95",},
{" 2 ", "Jerry", "male", "cloud computing", "002", "56",},
{" 3 ", "the Dmk", "male" and "artificial intelligence", "003", "85",},
{" 3 ", "the Cdg", "female", "mobile marketing", "004", "84",},
{" 3 ", "Hbf", "female", "Internet marketing", "005", "59"},
};

Public static void main (String [] args) {
JFrame jf=new JFrame (" information management system ");
Jf. SetDefaultCloseOperation (JFrame. EXIT_ON_CLOSE);
Jf. SetLayout (null);
Jf. SetSize (1200, 800);
//initialize the form center
Jf. SetLocationRelativeTo (null);
//form is not allowed to modify the size
Jf. SetResizable (false);
//header
//content
JLabel jumpers jl1=new JLabel (" make up ");
//set the font
Jumpers jl1. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
//locate
Jumpers jl1. SetBounds (200, 300, 80, 40).
//add
Jf. Add (jumpers jl1);
JLabel jl2=new JLabel (" name ");
//set the font
Jl2. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
//locate
Jl2. SetBounds (500, 300, 80, 40).
//add
Jf. Add (jl2);

JLabel jl3=new JLabel (" don't ");
//set the font
Jl3. SetFont (new Font, Font. SANS_SERIF, the Font, BOLD, 20));
//locate
Jl3. SetBounds (800, 300, 80, 40).
//add
Jf. Add (jl3);
JLabel jl4=new JLabel (" purpose ");
//set the font
Jl4. SetFont (new Font, Font. SANS_SERIF, the Font, BOLD, 20));
//locate
Jl4. SetBounds (200, 400, 80, 40).
//add
Jf. Add (jl4);
JLabel jl5=new JLabel (" ");
//set the font
Jl5. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
//locate
Jl5. SetBounds (500, 400, 80, 40).
//add
Jf. Add (jl5);
JLabel jl6=new JLabel (" number ");
//set the font
Jl6. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
//locate
Jl6. SetBounds (800, 400, 80, 40).
//add
Jf. Add (jl6);

//text input box
//for convenience, set the value of a text box to receive row index,
JTextField txt0=new JTextField ();
Txt0. SetBounds (150, 305, 50, 30);
Txt0. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Txt0. SetVisible (false);
Jf. Add (txt0);

//number
JTextField txt1=new JTextField ();
Txt1. SetBounds (265, 305, 200, 30);
Txt1. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Jf. Add (txt1);

//text input box
JTextField txt2=new JTextField ();
Txt2. SetBounds (565, 305, 200, 30);
Txt2. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Jf. Add (txt2);

//text input box
JTextField txt3=new JTextField ();
Txt3. SetBounds (865, 305, 200, 30);
Txt3. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Jf. Add (txt3);


//text input box
JTextField txt4=new JTextField ();
Txt4. SetBounds (265, 405, 200, 30);
Txt4. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Jf. Add (txt4);


//text input box
JTextField txt5=new JTextField ();
Txt5. SetBounds (565, 405, 200, 30);
Txt5. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Jf. Add (txt5);


//text input box
JTextField txt6=new JTextField ();
Txt6. SetBounds (865, 405, 200, 30);
Txt6. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Jf. Add (txt6);


//add the button
JButton btn1=new JButton (" addition ");
Btn1. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Btn1. SetBounds (200, 550, 130, 35).
Jf. Add (btn1);

//delete in addition to the button
JButton btn2=new JButton (" delete except ");
Btn2. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Btn2. SetBounds (400, 550, 130, 35).
Jf. Add (btn2);
//desired change button
JButton btn3=new JButton (" desired change ");
Btn3. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Btn3. SetBounds (600, 550, 130, 35).
Jf. Add (btn3);
//check) button
JButton btn4=new JButton (" look for ");
Btn4. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 20));
Btn4. SetBounds (800, 550, 130, 35).
Jf. Add (btn4);
//list: series, header, content
String [] colsName={" id ", "name", "gender", "professional", "student id",
"Score"};


DefaultTableModel tableModel=new DefaultTableModel ();
TableModel. SetDataVector (data, colsName);

This series jt=new series ();
Jt. SetModel (tableModel);



//for embedded class configuration of series
Jt. SetFont (new Font (Font. SANS_SERIF, the Font BOLD, 18));
The JScrollPane jp=new JScrollPane (jt);
Jp. SetBounds (100, 50, 1000, 600);
Jf. Add (jp);
Jf. SetVisible (true);
//to add button set to monitor events
Btn1. AddActionListener (new ActionListener () {
//rewrite an ActionListener event
@ Override
Public void actionPerformed (an ActionEvent e) {
//add data
String. No=txt1 getText ();
String name=txt2. GetText ();
String sex=txt3. GetText ();
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related