// The "CarService" class. import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.TitledBorder; public class CarService extends JFrame { Container contentArea = getContentPane (); JPanel northP, centerP, centerPW, centerPC, centerPE, southP; JLabel northL, centerTWT, centerTWB, centerTC, centerTE; TitledBorder titled; JButton southW, southC, southE; JTextField textF; JCheckBox optionW; JCheckBox optionW1, optionW2, optionW3, optionW4; ButtonGroup group, group2; JRadioButton radio1, radio2, radio3, radio4; Dimension dim; public CarService () { super ("Rapid Lube"); setSize (600, 250); setLocation (450, 200); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); setVisible (true); northL = new JLabel ("Rapid Lube - The home of 7 minute Oil Change"); northP = new JPanel (); northP.add (northL); //Center centerP = new JPanel (); //Center west //Place these two each in one panel,then add both panels in one //panel and place it north centerTWT = new JLabel ("Name"); centerTWB = new JLabel ("Regular Customer"); textF = new JTextField (""); dim = new Dimension (120, 20); textF.setPreferredSize (dim); optionW = new JCheckBox (); centerPW = new JPanel (); titled = BorderFactory.createTitledBorder ("Customer info"); centerPW.setBorder (titled); dim = new Dimension (188, 138); centerPW.setPreferredSize (dim); centerPW.setLayout (new FlowLayout (FlowLayout.LEFT)); centerPW.add (centerTWT); centerPW.add (textF); centerPW.add (optionW); centerPW.add (centerTWB); //Center center centerTC = new JLabel ("Content to go Center"); centerPC = new JPanel (); titled = BorderFactory.createTitledBorder ("Oil change"); centerPC.setBorder (titled); centerPC.setLayout (new BoxLayout (centerPC, BoxLayout.Y_AXIS)); centerPC.setPreferredSize (dim); group = new ButtonGroup (); radio1 = new JRadioButton ("None"); radio2 = new JRadioButton ("Natural"); radio3 = new JRadioButton ("Blend"); radio4 = new JRadioButton ("Synthetic"); group.add (radio1); group.add (radio2); group.add (radio3); group.add (radio4); centerPC.add (radio1); centerPC.add (radio2); centerPC.add (radio3); centerPC.add (radio4); //Center east centerTE = new JLabel ("Content to go East"); centerPE = new JPanel (); titled = BorderFactory.createTitledBorder ("Maintenance jobs"); centerPE.setBorder (titled); centerPE.setLayout (new BoxLayout (centerPE, BoxLayout.Y_AXIS)); centerPE.setPreferredSize (dim); group2 = new ButtonGroup (); optionW1 = new JCheckBox ("Tire Rotation"); optionW2 = new JCheckBox ("Muffler replacement"); optionW3 = new JCheckBox ("Transmission flush"); optionW4 = new JCheckBox ("Radiator flush"); group2.add (optionW1); group2.add (optionW2); group2.add (optionW3); group2.add (optionW4); centerPE.add (optionW1); centerPE.add (optionW2); centerPE.add (optionW3); centerPE.add (optionW4); //Add center panels to center centerP.add (centerPW, BorderLayout.WEST); centerP.add (centerPC, BorderLayout.CENTER); centerP.add (centerPE, BorderLayout.EAST); //South southW = new JButton ("Estimate"); southC = new JButton ("Checkout"); southE = new JButton ("Exit"); southP = new JPanel (); southP.add (southW); southP.add (southC); southP.add (southE); //Add all panels contentArea.add (northP, BorderLayout.NORTH); contentArea.add (centerP, BorderLayout.CENTER); contentArea.add (southP, BorderLayout.SOUTH); setContentPane (contentArea); } public static void main (String [] args) { CarService object = new CarService (); try { UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ()); } catch (Exception e) { System.out.println (e); } } // main method } // End CarService class