Private jbutton calculatebutton private jbutton

Info icon This preview shows pages 2–4. Sign up to view the full content.

View Full Document Right Arrow Icon
private JButton calculatebutton; private JButton exitbutton; private JTextField lengthfield; private JTextField widthfield; private JTextField areafield; private JLabel lengthlabel; private JLabel widthlabel; private JLabel arealabel; public OfficeAreaCalculator() { mainframe = new JFrame("office area calculator"); calculatebutton = new JButton("Calculate area"); exitbutton = new JButton("Exit"); lengthlabel = new JLabel("Enter the length of the office:"); lengthfield = new JTextField(15); widthlabel = new JLabel("Area: "); areafield = new JTextField(15); widthfield = new JTextField(15); arealabel = new JLabel("Enter the width of the office:"); Container c = mainframe.getContentPane(); c.setLayout(new GridLayout(0,2)); c.add(lengthlabel); c.add(lengthfield); c.add(widthlabel); c.add(widthfield);
Image of page 2

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
c.add(arealabel); c.add(areafield); c.add(calculatebutton); c.add(exitbutton); exitbutton.addActionListener(this); calculatebutton.setMnemonic('c'); exitbutton.setMnemonic('x'); mainframe.setSize(250, 150); mainframe.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); calculatebutton.addActionListener(this); lengthfield.addFocusListener(this); widthfield.addFocusListener(this); areafield.addFocusListener(this); mainframe.setVisible(true); }
Image of page 3
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern