X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FTextFrame.java;h=11954fa514b55f64d8f2c9d7f8aba241f5e8be7d;hb=06b38f91bc061d8ab1dfea3b6238c94c95a30d26;hp=54c6f800f70a11a99cb6494c6926dbe9c46d8b50;hpb=ccf4c584032d16ed0ed8d0678f01305887724f96;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/TextFrame.java b/forester/java/src/org/forester/archaeopteryx/TextFrame.java index 54c6f80..11954fa 100644 --- a/forester/java/src/org/forester/archaeopteryx/TextFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/TextFrame.java @@ -8,7 +8,7 @@ // and Howard Hughes Medical Institute // Copyright (C) 2003-2007 Ethalinda K.S. Cannon // All rights reserved -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -18,13 +18,13 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.archaeopteryx; @@ -41,6 +41,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.util.LinkedList; import javax.swing.JButton; import javax.swing.JFrame; @@ -53,24 +54,26 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner { /** * */ - private static final long serialVersionUID = -5012834229705518363L; - private static Color ta_text_color = new Color( 0, 0, 0 ), + private static final long serialVersionUID = -5012834229705518363L; + private static Color ta_text_color = new Color( 0, 0, 0 ), ta_background_color = new Color( 240, 240, 240 ), background_color = new Color( 215, 215, 215 ), button_background_color = new Color( 215, 215, 215 ), button_text_color = new Color( 0, 0, 0 ); - private final static Font button_font = new Font( "Helvetica", Font.PLAIN, 10 ), + private final static Font button_font = new Font( "Helvetica", Font.PLAIN, 10 ), ta_font = new Font( "Helvetica", Font.PLAIN, 10 ); - private boolean can_use_clipboard; - private final String text; - private final JTextArea jtextarea; - private final JButton close_button; - private JButton copy_button; - private final JPanel buttonjpanel; - private final Container contentpane; + private boolean can_use_clipboard; + private final String text; + private final JTextArea jtextarea; + private final JButton close_button; + private JButton copy_button; + private final JPanel buttonjpanel; + private final Container contentpane; + private final LinkedList _tframes; - private TextFrame( final String s ) { + private TextFrame( final String s, final String title, final LinkedList tframes ) { // first things first - setTitle( Constants.PRG_NAME ); + setTitle( title ); text = s; + _tframes = tframes; // check to see if we have permission to use the clipboard: can_use_clipboard = true; final SecurityManager sm = System.getSecurityManager(); @@ -118,16 +121,17 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner { @Override public void windowClosing( final WindowEvent e ) { - close(); + removeMe(); } } ); setVisible( true ); } + @Override public void actionPerformed( final ActionEvent e ) { final Object o = e.getSource(); if ( o == close_button ) { - close(); + removeMe(); } else if ( o == copy_button ) { copy(); @@ -139,6 +143,14 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner { dispose(); } + void removeMe() { + final int i = _tframes.indexOf( this ); + if ( i >= 0 ) { + _tframes.remove( i ); + } + close(); + } + private void copy() { if ( !can_use_clipboard ) { // can't do this! @@ -149,10 +161,11 @@ final class TextFrame extends JFrame implements ActionListener, ClipboardOwner { sys_clipboard.setContents( contents, this ); } + @Override public void lostOwnership( final Clipboard clipboard, final Transferable contents ) { } - static TextFrame instantiate( final String s ) { - return new TextFrame( s ); + static TextFrame instantiate( final String s, final String title, final LinkedList tframes ) { + return new TextFrame( s, title, tframes ); } }