JAVA-现实文本和图像

image

package com.itheima;

import javax.swing.*;

public class JFrame04 {
    public static void main(String[] args) {
        JFrame jf=new JFrame();
        jf.setTitle("我爱大郎");
        jf.setSize(2400,2400);
        jf.setDefaultCloseOperation(3);
        jf.setLocationRelativeTo(null);
        jf.setAlwaysOnTop(false);
        jf.setLayout(null);        //取消窗体的默认布局
        //使用指定的文本框创建JLabel实例
        JLabel jLabel=new JLabel("好好学习");
        jLabel.setBounds(0,0,100,20);


        //使用指定的图像创建JLabel实例
        //从指定的文件创建ImageIcon
        //C:\Users\Administrator\IdeaProjects\ITHEIMA\images\1.png
//        ImageIcon imageIcon=new ImageIcon("C:\\Users\\Administrator\\IdeaProjects\\ITHEIMA\\images\\1.png");
//        JLabel jLabel1 = new JLabel(imageIcon);
        JLabel jLabel1 = new JLabel(new ImageIcon("images\\dalang.png"));
        jLabel1.setBounds(50,50,1080,1920);

        jf.add(jLabel1);
        jf.add(jLabel);
        //窗体可见
        jf.setVisible(true);



    }
}

posted @ 2022-10-29 21:58  NiceTwocu  阅读(9)  评论(0编辑  收藏  举报