首页 > 代码库 > NetBeans Loading

NetBeans Loading

public JDialog showLoading() {
        JDialog dia = new JDialog();
        JPanel panel = new JPanel();
        panel.setBackground(new Color(220, 220, 220));
        BoxLayout layoutMgr = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
        panel.setLayout(layoutMgr);
        ClassLoader cldr = this.getClass().getClassLoader();
        java.net.URL imageURL = cldr.getResource("com/mapvision/dataspider/loading2.gif");
        ImageIcon imageIcon = new ImageIcon(imageURL);
        imageIcon.setImage(imageIcon.getImage().getScaledInstance(300, 205, Image.SCALE_DEFAULT));
        JLabel iconLabel = new JLabel();
        iconLabel.setIcon(imageIcon);
        imageIcon.setImageObserver(iconLabel);
        JLabel label = new JLabel();
        label.setSize(300, 25);
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setText("正在加载城市列表,请耐心等待");
        label.setForeground(new Color(140, 140, 140));
        Font fname = new Font("宋体", 0, 14);
        label.setFont(fname);
        panel.add(iconLabel);
        panel.add(label);
        dia.setSize(300, 270);
        dia.add(panel);
        dia.setEnabled(false);
        dia.setAlwaysOnTop(true);
        dia.setLocationRelativeTo(null);
        dia.setTitle("加载城市列表");
        dia.show();
        return dia;
    }

NetBeans Loading