Swing/ProgressSplashScreen のバックアップ差分(No.1)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/ProgressSplashScreen へ行く。
- 1 (2011-03-26 (土) 23:13:17)
- 2 (2012-07-20 (金) 11:21:50)
- 3 (2013-01-04 (金) 16:01:37)
- 4 (2013-04-06 (土) 05:28:19)
- 5 (2013-06-20 (木) 12:02:31)
- 6 (2014-11-22 (土) 03:59:58)
- 7 (2014-12-14 (日) 14:37:34)
- 8 (2015-02-18 (水) 15:05:40)
- 9 (2016-11-29 (火) 13:55:07)
- 10 (2017-11-28 (火) 13:55:17)
- 11 (2019-08-01 (木) 22:51:48)
- 12 (2021-03-31 (水) 02:34:06)
- 13 (2024-02-10 (土) 17:48:26)
- 追加された行はこの色です。
- 削除された行はこの色です。
TITLE:JDialogでモーダルなJPorgressBar付きSplash Screenを表示する #navi(../) RIGHT:Posted by [[aterai]] at 2009-11-09 *JDialogでモーダルなJPorgressBar付きSplash Screenを表示する [#oab96a8e] JDialogでモーダルなJPorgressBar付きSplash Screenを表示します。 -&jnlp; -&jar; -&zip; //#screenshot #ref(http://lh5.ggpht.com/_9Z4BYR88imo/TQTRSxG9iaI/AAAAAAAAAg8/Wpd3hycacS4/s800/ProgressSplashScreen.png) **サンプルコード [#id39b4bd] #code{{ final JFrame frame = new JFrame(); final JDialog splashScreen = new JDialog(frame, Dialog.ModalityType.DOCUMENT_MODAL); final JProgressBar progress = new JProgressBar(); EventQueue.invokeLater(new Runnable() { public void run() { splashScreen.setUndecorated(true); splashScreen.getContentPane().add(new JLabel(new ImageIcon(getClass().getResource("splash.png")))); splashScreen.getContentPane().add(progress, BorderLayout.SOUTH); splashScreen.pack(); splashScreen.setLocationRelativeTo(null); splashScreen.setVisible(true); } }); SwingWorker<Void,Void> worker = new SwingWorker<Void,Void>() { public Void doInBackground() { try{ int current = 0; int lengthOfTask = 120; while(current<lengthOfTask && !isCancelled()) { try { Thread.sleep(50); }catch(InterruptedException ie) { ie.printStackTrace(); return null; } setProgress(100 * current++ / lengthOfTask); } }catch(Exception ex) { ex.printStackTrace(); } return null; } public void done() { splashScreen.dispose(); } }; worker.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if("progress".equals(e.getPropertyName())) { progress.setValue((Integer)e.getNewValue()); } } }); worker.execute(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); EventQueue.invokeLater(new Runnable() { public void run() { frame.setVisible(true); } }); }} **解説 [#febdc412] 上記のサンプルでは、以下のようなスプラッシュスクリーンを表示しています。 - モーダルなJDialogに、画像とJProgressBarを追加 - Dialog#setUndecorated(true)として、タイトルバーを非表示 - SwingWorkerを使って、進捗状態を表示 **参考リンク [#w26f24db] -[[JWindowを使ったSplash Screenの表示>Swing/SplashScreen]] **コメント [#i7601646] #comment