import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FinalProject extends JFrame implements ActionListener
{
JLabel textPrompt;
JTextArea inputText;
JLabel keyPrompt;
JTextField inputKey;
Container container;
public FinalProject()
{
super( "Final Project " );
JTabbedPane tab = new JTabbedPane();
// constructing the Pool Panel
JPanel p1 = new JPanel();
JLabel label4,label5,lable6;
final JTextField text4,text5,text6,text13;
label4 = new JLabel();
label4.setText("Height:");
p1.add(label4);
text4 = new JTextField(20);
p1.add(text4);
JLabel space3 = new JLabel(" ");
p1.add(space3);
label5 = new JLabel();
label5.setText("Width:");
p1.add (label5);
text5 = new JTextField(20);
p1.add(text5);
JLabel space5 = new JLabel(" ");
p1.add(space5);
lable6 = new JLabel();
lable6.setText("Depth:");
p1.add(lable6);
text6 = new JTextField(20);
p1.add(text6);
JLabel space2 = new JLabel(" ");
p1.add(space2);
JButton button = new JButton("Enter");
p1.add(button);
tab.addTab( "Pool", null, p1, " Pool" );
text13 = new JTextField();
p1.add(text13);
button.addActionListener(this);
new ActionListener(){
public void actionPerformed(ActionEvent e) {
e.getActionCommand();
int length=Integer.parseInt(text4.getText());
int width=Integer.parseInt(text5.getText());
int depth=Integer.parseInt(text6.getText());
if (e.getActionCommand().equals("Enter")) {
int volume = ((length * width) * depth);
JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"for your pool.", JOptionPane.INFORMATION_MESSAGE);
}
}
};
// constructing the Hot Tube panel
new JLabel("Hot Tube");
JPanel p2 = new JPanel();
JLabel label7,label8,lable9;
final JTextField text7,text8,text9;{
label7 = new JLabel();
label7.setText("Height:");
p2.add(label7);
text7 = new JTextField(20);
p2.add(text7);
JLabel space6 = new JLabel(" ");
p2.add(space6);
label8 = new JLabel();
label8.setText("Width:");
p2.add(label8);
text8 = new JTextField(20);
p2.add(text8);
JLabel space7 = new JLabel(" ");
p2.add(space7);
lable9 = new JLabel();
lable9.setText("Depth:");
p2.add(lable9);
text9 = new JTextField(20);
p2.add(text9);
JLabel space8 = new JLabel(" ");
p2.add(space8);
JButton rbutton = new JButton("Oval");
p2.add(rbutton);
JButton rbutton1 = new JButton ("Round");
p2.add(rbutton1);
tab.addTab( "Hot Tube", null, p2, " Hot Tube" );
rbutton.addActionListener(this);
rbutton1.addActionListener(this);
new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
int length=Integer.parseInt(text7.getText());
int width=Integer.parseInt(text8.getText());
int depth=Integer.parseInt(text9.getText());
if(e.getActionCommand().equals("Oval")){
int volume = ((length * width) * depth);
JOptionPane.showMessageDialog(null, "The Volume is:"+volume,"" +
"for your oval hot tube.", JOptionPane.INFORMATION_MESSAGE);
}
else if(e.getActionCommand().equals("Round")){
int volume1= (((length/2)^2) * depth);
JOptionPane.showMessageDialog(null, "The Volume is:"+volume1,"" +
"for your round hot tube.", JOptionPane.INFORMATION_MESSAGE);
}
}
};
// constructing the Temperature Change panel
new JLabel( " Temperature Change!" );
JPanel p3 = new JPanel();
JLabel label10;
final JTextField text10;
label10 = new JLabel();
label10.setText("Temperature:");
p3.add(label10);
text10 = new JTextField(20);
p3.add(text10);
JButton button3 = new JButton("Enter");
p3.add(button3);
JCheckBox boxF = new JCheckBox("F");
p3.add(boxF);
JCheckBox boxC = new JCheckBox("C");
p3.add(boxC);
tab.addTab( "Temperature Change", null, p3, " Temperature Change" );
button3.addActionListener(this);
boxF.addActionListener(this);
boxC.addActionListener(this);
new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
int temperature=Integer.parseInt(text10.getText());
if(e.getActionCommand().equals("C")){
int temp = (( temperature* 9)/5+32);
JOptionPane.showMessageDialog(null, "The Celcuis temperature is changed to:"
+temp,"" +
"in fahrenheit", JOptionPane.INFORMATION_MESSAGE);
}
else if(e.getActionCommand().equals("F")){
int temp1= (((temperature - 32)/9)*5);
JOptionPane.showMessageDialog(null, "The farhrenheight temperature is changed to:"+temp1,""+
"in Celcius.", JOptionPane.INFORMATION_MESSAGE);
}
}
};
// constructing the Customer panel
JPanel p4 = new JPanel();
JLabel label1,label2;
final JTextField text1,text2;
label1 = new JLabel();
label1.setText("Name:");
p4.add(label1);
text1 = new JTextField(20);
p4.add(text1);
JLabel space = new JLabel(" ");//MDB
p4.add(space);
label2 = new JLabel();
label2.setText("Address:");
p4.add(label2);
text2 = new JTextField(20);
p4.add(text2);
JButton button4 = new JButton("Enter");
p4.add(button4);
tab.addTab( "Customer", null, p4, " Customer" );
button4.setActionCommand ("Enter");
new ActionListener(){
public void actionPerformed(ActionEvent e) {
e.getActionCommand();
int Name=Integer.parseInt(text1.getText()) ;
int Address=Integer.parseInt(text2.getText());
if (e.getActionCommand().equals("Enter")) {
JOptionPane.showMessageDialog(null, "Customer's name is:"+Name,"Their address is:"
+Address, JOptionPane.INFORMATION_MESSAGE);
}
}
};
// constructing the General panel
new JLabel( "General" );
JPanel p5 = new JPanel();
Date date = new Date();
SimpleDateFormat dateformatMMDDYYYY = new SimpleDateFormat("MM/dd/yyyy");
new StringBuilder( dateformatMMDDYYYY.format( date ) );
JLabel space11 = new JLabel(" ");
p5.add(space11);
JLabel space12 = new JLabel(" ");
p5.add(space12);
JLabel space13 = new JLabel(" ");
p5.add(space13);
JLabel label11;
label11 = new JLabel();
label11.setText("Today's Date is:");
p5.add(label11);
JLabel texta1;
texta1 = new JLabel();
texta1.setText(dateformatMMDDYYYY.format(date));
p5.add(texta1);
tab.addTab( "General", null, p5, " Today's Date");
//constructing the Manufacture panel
JPanel p6 = new JPanel();
JLabel label3;
final JTextField text3;
label3 = new JLabel();
label3.setText("Manufacture:");
p6.add(label3);
text3 = new JTextField(20);
p6.add(text3);
JLabel space1 = new JLabel(" ");
p6.add(space1);
tab.addTab( "Manufacture", null, p6, " Manufacture" );
JButton button6 = new JButton("Enter");
p6.add(button6);
button6.addActionListener(this);
{
button6.setActionCommand ("Enter");
new ActionListener(){
public void actionPerformed(ActionEvent e) {
e.getActionCommand();
int Manufacture=Integer.parseInt(text3.getText()) ;
if (e.getActionCommand().equals("Enter")) {
JOptionPane.showMessageDialog(null, "Manufacture's name is:"
+Manufacture,"", JOptionPane.INFORMATION_MESSAGE);
}
}
};
//constructing the Comment panel
new JLabel("Customer Comments?");
JPanel p7 = new JPanel();
new JPanel( );
textPrompt = new JLabel("Customer comments:");
inputText = new JTextArea(5, 15);
inputText.setLineWrap(true);
inputText.setWrapStyleWord(true);
//add components to window
container = getContentPane();
//use borderlayout to position our two i/o panels
container.setLayout(new BorderLayout());
p7.setLayout(new FlowLayout());
//add components to panels
p7.add(textPrompt);
p7.add(inputText);
//add panels to our primary borderlayout
add(p7, BorderLayout.NORTH);
// add JTabbedPane to container
getContentPane().add( tab );
setSize( 400, 250 );
setVisible( true );
JButton button7 = new JButton("Enter");
p7.add(button7);
tab.addTab ("Customer Comments?",null,p7,"Customer Comments?");
button7.addActionListener(this);}
new ActionListener(){
public void actionPerformed(ActionEvent e) {
e.getActionCommand();
int Comments=Integer.parseInt(inputText.getText()) ;
if (e.getActionCommand().equals("Enter")) {
JOptionPane.showMessageDialog(null, "Customer's comment:"+Comments,"", JOptionPane.INFORMATION_MESSAGE);
}
}
};
}
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
public static void main( String args[] )
{
FinalProject demo = new FinalProject();
demo.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}