I'm currently working with JTextArea. My question is what should I do with the JTextArea so I can set a specific size and also if the text its too much to fit then add a slider on the JTextArea
?
This is the method that is creating my JTextArea
:
public JPanel create_Output_Panel(){
//Setup Main Panel of the Chat Application
JPanel panel = new JPanel();
title = BorderFactory.createTitledBorder("Server Screen");
title.setTitleJustification(TitledBorder.CENTER);
title.setTitleColor(Color.BLACK);
panel.setBorder(title); //Set title to the Panel
panel.setLayout(new BorderLayout());
//Store IP Address in a String variable
String ip_Address = new ChatServerViewer().getServer_IP_Addres();
JLabel label = new JLabel("You are connected to Server : " + ip_Address, SwingConstants.CENTER);
label.setFont(new Font("Serif", Font.PLAIN, 17));
panel.add(label,BorderLayout.NORTH);
JLabel label2 = new JLabel("Use .bye to log-out ", SwingConstants.CENTER);
label2.setFont(new Font("Serif", Font.BOLD, 20));
panel.add(label2);
//CREATE TEXT AREA FOR THE USER MESSAGES
textArea = new JTextArea(12,1);
textArea.setFont(new Font("Serif", Font.PLAIN, 25));
textArea.setEditable(false); //Block User from Editing the Text Area
textArea.setText("\n\n Server:");
textArea.append("\n Hello User !");
panel.add(textArea, BorderLayout.SOUTH);
return panel;
}