Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. import javax.swing.*;
  2. import javax.swing.text.BadLocationException;
  3. import javax.swing.text.Document;
  4. import java.awt.*;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7.  
  8. public class lol {
  9. public static void main(String[] args) {
  10. JFrame mainWindow = new JFrame();
  11. mainWindow.setTitle("Поиск заданного текста в файлах");
  12. mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  13. mainWindow.setSize(800,600);
  14. JTextArea textArea=new JTextArea("6 pos\n" +
  15. "15 pos\n" +
  16. "24 pos\n" +
  17. "38 pos\n" +
  18. "47 pos\n" +
  19. "51 pos\n" +
  20. "64 pos\n" +
  21. "68 pos\n" +
  22. "83 pos\n" +
  23. "97 pos\n" +
  24. "106 pos\n" +
  25. "110 pos\n" +
  26. "119 pos\n" +
  27. "123 pos\n" +
  28. "142 pos\n" +
  29. "146 pos\n" +
  30. "164 pos\n" +
  31. "168 pos\n" +
  32. "182 pos\n" +
  33. "191 pos\n" +
  34. "195 pos\n" +
  35. "204 pos\n" +
  36. "208 pos\n" +
  37. "222 pos\n" +
  38. "226 pos\n" +
  39. "240 pos\n" +
  40. "244 pos\n" +
  41. "263 pos\n" +
  42. "270 pos\n" +
  43. "274 pos\n" +
  44. "293 pos\n" +
  45. "297 pos\n" +
  46. "15 pos\n" +
  47. "24 pos\n" +
  48. "38 pos\n" +
  49. "47 pos\n" +
  50. "51 pos\n" +
  51. "64 pos\n" +
  52. "68 pos\n" +
  53. "83 pos\n" +
  54. "97 pos\n" +
  55. "106 pos\n" +
  56. "110 pos\n" +
  57. "119 pos\n" +
  58. "123 pos\n" +
  59. "142 pos\n" +
  60. "146 pos\n" +
  61. "164 pos\n" +
  62. "168 pos\n" +
  63. "182 pos\n" +
  64. "191 pos\n" +
  65. "195 pos\n" +
  66. "204 pos\n" +
  67. "208 pos\n" +
  68. "222 pos\n" +
  69. "226 pos\n" +
  70. "240 pos\n" +
  71. "244 pos\n" +
  72. "263 pos\n" +
  73. "270 pos\n" +
  74. "274 pos\n" +
  75. "293 pos\n" +
  76. "297 pos\n" +
  77. "301 pos");
  78. JScrollPane scrollPane=new JScrollPane(textArea);
  79. JButton btn = new JButton("asd");
  80. btn.addActionListener(new SelectDirListener(textArea));
  81. JSplitPane splitPane = new JSplitPane();
  82. mainWindow.add(splitPane);
  83. splitPane.setLeftComponent(scrollPane);
  84. splitPane.setRightComponent(btn);
  85. mainWindow.setLocationRelativeTo(null);
  86. mainWindow.setVisible(true);
  87. }
  88. public static class SelectDirListener implements ActionListener{
  89. static JTextArea textArea;
  90. public SelectDirListener(JTextArea textArea) {
  91. this.textArea=textArea;
  92. }
  93.  
  94. @Override
  95. public void actionPerformed(ActionEvent e) {
  96. Document textAreaDocument =textArea.getDocument();
  97. try {
  98. textAreaDocument.remove(0,2);
  99. //textAreaDocument.insertString(curPosition,replaceTo.getText(),null);
  100. } catch (BadLocationException ex) {
  101. JOptionPane.showMessageDialog(null, ex.getLocalizedMessage());
  102. }
  103. }
  104. }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement