package autolaskuri; import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * Title: Autolaskuri for Java with Beans * Description: Autolaskuri for Java using beans * Copyright: Copyright (c) 2001 * Company: jyu * @author Vesa Lappalainen * @version 1.0 */ public class FrameAutolaskuri extends JFrame implements ActionListener { JPanel contentPane; JPanel jPanel1 = new JPanel(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JPanel jPanel2 = new JPanel(); GridLayout gridLayout1 = new GridLayout(); BeanLaskuri beanLaskuri1 = new BeanLaskuri(); BeanLaskuri beanLaskuri2 = new BeanLaskuri(); //Construct the frame public FrameAutolaskuri() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(gridLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); jPanel1.setPreferredSize(new Dimension(10, 50)); jButton1.setText("Henkilöautoja"); // Frame1_jButton1_actionAdapter ad = new Frame1_jButton1_actionAdapter(this); jButton1.addActionListener(this); jButton2.setText("Kuorma-autoja"); jButton2.addActionListener(this); jPanel2.setPreferredSize(new Dimension(10, 50)); gridLayout1.setColumns(0); gridLayout1.setRows(2); contentPane.setMaximumSize(new Dimension(210, 110)); contentPane.setMinimumSize(new Dimension(217, 70)); contentPane.setPreferredSize(new Dimension(200, 100)); beanLaskuri1.setPreferredSize(new Dimension(100, 50)); beanLaskuri2.setPreferredSize(new Dimension(100, 50)); jPanel1.add(jButton1, null); jPanel1.add(jButton2, null); contentPane.add(jPanel2, null); jPanel2.add(beanLaskuri1, null); jPanel2.add(beanLaskuri2, null); contentPane.add(jPanel1, null); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public void actionPerformed(ActionEvent e) { BeanLaskuri target = null; if (e.getSource()==jButton1) target = beanLaskuri1; if (e.getSource()==jButton2) target = beanLaskuri2; target.inc(1); } }