import java.awt.event.*;\r
\r
import javax.swing.*;\r
-\r
+import javax.swing.event.CaretListener;\r
+import javax.swing.event.CaretEvent;\r
\r
public class GFinder extends JPanel {\r
JLabel jLabel1 = new JLabel();\r
- protected JTextField textfield = new JTextField();\r
- protected JButton findAll = new JButton();\r
+ protected JButton findAll = new JButton();\r
protected JButton findNext = new JButton();\r
JPanel jPanel1 = new JPanel();\r
GridLayout gridLayout1 = new GridLayout();\r
protected JButton createNewGroup = new JButton();\r
-\r
- public GFinder() {\r
+ JScrollPane jScrollPane1 = new JScrollPane();\r
+ protected JTextArea textfield = new JTextArea();\r
+ BorderLayout borderLayout1 = new BorderLayout();\r
+ JPanel jPanel2 = new JPanel();\r
+ JPanel jPanel3 = new JPanel();\r
+ JPanel jPanel4 = new JPanel();\r
+ BorderLayout borderLayout2 = new BorderLayout();\r
+ JPanel jPanel5 = new JPanel();\r
+ JPanel jPanel6 = new JPanel();\r
+ public GFinder() {\r
try {\r
jbInit();\r
} catch (Exception e) {\r
private void jbInit() throws Exception {\r
jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));\r
jLabel1.setText("Find");\r
- jLabel1.setBounds(new Rectangle(3, 30, 34, 15));\r
- this.setLayout(null);\r
- textfield.setFont(new java.awt.Font("Verdana", 0, 12));\r
- textfield.setText("");\r
- textfield.setBounds(new Rectangle(40, 27, 133, 21));\r
- textfield.addKeyListener(new java.awt.event.KeyAdapter() {\r
- public void keyTyped(KeyEvent e) {\r
- textfield_keyTyped(e);\r
- }\r
- });\r
- textfield.addActionListener(new java.awt.event.ActionListener() {\r
- public void actionPerformed(ActionEvent e) {\r
- textfield_actionPerformed(e);\r
- }\r
- });\r
- findAll.setFont(new java.awt.Font("Verdana", 0, 12));\r
+ this.setLayout(borderLayout1);\r
+ findAll.setFont(new java.awt.Font("Verdana", 0, 12));\r
findAll.setText("Find all");\r
findAll.addActionListener(new java.awt.event.ActionListener() {\r
public void actionPerformed(ActionEvent e) {\r
findNext_actionPerformed(e);\r
}\r
});\r
- jPanel1.setBounds(new Rectangle(180, 5, 141, 64));\r
- jPanel1.setLayout(gridLayout1);\r
+ jPanel1.setLayout(gridLayout1);\r
gridLayout1.setHgap(0);\r
gridLayout1.setRows(3);\r
gridLayout1.setVgap(2);\r
createNewGroup_actionPerformed(e);\r
}\r
});\r
- jPanel1.add(findNext, null);\r
+ textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12));\r
+ textfield.setText("");\r
+ textfield.setLineWrap(true);\r
+ textfield.addCaretListener(new CaretListener()\r
+ {\r
+ public void caretUpdate(CaretEvent e)\r
+ {\r
+ textfield_caretUpdate(e);\r
+ }\r
+ });\r
+ borderLayout1.setHgap(5);\r
+ borderLayout1.setVgap(5);\r
+ jPanel4.setLayout(borderLayout2);\r
+ jPanel2.setPreferredSize(new Dimension(10, 1));\r
+ jPanel3.setPreferredSize(new Dimension(10, 1));\r
+ jPanel1.add(findNext, null);\r
jPanel1.add(findAll, null);\r
jPanel1.add(createNewGroup, null);\r
- this.add(textfield, null);\r
- this.add(jLabel1, null);\r
- this.add(jPanel1, null);\r
- }\r
+ this.add(jLabel1, java.awt.BorderLayout.WEST);\r
+ this.add(jPanel1, java.awt.BorderLayout.EAST);\r
+ this.add(jPanel2, java.awt.BorderLayout.SOUTH);\r
+ this.add(jPanel3, java.awt.BorderLayout.NORTH);\r
+ this.add(jPanel4, java.awt.BorderLayout.CENTER);\r
+ jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);\r
+ jPanel4.add(jPanel5, java.awt.BorderLayout.SOUTH);\r
+ jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH);\r
+ jScrollPane1.getViewport().add(textfield);\r
+ }\r
\r
protected void findNext_actionPerformed(ActionEvent e) {\r
}\r
\r
public void createNewGroup_actionPerformed(ActionEvent e) {\r
}\r
+\r
+ public void textfield_caretUpdate(CaretEvent e)\r
+ {\r
+ if (textfield.getText().indexOf("\t")>-1)\r
+ {\r
+ SwingUtilities.invokeLater(new Runnable()\r
+ {\r
+ public void run()\r
+ {\r
+ String text = textfield.getText();\r
+ text = text.substring(text.lastIndexOf("\t") + 1).trim();\r
+ text = jalview.analysis.AlignSeq.extractGaps(\r
+ jalview.util.Comparison.GapChars, text);\r
+ textfield.setText(text);\r
+ }\r
+ });\r
+ }\r
+ }\r
}\r