downloadingdialog.java

来自「这是Java编程艺术一书附带的源代码」· Java 代码 · 共 34 行

JAVA
34
字号
import java.awt.*;
import javax.swing.*;

/* This class displays a simple dialog instructing the user
   that messages are being downloaded. */
public class DownloadingDialog extends JDialog
{
  // Constructor for dialog.
  public DownloadingDialog(Frame parent)
  {
    // Call super constructor, specifying that dialog is modal.
    super(parent, true);

    // Set dialog title.
    setTitle("E-mail Client");

    // Instruct window not to close when the "X" is clicked.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    // Put a message with a nice border in this dialog.
    JPanel contentPane = new JPanel();
    contentPane.setBorder(
      BorderFactory.createEmptyBorder(5, 5, 5, 5));
    contentPane.add(new JLabel("Downloading messages..."));
    setContentPane(contentPane);

    // Size dialog to components.
    pack();

    // Center dialog over application.
    setLocationRelativeTo(parent);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?