package com.mes.component; import javax.swing.*; import java.awt.*; public class MyDialog extends JDialog { public MyDialog(Frame owner, String title, String msg){ super(owner, title); init(msg); } private void init(String msg){ Container container = this.getContentPane(); container.setLayout(null); container.setBackground(Color.BLACK); this.setSize(800,220); this.setLocationRelativeTo(null); JLabel tslabel = new JLabel(msg); tslabel.setHorizontalAlignment(SwingConstants.CENTER); tslabel.setForeground(Color.RED); tslabel.setFont(new Font("微软雅黑", Font.PLAIN,48)); tslabel.setBounds(0,30,800,100); container.add(tslabel); this.setModal(true); this.setVisible(true); } }