Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.swing.*;
- public class Lab3 extends JFrame
- {Image image;
- JLabel logo, logo1;
- Font myFont = new Font("Comic Sans",Font.BOLD,40);
- JLabel label1 = new JLabel("S c h n e l l w i c h");
- Font myFont1 = new Font("Times", Font.PLAIN, 14);
- JLabel sandwichlabel = new JLabel("Sandwich");
- JLabel drinkslabel = new JLabel("Drink");
- JLabel sideslabel = new JLabel("Side Orders");
- JCheckBox animation = new JCheckBox("Animation");
- JCheckBox sounds = new JCheckBox("Sounds");
- JCheckBox grilled = new JCheckBox("Grilled?");
- JButton cancel = new JButton("Cancel");
- JButton order = new JButton("Place Order");
- JTextArea price = new JTextArea(" Prices\n Small $5.50\n Medium $7.00\n Large $8.50\n XLarge $9.50");
- JTextArea open = new JTextArea("Open from 8 AM till Midnight");
- DefaultListModel list = new DefaultListModel();
- DefaultListModel list1 = new DefaultListModel();
- DefaultListModel list2 = new DefaultListModel();
- JList drinklist = new JList(list);
- JList sandwichlist = new JList(list1);
- JList sidelist = new JList(list2);
- JComboBox myChoice = new JComboBox();
- JScrollPane scrollpane = new JScrollPane(drinklist);
- JScrollPane scrollpane1 = new JScrollPane(sandwichlist);
- JScrollPane scrollpane2 = new JScrollPane(sidelist);
- JPanel topPanel = new JPanel(new GridLayout(1,3));
- JPanel labelPanel = new JPanel(new GridLayout(1,7));
- JPanel centerPanel = new JPanel(new GridLayout(1,5));
- JPanel bottomPanel = new JPanel(new GridLayout(1,3));
- JPanel main = new JPanel(new GridLayout(4,1));
- public static void main(String args[])
- {
- // Construct the frame
- new Lab3();
- }
- public Lab3() {
- Image img = Toolkit.getDefaultToolkit().getImage( "images/tcu.jpg" );
- logo = new JLabel( new ImageIcon(img) );
- logo1 = new JLabel( new ImageIcon(img) );
- // set properties of individual widgets
- label1.setForeground(Color.red);
- label1.setFont(myFont);
- label1.setSize(80,40);
- label1.setLocation(200,200);
- drinklist.setBackground(Color.green);
- Color myColor = new Color(124, 252, 0);
- sidelist.setBackground(myColor);
- sandwichlist.setBackground(Color.orange);
- drinklist.setBounds(5, 20, 80, 600);
- drinklist.setBackground(Color.LIGHT_GRAY);
- drinklist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- // add items to drinklist widget
- list.add(0,"Select Drink");
- list.add(1,"Cola");
- list.add(2,"Ice Tea");
- list.add(3,"Coffee");
- list.add(4,"Water");
- scrollpane.setPreferredSize(new Dimension(100,90));
- // add items to sandwichlist widget
- list1.add(0,"Select Sandwich");
- list1.add(1,"Hamburger");
- list1.add(2,"Cheeseburger");
- list1.add(3,"Ham & Cheese");
- list1.add(4,"Veggie");
- scrollpane1.setPreferredSize(new Dimension(130,90));
- // add items to sidelist widget
- list2.add(0,"Select Side");
- list2.add(1,"Fries");
- list2.add(2,"Chips");
- list2.add(3,"Onion Rings");
- list2.add(4,"Fried Okra");
- scrollpane2.setPreferredSize(new Dimension(100,90));
- // add items to Choice widget
- myChoice.addItem("Select Size");
- myChoice.addItem("Small");
- myChoice.addItem("Medium");
- myChoice.addItem("Large");
- myChoice.addItem("XLarge");
- //add widgets to this JFrame
- add(main);
- main.add(topPanel);
- topPanel.setBackground(Color.ORANGE);
- main.add(labelPanel);
- main.add(centerPanel);
- main.add(bottomPanel);
- topPanel.add(logo1);
- topPanel.add(label1);
- topPanel.add(logo);
- labelPanel.add(sandwichlabel);
- labelPanel.add(drinkslabel);
- labelPanel.add(sideslabel);
- centerPanel.add(scrollpane1);
- centerPanel.add(scrollpane);
- centerPanel.add(scrollpane2);
- centerPanel.add(myChoice);
- centerPanel.add(animation);
- centerPanel.add(sounds);
- centerPanel.add(grilled);
- bottomPanel.add(price);
- bottomPanel.add(open);
- bottomPanel.add(order);
- bottomPanel.add(cancel);
- setLayout(new FlowLayout());
- setBounds(200,300,1000,800);
- setVisible(true);
- }
- //end of constructor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement