I am working on a java gui project. I want to add scoll to JTextArea component. Even though I added it, only Vertical scroll works. That's why the text goes to the bottom line. I do not want this, so 2'scroll can be used at the same time so that the text does not boil over to the bottom line.
My class :
package net.macesdev.duckclient.installer;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
public class DebugConsole {
public static void runWindow() {
// THEME_MANAGER
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // This line gives Windows Theme
} catch (Exception e) {
e.printStackTrace();
}
// CREATING_COMPOMENTS
JFrame window = new JFrame();
ImageIcon app_logo_image = new ImageIcon(DebugConsole.class.getResource("/net/macesdev/duckclient/installer/app_logo.png"));
// COMPOMENT_SETTINGS
Font mainTextF = new Font("Consolas", Font.PLAIN, 11);
JTextArea textArea = new JTextArea(20, 20);
JScrollPane scroll = new JScrollPane (textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// scroll.setPreferredSize(new Dimension(window.getPreferredSize()));
scroll.setSize(new Dimension(700, 700));
window.getContentPane().add(scroll);
textArea.setLineWrap(true);
textArea.setFont(mainTextF);
textArea.setBounds(10, 10, 465, 540);
textArea.setText("null");
textArea.setColumns(70);
// FRAME & PANEL SETTINGS
window.setVisible(true);
window.setTitle("Duck Client Installer - Debug Console");
window.setIconImage(app_logo_image.getImage());
window.setResizable(true);
window.setLocationRelativeTo(null);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
int formSizeX = 500;
int formSizeY = 600;
window.setSize(formSizeX,formSizeY);
}
}
I've been working on it for several hours, but I couldn't find much useful information. Can you help me?