I am in the middle of a program and have a quick question and not sure how i do this...
"have the Frame display in the center of the monitor "
//import packages
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
//create a subclass at the fram class
public class RectangleApp extends Frame implements ActionListener
{
//construct variables
private Label lengthLabel = new Label("Enter the length: ", Label.RIGHT);
private Label widthLabel = new Label("Enter the width: ", Label.RIGHT);
private Label areaLabel = new Label("Area: ", Label.RIGHT);
private Label perimeterLabel = new Label("Perimeter: ", Label.RIGHT);
private Panel topPanel;
private Button calculateButton;
private Button exitButton;
private TextField lengthField = new TextField(10);
private TextField widthField = new TextField(10);
private TextField areaField = new TextField(10);
private TextField perimeterField = new TextField(10);
//constructor method
public RectangleApp()
{
//create an instance of the menu
MenuBar mnuBar = new MenuBar();
setMenuBar(mnuBar); //display the previously constructed MenuBar
//construct and populate File Menu
Menu mnuFile = new Menu("File"); //create a command on the MenuBar
mnuBar.add(mnuFile);
MenuItem mnuFileExit = new MenuItem("Exit");
//construct a command to go under a menu
mnuFile.add(mnuFileExit);
//construct and populate the edit menu
Menu mnuEdit = new Menu("Edit");
mnuBar.add(mnuEdit);
MenuItem mnuEditClear = new MenuItem("Clear");
mnuEdit.add(mnuEditClear);
//register the action listener with each of the menuitems
mnuFileExit.addActionListener(this);
mnuEditClear.addActionListener(this);
//assign an ActionCommand to each of the MenuItems
mnuFileExit.setActionCommand("Exit");
mnuEditClear.setActionCommand("Clear");
//set layouts for the Frame and Panels
setLayout(new BorderLayout());
topPanel.setLayout(new GridLayout(5, 2, 5, 5));
//allow the x to close the application
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
} //end window adapter
);
} //end calculator[] constructor method
public static void main(String args [])
{
//construct an instance of the Frame (Calculator)
RectangleApp f = new RectangleApp();
f.setTitle("Area and Perimeter of a Rectangle");
f.setSize(350, 200);
f.setLocationRelativeTo(null);
f.setVisible(true);
} //end main
public void actionPerformed(ActionEvent e)
{
} //and action performed
} //end class