Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3. public class Lab3 extends JFrame
  4.  
  5. {Image image;
  6. JLabel logo, logo1;
  7. Font myFont = new Font("Comic Sans",Font.BOLD,40);
  8. JLabel label1 = new JLabel("S c h n e l l w i c h");
  9. Font myFont1 = new Font("Times", Font.PLAIN, 14);
  10. JLabel sandwichlabel = new JLabel("Sandwich");
  11. JLabel drinkslabel = new JLabel("Drink");
  12. JLabel sideslabel = new JLabel("Side Orders");
  13. JCheckBox animation = new JCheckBox("Animation");
  14. JCheckBox sounds = new JCheckBox("Sounds");
  15. JCheckBox grilled = new JCheckBox("Grilled?");
  16. JButton cancel = new JButton("Cancel");
  17. JButton order = new JButton("Place Order");
  18. JTextArea price = new JTextArea(" Prices\n Small $5.50\n Medium $7.00\n Large $8.50\n XLarge $9.50");
  19. JTextArea open = new JTextArea("Open from 8 AM till Midnight");
  20. DefaultListModel list = new DefaultListModel();
  21. DefaultListModel list1 = new DefaultListModel();
  22. DefaultListModel list2 = new DefaultListModel();
  23. JList drinklist = new JList(list);
  24. JList sandwichlist = new JList(list1);
  25. JList sidelist = new JList(list2);
  26. JComboBox myChoice = new JComboBox();
  27. JScrollPane scrollpane = new JScrollPane(drinklist);
  28. JScrollPane scrollpane1 = new JScrollPane(sandwichlist);
  29. JScrollPane scrollpane2 = new JScrollPane(sidelist);
  30. JPanel topPanel = new JPanel(new GridLayout(1,3));
  31. JPanel labelPanel = new JPanel(new GridLayout(1,7));
  32. JPanel centerPanel = new JPanel(new GridLayout(1,5));
  33. JPanel bottomPanel = new JPanel(new GridLayout(1,3));
  34. JPanel main = new JPanel(new GridLayout(4,1));
  35.  
  36.  
  37. public static void main(String args[])
  38. {
  39. // Construct the frame
  40. new Lab3();
  41. }
  42. public Lab3() {
  43. Image img = Toolkit.getDefaultToolkit().getImage( "images/tcu.jpg" );
  44. logo = new JLabel( new ImageIcon(img) );
  45. logo1 = new JLabel( new ImageIcon(img) );
  46. // set properties of individual widgets
  47. label1.setForeground(Color.red);
  48. label1.setFont(myFont);
  49. label1.setSize(80,40);
  50. label1.setLocation(200,200);
  51. drinklist.setBackground(Color.green);
  52. Color myColor = new Color(124, 252, 0);
  53. sidelist.setBackground(myColor);
  54. sandwichlist.setBackground(Color.orange);
  55. drinklist.setBounds(5, 20, 80, 600);
  56. drinklist.setBackground(Color.LIGHT_GRAY);
  57. drinklist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  58.  
  59. // add items to drinklist widget
  60. list.add(0,"Select Drink");
  61. list.add(1,"Cola");
  62. list.add(2,"Ice Tea");
  63. list.add(3,"Coffee");
  64. list.add(4,"Water");
  65. scrollpane.setPreferredSize(new Dimension(100,90));
  66.  
  67. // add items to sandwichlist widget
  68.  
  69. list1.add(0,"Select Sandwich");
  70. list1.add(1,"Hamburger");
  71. list1.add(2,"Cheeseburger");
  72. list1.add(3,"Ham & Cheese");
  73. list1.add(4,"Veggie");
  74. scrollpane1.setPreferredSize(new Dimension(130,90));
  75. // add items to sidelist widget
  76.  
  77. list2.add(0,"Select Side");
  78. list2.add(1,"Fries");
  79. list2.add(2,"Chips");
  80. list2.add(3,"Onion Rings");
  81. list2.add(4,"Fried Okra");
  82. scrollpane2.setPreferredSize(new Dimension(100,90));
  83.  
  84. // add items to Choice widget
  85. myChoice.addItem("Select Size");
  86. myChoice.addItem("Small");
  87. myChoice.addItem("Medium");
  88. myChoice.addItem("Large");
  89. myChoice.addItem("XLarge");
  90. //add widgets to this JFrame
  91.  
  92. add(main);
  93. main.add(topPanel);
  94. topPanel.setBackground(Color.ORANGE);
  95. main.add(labelPanel);
  96. main.add(centerPanel);
  97. main.add(bottomPanel);
  98. topPanel.add(logo1);
  99. topPanel.add(label1);
  100. topPanel.add(logo);
  101. labelPanel.add(sandwichlabel);
  102. labelPanel.add(drinkslabel);
  103. labelPanel.add(sideslabel);
  104. centerPanel.add(scrollpane1);
  105. centerPanel.add(scrollpane);
  106. centerPanel.add(scrollpane2);
  107. centerPanel.add(myChoice);
  108. centerPanel.add(animation);
  109. centerPanel.add(sounds);
  110. centerPanel.add(grilled);
  111. bottomPanel.add(price);
  112. bottomPanel.add(open);
  113. bottomPanel.add(order);
  114. bottomPanel.add(cancel);
  115.  
  116.  
  117. setLayout(new FlowLayout());
  118. setBounds(200,300,1000,800);
  119. setVisible(true);
  120. }
  121.  
  122. //end of constructor
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement