public void run() {
makeGUI(); // initialize the GUI
}
});
} catch(Exception exc) {
System.out.println("Can't create because of "+ exc);
}
}
// Set up and initialize the GUI.
private void makeGUI() {
// Use a grid bag layout.
GridBagLayout gbag = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
setLayout(gbag);
JLabel heading = new
JLabel("Initial Investment Needed for " +
"Regular Withdrawals");
JLabel
regWDLab = new JLabel("Desired Withdrawal ");
JLabel
periodLab = new JLabel("Years ");
JLabel
rateLab = new JLabel("Rate of Return ");
JLabel
numWDLab =
new JLabel("Number of Withdrawals per Year ");
JLabel initialLab =
new JLabel("Initial Investment Required ");
regWDText = new JTextField(10);
periodText = new JTextField(10);
initialText = new JTextField(10);
rateText = new JTextField(10);
numWDText = new JTextField(10);
// Initial investment field for display only.
initialText.setEditable(false);
doIt = new JButton("Compute");
// Define the grid bag.
gbc.weighty = 1.0; // use a row weight of 1
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.anchor = GridBagConstraints.NORTH;
gbag.setConstraints(heading, gbc);
// Anchor most components to the right.
gbc.anchor = GridBagConstraints.EAST;
gbc.gridwidth = GridBagConstraints.RELATIVE;
gbag.setConstraints(regWDLab, gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home