Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.event.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5.  
  6. public class TextArea1 implements ActionListener {
  7.  
  8. JTextArea text;
  9.  
  10. public static void main (String[] args) {
  11. TextArea1 gui = new TextArea1();
  12. gui.go();
  13. }
  14.  
  15. public void go() {
  16. JFrame frame = new JFrame();
  17. JPanel panel = new JPanel();
  18. JButton button = new JButton("Solo haz clic aqui");
  19. button.addActionListener(this);
  20. text = new JTextArea(10, 20);
  21. text.setLineWrap(true);
  22.  
  23. JScrollPane scroller = new JScrollPane(text);
  24. scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  25. scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  26.  
  27. panel.add(scroller);
  28.  
  29. frame.getContentPane().add(BorderLayout.CENTER, panel);
  30. frame.getContentPane().add(BorderLayout.SOUTH, button);
  31.  
  32. frame.setSize(350, 300);
  33. frame.setVisible(true);
  34. }
  35.  
  36. public void actionPerformed (ActionEvent ev){
  37. text.append("hiciste clic en el botón \n" );
  38. }
  39. }
Add Comment
Please, Sign In to add comment