无标题一

“`
package cn.whf.UI;

import java.awt.Button;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import jdk.nashorn.internal.scripts.JS;
import sun.net.www.content.image.jpeg;

public class TestBox extends JFrame{
public TestBox() {
setSize(300, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(400, 300);
}

public static void main(String[] args) {
    new  TestBox().addcom().setVisible(true);
}

private TestBox addcom() {
    setLayout(new FlowLayout());
    JPanel jPane=new  JPanel();
    jPane.setLayout(new BoxLayout(jPane, BoxLayout.Y_AXIS));
    JPanel jPanel=new  JPanel();

// JPanel jPanel1=new JPanel();
jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.X_AXIS));
JLabel jLabel=new JLabel(“兴趣”);
// jLabel.setBackground(Color.BLUE);
//
jPanel.add(jLabel);

    JPanel jPane2=new  JPanel();
    BoxLayout boxLayout=new BoxLayout(jPane2, BoxLayout.Y_AXIS);
    jPane2.setLayout(boxLayout);
    jPane2.add(Box.createVerticalStrut(80));
    JCheckBox jCheckBox = new JCheckBox("box");

    jPane2.add(jCheckBox);
    JCheckBox jCheckBox1 = new JCheckBox("box1");
    jPane2.add(jCheckBox1);
    JCheckBox jCheckBox2 = new JCheckBox("box2");
    jPane2.add(jCheckBox2);

    jPanel.add(jPane2);

// JLabel jLabel1=new JLabel(“test”);
// jPanel.add(jLabel1);

    JPanel jPanel1=new  JPanel();
    jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.X_AXIS));
    jPanel1.add(new Label("性别"));
    jPanel1.add(new JRadioButton("男"));
    jPanel1.add(new JRadioButton("女"));
    jPane.add(jPanel);
    jPane.add(Box.createVerticalStrut(20));
    jPane.add(jPanel1);
    JTextArea jtext = new JTextArea(3,10);

    JTextField jTextField=new JTextField();
    jTextField.setSize(100, 100);
    jtext.setSize(100, 200);
    JScrollPane jScrollPane=new JScrollPane(jtext);

    jPane.add(jScrollPane);
    add(jPane);

    jCheckBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            jtext.setText(jCheckBox.getText());

        }
    });
    jCheckBox1.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            jtext.setText(jtext.getText()+"\n"+jCheckBox1.getText());


        }
    });
    jCheckBox2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                jtext.setText(jtext.getText()+"\n"+jCheckBox2.getText());


            }
        });
    return this;
}

}这里写图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值