📄 userjframe.java
字号:
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
public class UserJFrame extends JFrame implements ActionListener
{
private int number=1;
private JTextField text_number, text_no,text_name,text_sex,text_age,text_grade;
private JButton button_add;
private JTextArea text_user;
public UserJFrame()
{
super("显示学分积点");
this.setSize(450,360);
this.setLocation(300,240);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(new GridLayout(1,2));
text_user = new JTextArea();
this.add(text_user);
JPanel panel = new JPanel(new GridLayout(2,1));
this.add(panel);
text_number = new JTextField("1");
text_number.setEditable(false);
panel.add(text_number);
text_no = new JTextField("学号");
panel.add(text_no);
panel.add(text_age);
text_grade = new JTextField("成绩");
panel.add(text_grade);
button_add.addActionListener(this);
panel.add(button_add);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == button_add)
{
String aline="";
aline =text_no.getText()+","+text_name.getText()+","+text_sex.getText()+","+text_age.getText()+","+text_grade.getText();
aline += "\n学分基点为: ";
text_user.append(aline+"\n");
this.number++;
text_number.setText(""+this.number);
text_name.setText("姓名");
}
}
public static void main(String arg[])
{
new UserJFrame();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -