用上篇文章的方法做注册界面和计算器界面

1.java做一个注册界面

import javax.swing.*;
import java.awt.*;
public class ResisterUI {
    public void initLoginUI() {
    JFrame frame = new JFrame();
    frame.setTitle("注册界面");
    frame.setSize(400, 600);
    frame.setLocation(700, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FlowLayout flowLayout = new FlowLayout();
    frame.setLayout (flowLayout);
    JButton button = new JButton("注册");
    JLabel nameJla = new JLabel("昵称:");
    JTextField nameJtx = new JTextField();
    JLabel pwdJla = new JLabel("密码:");
    JPasswordField pwdJpf = new JPasswordField();
    JLabel phoneJla = new JLabel("手机号码:");
    JTextField phoneJtx = new JTextField();
    Dimension dim = new Dimension(310, 35);
    nameJtx.setPreferredSize(dim);
    pwdJpf.setPreferredSize(dim);
    phoneJtx.setPreferredSize(dim);
    ImageIcon imageIcon = new ImageIcon ("C:\\Users\\35320\\Desktop\\aaa.jpg");
    JLabel imageJla = new JLabel(imageIcon);
    frame.add(nameJla);
    frame.add(nameJtx);
    frame.add(pwdJla);
    frame.add(pwdJpf);
    frame.add(phoneJla);
    frame.add(phoneJtx);
    frame.add(button);
    frame.add(imageJla);
    frame.setVisible(true);
}
    public static void main(String[] args){
        ResisterUI ui = new ResisterUI();
        ui.initLoginUI();
    }
}

运行截图

2.java做一个计算器界面

import javax.swing.*;
import java.awt.*;
public class CalculatorUI {
    public void initLoginUI() {
        JFrame frame = new JFrame();
        frame.setTitle("计算器界面");
        frame.setSize(360, 530);
        frame.setLocation(700, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        FlowLayout flowLayout = new FlowLayout();
        frame.setLayout (flowLayout);
        JButton button1 = new JButton("AC");
        JButton button2 = new JButton("DEL");
        JButton button3 = new JButton("(");
        JButton button4 = new JButton(")");
        JButton button5 = new JButton("/");
        JButton button6 = new JButton("7");
        JButton button7 = new JButton("8");
        JButton button8 = new JButton("9");
        JButton button9 = new JButton("+");
        JButton button10 = new JButton("4");
        JButton button11 = new JButton("5");
        JButton button12 = new JButton("6");
        JButton button13 = new JButton("-");
        JButton button14 = new JButton("1");
        JButton button15 = new JButton("2");
        JButton button16 = new JButton("3");
        JButton button17 = new JButton("x");
        JButton button18 = new JButton("0");
        JButton button19 = new JButton(".");
        JButton button20 = new JButton("=");
        JTextField nameJtx = new JTextField();
        JPasswordField pwdJpf = new JPasswordField();
        Dimension dim1 = new Dimension(315, 70);
        Dimension dim2 = new Dimension(59, 60);
        Dimension dim3 = new Dimension(75, 60);
        Dimension dim4 = new Dimension(155, 60);
        nameJtx.setPreferredSize(dim1);
        pwdJpf.setPreferredSize(dim1);
        button1.setPreferredSize(dim2);
        button2.setPreferredSize(dim2);
        button3.setPreferredSize(dim2);
        button4.setPreferredSize(dim2);
        button5.setPreferredSize(dim2);
        button6.setPreferredSize(dim3);
        button7.setPreferredSize(dim3);
        button8.setPreferredSize(dim3);
        button9.setPreferredSize(dim3);
        button10.setPreferredSize(dim3);
        button11.setPreferredSize(dim3);
        button12.setPreferredSize(dim3);
        button13.setPreferredSize(dim3);
        button14.setPreferredSize(dim3);
        button15.setPreferredSize(dim3);
        button16.setPreferredSize(dim3);
        button17.setPreferredSize(dim3);
        button18.setPreferredSize(dim4);
        button19.setPreferredSize(dim3);
        button20.setPreferredSize(dim3);
        frame.add(nameJtx);
        frame.add(pwdJpf);
        frame.add(button1);
        frame.add(button2);
        frame.add(button3);
        frame.add(button4);
        frame.add(button5);
        frame.add(button6);
        frame.add(button7);
        frame.add(button8);
        frame.add(button9);
        frame.add(button10);
        frame.add(button11);
        frame.add(button12);
        frame.add(button13);
        frame.add(button14);
        frame.add(button15);
        frame.add(button16);
        frame.add(button17);
        frame.add(button18);
        frame.add(button19);
        frame.add(button20);
        frame.setVisible(true);
    }
    public static void main(String[] args){
        CalculatorUI ui = new CalculatorUI();
        ui.initLoginUI();
    }
}

运行截图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冯水流

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值