001 /** 002 * iFish - An iRiver iHP jukebox database creation tool 003 * 004 * Copyright (C) 2009 Richard "Shred" Körber 005 * http://ifish.shredzone.org 006 * 007 * This program is free software: you can redistribute it and/or modify 008 * it under the terms of the GNU General Public License as published by 009 * the Free Software Foundation, either version 3 of the License, or 010 * (at your option) any later version. 011 * 012 * This program is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU General Public License for more details. 016 * 017 * You should have received a copy of the GNU General Public License 018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 019 */ 020 package net.shredzone.ifish.actions; 021 022 import net.shredzone.ifish.*; 023 import net.shredzone.ifish.gui.*; 024 import net.shredzone.ifish.i18n.L; 025 import net.shredzone.ifish.pool.ImgPool; 026 import net.shredzone.jshred.swing.SwingUtils; 027 import java.awt.*; 028 import java.awt.event.*; 029 030 import javax.swing.*; 031 032 /** 033 * Shows the About window. 034 * 035 * @author Richard Körber <dev@shredzone.de> 036 * @version $Id: AboutAction.java 291 2009-04-28 21:29:27Z shred $ 037 */ 038 public class AboutAction extends IFishAction implements net.shredzone.ifish.Version { 039 private static final long serialVersionUID = 3257288041155277366L; 040 041 private JDialog dialog; 042 private JButton jbOK; 043 044 /** 045 * Create a new AboutAction. 046 * 047 * @param fish Related IFishPane 048 */ 049 public AboutAction( IFishPane fish ) { 050 super( 051 fish, 052 L.tr("action.about"), 053 ImgPool.get("about.png"), 054 L.tr("action.about.tt"), 055 KeyStroke.getKeyStroke( KeyEvent.VK_I, ActionEvent.CTRL_MASK ) 056 ); 057 } 058 059 /** 060 * The action implementation itself. Do not call directly. 061 */ 062 @Override 063 protected void action() { 064 if( dialog!=null ) { 065 //--- Already open? --- 066 // Then bring it to front 067 dialog.setVisible( true ); 068 dialog.toFront(); 069 }else { 070 //--- Create an about pane --- 071 AboutPane pAbout = new AboutPane(); 072 { 073 //--- Add the OK Button --- 074 JPanel jpOK = new JPanel( new FlowLayout( FlowLayout.TRAILING, 0,5 ) ); 075 { 076 jbOK = new JButton( L.tr("a.about.close"), ImgPool.get("accept.png") ); 077 jbOK.addActionListener( new ActionListener() { 078 @Override 079 public void actionPerformed( ActionEvent e ) { 080 if( dialog!=null ) dialog.setVisible( false ); 081 } 082 }); 083 jpOK.add( jbOK ); 084 } 085 SwingUtils.setMinimumHeight( jpOK ); 086 pAbout.add( jpOK ); 087 } 088 pAbout.setBorder( BorderFactory.createEmptyBorder( 5,5,0,5 ) ); 089 090 //--- Open the About modal dialog --- 091 dialog = new JDialog( 092 SwingUtils.getComponentFrame( fish ), 093 L.tr("a.about.title"), 094 true 095 ); 096 dialog.getContentPane().add( pAbout ); 097 098 SwingUtils.setConfirmKey( dialog, jbOK ); 099 SwingUtils.setCancelKey( dialog, jbOK ); 100 101 dialog.pack(); 102 dialog.setSize( 600,420 ); 103 dialog.setLocationRelativeTo( dialog.getOwner() ); 104 pAbout.bubble(); 105 dialog.setVisible( true ); 106 107 //--- Remember to remove the bubbles thread --- 108 pAbout.closed(); 109 110 //--- Dispose the dialog --- 111 dialog.dispose(); 112 dialog = null; 113 } 114 } 115 116 } 117