自己做得简单的登录框

package com.chinasoft.java.am;


import java.awt.BorderLayout;


public class denglu extends JFrame {


private JPanel contentPane;
private JPasswordField passwordField_1;
private JTextField textField;
private JLabel label;
private JLabel label_1;
private JRadioButton radioButton;
private JRadioButton radioButton_1;


/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
denglu frame = new denglu();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}


/**
* Create the frame.
*/
public denglu() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//登录整个页面的大小布局
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setToolTipText("\u91CD\u7F6E");
contentPane.setBackground(new Color(51, 153, 204));
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);

JButton btnNewButton = new JButton("\u767B\u5F55");//登录按钮
btnNewButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {

if(passwordField_1.getText().equals("a7144772"))
{
new shouyin().setVisible(true);
}else
{
JOptionPane.showMessageDialog(null, "错误", "alert", JOptionPane.ERROR_MESSAGE);
}
//textField.getText();

}

});
btnNewButton.setBounds(278, 158, 70, 33);

JButton button = new JButton("\u91CD\u7F6E");//重置按钮
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new denglu().setVisible(true);
}
});
button.setBounds(91, 158, 70, 33);

passwordField_1 = new JPasswordField();//密码框
passwordField_1.setBounds(137, 99, 140, 21);//密码框的大小
contentPane.setLayout(null);
contentPane.add(button);
contentPane.add(btnNewButton);
contentPane.add(passwordField_1);

textField = new JTextField();//登录名
textField.setText("售货员");//登录框输入的内容
textField.setBounds(137, 58, 140, 21);//登录名大小
contentPane.add(textField);
textField.setColumns(10);

label = new JLabel("\u767B\u5F55\uFF1A");//登录的字
label.setForeground(Color.ORANGE);
label.setFont(new Font("宋体", Font.PLAIN, 15));
label.setBounds(77, 52, 50, 33);
contentPane.add(label);

label_1 = new JLabel("\u5BC6\u7801\uFF1A");//密码的字
label_1.setForeground(Color.ORANGE);
label_1.setFont(new Font("宋体", Font.PLAIN, 15));
label_1.setBounds(77, 93, 50, 33);
contentPane.add(label_1);

radioButton = new JRadioButton("\u8BB0\u4F4F\u8D26\u6237");
radioButton.setBounds(305, 57, 79, 23);
contentPane.add(radioButton);

radioButton_1 = new JRadioButton("\u8BB0\u4F4F\u5BC6\u7801");
radioButton_1.setBounds(305, 98, 79, 23);
contentPane.add(radioButton_1);
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个简单登录微信小程序的实现步骤: 1. 创建一个新的微信小程序项目,打开微信开发者工具,在项目目录下创建以下文件: ``` pages/ index/ index.js index.wxml index.wxss ``` 2. 在 `index.wxml` 文件中添加以下代码: ```html <view class="container"> <view class="title">微信小程序登录</view> <view class="form"> <view class="input-group"> <text class="label">用户名:</text> <input class="input" placeholder="请输入用户名" bindinput="onUsernameInput" /> </view> <view class="input-group"> <text class="label">密码:</text> <input class="input" type="password" placeholder="请输入密码" bindinput="onPasswordInput" /> </view> </view> <button class="button" bindtap="onLogin">登录</button> </view> ``` 3. 在 `index.wxss` 文件中添加以下样式: ```css .container { height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 16px; color: #333; } .title { font-size: 24px; font-weight: bold; margin-bottom: 20px; } .form { width: 300rpx; border: 1px solid #ccc; border-radius: 4px; padding: 20rpx; box-sizing: border-box; } .input-group { display: flex; flex-direction: row; align-items: center; margin-bottom: 10rpx; } .label { width: 80rpx; text-align: right; margin-right: 20rpx; } .input { flex: 1; height: 50rpx; padding: 0 10rpx; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } .button { width: 300rpx; height: 50rpx; background-color: #007aff; color: #fff; border-radius: 4px; margin-top: 20rpx; text-align: center; line-height: 50rpx; } ``` 4. 在 `index.js` 文件中添加以下代码: ```javascript Page({ data: { username: '', password: '' }, onUsernameInput(event) { this.setData({ username: event.detail.value }) }, onPasswordInput(event) { this.setData({ password: event.detail.value }) }, onLogin(event) { if (!this.data.username) { wx.showToast({ title: '请输入用户名', icon: 'none' }) return } if (!this.data.password) { wx.showToast({ title: '请输入密码', icon: 'none' }) return } wx.showModal({ title: '提示', content: '登录成功!', showCancel: false }) } }) ``` 5. 测试小程序,可以通过微信开发者工具的模拟器或在手机上运行测试,输入用户名和密码后点击登录按钮可以弹出提示框表示登录成功。 以上就是一个简单的微信小程序登录的实现步骤,你可以根据自己的需要进行修改和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值