You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.lingnan.supermarket.view ; // 定义包名, 表示这段代码属于com.lingnan.supermarket.view这个包
import java.awt.BorderLayout ; // 导入BorderLayout类, 用于设置布局管理器
import javax.swing.ImageIcon ; // 导入ImageIcon类, 用于处理图片
import javax.swing.JFrame ; // 导入JFrame类, 用于创建窗口
import javax.swing.JLabel ; // 导入JLabel类, 用于显示文本或图片
import javax.swing.JPanel ; // 导入JPanel类, 用于创建面板
import javax.swing.SwingUtilities ; // 导入SwingUtilities类, 用于在事件调度线程中执行代码
public class SuperView extends JPanel { // 定义一个名为SuperView的公共类, 继承自JPanel类
private JLabel label ; // 声明一个私有的JLabel类型的变量, 用于显示图片
private JFrame jFrame ; // 声明一个私有的JFrame类型的变量, 用于引用窗口
public SuperView ( JFrame jFrame ) { // SuperView类的构造方法, 接收一个JFrame类型的参数
this . setLayout ( new BorderLayout ( ) ) ; // 设置面板的布局管理器为BorderLayout
initView ( ) ; // 调用初始化视图的方法
this . jFrame = jFrame ; // 将传入的JFrame参数赋值给成员变量jFrame
}
private void initView ( ) { // 定义一个私有的初始化视图的方法
//中间
label = new JLabel ( ) ; // 创建一个JLabel对象
label . setIcon ( new ImageIcon ( "static\\img\\3.png" ) ) ; // 设置JLabel的图标为指定的图片路径
label . setHorizontalAlignment ( SwingUtilities . CENTER ) ; // 设置标签的水平对齐方式为居中
label . setVerticalAlignment ( SwingUtilities . CENTER ) ; // 设置标签的垂直对齐方式为居中
this . add ( label , "Center" ) ; // 将标签添加到面板的中间位置
setVisible ( true ) ; // 设置面板可见
}
}