swing界面设计之添加好友、个人信息


如果有不清楚的地方,请参考本系列前述记录。

界面效果

这里写图片描述


这里写图片描述

源码

package com.lsh.view;

import java.awt.EventQueue;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;

@SuppressWarnings("serial")
public class InquiryFriendFrame extends JFrame {

    private JPanel contentPane;
    private JTextField textField;

    private Vector<String> cols;
    private Vector<String> rows;
    private JTable table;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        try
        {
            org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
        }
        catch(Exception e)
        {
            //TODO exception
            System.out.println("加载炫彩皮肤失败!");
        }
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    InquiryFriendFrame frame = new InquiryFriendFrame();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public InquiryFriendFrame() {
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 427, 395);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);

        JLabel label = new JLabel("昵 称");
        label.setBounds(12, 12, 55, 18);
        contentPane.add(label);

        textField = new JTextField();
        textField.setBounds(69, 7, 189, 28);
        contentPane.add(textField);
        textField.setColumns(10);

        JButton btnNewButton = new JButton("查 询");
        btnNewButton.setBounds(270, 4, 83, 35);
        contentPane.add(btnNewButton);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBounds(12, 42, 349, 260);
        contentPane.add(scrollPane);

        cols=new Vector<>();
        cols.add("昵 称");
        cols.add("在线");
        rows=new Vector<>();

        table = new JTable(rows,cols);
        scrollPane.setViewportView(table);
    }
}


package com.lsh.view;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.JRadioButton;
import javax.swing.JComboBox;
import javax.swing.JTextArea;

@SuppressWarnings("serial")
public class ProfileFrame extends JFrame {

    private JPanel contentPane;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        try
        {
            org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
        }
        catch(Exception e)
        {
            //TODO exception
            System.out.println("加载炫彩皮肤失败!");
        }
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    ProfileFrame frame = new ProfileFrame();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    @SuppressWarnings("rawtypes")
    public ProfileFrame() {
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 415, 435);
        contentPane = new JPanel();
        setContentPane(contentPane);
        contentPane.setLayout(null);

        JLabel lblNewLabel = new JLabel("");
        lblNewLabel.setBorder(new LineBorder(new Color(0, 0, 0)));
        lblNewLabel.setBounds(10, 10, 64, 64);
        contentPane.add(lblNewLabel);

        textField = new JTextField();
        textField.setBounds(84, 10, 267, 31);
        contentPane.add(textField);
        textField.setColumns(10);

        textField_1 = new JTextField();
        textField_1.setBounds(84, 51, 267, 23);
        contentPane.add(textField_1);
        textField_1.setColumns(10);

        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(null, "\u8D44\u6599\u8BE6\u60C5", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.setBounds(10, 86, 341, 258);
        contentPane.add(panel);
        panel.setLayout(null);

        JLabel label = new JLabel("真实姓名");
        label.setBounds(12, 34, 55, 18);
        panel.add(label);

        JLabel label_1 = new JLabel("性 别");
        label_1.setBounds(12, 75, 55, 18);
        panel.add(label_1);

        JLabel label_2 = new JLabel("出生日期");
        label_2.setBounds(12, 116, 55, 18);
        panel.add(label_2);

        textField_2 = new JTextField();
        textField_2.setBounds(74, 29, 118, 28);
        panel.add(textField_2);
        textField_2.setColumns(10);

        JRadioButton radioButton = new JRadioButton("男");
        radioButton.setBounds(65, 69, 61, 30);
        panel.add(radioButton);

        JRadioButton radioButton_1 = new JRadioButton("女");
        radioButton_1.setBounds(132, 69, 68, 30);
        panel.add(radioButton_1);

        JComboBox comboBox = new JComboBox();
        comboBox.setBounds(74, 112, 93, 26);
        panel.add(comboBox);

        JComboBox comboBox_1 = new JComboBox();
        comboBox_1.setBounds(171, 112, 68, 26);
        panel.add(comboBox_1);

        JComboBox comboBox_2 = new JComboBox();
        comboBox_2.setBounds(247, 112, 68, 26);
        panel.add(comboBox_2);

        JLabel lblNewLabel_1 = new JLabel("备 注");
        lblNewLabel_1.setBounds(12, 163, 55, 18);
        panel.add(lblNewLabel_1);

        JTextArea textArea = new JTextArea();
        textArea.setBounds(74, 158, 255, 88);
        panel.add(textArea);
    }
}
  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值