1. // The "CarService" class.
  2. import javax.swing.*;
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.border.TitledBorder;
  6.  
  7. public class CarService extends JFrame
  8. {
  9. Container contentArea = getContentPane ();
  10. JPanel northP, centerP, centerPW, centerPC, centerPE, southP;
  11. JLabel northL, centerTWT, centerTWB, centerTC, centerTE;
  12. TitledBorder titled;
  13.  
  14. JButton southW, southC, southE;
  15. JTextField textF;
  16. JCheckBox optionW;
  17. JCheckBox optionW1, optionW2, optionW3, optionW4;
  18. ButtonGroup group, group2;
  19.  
  20. JRadioButton radio1, radio2, radio3, radio4;
  21.  
  22. Dimension dim;
  23.  
  24. public CarService ()
  25. {
  26. super ("Rapid Lube");
  27. setSize (600, 250);
  28. setLocation (450, 200);
  29. setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
  30. setVisible (true);
  31.  
  32. northL = new JLabel ("Rapid Lube - The home of 7 minute Oil Change");
  33. northP = new JPanel ();
  34. northP.add (northL);
  35.  
  36. //Center
  37. centerP = new JPanel ();
  38.  
  39. //Center west
  40. //Place these two each in one panel,then add both panels in one
  41. //panel and place it north
  42. centerTWT = new JLabel ("Name");
  43. centerTWB = new JLabel ("Regular Customer");
  44. textF = new JTextField ("");
  45. dim = new Dimension (120, 20);
  46. textF.setPreferredSize (dim);
  47.  
  48. optionW = new JCheckBox ();
  49.  
  50.  
  51. centerPW = new JPanel ();
  52. titled = BorderFactory.createTitledBorder ("Customer info");
  53. centerPW.setBorder (titled);
  54. dim = new Dimension (188, 138);
  55. centerPW.setPreferredSize (dim);
  56. centerPW.setLayout (new FlowLayout (FlowLayout.LEFT));
  57. centerPW.add (centerTWT);
  58. centerPW.add (textF);
  59. centerPW.add (optionW);
  60. centerPW.add (centerTWB);
  61.  
  62.  
  63.  
  64. //Center center
  65.  
  66. centerTC = new JLabel ("Content to go Center");
  67. centerPC = new JPanel ();
  68. titled = BorderFactory.createTitledBorder ("Oil change");
  69. centerPC.setBorder (titled);
  70. centerPC.setLayout (new BoxLayout (centerPC, BoxLayout.Y_AXIS));
  71. centerPC.setPreferredSize (dim);
  72. group = new ButtonGroup ();
  73. radio1 = new JRadioButton ("None");
  74. radio2 = new JRadioButton ("Natural");
  75. radio3 = new JRadioButton ("Blend");
  76. radio4 = new JRadioButton ("Synthetic");
  77.  
  78. group.add (radio1);
  79. group.add (radio2);
  80. group.add (radio3);
  81. group.add (radio4);
  82.  
  83. centerPC.add (radio1);
  84. centerPC.add (radio2);
  85. centerPC.add (radio3);
  86. centerPC.add (radio4);
  87.  
  88. //Center east
  89. centerTE = new JLabel ("Content to go East");
  90. centerPE = new JPanel ();
  91. titled = BorderFactory.createTitledBorder ("Maintenance jobs");
  92. centerPE.setBorder (titled);
  93. centerPE.setLayout (new BoxLayout (centerPE, BoxLayout.Y_AXIS));
  94. centerPE.setPreferredSize (dim);
  95.  
  96. group2 = new ButtonGroup ();
  97. optionW1 = new JCheckBox ("Tire Rotation");
  98. optionW2 = new JCheckBox ("Muffler replacement");
  99. optionW3 = new JCheckBox ("Transmission flush");
  100. optionW4 = new JCheckBox ("Radiator flush");
  101.  
  102. group2.add (optionW1);
  103. group2.add (optionW2);
  104. group2.add (optionW3);
  105. group2.add (optionW4);
  106.  
  107. centerPE.add (optionW1);
  108. centerPE.add (optionW2);
  109. centerPE.add (optionW3);
  110. centerPE.add (optionW4);
  111.  
  112.  
  113. //Add center panels to center
  114. centerP.add (centerPW, BorderLayout.WEST);
  115. centerP.add (centerPC, BorderLayout.CENTER);
  116. centerP.add (centerPE, BorderLayout.EAST);
  117.  
  118.  
  119. //South
  120. southW = new JButton ("Estimate");
  121. southC = new JButton ("Checkout");
  122. southE = new JButton ("Exit");
  123. southP = new JPanel ();
  124. southP.add (southW);
  125. southP.add (southC);
  126. southP.add (southE);
  127.  
  128. //Add all panels
  129. contentArea.add (northP, BorderLayout.NORTH);
  130. contentArea.add (centerP, BorderLayout.CENTER);
  131. contentArea.add (southP, BorderLayout.SOUTH);
  132. setContentPane (contentArea);
  133.  
  134. }
  135.  
  136.  
  137.  
  138.  
  139.  
  140. public static void main (String [] args)
  141. {
  142. CarService object = new CarService ();
  143.  
  144. try
  145. {
  146. UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ());
  147. }
  148. catch (Exception e)
  149. {
  150. System.out.println (e);
  151. }
  152.  
  153.  
  154.  
  155. } // main method
  156. } // End CarService class