Advertisement
makispaiktis

TextPanel (Swing)

Feb 19th, 2019 (edited)
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2.  
  3. import javax.swing.JPanel;
  4. import javax.swing.JScrollPane;
  5. import javax.swing.JTextArea;
  6.  
  7. public class TextPanel extends JPanel {
  8.    
  9.     // Variables-components
  10.     private JTextArea textArea;
  11.    
  12.     // Constructor
  13.     public TextPanel() {
  14.         // Initialize the variables
  15.         textArea = new JTextArea();
  16.         // Create the layout and determine the position of textArea
  17.         setLayout(new BorderLayout());
  18.         add(new JScrollPane(textArea), BorderLayout.CENTER);                // Gia na mporw na scrollarw stin textArea (tin pernaw san orisma sto JScrollPane)
  19.        
  20.     }
  21.    
  22.     // Methods
  23.     public void appendText(String text) {
  24.         textArea.append(text);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement