注册 登录
编程论坛 JAVA论坛

初学者 关于组件的图片插入问题 如何将插入的图片安放在指定的一个角落呢。

Poppy辉 发布于 2016-11-30 23:27, 1505 次点击
其实也就是如何规范的排版。
import java.awt.FlowLayout;

import javax.swing.*;

public class week12 {

    public static void main(String[] args) {
        
        Condition con = new Condition();

    }

}

    class Condition extends JFrame
    {   
        JPanel p1, p2;
        JLabel name, number, photo;
        JTextField adress;
        JTextArea intruduction;
        JRadioButton sex1,sex2;
        JCheckBox b1, b2, b3, b4;
        ButtonGroup bg;
        
        public Condition()
        {
            init();
            setBounds(300,300,500,500);
            setVisible(true);
        }
        
        public void init()
        {   
            setLayout(new FlowLayout());
            p1 = new JPanel();
            name = new JLabel("马云");
            number = new JLabel("41610055");
            photo = new JLabel(new ImageIcon("005.JPG"));
            adress = new JTextField(10);
            intruduction = new JTextArea(15,30);
            sex1 = new JRadioButton("男");
            sex2 = new JRadioButton("女");
            b1 = new JCheckBox("足球");
            b2 = new JCheckBox("音乐");
            b3 = new JCheckBox("舞蹈");
            b4 = new JCheckBox("主持");
            bg = new ButtonGroup();            
            bg.add(b1);
            bg.add(b2);
            bg.add(b3);
            bg.add(b4);
            add(name);
            add(number);
            add(adress);
            add(intruduction);
            add(sex1);
            add(sex2);
            add(b1);
            add(b2);
            add(b3);
            add(b4);
            add(photo);
            getContentPane().add(new JScrollPane(p1));
            
        }
        
    }
只有本站会员才能查看附件,请 登录
1 回复
#2
Poppy辉2016-12-01 10:30
回复 楼主 Poppy辉
就是这个图片太大了 如何缩小并移动位置
1