JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / test / jalview / gui / JAL1353bugdemo.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.gui;
22
23 import jalview.bin.Cache;
24
25 import java.awt.Dimension;
26 import java.awt.event.MouseAdapter;
27 import java.awt.event.MouseEvent;
28
29 import javax.swing.JDesktopPane;
30 import javax.swing.JFrame;
31 import javax.swing.JInternalFrame;
32 import javax.swing.JTextArea;
33
34 import org.testng.annotations.AfterClass;
35 import org.testng.annotations.BeforeClass;
36 import org.testng.annotations.Test;
37
38 public class JAL1353bugdemo
39 {
40
41   @BeforeClass(alwaysRun = true)
42   public static void setUpBeforeClass() throws Exception
43   {
44   }
45
46   @AfterClass(alwaysRun = true)
47   public static void tearDownAfterClass() throws Exception
48   {
49   }
50
51   volatile boolean finish = false;
52
53   @Test(groups = { "Functional" }, enabled = false)
54   public void test()
55   {
56     Cache.initLogger();
57     // final Desktop foo = new Desktop();
58     final JFrame cfoo = new JFrame("Crash Java");
59     final JDesktopPane foo = new JDesktopPane();
60     foo.setPreferredSize(new Dimension(600, 800));
61     cfoo.setSize(600, 800);
62     final JInternalFrame cont = new JInternalFrame("My Frame");
63     cont.setPreferredSize(new Dimension(400, 400));
64     String msg = "This is a dummy string. See the dummy string go.\n";
65     msg += msg; // 2
66     msg += msg; // 4
67     msg += msg; // 8
68     msg += msg; // 16
69     JTextArea evt = new JTextArea(
70             "Click here and drag text over this window to freeze java.\n\n"
71                     + msg);
72     cont.add(evt);
73     cont.pack();
74     foo.add("A frame", cont);
75     foo.setVisible(true);
76     foo.setEnabled(true);
77     foo.doLayout();
78     cfoo.add(foo);
79     // final JMenu jm = new JMenu("Do");
80     // JMenuItem jmi = new JMenuItem("this");
81     // jm.add(jmi);
82     evt.addMouseListener(new MouseAdapter()
83     {
84
85       @Override
86       public void mouseClicked(MouseEvent e)
87       {
88         // JFrame parent = new JFrame();
89         // parent.setBounds(foo.getBounds());
90         // JPanel oo = new JPanel();
91         // parent.add(oo);
92         // oo.setVisible(true);
93         // parent.setVisible(true);
94         EditNameDialog end = new EditNameDialog("Sequence Name",
95                 "Sequence Description", "label 1", "Label 2",
96                 "Try and drag between the two text fields", foo);// );cont.getRootPane());
97         assert (end != null);
98         finish = true;
99       }
100     });
101     cont.setVisible(true);
102
103     // jmi.addActionListener(new ActionListener()
104     // {
105     //
106     // @Override
107     // public void actionPerformed(ActionEvent arg0)
108     // {
109     // EditNameDialog end = new EditNameDialog("Sequence Name",
110     // "Sequence Description", "label 1", "Label 2",
111     // "Try and drag between the two text fields", cont);
112     // assert (end != null);
113     // finish = true;
114     // }
115     // });
116     foo.setVisible(true);
117     cfoo.setVisible(true);
118     while (!finish)
119     {
120       try
121       {
122         Thread.sleep(100);
123       } catch (InterruptedException x)
124       {
125       }
126     }
127   }
128
129 }