3 TrakEM2 plugin for ImageJ(C).
4 Copyright (C) 2005, 2006, 2007 Albert Cardona and Rodney Douglas.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation (http://www.gnu.org/licenses/gpl.txt )
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 You may contact Albert Cardona at acardona at ini.phys.ethz.ch
20 Institute of Neuroinformatics, University of Zurich / ETH, Switzerland.
22 package ini
.trakem2
.display
;
26 import java
.awt
.event
.*;
28 /** A modal dialog box with a one line message and
29 "Yes" and "No" buttons.
30 Almost literally copied from ij.gui.YesNoCancelDialog class
32 public class YesNoDialog
extends Dialog
implements ActionListener
, KeyListener
{
33 private Button yesB
, noB
;
34 private boolean yesPressed
;
35 private boolean firstPaint
= true;
37 public YesNoDialog(String title
, String msg
) {
38 this(IJ
.getInstance(), title
, msg
);
41 public YesNoDialog(Frame parent
, String title
, String msg
) {
42 super(parent
, title
, true);
43 setLayout(new BorderLayout());
44 Panel panel
= new Panel();
45 panel
.setLayout(new FlowLayout(FlowLayout
.LEFT
, 10, 10));
46 MultiLineLabel message
= new MultiLineLabel(msg
);
47 message
.setFont(new Font("Dialog", Font
.PLAIN
, 12));
52 panel
.setLayout(new FlowLayout(FlowLayout
.RIGHT
, 15, 8));
53 if (IJ
.isMacintosh() && msg
.startsWith("Save")) {
54 yesB
= new Button(" Save ");
55 noB
= new Button("Don't Save");
57 yesB
= new Button(" Yes ");
58 noB
= new Button(" No ");
60 yesB
.addActionListener(this);
61 noB
.addActionListener(this);
62 yesB
.addKeyListener(this);
63 noB
.addKeyListener(this);
64 if (IJ
.isMacintosh()) {
78 public void actionPerformed(ActionEvent e
) {
79 if (e
.getSource()==yesB
)
84 /** Returns true if the user dismissed dialog by pressing "Yes". */
85 public boolean yesPressed() {
94 public void keyPressed(KeyEvent e
) {
95 int keyCode
= e
.getKeyCode();
96 IJ
.setKeyDown(keyCode
);
97 if (keyCode
==KeyEvent
.VK_ENTER
||keyCode
==KeyEvent
.VK_Y
||keyCode
==KeyEvent
.VK_S
) {
102 // PREVENTING unintentional saving of projects. TODO setup an auto save just like Blender, a .quit file with the contents of the last XML, without exporting images (but with their correct paths) (maybe as an .xml1, similar to the .blend1)
103 } else if (keyCode
==KeyEvent
.VK_N
|| keyCode
==KeyEvent
.VK_D
) {
108 public void keyReleased(KeyEvent e
) {
109 int keyCode
= e
.getKeyCode();
110 IJ
.setKeyUp(keyCode
);
113 public void keyTyped(KeyEvent e
) {}
115 public void paint(Graphics g
) {