Mình đang tập tành làm về giao diện với Java.


Trong quá trình làm thì mình bị mắc lỗi TextArea và JSrollPane.
khi viết trong Text area, độ rộng của khuôn text area sẽ tự động giãn ra khỏi mặc định khi chữ viết lấn quá.
Trong khi đó JScrollPane lại ko hiển thị



/**
* DES Algorithm is done by
* HUNG VU PHAM, 06054292
*/


import java.awt.*;
import javax.swing.*;




public class DESAlgorithm extends JFrame
{
public static void main( String[] args )
{
JLabel plainText;
JTextField tfPlainText;
JButton btEncrypt, btDecrypt;
JTextArea taEncrypt, taDecrypt;
JPanel p1;
JScrollPane sp1, sp2;

JFrame frame = new JFrame("Information Security");// Create Frame and set title for the frame
//the program to terminate when the frame is closed
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
//Create Panel to contain all components
p1= new JPanel();
//Set FlowLayout, aligned left with horizontal gap 10 and vertical gap 20 between components
p1.setLayout(new FlowLayout());
frame.add(p1);// add panel to frame
//Get content
//Make Label
plainText = new JLabel("Plain Text Input");
//Make textfield
tfPlainText = new JTextField("Plain Text input",20);
//Encryption Output
btEncrypt = new JButton("Encryption");
taEncrypt = new JTextArea (10,30);
//taEncrypt.setEditable (false);
sp1 = new JScrollPane(taEncrypt, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//Decryption Output
btDecrypt = new JButton("Decryption");
taDecrypt = new JTextArea (10,30);
taDecrypt.setEditable (false);
//Add all components to panel
p1.add(plainText);
p1.add(tfPlainText);
p1.add(btEncrypt);
p1.add(taEncrypt);
p1.add(btDecrypt);
p1.add(taDecrypt);

frame.setSize(400,480);
frame.setVisible(true);
}
}




Mong các bạn xem qua và chỉnh sửa dùm mình.
Cám ơn rất nhiều