“`
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;
}
}