Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2007, 04:15 PM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java code for Booking form

im new on here and i need some help creating a booking form using java code and i need 2 pages the first being a picture and the second of a booking form
can someone please help me

booking form details
Surname (label) then a text box
First Name (label) then a text box
Gender (radio button) options are Male and Female
method of payment(label) then a drop down box (credit card, Cheque, Cash)

then a save button

thanks in advance
can someone please help thanks
 
Old April 2nd, 2007, 06:29 PM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok i have figured out how to do the text boxes and labels and readio buttons but can someone please help me create 2 pages the first being a picture and i need to implement tabs so that i can switch form the pages
thanks
 
Old April 3rd, 2007, 12:35 PM
Authorized User
 
Join Date: Mar 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

do you mean those:
http://java.sun.com/docs/books/tutor...abbedpane.html

 
Old April 4th, 2007, 04:35 PM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can somebody help me to fix the code below so it complies

// Demonstrating the JLabel class.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;


public class pottery1 extends JFrame {
   private JLabel label1, label2;
   private JButton button1;
   private JTextField text;

 public pottery1()
   {
      super( "The Pottery Store" );

      Container c = getContentPane();
      c.setLayout( new FlowLayout(FlowLayout.CENTER, 30,30));



public TabbedPane() {
     super(new GridLayout(1, 1));

JTabbedPane tabbedPane = new JTabbedPane();

JComponent panel1 = makeTextPanel("Panel #1");
tabbedPane.addTab("Tab 1", panel1,
                  "Does nothing");
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

JComponent panel2 = makeTextPanel("Panel #2");
tabbedPane.addTab("Tab 2", panel2,
                  "Does twice as much nothing");
tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);



// JLabel constructor with a string argument
      label1 = new JLabel( "Surname" );
      label1.setToolTipText( "Surname" );
      c.add( label1 );


text = new JTextField (20);

      // JLabel constructor with a string argument
      label2 = new JLabel( "First Name" );
      label2.setToolTipText( "First Name" );
      c.add( label2 );

text = new JTextField (10);


c.add(text);
      button1 = new JButton("Save");
      c.add(button1);

      setSize( 500, 600 );
      setVisible(true);
   }

   public static void main( String args[] )
   {
      pottery1 app = new pottery1();

      app.addWindowListener(
         new WindowAdapter() {
            public void windowClosing( WindowEvent e )
            {
               System.exit( 0 );
            }
         }
      )
   };
};
 
Old April 5th, 2007, 05:09 PM
Authorized User
 
Join Date: Mar 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

three things
1. What's your error?
2. Where is the error located?
3. And, it looks like you're missing a closing brace for the pottery1 constructor

 
Old April 5th, 2007, 08:47 PM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here are the errors

javac -d . -g -classpath . pottery1.java

pottery1.java:33: illegal start of expression
public TabbedPane() {
^
pottery1.java:87: '}' expected
};
  ^
2 errors
 
Old April 6th, 2007, 08:50 AM
Authorized User
 
Join Date: Mar 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for the first error: if TabbedPane is supposed to be a method, then it should have a return type (for example public void TabbedPane { ... })

for the second error:
app.addWindowListener(
   new WindowAdapter() {
      public void windowClosing( WindowEvent e )
      {
         System.exit( 0 );
      }
   }
); <-- you forgot the semicolon here

That should take care of those two immediate errors, but you may still get more syntatic errors.

In one case, you call super() twice, but you're only supposed to call it once. If you need to set the layout then use the setLayout method

On a different note, panel1 and panel2 are your different tabs. If you are going to assign texts and labels then you should assign them to one of the panels: panel1.add(theComponent);
In this way, when you click on the other tab, the correct texts and labels appear and the others disappear.

I hope this helps you a little bit.

On one last note, in order to help yourself find some of the simple syntatic errors use TABS between all { and }
Code:
{
   first level indentation
   {
      second level indentation
      {
         third level indentation
      }
   }
}
In this way you can easily match them up against one another. However, if the lack of indentation happened because of the copy and paste then ignore that.

 
Old April 6th, 2007, 10:40 AM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is the corrected version that i have done accrding to your comments and i stil have one error

if you know the code to correct this error can you please tell me

thank you

javac -d . -g -classpath . pottery1.java

pottery1.java:33: illegal start of expression
public void TabbedPane() {
^
1 error



// Demonstrating the JLabel class.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;


public class pottery1 extends JFrame {
   private JLabel label1, label2;
   private JButton button1;
   private JTextField text;

 public pottery1()
   {
      super( "The Pottery Store" );

      Container c = getContentPane();
      c.setLayout( new FlowLayout(FlowLayout.CENTER, 30,30));



public void TabbedPane() {
     super(new GridLayout(1, 1));

JTabbedPane tabbedPane = new JTabbedPane();

JComponent panel1 = makeTextPanel("Panel #1");
tabbedPane.addTab("Tab 1", panel1,
                  "Does nothing");
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

JComponent panel2 = makeTextPanel("Panel #2");
tabbedPane.addTab("Tab 2", panel2,
                  "Does twice as much nothing");
tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);



// JLabel constructor with a string argument
      label1 = new JLabel( "Surname" );
      label1.setToolTipText( "Surname" );
      c.add( label1 );


text = new JTextField (20);

      // JLabel constructor with a string argument
      label2 = new JLabel( "First Name" );
      label2.setToolTipText( "First Name" );
      c.add( label2 );

text = new JTextField (10);


c.add(text);
      button1 = new JButton("Save");
      c.add(button1);

      setSize( 500, 600 );
      setVisible(true);
   }

   public static void main( String args[] )
   {
      pottery1 app = new pottery1();

      app.addWindowListener(
         new WindowAdapter() {
            public void windowClosing( WindowEvent e )
            {
               System.exit( 0 );
            }
         }
      );
   };
}
}
 
Old April 6th, 2007, 07:15 PM
Authorized User
 
Join Date: Mar 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 public pottery1()
   {
      super( "The Pottery Store" );

      Container c = getContentPane();
      c.setLayout( new FlowLayout(FlowLayout.CENTER, 30,30));
   } <-- you still forgot the closing brace for the pottery1 constructor

seems like this would be a simple error to spot
in order to avoid this error in the future make sure to write the starting and closing brace before adding the method code:
Code:
public void method()
   {
      // Ready to code
   }



 
Old April 13th, 2007, 07:05 AM
Registered User
 
Join Date: Mar 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

does anybody know the code for a save button





Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Code - Wrox - Beginning JAVA - Ivor Horton ponguru Java Databases 3 May 18th, 2006 12:30 PM
Booking form hameed123 PHP How-To 1 May 12th, 2005 11:22 AM
JavaScriopt booking form yatesie Java Databases 2 November 26th, 2003 11:57 AM
Java code problem Loevet J2EE 5 October 23rd, 2003 08:42 AM
booking form LITOTES PHP How-To 2 June 4th, 2003 03:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.