gvsu/cs623/proj1/RetirementCalculator.java
josh dd5b4a7bf1 filling out more Model functions
git-svn-id: svn://anubis/gvsu@434 45c1a28c-8058-47b2-ae61-ca45b979098e
2009-10-03 18:24:47 +00:00

69 lines
1.9 KiB
Java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
/*
* The main work of the application is done in this JPanel-extending class.
* This allows the java class to be run as a stand-alone application or
* as an applet within a web browser.
*/
class RetirementCalculatorPanel extends JPanel implements ActionListener
{
private RetirementCalculatorModel myModel;
public RetirementCalculatorPanel()
{
JPanel inner = new JPanel(new GridLayout(3, 2));
inner.add(new JLabel("How much annual income will you want in retirement?"));
inner.add(new JTextField());
JScrollPane scrollpane = new JScrollPane(inner,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
add(scrollpane);
}
public void actionPerformed(ActionEvent e)
{
}
}
/*
* The "main" class of this file allows the app to be run as an applet
* but also provides a "main" method to run as an application.
*/
public class RetirementCalculator extends JApplet
{
final static private String PROG_NAME = "Josh's Retirement Calculator";
RetirementCalculatorPanel panel;
public void init()
{
setLayout(new BorderLayout());
panel = new RetirementCalculatorPanel();
add(panel, BorderLayout.CENTER);
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run()
{
JFrame frame = new JFrame(PROG_NAME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
RetirementCalculatorPanel panel =
new RetirementCalculatorPanel();
frame.getContentPane().add(panel);
frame.setPreferredSize(new Dimension(600, 450));
frame.pack();
frame.setVisible(true);
}
});
}
}