Skip to content
Snippets Groups Projects
Commit 0196c004 authored by tjc's avatar tjc
Browse files

mac handler added

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@2676 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 6fa1cd91
No related branches found
No related tags found
No related merge requests found
/* MacHandler.java
*
* created: May 2005
*
* This file is part of Artemis
*
* Copyright (C) 2005 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package uk.ac.sanger.artemis.components;
import com.apple.mrj.*;
import javax.swing.SwingUtilities;
class MacHandler
implements MRJQuitHandler, MRJPrefsHandler, MRJAboutHandler
{
Splash us;
public MacHandler(Splash theProgram, String title)
{
us = theProgram;
// System.setProperty("com.apple.mrj.application.apple.menu.about.name", title);
System.setProperty("apple.laf.useScreenMenuBar", "true");
MRJApplicationUtils.registerAboutHandler(this);
MRJApplicationUtils.registerPrefsHandler(this);
MRJApplicationUtils.registerQuitHandler(this);
}
public void handleAbout()
{
us.about();
}
public void handlePrefs()
{
// us.prefs();
}
public void handleQuit()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
us.exit();
}
});
throw new IllegalStateException("Let the quit handler do it");
}
}
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/Splash.java,v 1.8 2005-04-01 16:08:23 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/Splash.java,v 1.9 2005-05-25 12:33:02 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
......@@ -38,12 +38,13 @@ import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.lang.reflect.Constructor;
/**
* Base class that creates a generic "Splash Screen"
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: Splash.java,v 1.8 2005-04-01 16:08:23 tjc Exp $
* @version $Id: Splash.java,v 1.9 2005-05-25 12:33:02 tjc Exp $
**/
abstract public class Splash extends JFrame
......@@ -97,6 +98,22 @@ abstract public class Splash extends JFrame
{
super(program_title + " " + program_version);
if(isMac())
{
try
{
Object[] args = { this, program_title };
Class[] arglist = { Splash.class, String.class };
Class mac_class = getClass().forName("uk.ac.sanger.artemis.components.MacHandler");
Constructor new_one = mac_class.getConstructor(arglist);
new_one.newInstance(args);
}
catch(Exception e)
{
System.out.println(e);
}
}
this.program_name = program_name;
this.program_version = program_version;
......@@ -179,6 +196,30 @@ abstract public class Splash extends JFrame
(screen.height - getSize().height) / 2));
}
private boolean isMac()
{
return System.getProperty("mrj.version") != null;
}
public void about()
{
ClassLoader cl = this.getClass().getClassLoader();
ImageIcon icon = new ImageIcon(cl.getResource("images/icon.gif"));
JOptionPane.showMessageDialog(this,
getTitle()+ "\nthis is free software and is distributed"+
"\nunder the terms of the GNU General Public License.",
"About", JOptionPane.INFORMATION_MESSAGE,
icon);
// JOptionPane.showMessageDialog(this,
// getTitle()+ "\nthis is free software and is distributed"+
// "\nunder the terms of the GNU General Public License.");
}
/**
* Return a JComponent object that will display a helix and a short
* copyright notice.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment