Hi there fellow comrades!
Thanks to you all I've managed to get my small experiment project going further but as you go further there are always obsticles so I again ran into one. I got a JTextArea outputting a list of running processes but JScrollPane isn't showing up but when I resize the window itself the JScrollPane hovers over the whole JTextArea.
Looks like this:
After sever hours of scratching the back of my head I decided to ask you guys!
Code is:
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridBagLayout;
import java.io.*;
import javax.swing.*;
public class JTask {
JButton button = new JButton();
JFrame frame = new JFrame();
JTextArea area = new JTextArea();
JScrollPane scrollPane = new JScrollPane();
JTask() throws IOException{
frame.setBounds(100, 100, 1000, 700);
frame.setLayout(null);
area.setFont(new Font("monospaced", Font.PLAIN, 14));
area.setBounds(5,25,972,500);
scrollPane.add(area);
scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setBounds(5,25,972,500);
scrollPane.setViewportView(area);
scrollPane.setEnabled(true);
scrollPane.setVisible(true);
scrollPane.repaint();
scrollPane.revalidate();
area.setVisible(true);
frame.add(scrollPane);
frame.add(area);
frame.setVisible(true);
try {
String line;
Process p = Runtime.getRuntime().exec(System.getenv("windir") +"\\system32\\"+"tasklist.exe");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
area.append(line);
area.append("\n");
}
input.close();
} catch (Exception e) {
e.printStackTrace();
}
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args []) throws IOException{
JTask task = new JTask();
}
}
I apologize for a messy code and if anything could be done better but I hope you understand that I am just a beginner that is trying to understand the mechanics of Java programming language and sink in into the world of Java. Thank you all in advance!