0

I am Trying to write a Java Program that animates 4 arcs to make it look like a moving fan. As of now I have the arcs drawn and Im trying to make buttons for my slow, med, fast and off settings

Im getting the following errors:
DrawArcs.java:6: cannot find symbol
symbol : class JButton
location: class DrawArcs
private JButton jbtOff = new JButton("Off");

DrawArcs.java:27: cannot find symbol
symbol : class ActionListener
location: class DrawArcs
jbtSlow.addActionListener(new ActionListener(){

Im getting a few more but listing them would be kinda redundant as they refer to the other lines i wrote to create the buttons and action listeners. I figured that If we could solve the first ones the others probably have the same issue.

Any help would be greatly appreciated

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;

public class DrawArcs extends JFrame {
   private JButton jbtOff = new JButton("Off");
	private JButton jbtSlow = new JButton("Slow");
	private JButton jbtMed = new JButton("Med");
	private JButton jbtFast = new JButton("Fast");


	public DrawArcs() {
		JPanel arcsPanel = new JPanel();
		setTitle("DrawArcs");
		arcsPanel.add(jbtOff);
		arcsPanel.add(jbtSlow);
		arcsPanel.add(jbtMed);
		arcsPanel.add(jbtFast);
		
		this.add(arcsPanel, BBorderLayout.SOUTH);	
		
		jbtOff.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
			}
		});
		
			jbtSlow.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
			}
		});
		
			jbtMed.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
			}
		});
		
			jbtFast.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
			}
		});
		
	}
		//Main Method
		public static void main(String[]args){
		DrawArcs frame = new DrawArcs();
		frame.setSize(250, 300);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
		
	}	
}

		//Draw Arcs On Panel
		class ArcsPanel extends JPanel {
			protected void paintComponent(Graphics g) {
				super.paintComponent(g);
				
				int xCenter = getWidth() /2;
				int yCenter = getHeight() /2;
				int radius = (int)(Math.min(getWidth(),getHeight())*0.4);
				
				int x = xCenter - radius;
				int y = yCenter - radius;
				
				g.fillArc(x, y, 2*radius, 2*radius, 0, 30);
				g.fillArc(x, y, 2*radius, 2*radius, 90, 30);
				g.fillArc(x, y, 2*radius, 2*radius, 180, 30);
				g.fillArc(x, y, 2*radius, 2*radius, 270, 30);
				
				}
		}
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by geek_till_itMHZ
0

you need to import the classes that the compiler isn't finding. Right not you're only importing 3 classes.

0

Hi there, am only learning java, but I notice you have not imported the libraries, java.awt.event. I thought this was where the refrence to the action listner was held. If not please can you tell me how you got round it.

0

Hi there, am only learning java, but I notice you have not imported the libraries, java.awt.event. I thought this was where the refrence to the action listner was held. If not please can you tell me how you got round it.

That Fixed one of them... I completely Restructured how I was adding
the buttons and fixed the other problem

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.