From: amwaterhouse Date: Thu, 16 Jun 2005 09:35:21 +0000 (+0000) Subject: textarea replaces textfield - can cut and paste sequence from seqpanel X-Git-Tag: Release_2_0~18 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1cd8649ecb6dbce0c78389b112052542fd8cd7bc;p=jalview.git textarea replaces textfield - can cut and paste sequence from seqpanel --- diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index 5aa9db1..554d8bc 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -22,18 +22,26 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; - +import javax.swing.event.CaretListener; +import javax.swing.event.CaretEvent; public class GFinder extends JPanel { JLabel jLabel1 = new JLabel(); - protected JTextField textfield = new JTextField(); - protected JButton findAll = new JButton(); + protected JButton findAll = new JButton(); protected JButton findNext = new JButton(); JPanel jPanel1 = new JPanel(); GridLayout gridLayout1 = new GridLayout(); protected JButton createNewGroup = new JButton(); - - public GFinder() { + JScrollPane jScrollPane1 = new JScrollPane(); + protected JTextArea textfield = new JTextArea(); + BorderLayout borderLayout1 = new BorderLayout(); + JPanel jPanel2 = new JPanel(); + JPanel jPanel3 = new JPanel(); + JPanel jPanel4 = new JPanel(); + BorderLayout borderLayout2 = new BorderLayout(); + JPanel jPanel5 = new JPanel(); + JPanel jPanel6 = new JPanel(); + public GFinder() { try { jbInit(); } catch (Exception e) { @@ -44,22 +52,8 @@ public class GFinder extends JPanel { private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); jLabel1.setText("Find"); - jLabel1.setBounds(new Rectangle(3, 30, 34, 15)); - this.setLayout(null); - textfield.setFont(new java.awt.Font("Verdana", 0, 12)); - textfield.setText(""); - textfield.setBounds(new Rectangle(40, 27, 133, 21)); - textfield.addKeyListener(new java.awt.event.KeyAdapter() { - public void keyTyped(KeyEvent e) { - textfield_keyTyped(e); - } - }); - textfield.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - textfield_actionPerformed(e); - } - }); - findAll.setFont(new java.awt.Font("Verdana", 0, 12)); + this.setLayout(borderLayout1); + findAll.setFont(new java.awt.Font("Verdana", 0, 12)); findAll.setText("Find all"); findAll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { @@ -74,8 +68,7 @@ public class GFinder extends JPanel { findNext_actionPerformed(e); } }); - jPanel1.setBounds(new Rectangle(180, 5, 141, 64)); - jPanel1.setLayout(gridLayout1); + jPanel1.setLayout(gridLayout1); gridLayout1.setHgap(0); gridLayout1.setRows(3); gridLayout1.setVgap(2); @@ -89,13 +82,34 @@ public class GFinder extends JPanel { createNewGroup_actionPerformed(e); } }); - jPanel1.add(findNext, null); + textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12)); + textfield.setText(""); + textfield.setLineWrap(true); + textfield.addCaretListener(new CaretListener() + { + public void caretUpdate(CaretEvent e) + { + textfield_caretUpdate(e); + } + }); + borderLayout1.setHgap(5); + borderLayout1.setVgap(5); + jPanel4.setLayout(borderLayout2); + jPanel2.setPreferredSize(new Dimension(10, 1)); + jPanel3.setPreferredSize(new Dimension(10, 1)); + jPanel1.add(findNext, null); jPanel1.add(findAll, null); jPanel1.add(createNewGroup, null); - this.add(textfield, null); - this.add(jLabel1, null); - this.add(jPanel1, null); - } + this.add(jLabel1, java.awt.BorderLayout.WEST); + this.add(jPanel1, java.awt.BorderLayout.EAST); + this.add(jPanel2, java.awt.BorderLayout.SOUTH); + this.add(jPanel3, java.awt.BorderLayout.NORTH); + this.add(jPanel4, java.awt.BorderLayout.CENTER); + jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); + jPanel4.add(jPanel5, java.awt.BorderLayout.SOUTH); + jPanel4.add(jPanel6, java.awt.BorderLayout.NORTH); + jScrollPane1.getViewport().add(textfield); + } protected void findNext_actionPerformed(ActionEvent e) { } @@ -112,4 +126,22 @@ public class GFinder extends JPanel { public void createNewGroup_actionPerformed(ActionEvent e) { } + + public void textfield_caretUpdate(CaretEvent e) + { + if (textfield.getText().indexOf("\t")>-1) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + String text = textfield.getText(); + text = text.substring(text.lastIndexOf("\t") + 1).trim(); + text = jalview.analysis.AlignSeq.extractGaps( + jalview.util.Comparison.GapChars, text); + textfield.setText(text); + } + }); + } + } }