So I have created a JTextArea (in my case TextArea - to override append
and setText
methods that include line breaks), to visualise end user what is going on at what time.
I have:
- limited space
- Vision for the general look
I want to have that TextField "scrollable", but also I want the size to be whatever I setPrefferedSize
to.
In first place, scrolling ability didn't work - this has been solved by removing the setPrefferedSize
from the code.
Just to see what would happen I tried doing setSize
, which didn't help either.
Is it possible to combine those two functionalities? I position scrolling ability beyond the size, because I can just spam spaces, which doesn't sound like supported way to do it...
[...]
TextArea interfaceArea = new TextArea();
interfaceArea.setBorder(BorderFactory.createLoweredBevelBorder());
// interfaceArea.setLineWrap(true);
// interfaceArea.setPreferredSize(new Dimension(650, 70));
// interfaceArea.setSize(new Dimension(650, 70));
interfaceArea.setFont(FONT_BAGHDAD);
interfaceArea.setText("PLACEHOLDER FOR LOGS\n");
interfaceArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(interfaceArea);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
interfacePanel.add(scrollPane);
[...]