{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Private jbutton calculatebutton private jbutton

Info iconThis 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);
Background 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); }
Background 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 ]}

Page2 / 7

private JButton calculatebutton private JButton exitbutton...

This preview shows document pages 2 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online