import java.io.*; import java.awt.*; import javax.swing.*; public class paintEstimatorView extends JFrame { JPanel panel1 = new JPanel(); public paintEstimatorView() { setLayout(new BorderLayout()); panel1.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); panel1.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); panel1.setBorder(BorderFactory.createLineBorder(Color.black)); { /* Panel 1 Components */ JLabel label1 = new JLabel("Square Ft/Gallon"); c.weightx = 0; c.gridx = 0; c.gridy = 0; c.insets = new Insets(10,20,0,10); c.anchor = GridBagConstraints.WEST; panel1.add(label1, c); JLabel label2 = new JLabel("Number of Coats"); c.weightx = 0; c.gridx = 0; c.gridy = 1; c.insets = new Insets(10,20,10,10); c.anchor = GridBagConstraints.WEST; panel1.add(label2, c); JTextField jtSquareFt = new JTextField("0"); c.weightx = 1; c.gridx = 1; c.gridy = 0; c.insets = new Insets(10,0,0,0); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; panel1.add(jtSquareFt, c); JTextField jtCoats = new JTextField("0"); c.weightx = 1; c.gridx = 1; c.gridy = 1; c.insets = new Insets(10,0,10,0); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; panel1.add(jtCoats, c); JLabel label3 = new JLabel("Gallons Required"); c.weightx = 0; c.gridx = 2; c.gridy = 0; c.insets = new Insets(10,30,0,0); //c.anchor = GridBagConstraints.EAST; panel1.add(label3, c); JTextField jtGallonsRequired = new JTextField("0"); jtGallonsRequired.setEditable(false); c.weightx = 0; c.gridx = 3; c.gridy = 0; c.insets = new Insets(10,10,0,10); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; panel1.add(jtGallonsRequired, c); JButton jbtnCompute = new JButton("Compute Gallons Needed"); c.weightx = 0; c.gridx = 2; c.gridy = 1; c.gridwidth = 2; c.insets = new Insets(10,50,10,10); c.anchor = GridBagConstraints.EAST; panel1.add(jbtnCompute, c); } add(panel1, BorderLayout.NORTH); } public static void main(String[] args) { paintEstimatorView frame = new paintEstimatorView(); frame.setTitle("Paint Estimator"); //frame.setSize(500,400); frame.setPreferredSize(new Dimension(500,400)); frame.setMinimumSize(new Dimension(500,400)); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } }