Save button
i have to create a save button with java code and i have no idea how to do it. i have created a button
can someone help please
the code is shown below
// Demonstrating the JLabel class.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class pottery extends JFrame {
private JLabel label1,label2,label3,label4,label5,label6,label7,l abel8,label9,label10,label11,label12,label13,label 14,label15,label16,label17,label18,label19,label20 ,label21,label22;
private JButton button1;
private ButtonGroup gbutton;
private JTextField text,text1,text2,text3,text4,text5;
private JComboBox Combo1,Combo2,Combo3,Combo4,Combo5,Combo6,Combo7,C ombo8,Combo9,Combo10,Combo11;
String[] combo = {"1", "2", "3", "4", "5", "6"};
String[] combo1 = {"Shropshire", "Cornwall", "SW France", "East Anglia"};
String[] combo2 = {"9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00"};
String[] combo3 = {"Smoking", "Non-Smoking"};
String[] combo4 = {"Adult", "Child", "Disabled"};
String[] combo5 = {"Economy", "First Class"};
String[] combo6 = {"Beginner", "Intermediate", "Advanced"};
String[] combo7 = {"Mr", "Mrs", "Miss"};
String[] combo8 = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"};
String[] combo9 = {"January", "Februrary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
public pottery()
{
super( "Airline Booking Form" );
Container c = getContentPane();
c.setLayout( new FlowLayout(FlowLayout.CENTER, 30,30));
// JLabel constructor with a string argument
label1 = new JLabel( "Airline Booking Form" );
label1.setToolTipText( "Airline Booking Form" );
c.add( label1 );
//LABEL
label2 = new JLabel( "Customer Information" );
c.add( label2 );
label3 = new JLabel( "Title" );
c.add( label3 );
//COMBOBOX
Combo8 = new JComboBox(combo7);
Combo8.setToolTipText("This is a Combo Box");
c.add(Combo8);
label4 = new JLabel( "First Name" );
c.add( label4 );
//TEXTBOX
text = new JTextField (10);
c.add(text);
label5 = new JLabel( "Surname" );
c.add( label5 );
text1 = new JTextField (10);
c.add(text1);
label6 = new JLabel( "Address 1" );
c.add( label6 );
text2= new JTextField (10);
c.add(text2);
label7= new JLabel( "Address 2" );
c.add( label7 );
text3 = new JTextField (10);
c.add(text3);
label8 = new JLabel( "City" );
c.add( label8 );
text4 = new JTextField (10);
c.add(text4);
label9 = new JLabel( "Postcode" );
c.add( label9 );
text5 = new JTextField (8);
c.add(text5);
label10 = new JLabel( "Ticket Information" );
c.add( label10 );
label11 = new JLabel( "Departure Date" );
c.add( label11 );
label12 = new JLabel( "Day" );
c.add( label12 );
Combo9 = new JComboBox(combo8);
Combo9.setToolTipText("This is a Combo Box");
c.add(Combo9);
label13 = new JLabel( "Month" );
c.add( label13 );
Combo10 = new JComboBox(combo9);
Combo10.setToolTipText("This is a Combo Box");
c.add(Combo10);
label14 = new JLabel( "Return Date" );
c.add( label14 );
label15 = new JLabel( "Day" );
c.add( label15 );
Combo9 = new JComboBox(combo8);
Combo9.setToolTipText("This is a Combo Box");
c.add(Combo9);
label13 = new JLabel( "Month" );
c.add( label13 );
Combo10 = new JComboBox(combo9);
Combo10.setToolTipText("This is a Combo Box");
c.add(Combo10);
label18 = new JLabel( "Number of Tickets" );
c.add( label18 );
Combo1 = new JComboBox(combo);
Combo1.setToolTipText("This is a Combo Box");
c.add(Combo1);
label19 = new JLabel( "Destination" );
c.add( label19 );
Combo2 = new JComboBox(combo1);
Combo2.setToolTipText("This is a Combo Box");
c.add(Combo2);
label20 = new JLabel( "Passenger Type" );
c.add( label20 );
Combo5 = new JComboBox(combo4);
Combo5.setToolTipText("This is a Combo Box");
c.add(Combo5);
label21 = new JLabel( "Ticket Type" );
c.add( label21 );
Combo6 = new JComboBox(combo5);
Combo6.setToolTipText("This is a Combo Box");
c.add(Combo6);
label17 = new JLabel( "Seat Preference" );
c.add( label17 );
Combo4 = new JComboBox(combo3);
Combo4.setToolTipText("This is a Combo Box");
c.add(Combo4);
label22 = new JLabel( "Pottery Package Type" );
c.add( label22 );
Combo7 = new JComboBox(combo6);
Combo7.setToolTipText("This is a Combo Box");
c.add(Combo7);
//BUTTON
button1 = new JButton("Save");
c.add(button1);
setSize( 500, 600 );
setVisible(true);
}
public static void main( String args[] )
{
pottery app = new pottery();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
}
);
}
}
|