PLEAS help opening a frame when clicking a button

i have a applet and when i click on a button it opens a frame. i have atried a couple of things but the frame does not open. Can anybody Please help
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class mainscreen1 extends Applet implements ItemListener, ActionListener
private Image layout1;
private int frame;
private int xpos,ypos,xdir,ydir;
public TextField tn, tt1, tt2, total;
public int value, ticketnum, sum;
public Label title, seat, need, payable;
public Button b1, b2;
Mydialog1 d;
public void init()
     setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
     xpos = getSize().width/-1400;
     ypos = getSize().height/12;
     layout1 = getImage(getDocumentBase(),"layout1.gif");
title=new Label("Almeida Theater booking system");
     title.setBounds(150,0,185,30);
     add(title);
seat=new Label("Please choose a seating location:");
     seat.setBounds(300,40,190,25);
     add(seat);
payable=new Label("Total Payable:�");
     payable.setBounds(300,390,100,30);
     add(payable);
     need=new Label("Please enter the number of seats needed:");
     need.setBounds(300,180,245,30);
     add(need);
     CheckboxGroup radio = new CheckboxGroup();
     Checkbox Stalls = new Checkbox("Stalls", true, radio);
     Stalls.setBounds(490,40,60,25);
     add(Stalls);
     Stalls.addItemListener(this);
     Checkbox Balcony = new Checkbox("Balcony", false, radio);
     Balcony.setBounds(490,65,65,25);
     add(Balcony);
     Balcony.addItemListener(this);
     Checkbox Concessions = new Checkbox("Concessions", false, radio);
     Concessions.setBounds(490,90,94,25);
     add(Concessions);
     Concessions.addItemListener(this);
Button b1=new Button("Quote");
     b1.setBounds(20,395,80,30);
     add(b1);
     b1.addActionListener( this );
     Button b2=new Button("Confirm booking");
     b2.setBounds(110,395,100,30);
     add(b2);
     b2.addActionListener( this );
     tt1=new TextField(60);
     tt1.setBounds(300,250,270,30);
add(tt1);
     tt1.addActionListener(this);
     tt2=new TextField(60);
     tt2.setBounds(300,300,150,30);
     add(tt2);
     tt2.addActionListener(this);
     tn=new TextField(3);
     tn.setBounds(545,180,30,30);
     add(tn);
     tn.addActionListener(this);
     total=new TextField(5);
     total.setBounds(400,390,45,30);
     add(total);
     total.addActionListener(this);
public void itemStateChanged(ItemEvent e)
     String c1 = (String) e.getItem();
     if (c1 == "Stalls")
          value = 20;
     else if (c1 == "Balcony")
          value = 15;
     else
          value = 10;
     tt1.setText("You have chosen to sit in the " + c1 + " area");
     tt2.setText("Each seat will cost: �" + value);
     repaint();
public void actionPerformed ( ActionEvent e )
if( e.getActionCommand() == "Quote" )
     //String sum = (String) e.getItem();
//sum = value*ticketnum;
     //Ssumtotal
     //total.setText(sum);
else if( e.getActionCommand() == "Confirm booking")
d = new Mydialog1(new Frame());
          ticketnum = Integer.parseInt(tn.getText());
          repaint();
     public void paint(Graphics g)
          g.setColor(Color.black);
          g.drawString ("You have chosen:" + ticketnum +" seats", 300, 365);
          g.drawImage(layout1,xpos,ypos,null);
Above is the 1st screen and when i click
confirm booking it don't open the frame, which is below:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Mydialog1 extends Frame implements ActionListener
public Label title;
public Button b1, b2;
public void init()
     setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
     setLocation(320,140);
     setVisible(true);
     Mydialog1(Frame f);
title=new Label("Almeida Theater booking system");
     title.setBounds(150,0,185,30);
     add(title);
     Button b1=new Button("Close");
     b1.setBounds(20,395,80,30);
     add(b1);
     b1.addActionListener( this );
     Button b2=new Button("Proced with booking");
     b2.setBounds(110,395,100,30);
     add(b2);
     b2.addActionListener( this );
public void actionPerformed( ActionEvent e )
if( e.getActionCommand() == "Close" )
this.dispose();
else if( e.getActionCommand() == "Proced with booking")
setBackground(Color.blue);
Can anyone help also can anyone explain how i do calcualtions on the mainscreen.calss. the bit that says Quote. it has // cos i canot get it to work
PLEASE PLEASE

no, you dont have to create a new class.
here is your own code. This time we pass the parameters to another method, and
not the constructor.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class mainscreen1 extends Applet implements ItemListener, ActionListener
private Image layout1;
private int frame;
private int xpos,ypos,xdir,ydir;
public TextField tn, tt1, tt2, total;
public int value, ticketnum, sum;
public Label title, seat, need, payable;
public Button b1, b2;
Mydialog1 d;
String c1;                   // obs
public void init()
setBackground(Color.pink);
setSize (600, 460);
setLayout(null);
xpos = getSize().width/-1400;
ypos = getSize().height/12;
layout1 = getImage(getDocumentBase(),"layout1.gif");
title=new Label("Almeida Theater booking system");
title.setBounds(150,0,185,30);
add(title);
seat=new Label("Please choose a seating location:");
seat.setBounds(300,40,190,25);
add(seat);
payable=new Label("Total Payable:�");
payable.setBounds(300,390,100,30);
add(payable);
need=new Label("Please enter the number of seats needed:");
need.setBounds(300,180,245,30);
add(need);
CheckboxGroup radio = new CheckboxGroup();
Checkbox Stalls = new Checkbox("Stalls", true, radio);
Stalls.setBounds(490,40,60,25);
add(Stalls);
Stalls.addItemListener(this);
Checkbox Balcony = new Checkbox("Balcony", false, radio);
Balcony.setBounds(490,65,65,25);
add(Balcony);
Balcony.addItemListener(this);
Checkbox Concessions = new Checkbox("Concessions", false, radio);
Concessions.setBounds(490,90,94,25);
add(Concessions);
Concessions.addItemListener(this);
Button b1=new Button("Quote");
b1.setBounds(20,395,80,30);
add(b1);
b1.addActionListener( this );
Button b2=new Button("Confirm booking");
b2.setBounds(110,395,100,30);
add(b2);
b2.addActionListener( this );
tt1=new TextField(60);
tt1.setBounds(300,250,270,30);
add(tt1);
tt1.addActionListener(this);
tt2=new TextField(60);
tt2.setBounds(300,300,150,30);
add(tt2);
tt2.addActionListener(this);
tn=new TextField(3);
tn.setBounds(545,180,30,30);
add(tn);
tn.addActionListener(this);
total=new TextField(5);
total.setBounds(400,390,45,30);
add(total);
total.addActionListener(this);
public void itemStateChanged(ItemEvent e)
c1 = (String) e.getItem();
if (c1 == "Stalls")
value = 20;
else if (c1 == "Balcony")
value = 15;
else
value = 10;
tt1.setText("You have chosen to sit in the " + c1 + " area");
tt2.setText("Each seat will cost: �" + value);
repaint();
public void actionPerformed ( ActionEvent e )
  if( e.getActionCommand() == "Quote" )
    //String sum = (String) e.getItem();
    //sum = value*ticketnum;
    //Ssumtotal
    //total.setText(sum);
  else if( e.getActionCommand() == "Confirm booking")
    int nr_seats = Integer.parseInt(tn.getText());
    total.setText("" +nr_seats*value);
    d = new Mydialog1();
    d.set_text(c1, nr_seats); // pass the c1 and the nr_seats vriables to the
                              //  set_text method in the Mydialog1 class.
  ticketnum = Integer.parseInt(tn.getText());
  repaint();
public void paint(Graphics g)
g.setColor(Color.black);
g.drawString ("You have chosen:" + ticketnum +" seats", 300, 365);
g.drawImage(layout1,xpos,ypos,null);
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Mydialog1 extends Frame implements ActionListener
  public Label title;
  public Button b1, b2;
  TextField tf; ///***/
  public Mydialog1()
    setBackground(Color.pink);
    setSize (600, 460);
    setLayout(null);
    setLocation(320,140);
    //Mydialog1(Frame f);
    title=new Label("Almeida Theater booking system");
    title.setBounds(150,0,185,30);
    add(title);
    Button b1=new Button("Close");
    b1.setBounds(20,395,80,30);
    add(b1);
    b1.addActionListener( this );
    Button b2=new Button("Proced with booking");
    b2.setBounds(110,395,100,30);
    add(b2);
    b2.addActionListener( this );
    tf = new TextField();                    //new
    tf.setBounds(230, 395, 100,30);   //new
    add(tf);                                       //new
    setVisible(true);
  public void actionPerformed( ActionEvent e )
    if( e.getActionCommand() == "Close" )
      this.dispose();
    else if( e.getActionCommand() == "Proced with booking")
      setBackground(Color.blue);
   *  Folowing method can take two parameters. One string and one int.
  public void set_text ( String seat_type, int nr_seats ) 
    tf.setText (seat_type +". "  +nr_seats);
}

Similar Messages

  • Unable to close open apps with double clicking the button and when I tap screen does not respond?

    Cannot not close open apps with double clicking the button Since downloading iOS8.

    What happens when you try? Does double clicking the ?home button bring up the Task Bar of recently used apps? If so what happens when you flick up on the preview screen for the app you want to close?
    To quit an app double click the Home button to reveal the row of recently used apps. Flick up on the page preview and it will fly away and disappear. That quits the app.

  • Multiple windows open in safari when click on web site.  Also can't change/edit DNS servers or any other changes in advance window of network tab

    macbook pro
    osx - mavericks
    multiple windows open in safari when click on web site.  Also can't change/edit DNS servers or any other changes in advance window of network tab.
    Basically every time i click on website other windows open and get redirected to other websites selling something (same as that mackeeper site which seems to open often)  Really ***** as in just a few minutes on the web I have many windows open and many are the same pages.  Can't make changes in the advanced tab of network as options are greyed out and the + & - symbols do nothing when clicked.  Hope there is an easy answer as surfing net is really sucking right now

    I hope to get some more info on a similar situation.
    I have a new Mac Pro, less than 2 months old. OSX 10.5 updated to 10.5.2. Quicktime updated too. When I use the Desktop and Screen Saver system pref, I can easily select and use one of the Apple supplied desktop pictures as a desktop background.
    But I wish to use a Photo from an iPhoto (iLife 08) folder / album as the desktop background. I can find all the albums, I can see all the icons for the pictures, I can select an iconed pciture and it appears in the top left of the preference pane (showing the effect of "fit to window" or "stretch to fit", etc). But all I get is a pale blue screen (which might be my default desktop colour). I don't get any of my iPhoto album pics to appear as a dektop background.
    There is one minor note on this, I don't keep the pictures in my iPhoto Library, I just reference them, and the originals are on a different internal disk.
    I've tried the suggestions above, trashing finder and desktop plists, killall Finder, etc. restart. Nothing gets it working again. It did work originally, for most of the time I've had the Mac Pro, then I changed the dektop to an Apple supplied picture of Earth.
    This affects both an Admin, and a standard user. The photos (and enclosing folders) are read / writable by the admin user, and readable by the Standard user. Both users can easily access the photos in their iPhoto. They open the original files on the second internal drive, and performing a right click - Show File shows the original file as expected. I've even emptied the iPhoto library completely and rebuilt it, just in case there was an issue here.
    Any ideas ? or anyone else seen this ? I don't really want to start reformatting disks and reinstalling the OS, but any suggestions short of this are extremely welcome.

  • How to switch to another page when clicking a button

    I have a main frame consits of many button.What I need to do when click
    a button,it switch to another page?
    Thanx....

    Try this, it should work.
    // not tested
    JButton linkButton = new JButton("<html><a href=\"http://forum.java.sun.com\">link to<br>forum</a></html>");

  • How to display the details of particular order when click on button in sapui5

    Hi Experts,
        How to display the details of particular order when click on button in sapui5?
    I Have a requirement that is i want display all the list of orders coming from backend as shown in image below
    then in that i have a button when i press the button  it need to display the details of particular order as shown in image below
    Please help me .
    Thanks & Regards
    chitti

    Does anyone know how to display the index of current desktop?
    Brute force - - I have written the number of the Desktop directly onto the wallpaper picture I am using for each Desktop  (easy to do with Preview).
    All Desktops are using different wallpaper photos, so they are easily recognized by the color scheme, and in the upper left corner is the number.
    Regards
    Léonie

  • Microsoft Expression Encoder 4 crashes when clicking Start button to begin live smooth streaming to a publishing point created in Windows Server 2012

    Microsoft Expression Encoder 4 crashes when clicking Start button to begin live smooth streaming to a publishing point created in Windows Server 2012, I've got the following error. Can anyone help me with this? Thanks in advance!
    Nombre del evento de problema:    CLR20r3
      Firma del problema 01:    encoder.exe
      Firma del problema 02:    4.0.4276.0
      Firma del problema 03:    4eafa0d7
      Firma del problema 04:    mscorlib
      Firma del problema 05:    4.0.30319.18408
      Firma del problema 06:    52310b91
      Firma del problema 07:    3e69
      Firma del problema 08:    0
      Firma del problema 09:    System.InvalidCastException
      Versión del sistema operativo:    6.2.9200.2.0.0.272.7
      Id. de configuración regional:    3082
      Información adicional 1:    5861
      Información adicional 2:    5861822e1919d7c014bbb064c64908b2
      Información adicional 3:    dac6
      Información adicional 4:    dac6c2650fa14dd558bd9f448e23afd1
    Lea nuestra declaración de privacidad en línea:
      http://go.microsoft.com/fwlink/?linkid=190175
    Si la declaración de privacidad en línea no está disponible, lea la declaración de privacidad sin conexión:
      C:\Windows\system32\es-ES\erofflps.txt

    2014-12-17 16:05:41  Msg 5170, Level 16, State 1, Server \\.\pipe\Microsoft##WID\tsql\query,  Line 2
    Cannot create file 'C:\Windows\WID\Data\SUSDB.mdf' because it already exists
    Looks like somebody forgot to remove the database from the last time WSUS was installed.
    Lawrence Garvin, M.S., MCSA, MCITP:EA, MCDBA
    SolarWinds Head Geek
    Microsoft MVP - Software Packaging, Deployment & Servicing (2005-2014)
    My MVP Profile: http://mvp.microsoft.com/en-us/mvp/Lawrence%20R%20Garvin-32101
    http://www.solarwinds.com/gotmicrosoft
    The views expressed on this post are mine and do not necessarily reflect the views of SolarWinds.

  • How to hide a TextField when clicking another button

    Hello!
    I've been able to generate a TextField to appear when clicking a button, but when I click on another button, to display some more information, I still have the first TextField displayed.  I've had a look around, but not been able to find anything to help me with getting the first to disappear.  Can anyone provide any ideas for this?
    The code I'm using for displaying the TextField is:
    button10.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);
    var fl_TF:TextField;
    var fl_TextToDisplay:String = "Send disply to the right screen/projector";
    function fl_ClickToPosition(event:MouseEvent):void
    fl_TF = new TextField();
    fl_TF.autoSize = TextFieldAutoSize.LEFT;
    fl_TF.background = true;
    fl_TF.border = true;
    fl_TF.x = 300;
    fl_TF.y = 100;
    fl_TF.text = fl_TextToDisplay;
    addChild(fl_TF);
    Many thanks in advance

    all your buttons should call the same function. 
    because each button probably triggers different text to be displayed, you can use an object or dictionary to associate the buttons and their text:
    // execute these two lines and your function once at the start of your app
    var dictionary:Dictionary=new Dictionary(true);
    var fl_TF:TextField;
    function fl_ClickToPosition(event:MouseEvent):void
    if(fl_TF&&fl_TF.parent){  /
    fl_TF.parent.removeChild(fl_TF);
    fl_TF=null
    fl_TF = new TextField();
    fl_TF.autoSize = TextFieldAutoSize.LEFT;
    fl_TF.background = true;
    fl_TF.border = true;
    fl_TF.x = 300;
    fl_TF.y = 100;
    fl_TF.text = dictionary[e.currentTarget];
    addChild(fl_TF);
    ////////// and for each button use something like:
    button10.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);
    dictionary[button10] = "Send disply to the right screen/projector";

  • After upgrading ipad to iOS 7.1 I can no longer close open apps by double clicking home button. Any other way to close open apps?

    After upgrading ipad to iOS 7.1 I can no longer close open apps by double clicking home button.  Any ideas

    Double-tap on the Home button. You will see a preview of the app above the actual icon. Slide the preview up to kill it.
    Please get the iPhone User Guide (For iOS 7 Software)Sep 19, 2013 - 23 MB.

  • Can you launch an Internal Frame by clicking a button

    is it possible to launch an internal frame from clicking a button, instead of the menu system way?

    You can instantiate an object of the JInternal frame in the actionperformed for the button.
    also remember to say jinternal.setvisible(true) and also set bounds for the internalframe

  • Help me make panel when clicking ,it is on frame

    I have one tool bar on the left and button on it .When clicking on this button ,one panel appear on main panel .and When clicking again it is indented
    [http://www.javavietnam.org/javavn/mvnforum/getattachment?attach=2532]
    [http://www.javavietnam.org/javavn/mvnforum/getattachment?thumbnail=yes&attach=2533]
    I'm very sorry because multi-posting questions.But I cannot edit it
    Edited by: churan on May 28, 2009 6:27 AM
    Edited by: churan on May 28, 2009 6:28 AM
    Edited by: churan on May 28, 2009 6:29 AM
    Edited by: churan on May 28, 2009 6:30 AM

    two posts of the same problem, and you've yet to ask a decent question in either of them.Actually, this is a triple posting and the first made no sense either which is why the OP was asked to post a SSCCE.
    Maybe with the link you provided and a proper SSCCE in two or three days the OP will be able to put together a meaningfull question.

  • How to Open GUI Transaction when clicking in Hyper Link

    Hello All,
    I want to open GUI Transaction  when user will click on Hyper Link created in a particular column in a table view. For that I have created  Transaction Launcher ID using Transaction Launcher  Wizard. Then what will be the next step, i'm not getting. Can anybody help me out on this?
    Thanks in advance,
    Madhusudan

    Hi,
    Here is the sample code:
    DATA: lr_navigation TYPE REF TO if_crm_ui_navigation_service.
    lr_navigation = cl_crm_ui_navigation_service=>get_instance( me ).
    CHECK lr_navigation IS BOUND.
    lr_navigation->navigate( iv_link_id = 'ZLINKID' ).
    -ASB

  • Xcode question. Need to open an app from clicking a button! Please help!!!!

    Hello, I am new to this forum so sorry if this is in the wrong spot. I'm trying to make a simple Xcode app, so that when people click a button, it will open another app, such as an AppleScript, which will run a code in Terminal. So for instance, click "Make my Mac speak" Then it would open the AppleScript and Terminal would pop open and run the code " say Hello, my name is Macintosh". Thats just an example of what I'm trying to do. Please can someone help me. I don't need help with the AppleScript part, just getting Xcode to open the AppleScript. Thank you!

    You want the Mac OS X Technologies Software Development 101 forum
    <http://discussions.apple.com/forum.jspa?forumID=728>
    Or Mac OS X Technologies Developer forum
    <http://discussions.apple.com/forum.jspa?forumID=727>

  • New windows in Firefox 29 on Windows 8.1 don't open fully maximized when clicked through a link

    New problem in firefox 29:
    When I click a link that opens the new page in a new window, the window pops open in the last partially maximized state that it was in. Should I maximize the new window (in Windows 8.1) and close it and re-click the original link, the window opens again in the partially maximized state, not the last fully maximized state that I previously closed it in.
    To create it as I've encountered it:
    -go to https://news.google.com
    -click on any article. the default behavior should be to open the article in a new window
    -the window won't be maximized in my experience
    -you can maximize the window and then close the window/ article
    -re-click on the same article and the new window should appear again in the non-maximized state, not the fully maximized state that you closed it in previously
    One point of note. Right-clicking the same link that opens the new window and specifically choosing "Open Link in New Window" DOES open the new window in a fully maximized state. I repeat, the new window does open fully maximized when you choose "Open Link in New Window" from the right-click drop downs menu. But, this doesn't happen with the simple left-click, which I'm concerned with.

    Reverted back to version 28.0, 29 just isnt working, layout is a mess. (Ok i got the old layout back by installing and setting up Classic Theme Restorer, but once you remove the orange title bar, the screen resize bug appears.) Also its a very bad thing such a large graphical overhaul took place without prior notice. If i wanted google Chrome i would have just installed that, dont need FF to provide me with it. Might upgrade again if bugs and layout are changed, otherwise ill stay with 28.0 or maybe start using Waterfox.

  • Will not open new tab when clicked on the + next to open page

    firefox does not open new window when I click on the new tab +
    also does not open new tab when going through the file menu

    This issue can be caused by the Ask<i></i>.com toolbar (Tools > Add-ons > Extensions)
    See:
    * [[Troubleshooting extensions and themes]]

  • Finder Windows always open new windows when clicking subfolders

    since i upgraded to 10.5.6, my finder windows only open new windows when I click on a subfolder. this is no matter what I do with the setting in preferences.
    Also, my finder windows no longer display the side bars with folder icons.
    I searched my library (and whole computer) for the finder preferences .plist file and can't find it. (was going to delete it and re-create it).
    Any ideas here?

    Thanks for the star.
    The default of Finder’s Find will not search that folder, but you can change the pulldown menu just beneath where it says Search, from Kind to System files by selecting Other from that menu and then scroll down the next window and check the box next to System files. You’ll then need to change the pulldown menu next to that to “include” instead of “don’t include.”
    The next time you do a search using Find, that pulldown menu will have System files as an option, if you think you might want to search for something in your home folder.

Maybe you are looking for

  • DBIF_RSQL_SQL_ERROR while activating data in ODS

    Hi, I'm getting the following error when I try to activate the data in ODS. This is happening for all the ODSs in the system. SQL-ERROR: 603 ORA-00603: ORACLE server session terminated by fat al error System error: RSDU_ANALYZE_TABLE_ORA/ ORACLE ABAP

  • WorkFlow - WS10000276: Shopping cart is hanging with "Awaiting Approval'

    Hi, We are SRM 4.0 (SRM_SERVER 5.0) SP 8 (SAPKIBKS08). We have only WS10000276 active in the system. The User orders the SC. SC goes to the approver (mentioned in attribute SLAPPROVER). Approver changes the quantity in the SC and saves. SC comes back

  • Java and c++ on mac OS X

    Hi I need to access from java to c++ code on mac OS X. How do I define the methos in the java code and in c++ code? Is it the same way like with PC? Can anyone give me a short example of how can i do it? Do you know good links with good examples abou

  • How can I print black ink only when in automatic two-sided mode for Officejet 6500?

    When I set the printer to automatically print on two sides, it only allows color or high quality grayscale as print color options.  If I print on only one side, then I have a third option for black ink only.  Does anyone know how to get black ink onl

  • Scanning Old Photos

    I'm looking to scan all my old photos but want to make sure they are going to look as good as my digital ones do on the apple tv. Anybody have a good scanner that they would recommend. Its going to take a long time to do it so I want to make sure the