if you do Pull requests in furture I can do propper comments but anyway in relation to the code:
public HelloWorldGUI()
{
setTitle("Hello World in Java");//DOMS COMMENTS - MAKE THIS A CONSTANT STRING
Container c = getContentPane(); //DOMS COMMENTS - c is not a good name contentPane seems better
setSize(WIDTH, HEIGHT);
c.setLayout(new GridLayout(3,1));
//DOMS COMMENTS - REMOVE SPACES
// define textarea and buttons
displayBox = new JTextArea(1,3);
printB = new JButton("Print");//DOMS COMMENTS -call it printButton instead i think
exitB = new JButton("Exit");//DOMS COMMENTS -call it exitButton instead i think
//DOMS COMMENTS - Good spacing here !!!! and below before // add items to pane
// button setup for action listener
exitB.addActionListener(this);
printB.addActionListener(this);
// add items to pane
c.add(displayBox);
c.add(printB);
c.add(exitB);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("Print"))//DOMS COMMENTS - MAKE THIS A CONSTANT STRING
{
displayBox.setText("Hello World"); //DOMS COMMENTS - MAKE THIS A CONSTANT STRING
else if (e.getActionCommand().equals("Exit")) //DOMS COMMENTS - MAKE THIS A CONSTANT STRING
System.exit(0); // Close the application.
}
if you do Pull requests in furture I can do propper comments but anyway in relation to the code: public HelloWorldGUI() { setTitle("Hello World in Java");//DOMS COMMENTS - MAKE THIS A CONSTANT STRING Container c = getContentPane(); //DOMS COMMENTS - c is not a good name contentPane seems better setSize(WIDTH, HEIGHT); c.setLayout(new GridLayout(3,1)); //DOMS COMMENTS - REMOVE SPACES