Hello:   -Easy Question I believe - JOptionPane

Hello: **My program is below**
I just started programming and have some basic problems. I would like my program to have a window that asks whether the amount of "people in party" is correct it would then have a text field for yes enter 1 and no enter 2. But I don't know how do get it correct. Thanks for any help. I'm getting confused with the Pane being from the main Pane add how to add different button/textfield to each.
Tim
I have JOptionPane open and but don't know how to add a textField and the button "ENTER" to the that JOptionPane
**********CODE**********
package finalproject;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Menu extends JFrame {
private JTextField partyNumField;
private int partyNum;
private JButton getParty;
private JLabel party, companyLogo;
public Menu() {
super("O'Brien Caterer - Where we make good Eats!");
Container container = getContentPane();
JPanel northPanel = new JPanel();
northPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 80, 5));
companyLogo = new JLabel("Welcome to O'Brien's Caterer's");
northPanel.add(companyLogo);
party = new JLabel("Enter the Total Number in Party Please");
partyNumField = new JTextField(5);
northPanel.add(party);
northPanel.add(partyNumField);
getParty = new JButton("GO - Continue with Order");
getParty.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent actionEvent)
partyNum = Integer.parseInt(partyNumField.getText());
JOptionPane.showMessageDialog(null, "Total Number is party is: " + partyNum
+ " is this correct?\n\n" + "Enter 1 to continue\n"
+ "Enter 2 to cancel\n");
); // end Listener
northPanel.add(getParty);
container.add(northPanel);
setSize(300, 500);
show();
public static void main(String args[])
Menu application = new Menu();
application.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent windowEvent)
System.exit(0);

This will do:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Menu extends JFrame
     private JTextField partyNumField;
     private int        partyNum;
     private JButton    getParty;
     private JLabel     party, companyLogo;
public Menu()
     super("O'Brien Caterer - Where we make good Eats!");
     addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
               dispose();     
               System.exit(0);
     Container container = getContentPane();
     JPanel northPanel   = new JPanel();
     northPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 80, 5));
     companyLogo         = new JLabel("Welcome to O'Brien's Caterer's");
     northPanel.add(companyLogo);
     party               = new JLabel("Enter the Total Number in Party Please");
     partyNumField       = new JTextField(5);
     northPanel.add(party);
     northPanel.add(partyNumField);
     getParty            = new JButton("GO - Continue with Order");
     getParty.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent actionEvent)
               partyNum = Integer.parseInt(partyNumField.getText());
               String a = JOptionPane.showInputDialog(null, "Total Number is party is: " + partyNum
                    + " is this correct?\n\n" + "Enter 1 to continue\n"
                    + "Enter 2 to cancel\n");
     northPanel.add(getParty);
     container.add(northPanel);
     setSize(500,300);
     show();
public static void main(String args[])
     new Menu();
Noah

Similar Messages

  • Easy question about Reformatting

    Hello all,
    I am trying to reformat my HD after I have deleted Windows XP off of a partition. The reason for this is an upgrade to Vista and a larger allotment of HD space. My question is:
    I am using Backup v3.1.1. (v369) and I have FULL backup files of my Home folder, and my Music folder (as backup for my backup) for all my iTunes libraries. These are located on a portable HD. Are these the correct files to have backed up in order to have my MAC the way it was before I started the process? If so, then once the reformatting is complete, how do I get it all back onto my MAC permanently? Will all my apps and tweaks work as before?
    I am sure this is a simple question, however, I have never had to do this with a MAC, and I want to make sure I have all bases covered before I begin this. Any other comments or advice would be greatly appreciated.
    Thanks All!

    You call this an easy question ???
    Just messin with ya
    Your home folder is the most important folder containing your music, documents, preferences etc. but a lot is also stored in the system folder and library folder outside your home folder, if you want to be ensured of an exact copy of your current system the best way to go at this is to clone your system partition.
    The app i use for this is carbonCopyCloner
    http://www.bombich.com/software/ccc.html
    To add to this.. i've heard there is software for the mac that allows you to make adjustments to the size of your partitions without having to format the drive, i don't know the names of these products but i do know that it's very risky to use them, if you decide to use an app like that make sure you have proper backups of everything just in case it goes wrong.
    Message was edited by: Pr0digy V.

  • Easy question array

    Hello experts,
    i have an easy question. I need to store data in a 1D array so that the first data is written in the place of index 1 the second in index 2 aso.  I've tried it but somehow either i only had the last data in all indexes or only the last data in the last index. I am posting you a vi. I know where i should change it but i need a small idea oder change in the vi.
    Thank u for your help.

    Attachments:
    array_shift.vi ‏7 KB

    Please save your VI in ver 8.2 and then paste it on the forum so that i may help in making it into what you want. Without seeing the VI i am guessing that you have elements or 1-D arrays that you want to append into a single array.
    Its simple whether its the elements that you want to build into 1-d array or arrays that you want to make into a single array. Just use the build array function. Connect the input wires to the element and you'll have your 1-D array, provided you havent unchecked Concatenate Inputs in which case you will have a higher order array instead.
    Anyways kindly paste it in changed format so that i may help.
    Regards
    Asad Tirmizi
    Design Engineer
    Institute of Avionics and Aeronautics
    " Its never too late to be, what u want to be"
    Using LabVIEW 8.2

  • Easy Question: Illegal Start of Expression

    This is a ridiculously easy question... but I am having trouble with it...
    Anyway, here is the line of code that is giving me trouble:
    jButtons = {{jButton1, jButton5, jButton9, jButton13},
    {jButton2, jButton6, jButton10, jButton14},
    {jButton3, jButton7, jButton11, jButton15},
    {jButton4, jButton8, jButton12, jButton16}};
            That's it. jButton1 through jButton16 are all jButton objects (for a GUI). jButtons is an array (4 by 4) of jButton. All are global variables, the buttons are all initilized (in fact, that was the problem I had before, and why I need to put this here: otherwise I get a null pointer exception).
    Surprisingly, such a simple line of code causes TONS of errors to occur. To save space, {...} * 2 means that the exception occurs twice in a row, errors are separated by comma's.
    { Illegal Start of Expression, {Not a statement, ; required} * 2} * 4, Empty statement
    A similar statement (int[] test = {{1,2,3},{4,5,6}};) works perfectly fine.
    Please help, doing this will reduce the size of my code to about a third of the size of the code. And then I can laugh in the faces of those people who say that I write long, and in-efficient code! MWHAHAHAHAHAHA!!
    However, I will keep at it, and Murphy's Law states I will find a solution 10 seconds after posting. If I do, I will edit this post, and tell you guys the answer ;)
    [Edit]In case you are wondering... all my other code is correct. Here is the adjacent 3 methods:
    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
        ButtonClick(3,3);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton10;
        private javax.swing.JButton jButton11;
        private javax.swing.JButton jButton12;
        private javax.swing.JButton jButton13;
        private javax.swing.JButton jButton14;
        private javax.swing.JButton jButton15;
        private javax.swing.JButton jButton16;
        private javax.swing.JButton jButton17;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JButton jButton4;
        private javax.swing.JButton jButton5;
        private javax.swing.JButton jButton6;
        private javax.swing.JButton jButton7;
        private javax.swing.JButton jButton8;
        private javax.swing.JButton jButton9;
        private javax.swing.JLabel jLabel1;
        // End of variables declaration
         * @param args the command line arguments
        public static void main(String args[])
            jButtons = {{jButton1, jButton5, jButton9, jButton13},
    {jButton2, jButton6, jButton10, jButton14},
    {jButton3, jButton7, jButton11, jButton15},
    {jButton4, jButton8, jButton12, jButton16}};
            int[][] test = {{1,2,3},{4,5,6}};
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new GameWindow().setVisible(true);               
        String[] row1 = {"1", "5", "9", "13"};
        String[] row2 = {"2", "6", "10", "14"};
        String[] row3 = {"3", "7", "11", "15"};
        String[] row4 = {"4", "8", "12", ""};
        String[][] labels = {row1, row2, row3, row4};
        int blankX = 3;
        int blankY = 3;
        static javax.swing.JButton[][] jButtons;
        private void DisableAll()
            for (int looperX = 0; looperX < 4; looperX++)
                for (int looperY = 0; looperY < 4; looperY++)
                    jButtons[looperX][looperY].setEnabled(false); 
        Edited by: circularSquare on Oct 13, 2008 5:49 PM
    Edited by: circularSquare on Oct 13, 2008 5:52 PM

    You can only initialise an array like that when you declare it at the same time. Otherwise you have to do as suggested above.
    int[] numbers = {1,2,3,4}; //ok
    int[] numbers;
    numbers = {1,2,3,4}; // not ok

  • Easy question - how to increase number of recent files in menu?

    This is for CS5 if it matters.
    I'm an infrequent Illustrator user (at best) but I have what I hope is an easy question: I want to increase number of recent files showing in the menu.
    I can't find a preferece to set such as in PS and almost every other application on the face of the earth. I've tried to reset the preferences file (start Illustrator with ctrl-alt-shift held down) but I'm stuck at 4 files, which I assume is the anemic default option.
    Is there an easy way to do this that Adobe has hidded somewhere? As expected, it can't be found in the help, I can't find it on the forums, or even on the net, but I do know it can be done because I can see other installs showing lots of files in the list.
    thanks for any help.

    This might be because of a new feature that you can turn off for each object, and alltogether. When you create a new document at the bottom, make sure 'Align New Objects to Pixel Grid' is unchecked.  After you have created a new file, you can still go into the 'TRANSFORM' palette (SHIFT+8), use the little right top menu, and make sure 'Align New Objects to Pixel Grid' is unchecked. And if you want to get fancy with each object; you can select an object, and look at the 'TRANSFORM' palette at the bottom is a place to uncheck the 'Align to Pixel Grid' at your disposall.
    Before I found this, it ruined my week.
    http://www.kenwells.com

  • Easy question I'm sure. imac hard full (500gb) mostly from iphoto. no capacity left. what are my options? I've thought of an external drive of 1tb and then a 2nd external drive of 3tb to back up both???? please help.

    easy question I'm sure. imac hard full (500gb) mostly from iphoto. no capacity left. what are my options? I've thought of an external drive of 1tb and then a 2nd external drive of 3tb to back up both???? please help.

    Those are the options - more space is more space.
    Moving the iPhoto Library is simple:
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    Regards
    TD

  • Hello, small question, how to change the bank details my account is on? keep on charging the old card nr of a friend ;-(

    hello, small question, how to change the bank details my account is on? keep on charging the old card nr of a friend ;-(

    Go to iTunes, click on your Apple ID (right top iTunes' corner), enter your paswword if requested and edit the details you want

  • Hello, the question of content.

    Hello, the question of content. in the past we used a link to our content in the U.S. Store now this is not possible because the system says that the content can not be manufactured in the U.S. Store. the problem could you explain?
    link to the content in the past:
    https://itunes.apple.com/us/album/bells-feat.-oley-elate-zcinzsar/id576097582?i= 576097778&ign-mpt=uo%3D4
    link to the content in the now:
    https://itunes.apple.com/gb/album/dark-avenue-feat.-oley-elate/id576097582
    Oley Elate

    Please go through this thread Origin of Sales Tax ID Number in billing document
    hope this will clarify ur doubts about origin of sales tax id no.

  • Hello, my question is to forget the questions to buy in the store is there any way to recover it, because hey tried but there is only option to reset the password and no questions

    hello, my question is to forget the questions to buy in the store is there any way to recover it, because hey tried but there is only option to reset the password and no questions

    Didn't the link to contact the iTunes Store staff in the 'Additional Information' section of that article work for you? If you don't already have a valid rescue email address, only Apple itself can reset the questions.
    (90961)

  • Easy question for the MODS

    Unlike more difficult questions like CRC problems, ps problems, etc, this is rather an easy question.
    The KT4V manual (page 3-8) lists the onboard NIC as a "boot device" option.  This "feature" is available in Bios 1.1, 1.2 but not available in Bios 1.4 and later.  
    Any reason why this feature was mutilated and not available anymore in the later bioses?
    Are there two different bioses for KT4V and KT4V-L?  If yes where can one find the bios for KT4V-L?
    I know this feature is not very popular with the majority of users, and I'm not trying to bust anyone's balls for removing un-popular features, but the "boot from NIC"  was one of the features/reasons why I got this mb, and I would rather use a much newer bios than 1.2 (for known reasons).
    Also, while on this topic, boot-from-usb (especially thumb drives) feature would also be greatly appreciated - I think it is also listed in the manual.
    TIA

    Hi,
    Quote
    Please suggest him to update the BIOS Ver1.9 which can support Boot from LAN and boot from USB devices.
    AMI BIOS can boot from the devices which support BIOS Boot specifications (BBS, you can refer to the attached file for the information).
    Email me, so I can send you the BIOS PDF.

  • I have what is hopefully a quick and easy question. I kno...

    I have what is hopefully a quick and easy question. I know almost nothing about this stuff so go easy on me . All I need to do is find out if my DHCP is enabled. I'm having problems with my Xbox 360 and one of the possible problems is this DHCP thing. However I have no idea how to find the settings for my router on my computer. If it helps I have a Wirless model BEFW11S4. Thanks in advance for any help.

    You need to access your router to check if the DHCP is on.  To access the router open your browser and type in http://192.168.1.1 into the address field and hit enter.  That should open the routers log on screen and by default the user is left blank (some routers it is admin) and the password is abmin.  If you changed your routers password as you should for security reasons then use that password.  That will bring you to your routers user interface and on the main set up page should be your DHCP.
    Richard Aichner (Ikester)

  • Profit center field in Material MD - Easy question

    Hi Experts,
    I have an easy question..
    The material master data screen have a  tab 'General Plan', and there is  the field 'Profit Center'.  
    a) Is this field is filled, which is the impact in the system? 
    b) is this value (profit center) used in other area or calculation?
    c) What happend if this field is empty? 
    Thank you in advance!

    Hi,
    The path told in above reply is correct but making profit centre mandatory for only two plants is not possible.
    You can make it mandatory for specified Material Type or you can make it mandatory while doing selected Transaction Like MM01 or MM02 etc
    Regards,
    Amol

  • Easy Question: How to split concatenated string into multiple rows?

    Hi folks,
    this might be an easy question.
    How can I split a concatenated string into multiple rows using SQL query?
    INPUT:
    select 'AAA,BBB,CC,DDDD' as data from dualDelimiter = ','
    Expected output:
    data
    AAA
    BBB
    CCC
    DDDDI'm looking for something kind of "an opposite for 'sys_connect_by_path'" function.
    Thanks,
    Tomas

    Here is the SUBSTR/INSTR version of the solution:
    SQL> WITH test_data AS
      2  (
      3          SELECT ',' || 'AAA,BBB,CC,DDDD' || ',' AS DATA FROM DUAL
      4  )
      5  SELECT  SUBSTR
      6          (
      7                  DATA
      8          ,       INSTR
      9                  (
    10                          DATA
    11                  ,       ','
    12                  ,       1
    13                  ,       LEVEL
    14                  ) + 1
    15          ,       INSTR
    16                  (
    17                          DATA
    18                  ,       ','
    19                  ,       1
    20                  ,       LEVEL + 1
    21                  ) -
    22                  INSTR
    23                  (
    24                          DATA
    25                  ,       ','
    26                  ,       1
    27                  ,       LEVEL
    28                  ) - 1
    29          )       AS NEW_STRING
    30  FROM    test_data
    31  CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(DATA,'[^,]','')) - 1
    32  /
    NEW_STRING
    AAA
    BBB
    CC
    DDDD

  • Hopefully easy question...

    I am new to TestStand and have a couple of (hopefully) easy questions.  I am using TestStand 3.5.
    1)  I have written a couple of sub-sequences in another file that we use for common tasks.  Some of the parameters we pass will always be the same variable name.  Is there a way I can get that default parameter name to show up when I write the program to call this sub-sequence so I wont have to enter it each time?
    2)  When I run a program that calls a sub-sequence in the above file, the first time I run it, I get an error saying the resource already exists...  If I open the sub-sequence file in TestStand, and then close it, it is fine after that.
    Thanks for your help!

    With TestStand the answer is usually 'yes' it is just a matter of which way is best for you.
    1)
    TestStand has a full application interface so that you can pragmatically read parameter names and types, and populate calling programs with the right stuff.  This takes some learning.  There may be an easier way depending on what you are doing.
    I'm not sure what you mean when you say you write a program to call the subsequence.   In  TestStand 4.0 ( don't have 3.5 installed) you can create a Sequence Call template step that can be used in new sequences that you program.  That is, I can open a new sequence, drop a generic Sequence Call step and rename it, configure it to call your subsequence by choosing the right path, sequence file, values/expressions to be passed to the subsequence, and then I can save this step as a template (drag to the Step section of the template window).  Then, when I have a brand new sequence, I can drop an instance of this template step into my sequence, with the parameter values preconfigured.  Assuming all the expressions are valid, you're ready to go. 
    2)
    Without more information I can't help with this one.  Perhaps the sequence file that contains the called subsequence is not in one of your search directories (see Configure>>Search Directories) and therefore it can't be found until you open, identify and save the calling sequence file. What error code are you getting?

  • Quik easy question does Win QT playback h.264?

    quik easy question does Win QT playback h.264?

    It does.
    For Windows version of QuickTime, please use QuickTime for Windows

Maybe you are looking for

  • Sales order creation using BAPI in LSMW

    Hi ABAPers, I am trying to create Sales orders using the BAPI SALESORDER_CREATEFROMDAT2. I am supplying the item target quantity in sale units to the field E1BPSDITM-- TARGET_QTY. my documents are getting posted but when i go to VA03 to display my do

  • How to create a web template with company logo

    how to create a web template with company logo . can any one help me with the steps. or any notes. thnaks in advance . 2. i have 25000 articles and client want to have a selection feild to see top article ex:50,10,20, 100, 1000 etc . same for bottom

  • Query while configuring foreign server in JMS module

    Hi All, I'm configuring foreign server in my weblogic 10.3 to access the queues in the remote weblogic server 10.3. while configuring the foreign server it is asking for the destination and connection factory JNDIs for both local and remote server. M

  • Error: java.lang.NoClassDefFoundError: org/aspectj/lang/Signature

    My applications run well before, And after I remove org foleder: webapps\ROOT\WEB-INF\classes\org, and later put it back again( I did that just for testing something) Then I always get the error message: java.lang.NoClassDefFoundError: org/aspectj/la

  • How to backup RMS database to PC?

    Hi! Is it possible in j2me to backup the internal RMS db in the device to a PC for example? My main objective is to transfer the db to another device but j2me doesn't support infrared. Therefore, my last resort is to save the internal db of a Java-en