Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java program for to implement supermarket menu

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Java program for to implement supermarket menu

    I have been asked to create a java window tool kit as follows and make the 'rumolar' 'supermarket' menu have addition,subtraction where the total addition will be added every time into a file, also the rumolar --- 'rental' should have rental materials and should deduct rented materials when neccessary . . . . .

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public class rum extends JFrame implements ActionListener{
     
        public static void main(String[] argv) {
            rum mainApp = new rum();
        }
        public rum()
        {
     
            super("Store Query");
            setBounds(0, 0, 300, 300);
            setResizable(false);
            setLocation(400,250);
            setSize(400,400);
            getContentPane().setLayout(null);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
     
            passwordfield = new JPasswordField(15);
            passwordfield.setLocation(140, 10);
            passwordfield.setSize(passwordfield.getPreferredSize());
     
            String passwordString = String.copyValueOf(passwordfield.getPassword());
     
     
            button1 = new JButton("Admin Login");
            button1.setLocation(10, 40);
            button1.setSize(button1.getPreferredSize());
     
            button1.addActionListener(this);
     
            getContentPane().add(button1);
            setVisible(true);
      /**      
            button1 = new JButton(new ImageIcon("image.jpg"));
     
            button1.setPressedIcon(new ImageIcon("image.jpg"));
            button1.setRolloverIcon(new ImageIcon("image.jpg"));
     
            button1.setFocusPainted(false);
            button1.setContentAreaFilled(false);
            button1.setBorderPainted(false);
     
            button1.setMargin(new Insets(0, 0, 0, 0));
     
            button1.addActionListener(this);
     
            getContentPane().add(button1);
            setVisible(true);
    */
     
            menuBar = new JMenuBar();
            menuBar.setBounds(0, 0, 400, 25);
     
            fileMenu = new JMenu("File");
            fileMenu.setMnemonic('F');
     
            openItem = new JMenuItem("Open...");
            openItem.addActionListener(this);
     
            saveItem = new JMenuItem("Save...");
            saveItem.addActionListener(this);
     
            quitItem = new JMenuItem("Quit");
            quitItem.addActionListener(this);
            // add items to file menu object
            fileMenu.add(openItem);
            fileMenu.add(saveItem);
            fileMenu.addSeparator();
            fileMenu.add(quitItem);
     
            //creating rumolar menu
     
            rumolarMenu = new JMenu("Rumolar");
            rumolarMenu.setMnemonic('R');
            //creating items under rumolar
            RentalItem = new JMenuItem("Rentals");
            RentalItem.addActionListener(this);
     
            SupermarketItem = new JMenu("Supermarket");
            SupermarketItem.addActionListener(this);
     
            OthersItem = new JMenu("Others");
            OthersItem.addActionListener(this);
            //add items under rumolar to rumolar menu bar
            rumolarMenu.add(RentalItem);
            rumolarMenu.add(SupermarketItem);
            rumolarMenu.add(OthersItem);
     
            //creating the about tab
     
            AboutMenu = new JMenu("About");
            AboutMenu.addActionListener(this);
            AboutMenu.setMnemonic('A');
     
            //adding to main menu bar
     
            menuBar.add(fileMenu);
            menuBar.add(rumolarMenu);
            menuBar.add(AboutMenu);
     
            getContentPane().add(menuBar);
            setVisible(true);
        }
        public void actionPerformed(ActionEvent e)
        {
            if (e.getSource() == openItem)
            {
                //what to open
                JOptionPane.showMessageDialog(this, "You selected the 'open' menu option", "Info", 
                    JOptionPane.INFORMATION_MESSAGE); 
            }
            else if (e.getSource() == saveItem)
            {
                //what to save
                JOptionPane.showMessageDialog(this, "You selected the 'save' menu option", "Info",
                    JOptionPane.INFORMATION_MESSAGE);    
            }
            else if (e.getSource() == quitItem)
            {
                System.exit(1);
            }
            else if (e.getSource() == RentalItem)
            {
                JOptionPane.showMessageDialog(this, "You selected the 'Rumolar rentals' menu option", "Info",
                    JOptionPane.INFORMATION_MESSAGE);  
            }
            else if (e.getSource() == SupermarketItem)
            {
                JOptionPane.showMessageDialog(this, "You selected the 'Rumolar Supermarket' menu option", "Info",
                    JOptionPane.INFORMATION_MESSAGE);  
            }
            else if (e.getSource() == OthersItem)
            {
                JOptionPane.showMessageDialog(this, "You selected the 'Rumolar others' menu option", "Info",
                    JOptionPane.INFORMATION_MESSAGE);  
            }
             else if (e.getSource() == AboutMenu)
            {
                JOptionPane.showMessageDialog(this, "This program was developed for RUMOLAR INC. by RUMOLAR SOFTWARES", "Info",
                    JOptionPane.INFORMATION_MESSAGE);  
            }
            else if(e.getSource() == button1)
            {
                getContentPane().add(passwordfield);
                setVisible(true);
            }
           }
     
        JMenuBar menuBar;
            JMenu fileMenu;
                JMenuItem openItem;
                JMenuItem saveItem;
                 JMenuItem quitItem;
            JMenu rumolarMenu;
                JMenuItem RentalItem;
                JMenuItem SupermarketItem;
                JMenuItem OthersItem;
            JMenu AboutMenu;
           JButton button1;
           JPasswordField passwordfield;
     
    }


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: help with school assignment

    Hello 5723 and welcome to the Java Programming Forums.

    What is your problem exactly? How far have you got with the code?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Replies: 1
    Last Post: May 8th, 2009, 08:55 AM
  2. New assignments for JAVA beginners
    By Peetah05 in forum File I/O & Other I/O Streams
    Replies: 24
    Last Post: April 24th, 2009, 11:33 AM
  3. How to use for loop for movement of points in a picture display?
    By Dman in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 8th, 2009, 09:19 AM
  4. [SOLVED] Problem with Grading calculator in java program
    By Peetah05 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: March 28th, 2009, 04:25 PM