标签:jbutton 输入 listener 注册 rap location string action textarea
package com.wsy.work2; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; public class WindowsSwitch { JFrame jf; JButton jb1; JButton jb2; JPanel jp; JLabel jl; public WindowsSwitch() { jf = new JFrame(); jb1 = new JButton("注册"); jb2 = new JButton("登录"); jp = new JPanel(); jl = new JLabel("欢迎使用本程序\n请选择您需要进行的操作"); jb1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFrame jf1 = new JFrame(); JPanel jp1 = new JPanel(); JLabel jl1 = new JLabel("请输入您的手机号和您的个人信息"); JTextArea jta1 = new JTextArea(3,10); jf.setVisible(false); jta1.setLineWrap(true); jp1.add(jl1); jp1.add(jta1); jf1.add(jp1); jf1.setSize(600,200); jf1.setLocation(800, 400); jf1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf1.setVisible(true); } }); jb2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFrame jf1 = new JFrame(); JPanel jp1 = new JPanel(); JLabel jl1 = new JLabel("登陆成功"); jf.setVisible(false); jp1.add(jl1); jf1.add(jp1); jf1.setSize(200,100); jf1.setLocation(800, 400); jf1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf1.setVisible(true); } }); jp.add(jl); jp.add(jb1); jp.add(jb2); jf.add(jp); jf.setSize(300,100); jf.setLocation(800, 400); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); } public static void main(String[] args) { new WindowsSwitch(); } }
标签:jbutton 输入 listener 注册 rap location string action textarea
原文地址:https://www.cnblogs.com/heyishuozaijian/p/10880652.html