Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import javax.swing.text.BadLocationException;
- import javax.swing.text.Document;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class lol {
- public static void main(String[] args) {
- JFrame mainWindow = new JFrame();
- mainWindow.setTitle("Поиск заданного текста в файлах");
- mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- mainWindow.setSize(800,600);
- JTextArea textArea=new JTextArea("6 pos\n" +
- "15 pos\n" +
- "24 pos\n" +
- "38 pos\n" +
- "47 pos\n" +
- "51 pos\n" +
- "64 pos\n" +
- "68 pos\n" +
- "83 pos\n" +
- "97 pos\n" +
- "106 pos\n" +
- "110 pos\n" +
- "119 pos\n" +
- "123 pos\n" +
- "142 pos\n" +
- "146 pos\n" +
- "164 pos\n" +
- "168 pos\n" +
- "182 pos\n" +
- "191 pos\n" +
- "195 pos\n" +
- "204 pos\n" +
- "208 pos\n" +
- "222 pos\n" +
- "226 pos\n" +
- "240 pos\n" +
- "244 pos\n" +
- "263 pos\n" +
- "270 pos\n" +
- "274 pos\n" +
- "293 pos\n" +
- "297 pos\n" +
- "15 pos\n" +
- "24 pos\n" +
- "38 pos\n" +
- "47 pos\n" +
- "51 pos\n" +
- "64 pos\n" +
- "68 pos\n" +
- "83 pos\n" +
- "97 pos\n" +
- "106 pos\n" +
- "110 pos\n" +
- "119 pos\n" +
- "123 pos\n" +
- "142 pos\n" +
- "146 pos\n" +
- "164 pos\n" +
- "168 pos\n" +
- "182 pos\n" +
- "191 pos\n" +
- "195 pos\n" +
- "204 pos\n" +
- "208 pos\n" +
- "222 pos\n" +
- "226 pos\n" +
- "240 pos\n" +
- "244 pos\n" +
- "263 pos\n" +
- "270 pos\n" +
- "274 pos\n" +
- "293 pos\n" +
- "297 pos\n" +
- "301 pos");
- JScrollPane scrollPane=new JScrollPane(textArea);
- JButton btn = new JButton("asd");
- btn.addActionListener(new SelectDirListener(textArea));
- JSplitPane splitPane = new JSplitPane();
- mainWindow.add(splitPane);
- splitPane.setLeftComponent(scrollPane);
- splitPane.setRightComponent(btn);
- mainWindow.setLocationRelativeTo(null);
- mainWindow.setVisible(true);
- }
- public static class SelectDirListener implements ActionListener{
- static JTextArea textArea;
- public SelectDirListener(JTextArea textArea) {
- this.textArea=textArea;
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- Document textAreaDocument =textArea.getDocument();
- try {
- textAreaDocument.remove(0,2);
- //textAreaDocument.insertString(curPosition,replaceTo.getText(),null);
- } catch (BadLocationException ex) {
- JOptionPane.showMessageDialog(null, ex.getLocalizedMessage());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement