p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Java > Other Java > Java GUI
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java GUI Discussions specific to programming Java GUI.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 15th, 2007, 07:46 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 );
            }
         }
      );
   }
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 17th, 2007, 12:44 AM
Friend of Wrox
Points: 1,108, Level: 13
Points: 1,108, Level: 13 Points: 1,108, Level: 13 Points: 1,108, Level: 13
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,
You've not explained your problem clearly, what i understand is you want to save the data given in the fields when user click on the Save button you've created.

For that you need to user event listeners [to recieve the click events on the button] in perticular ActionListener interface it has one method actionPerformed(ActionEvent e){} which you need to override and write the code which you want to use for saving the data.
And dont forget to add the actionlister to the button using addActionListener() method of the JButton

i.e button1.addActionListener(actionlisternobject);

Regards,
Rakesh
:)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Overflow Problem in ToolStrip Save button zaki79 VB Databases Basics 2 June 5th, 2008 02:38 PM
avoid getting save confirmation on button click sansircar .NET Framework 1.x 1 February 1st, 2006 12:52 AM
how to show a button when save is done noor ASP.NET 1.0 and 1.1 Basics 4 May 9th, 2005 01:49 AM
When I hit save button the selected employee clear shoakat Classic ASP Databases 6 September 16th, 2004 02:41 AM
onclick button, we want to save our company profil pawan Javascript 3 September 26th, 2003 08:04 AM



All times are GMT -4. The time now is 07:08 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc