
Originally Posted by
JPHamlett
Multi I think.
Ok now it's not drawing the button and it's claiming "Calc" cannot be resolved to a variable (at e.getsource) but the code still runs
java Code:
import java.awt.*;//import java.awt.event.*;import javax.swing.*;//import javax.swing.event.*;//import java.awt.Container;import java.awt.Dimension;import java.awt.Graphics;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;//import java.awt.event.WindowAdapter;//import java.awt.event.WindowEvent;//import java.awt.AWTException;public class Size
extends JPanel implements ActionListener { double base
; int shoesize
; String race
; public Size
() { JButton calc
; calc
= new JButton("Calculate"); calc.
addActionListener(this); add
(calc
); calc.
setBounds(135,
200,
120,
40); setPreferredSize
(new Dimension(400,
300)); setLayout
(null); } public static void main
(String[] args
) { JFrame frame
= new JFrame("Size calc"); frame.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE); frame.
getContentPane().
add(new Size
()); frame.
pack(); frame.
setVisible(true); } @Override
public void paint
(Graphics g
){ DrawStats
(g
); } public void actionPerformed
(ActionEvent e
) { if (e.
getSource() == calc
) { } } public void DrawStats
(Graphics g
) { g.
setFont(new Font(null,
Font.
PLAIN,
12)); g.
setColor(Color.
red); g.
drawString("Aprrox Size",
7,
7); }}