I got a little JLabel Counter Program here which basically just should add a Number to a Counter when i press "+1" but when i try to run it it say that it isnt able to find the Main Class in my tCounter.ButtonAction class here's my Code so far hope you can help me.
package tCounter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class ButtonAction {
static int Zahl = 0;
public static void createAndShowGUI() {
JFrame frame1 = new JFrame("JAVA");
frameg1.setText(String.valueOf(Zahl));
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("+1");
//Add action listener to button
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
//System.out.println("You clicked the button");
Zahl = Zahl +1;
String Penis = Integer.toString(Zahl);
System.out.println(Zahl);
}
});
frame1.getContentPane().add(button);
frame1.pack();
frame1.setVisible(true);
}
private static class frameg1 {
private static void setText(String valueOf) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public frameg1() {
}
}
}