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);
}
}