public void translucentDialog(String msg) {
JLabel messageJLabel = new JLabel(msg);
messageJLabel.setBackground(new Color(0, 0, 0, 0));
showTranslucentMemberZheKouConfirmDialog(innerDlg, messageJLabel, 1);
}
public void showTranslucentMemberZheKouConfirmDialog(Window parentDialog, JLabel msgLab, int sec) {
secends = sec;
msgLab.setFont(getFontInTextBox());
msgLab.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
msgLab.setOpaque(false);
msgLab.setForeground(Color.WHITE);
msgLab.setHorizontalAlignment(SwingConstants.CENTER);
dialog = null == parentDialog ? new JDialog(MainFrame.getInstance()) : new JDialog(parentDialog);
dialog.setUndecorated(true);
UndergroundPanel mainPanel = new UndergroundPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(msgLab, BorderLayout.CENTER);
TransparentPanel pTmp = new TransparentPanel(new BorderLayout());
pTmp.add(mainPanel, BorderLayout.SOUTH);
pTmp.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0));
pTmp.setBackground(new Color(0, 0, 0, 0));
dialog.setContentPane(PanelWraper.wrapForFullScr(pTmp));
dialog.setModal(true);
dialog.setLocation(0, 0);
dialog.setResizable(false);
AWTUtilities.setWindowOpaque(dialog, false);
ScheduledExecutorService s = Executors.newSingleThreadScheduledExecutor();
s.scheduleAtFixedRate(() -> {
float translucent = 1.0f;
while (translucent > 0) {
dialog.setOpacity(translucent);
translucent -= 0.02f;
}
dialog.dispose();
s.shutdown();
}, 1, 1, TimeUnit.SECONDS);
dialog.pack();
dialog.setLocationRelativeTo(parentDialog);
dialog.setVisible(true);
}