I would like to create a simple window that has a text area
where people cannot edit text area, and there should be a scroll bar for it also.
On the top right corner above the text area should be a button that says “Print Out Config”
the result is just a simple widow that has a blank text area with a scroll bar next to it, a button somewhere that says Print Out Config.
I have tried the following, but nothing shows up when I run the program.
so far this is what I have came up with
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.BorderLayout;
public class ConfigTester {
private static final int FRAME_WIDTH = 800;
private static final int FRAME_HEIGHT = 600;
public static void main(String[] args) {
JFrame myFrame = new JFrame("Config Editor 1.0");
myFrame.setBounds(0,0,FRAME_WIDTH,FRAME_HEIGHT);
myFrame.setVisible(true);
myFrame.addWindowListener( new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);} });
final int AREA_ROWS = 10;
final int AREA_COLUMNS= 30;
final JTextArea resultsArea = new JTextArea(AREA_ROWS, AREA_COLUMNS);
JScrollPane scrollPane = new JScrollPane(resultsArea);
resultsArea.setEditable(false);
JButton printAllButton = new JButton("Print Out Config");
JPanel northPanel = new JPanel();
northPanel.add(printAllButton);
myFrame.add(northPanel, BorderLayout.NORTH);
myFrame.add(scrollPane);
}
}